var df= document.page1;
var Images_Path = 'images';
var ErrorDetails = new Array();
var alreadyFocussed = false;
var fd_tout = 10000;
var arr_v = {
	"USERNAME": {
		"events": {
			"onfocus": {
				"fname": "showhint",
				"param": "'Min. 6 characters without space. You may use your e-mail id as username', 'username', '230px'"
			},
			"onchange": {
				"fname": "CheckUsernameAvailability",
				"param": "1"
			},
			"onblur": {
				"fname": "CheckUsernameAvailability|X|hidetip",
				"param": "1|X| "
			},
			"onkeydown": {
				"fname": "hideErrorCSS",
				"param": "'username','error_username','status_username'"
			}
		}
	},
	"PASSWORD": {
		"events": {
			"onfocus": {
				"fname": "showhint",
				"param": "'Min 6 characters. Capitalization matters.', 'password', '230px'"
			},
			"onblur": {
				"fname": "hidetip|X|v_PASSWORD",
				"param": "|X|1"
			},
			"onkeydown": {
				"fname": "hideErrorCSS",
				"param": "'password','error_password','status_password'"
			}
		}
	},
	"CPASSWORD": {
		"events": {
			"onfocus": {
				"fname": "showhint",
				"param": "'Must be same as password','cpassword', '170px'"
			},
			"onblur": {
				"fname": "v_CPASSWORD|X|hidetip",
				"param": "1|X|"
			},
			"onkeydown": {
				"fname": "hideErrorCSS",
				"param": "'cpassword','error_cpassword','status_cpassword'"
			}
		}
	},
	"CNAME": {
		"events": {
			"onblur": {
				"fname": "v_CNAME",
				"param": "1"
			},
			"onkeydown": {
				"fname": "hideErrorCSS",
				"param": "'cname','error_cname','status_cname'"
			}
		}
	},
	"EMAIL": {
		"events": {

			"onfocus": {
				"fname": "showhint",
				"param": "'Please use an existing/valid email id. We use email id to send job alert', 'email', '210px'"
			},
			"onblur": {
				"fname": "v_EMAIL",
				"param": "1"
			},
			"onkeydown": {
				"fname": "hideErrorCSS",
				"param": "'email','error_email','status_email'"
			}
		}
	},
        "COUNTRY":{
                "events":{
						"onfocus": {
				"fname": "showhint",
				"param": "'Please select your Country', 'country', '210px'"
			},
                        "onchange":{
				"fname":"hideErrorCSS|X|CountryChangedEvent|X|v_COUNTRY",
                                "param":"'country','error_country','status_country'|X||X|1"
                        },
                        "onkeyup":{
                                "fname":"hideErrorCSS|X|hideErrorCSS|X|trapCountry",
                                "param":"'country','error_country','status_country'|X|'ocountry','error_country','status_country'|X|"
                        }
                }
        },
       
        "CITY":{
                "events":{
			"onfocus": {
				"fname": "showhint",
				"param": "'Please select your city','city', '210px'"
			},
                        "onblur":{
                                "fname":"CityChangedEvent|X|v_CITY|X|hidetip",
                                "param":"|X|1|X|'city','error_city','status_city'"
                        },
                        
			"onkeydown" : {
				"fname": "hidetip",
				"param": ""
			}
                }
        },
	"AREACODE":{
		"events":{
			"onblur":{
				"fname":"hidetip|X|v_RAREACODE",
				"param":"|X|1"
			},
			"onkeydown":{
				"fname":"hideErrorCSS|X|hideErrorCSS|X|hideErrorCSS|X|trapRphone",
				"param":"'countrycode','error_landline','status_landline'|X|'areacode','error_landline','status_landline'|X|'landline','error_landline','status_landline'|X|"
			}
		}
	},
	"LANDLINE":{
		"events":{
			/*"onfocus": {
				"fname": "showhint",
				"param": "'Privacy assured', 'landline','120px'"
			},*/
			"onblur":{
				"fname":"hidetip|X|v_RPHONE",
				"param":"|X|1"
			},
			"onkeydown":{
				"fname":"hideErrorCSS|X|hideErrorCSS|X|hideErrorCSS|X|trapRphone",
				"param":"'countrycode','error_landline','status_landline'|X|'areacode','error_landline','status_landline'|X|'landline','error_landline','status_landline'|X|"
			}
		}
	},
	"MPHONE":{
		"events":{
			/*"onfocus": {
				"fname": "showhint",
				"param": "'Privacy assured', 'mphone','120px'"
			},*/
			"onblur":{
				"fname":"hidetip|X|v_MPHONE",
				"param":"|X|1"
			},
			"onkeydown":{
				"fname":"hideErrorCSS|X|trapMphone",
				"param":"'mphone','error_mphone','status_mphone'|X|"
			}
		}
	},
	
	"EXPERIENCE":{
		"events":{
			"onfocus": {
				"fname": "showhint",
				"param": "'Select your experience', 'months','150px'"
			},
			 "onblur":{
                                "fname":"v_EXPERIENCE",
                                "param":"1"
                        },
                        "onkeyup":{
                                "fname":"hideErrorCSS",
                                "param":"'experience','error_experience','status_experience'"
                        },
						"onchange":{
									"fname":"hidemonths",
									"param":"'experience'"
							
							}
		}
		                        
	},
	
	"SALARY":{
		"events":{
			"onfocus": {
				"fname": "showhint",
				"param": "'Select your salary', 'salary','130px'"
			},
			 "onblur":{
                                "fname":"v_SALARY",
                                "param":"1"
                        },
                        "onkeyup":{
                                "fname":"hideErrorCSS",
                                "param":"'salary','error_salary','status_salary'"
                        }
		}
		                        
	},
	
	"SPECIALIZATION":{
		
		"events":{
			"onfocus": {
				"fname": "showhint",
				"param": "'Select your specialization', 'specialization','200px'"
			},
			"onchange":{
				"fname":"hideErrorCSS|X|SpecializationChangedEvent|X|v_SPECIALIZATION",
                                "param":"'specialization','error_specialization','status_specialization'|X||X|1"
			},
			 "onblur":{
                                "fname":"v_SPECIALIZATION",
                                "param":"1"
                        },
                        "onkeyup":{
                                "fname":"hideErrorCSS",
                                "param":"'specialization','error_specialization','status_specialization'"
                        }
		}
		                        
	},
	
	"INDUSTRY":{
		"events":{
			"onfocus": {
				"fname": "showhint",
				"param": "'Select your Industry', 'industry','130px'"
			},
			 "onblur":{
                                "fname":"v_INDUSTRY",
                                "param":"1"
                        },
                        "onkeyup":{
                                "fname":"hideErrorCSS",
                                "param":"'industry','error_industry','status_industry'"
                        }
		}
		                        
	},
	
	"ROLE":{
		"events":{
			"onfocus": {
				"fname": "showhint",
				"param": "'Select your role', 'role','130px'"
			},
			 "onblur":{
                                "fname":"v_ROLE",
                                "param":"1"
                        },
                        "onkeyup":{
                                "fname":"hideErrorCSS",
                                "param":"'role','error_role','status_role'"
                        }
		}
		                        
	},
	"KEYSKILLS":{
		"events":{
			"onfocus": {
				"fname": "showhint",
				"param": "'Please enter comma separated Key Skills Eg.C,C++,Java,Sales,Marketing', 'keyskills','230px'"
			},
			 "onblur":{
                                "fname":"v_KEYSKILLS",
                                "param":"1"
                        },
                        "onkeyup":{
                                "fname":"hideErrorCSS",
                                "param":"'keyskills','error_keyskills','status_keyskills'"
                        }
		}
		                        
	},
	"SECCODE": {
		
		"events": {
			"onfocus": {
				"fname": "showhint",
				"param": "'Type the characters you see in the picture.', 'seccode', '210px'"
			},
			"onblur": {
				"fname": "v_SECCODE",
				"param": "1"
			},
			"onkeydown": {
				"fname": "hideErrorCSS",
				"param": "'seccode','error_seccode','status_seccode'"
			}
		}
	}
}

var arr_opacThread = {}; // prevent multiple parallel threads on "correct" img

function opacity(id, opacStart, opacEnd, millisec, idx) {
	if (idx == undefined) {
		ele = document.getElementById(id);
		idx = "";
	}
	else {
		tmpele = document.getElementsByName(id);
		ele = tmpele[idx];
	}


    if (arr_opacThread[id+idx])
    	return;
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;
    var i=0; // very imp line - don't remove this
    var processingCorrect = (ele.src.search("correct") != -1);
    if (processingCorrect)
    	arr_opacThread[id+idx] = 1;
    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i-=2) {
            setTimeout("changeOpac(" + i + ",'" + id + "','" + idx + "')",(timer * speed));
            timer++;
        }
	    if (processingCorrect)
	    	setTimeout("arr_opacThread['"+id+idx+"'] = 0",(timer * speed))
    } else if(opacStart < opacEnd) {
      for(i = opacStart; i <= opacEnd; i+=2)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "','" + idx + "')",(timer * speed));
            timer++;
        }
	    if (processingCorrect)
	    	setTimeout("arr_opacThread['"+id+idx+"'] = 0",(timer * speed))
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id, idx) {
	if (idx == "")
    		object = document.getElementById(id);
	else {
    		tmpobject = document.getElementsByName(id);
    		object = tmpobject[idx];
    	}
    	if (String(object.src).indexOf("erroricon") != -1) // stop the fade out threads in case of error
    		opacity = 100;
	object.style.opacity = (opacity / 100);
	object.style.MozOpacity = (opacity / 100);
	object.style.KhtmlOpacity = (opacity / 100);
	object.style.filter = "alpha(opacity=" + opacity + ")";
}

function hideErrorCSS(objId, ErrMsgDivId, StatusObjId) {
	var obj = document.getElementById(objId)
	obj.className = '';
	document.getElementById(ErrMsgDivId).style.display = 'none';
	document.getElementById(StatusObjId).style.display = 'none';
	if (obj.parentNode && obj.parentNode.name && obj.parentNode.name == "borderele") {
		obj.parentNode.className = "";
	}
	return true;
}



function showErrMsg(arr_params) {
	var i;
	arr_params['ErrDivObj'].style.display = "";
	arr_params['ErrDivObj'].innerHTML = "<img src=\""+Images_Path+"/error.gif\">"+arr_params['ErrorMsg'];

	if (arr_params['EleToFocus']) {
		if (arr_params['EleToFocus']["isArray"]) {
			for (i=0; i<arr_params['EleToFocus'].length; ++i) {
				arr_params['EleToFocus'][i].className = "errorcss";
				if (!arr_params['noborder'] && arr_params['EleToFocus'][i].parentNode && arr_params['EleToFocus'][i].parentNode.name && arr_params['EleToFocus'][i].parentNode.name == "borderele") {
			//		var border = document.getElementById(arr_params['ErrDivObj'].id + "_border");
			//		if (border) border.className = "errorcss";
					arr_params['EleToFocus'][i].parentNode.className = "errorcss";
				}
			}
		}
		else
			arr_params['EleToFocus'].className = "errorcss";
			if (!arr_params['noborder'] && arr_params['EleToFocus'].parentNode && arr_params['EleToFocus'].parentNode.name && arr_params['EleToFocus'].parentNode.name == "borderele") {
		//		var border = document.getElementById(arr_params['ErrDivObj'].id + "_border");
		//		if (border) border.className = "errorcss";
				arr_params['EleToFocus'].parentNode.className = "errorcss";
			}
	}
	if (arr_params['StatusObj']) {
		if (arr_params['StatusObj']["isArray"]) {
			for (i=0; i<arr_params['StatusObj'].length; ++i) {
				arr_params['StatusObj'][i].style.display = "";
				arr_params['StatusObj'][i].src = Images_Path+"/erroricon1.gif";
				//opacity(arr_params['StatusObj'][i].id, 99, 100, 1);
			}
		}
		else {
			arr_params['StatusObj'].style.display = "";
			arr_params['StatusObj'].src = Images_Path+"/erroricon1.gif";
			//opacity(arr_params['StatusObj'].id, 99, 100, 1);
		}
	}
	if (!arr_params['ob']) {
		ErrorDetails[arr_params["HName"]] = 1;
		if (arr_params['EleToFocus']) {
			if (!alreadyFocussed) {
				alreadyFocussed = true;
				if (arr_params['EleToFocus']["isArray"]) {
					arr_params['EleToFocus'][0].focus();
				}
				else {
					arr_params['EleToFocus'].focus();
				}
			}
		}
	}
}

function v_init(arr_v_override) {
	var i;
	var _tmpImg = new Image(); _tmpImg.src = Images_Path+"/error.gif"; // preload
	arr_v = arr_v_override ? arr_v_override : arr_v;
	if ( !df ) {
		df = document.page1;
		}
	var f_list, p_masterlist, p_list, f_str = '';
	for(elementName in arr_v) {
		if (arr_v[elementName]["isArray"]) {
			arr_ele = df.elements[elementName];
			for (ec=0; ec<arr_ele.length; ++ec) {
				for(eventName in arr_v[elementName]['events']) {
					f_list = arr_v[elementName]['events'][eventName]['fname'].toString().split("|X|");
					p_masterlist = new String(arr_v[elementName]['events'][eventName]['param']).split("|X|");
					if ( f_list.length <= 0 ) {
						break;
					}
					for(i=0; i<f_list.length; ++i) {
						f_str = f_str + f_list[i] + '(' + p_masterlist[i] + (p_masterlist[i] != '' ? ',' : '') + ec + ');';
					}
					eval("df.elements['" + elementName + "'][" + ec + "]." + eventName + "= function() {\
						eval(\"" + f_str + "\");\}");
					f_str = '';
				}
			}
		}
		else {
			for(eventName in arr_v[elementName]['events']) {
				f_list = arr_v[elementName]['events'][eventName]['fname'].toString().split("|X|");
				p_masterlist = new String(arr_v[elementName]['events'][eventName]['param']).split("|X|");
				if ( f_list.length <= 0 ) {
					break;
				}
				for(i=0; i<f_list.length; ++i) {
					f_str = f_str + f_list[i] + '(' + p_masterlist[i] + ');';
				}
								
				eval("df.elements['" + elementName + "']." + eventName + "= function() {\
					eval(\"" + f_str + "\");\}");
				
				f_str = '';
			}

		}
	}
}

function rm_trim(inputString)
{
        if (typeof inputString != "string") { return inputString; }

        var temp_str = '';
        temp_str = inputString.replace(/[\s]+/g,"");
        if(temp_str == '')
                return "";

        var retValue = inputString;
        var ch = retValue.substring(0, 1);
        while (ch == " ")
        {
                retValue = retValue.substring(1, retValue.length);
                ch = retValue.substring(0, 1);
        }
        ch = retValue.substring(retValue.length-1, retValue.length);
        while (ch == " ")
        {
                retValue = retValue.substring(0, retValue.length-1);
                ch = retValue.substring(retValue.length-1, retValue.length);
        }
        while (retValue.indexOf("  ") != -1)
        {
          retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
        }
        return retValue;
}

<!--
var horizontal_offset="6px" //horizontal offset of hint box from anchor link

var vertical_offset="-10px" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;}

return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y > dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, objId, tipwidth){
	
	
	var obj = document.getElementById(objId);
	if ( obj.tagName.toString().toLowerCase().indexOf('input') > -1 || obj.toString().indexOf('HTMLInputElement') > -1 ) {
		if( rm_trim(obj.value).toString().length > 0 ) {
			return;
		}
	} else if ( obj.tagName.toString().toLowerCase().indexOf('select') > -1  || obj.toString().indexOf('HTMLSelectElement') > -1 ) {
		if ( obj.selectedIndex > 0 ) {
			return
		}
	} else if( obj.tagName.toString().toLowerCase().indexOf('textarea') > -1 || obj.toString().indexOf('HTMLTextAreaElement') > -1) {
		if ( rm_trim(obj.value).toString().length > 0 ) {
			return ;
		}
	} else { alert('no match found'); }
	if ((ie||ns6) && document.getElementById("hintbox")){
		dropmenuobj=document.getElementById("hintbox")
		document.getElementById('hintbox').style.margin="0 0 0 20px";
		menucontents="<div id='new_'><font color='#FB6E06'>"+ menucontents +"</font><div style='position:absolute; left:-9px; bottom:5px;'><img src='images/arrow2.gif' /></div></div>"
		
		dropmenuobj.innerHTML=menucontents
		dropmenuobj.style.left=dropmenuobj.style.top=-500
		if (tipwidth!=""){
			dropmenuobj.widthobj=dropmenuobj.style
			dropmenuobj.widthobj.width=tipwidth
		}
		dropmenuobj.x=getposOffset(obj, "left")
		dropmenuobj.y=getposOffset(obj, "top")
		dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
		dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
		dropmenuobj.style.visibility="visible"
		//obj.onblur=hidetip
	}
}

function hidetip(){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

var requester = null;

function CheckUsernameAvailability(ob)
{
        var username = document.getElementById("username");
        var error_username = document.getElementById("error_username");
	var status_username = document.getElementById("status_username");
	var params = new Array();
	var err = false;
	error_username.innerHTML = "";

	username.value = rm_trim(username.value);
	
	 if ( username.value.length < 6 ) { 
		params = { "ErrDivObj": error_username, "ErrorMsg": "Username must be minimum 6 characters long.", "EleToFocus":username, "StatusObj": status_username, "ob":ob, "HName":"Username" }
		showErrMsg(params);
		err = true;
		//return ;
        } else if ( username.value.length > 50  )  {
		params = { "ErrDivObj": error_username, "ErrorMsg": "Username should not be more than 50 characters long.", "EleToFocus":username, "StatusObj": status_username, "ob":ob, "HName":"Username" }
		showErrMsg(params);
		err = true;
	} else if ( isValidUsername(username.value) == false  ) {
		params = { "ErrDivObj": error_username, "ErrorMsg": "Special characters other than (Hyphen Underscore Dot @) are not allowed.", "EleToFocus":username, "StatusObj": status_username, "ob":ob, "HName":"Username" }
		if ( username.value.toString().indexOf(' ') > -1 )
			params['ErrorMsg'] = "Username cannot contain blank space";
		showErrMsg(params);
		err = true;
		//return;
	}

	if ( ob && !err ) {
		error_username.style.display = "";
		if ( ! this.verified )  {
			error_username.innerHTML = "Checking availability of username.....";
			error_username.style.display = "";
			if ( requester != null && requester.readyState != 0 && requester.readyState != 4 )
				requester.abort();

			try  {
				requester = new XMLHttpRequest();
			}
			catch (error)  {
				try  {
					requester = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (error)  {
					requester = null;
					return ;
				}
			}
			requester.onreadystatechange = onReadyStateChangeUsername;
			requester.open("GET", "CheckUsername.php?username=" + username.value);
			requester.send(null);
		}
	}
	
        return true;

       
}


function onReadyStateChangeUsername()
{
        if ( requester.readyState == 4 ) {
                try {
                        if ( requester.status == 200 )  {
						
				var response = String(requester.responseText).split("|X|");
				
				if ( String(response[0]).toLowerCase() == "show" ) {
				}
				else {
					//response[1] = "";
				}
				if ( response[0] == "hide" ) {
					document.getElementById("error_username").className = "error";
					document.getElementById("status_username").style.display = '';
					document.getElementById("status_username").src = Images_Path + '/correct.gif';
					document.getElementById("error_username").innerHTML ='<font color="green">'+response[1]+'</font>';
					//opacity('status_username', 100, 0 , fd_tout);
				} else {
					document.getElementById("username").value="";
					document.getElementById("error_username").className = "error";
					document.getElementById("error_username").style.display = "";
					document.getElementById("error_username").innerHTML = "<img src=\""+Images_Path+"/error.gif\">"+response[1];
					document.getElementById("username").value = "";
					
					//document.getElementById("status_username").src = Images_Path + '/erroricon1.gif';
					//document.getElementById("error_username").innerHTML = response[1];
				}

				
                        }
                        else  if ( requester.status != 0 ) {
                                alert("There was an error while checking username availability.\nPlease try again.");
                        }
                }
                catch(e2)  { }
        }
        return true;
}

var arrInvalidDomain=new Array( "yahoomail.com","yahoo.com",
				"yahoomail.co.in","yahoo.co.in",
				"yahoo.com.in","yahoo.co.in",
				"redifmail.com","rediffmail.com",
				"radiffmail.com","rediffmail.com"
);

function CheckEmailAvailability(emailObjId, ob)
{
	var email = document.getElementById(emailObjId);
	var error_div = document.getElementById("error_email");
	var HideErrorDivFlag = false;
	if ( String(error_div.innerHTML).length > 0 )
		HideErrorDivFlag = false;
	else
		HideErrorDivFlag = true;

	error_div.style.display = "";
	if ( isValidEmail(email.value) == false )  {
		error_div.style.display = "none";
		error_div.innerHTML = null;
		return;
	} else {
		var tmpmail = email.value.split("@");
		for ( i = 0; i < arrInvalidDomain.length; i = i+2) {
			if (tmpmail[1] == arrInvalidDomain[i]) 	{
				error_div.style.display = "";
				error_div.innerHTML = "This Email Id seems incorrect. Did You Mean <b>"+tmpmail[0]+"@" +arrInvalidDomain[i+1]+ "</b>";
				return;
			}
		}
	}

	if ( ob ) {
		if ( ! this.verified )  {
			error_div.innerHTML = "Checking availability of email.....";
			error_div.style.display = "";
			if ( requester != null && requester.readyState != 0 && requester.readyState != 4 ) {
				requester.abort();
			}
			try  {
				requester = new XMLHttpRequest();
			}catch (error)  {
				try  {
					requester = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (error)  {
					requester = null;
					return ;
				}
			}
			requester.onreadystatechange = onReadyStateChangeEmail;
			requester.open("GET", "CheckUsername.php?email=" + email.value);
			requester.send(null);
		}
	}
        return true;
}

function onReadyStateChangeEmail()
{
        if ( requester.readyState == 4 ) {
                try {
                        if ( requester.status == 200 )  {
				var response = String(requester.responseText).split("|X|");
				
				
				if ( response[0] == "hide" ) {
					document.getElementById("error_email").className = "error";
					document.getElementById("status_email").style.display = '';
					document.getElementById("status_email").src = Images_Path + '/correct.gif';
					document.getElementById("error_email").innerHTML ='<font color="green">'+response[1]+'</font>';
					//opacity('status_username', 100, 0 , fd_tout);
				} else {
					document.getElementById("error_email").className = "error";
					document.getElementById("status_email").src = Images_Path + '/erroricon1.gif';
					document.getElementById("error_email").innerHTML = response[1];
					document.getElementById("email").value = "";
				}
                        }
                        else  if ( requester.status != 0 ) {
                                alert("There was an error while checking email availability.\nPlease try again.");
                        }
                }
                catch(e2)  { }
        }
        return true;
}

function SendPassByAjax(emailId)  {
	var error_email = document.getElementById("error_email");
        if ( emailId.length == 0 )
                return;

        if ( !this.verified )   {
                if (requester != null && requester.readyState != 0 && requester.readyState != 4)  {
                        requester.abort();
                }

                try  {
                        requester = new XMLHttpRequest();
                }
                catch (error)  {
                        try  {
                                requester = new ActiveXObject("Microsoft.XMLHTTP");
                        }
                        catch (error)  {
                                requester = null;
                                return false;
                        }
                }

        }

        error_email.innerHTML = "Please wait while the mail is being sent...";
        requester.onreadystatechange = onreadystatechangepass;
        requester.open("GET", "../manager/SendPass.php?email=" + emailId );
        requester.send(null);
	return false;
}

function onreadystatechangepass()  {
	var error_email = document.getElementById("error_email");
        if ( requester.readyState == 4 )  {
                try  {
                        if ( requester.status == 200 )  {
				var tmp = String(requester.responseText).split("|X|");
				
					error_email.innerHTML = tmp[1];
					error_email.style.display = "";
				
                        }
                        else if ( requester.status != 0 )  {
				error_email.innerHTML = "There Was a Temporary Problem While Sending the Password. Please Try Again.";
				error_email.style.display = "";
                        }
                }
                catch(error)  {
                }
        }
	return false;
}


function isValidUsername(Username)
{
        var pattern = /[^a-zA-Z0-9.@_-]+/;
	return ! pattern.test ( Username );
}


function trapKey(event, src) {
	if ((event && event.keyCode == 9 && !event.shiftKey)) { // tab key
		if ((src.name == "UGCOURSE" && src.value != "1") || (src.name == "PPGCOURSE" && src.value == "9999"))
			return true;

		ifd = rm_getFrame(1);
		if (ifd && iframe && iframe.style.display == "") {
			ifd.forms["uploadform"].BROWSECV.focus();
			return false;
		}
	}

	return true;
}


function trapRphone() {
	var error_landline = document.getElementById("error_landline");
	var error_mphone = document.getElementById("error_mphone");
	if (error_landline.style.display == "none" && error_mphone.innerHTML.search("Please Specify At Least One Contact Number") != -1)
		hideErrorCSS('mphone','error_mphone','status_mphone');
}

function trapMphone() {
	var error_landline = document.getElementById("error_landline");
	var error_mphone = document.getElementById("error_mphone");
	if (error_landline.style.display == "none" && error_mphone.innerHTML.search("Please Specify At Least One Contact Number") != -1) {
		hideErrorCSS('areacode','error_landline','status_landline');
		hideErrorCSS('landline','error_landline','status_landline');
	}
}


function v_EXPERIENCE(ob) {
        var err = false;
        var experience = document.getElementById("experience");
        var error_experience = document.getElementById("error_experience");
        var status_experience = document.getElementById("status_experience");
		
		var salary = document.getElementById('salary')
		var specialization = document.getElementById('specialization')
		var industry = document.getElementById('industry')
		var role = document.getElementById('role')
        
		error_experience.style.display = "none";
        status_experience.style.display = "none";
		hidetip();
		 if (experience.value == "Fresher") {
			 salary.disabled=true;
			 	 
		 }
        if (experience.value == "") {
                err = true;
                showErrMsg({"ErrDivObj":error_experience, "ErrorMsg":"Please select your Experience", "EleToFocus":experience, "StatusObj":status_experience, "ob":ob, "HName":"Experince"});
        }

        if (ob && !err) {
                //industry.className = "";
		hideErrorCSS("experience","error_experience","status_experience");
                status_experience.src = Images_Path+"/correct.gif";
                status_experience.style.display = "";
                //opacity("status_experience", 100, 0, fd_tout);
        }
}



function v_SALARY(ob) {
        var err = false;
        var salary = document.getElementById("salary");
        var error_salary = document.getElementById("error_salary");
        var status_salary = document.getElementById("status_salary");
        error_salary.style.display = "none";
        status_salary.style.display = "none";
		hidetip();

        if (salary.value == "") {
                err = true;
                showErrMsg({"ErrDivObj":error_salary, "ErrorMsg":"Please select your Salary", "EleToFocus":salary, "StatusObj":status_salary, "ob":ob, "HName":"Salary"});
        }

        if (ob && !err) {
                //industry.className = "";
		hideErrorCSS("salary","error_salary","status_salary");
                status_salary.src = Images_Path+"/correct.gif";
                status_salary.style.display = "";
               // opacity("status_salary", 100, 0, fd_tout);
        }
}


function v_SPECIALIZATION(ob) {
        var err = false;
        var specialization = document.getElementById("specialization");
        var error_specialization = document.getElementById("error_specialization");
        var status_specialization = document.getElementById("status_specialization");
        error_specialization.style.display = "none";
        status_specialization.style.display = "none";
		hidetip();

        if (specialization.value == "") {
                err = true;
                showErrMsg({"ErrDivObj":error_specialization, "ErrorMsg":"Please select your Specialization", "EleToFocus":specialization, "StatusObj":status_specialization, "ob":ob, "HName":"Specialization"});
        }

        if (ob && !err) {
                //industry.className = "";
		hideErrorCSS("specialization","error_specialization","status_specialization");
                status_specialization.src = Images_Path+"/correct.gif";
                status_specialization.style.display = "";
               // opacity("status_salary", 100, 0, fd_tout);
        }
}


function v_INDUSTRY(ob) {
        var err = false;
        var industry = document.getElementById("industry");
        var error_industry = document.getElementById("error_industry");
        var status_industry = document.getElementById("status_industry");
        error_industry.style.display = "none";
        status_industry.style.display = "none";
		hidetip();

        if (industry.value == "") {
                err = true;
                showErrMsg({"ErrDivObj":error_industry, "ErrorMsg":"Please select your Industry", "EleToFocus":industry, "StatusObj":status_industry, "ob":ob, "HName":"Industry"});
        }

        if (ob && !err) {
                //industry.className = "";
		hideErrorCSS("industry","error_industry","status_industry");
                status_industry.src = Images_Path+"/correct.gif";
                status_industry.style.display = "";
               // opacity("status_salary", 100, 0, fd_tout);
        }
}

function v_ROLE(ob) {
        var err = false;
        var role = document.getElementById("role");
        var error_role = document.getElementById("error_role");
        var status_role = document.getElementById("status_role");
        error_role.style.display = "none";
        status_role.style.display = "none";
		hidetip();

        if (role.value == "") {
                err = true;
                showErrMsg({"ErrDivObj":error_role, "ErrorMsg":"Please select your Role", "EleToFocus":role, "StatusObj":status_role, "ob":ob, "HName":"Role"});
        }

        if (ob && !err) {
                //role.className = "";
		hideErrorCSS("role","error_role","status_role");
                status_role.src = Images_Path+"/correct.gif";
                status_role.style.display = "";
               // opacity("status_salary", 100, 0, fd_tout);
        }
}

function v_KEYSKILLS(ob) {
        var err = false;
        var keyskills = document.getElementById("keyskills");
        var error_keyskills = document.getElementById("error_keyskills");
        var status_keyskills = document.getElementById("status_keyskills");
        error_keyskills.style.display = "none";
        status_keyskills.style.display = "none";
		hidetip();

        if (keyskills.value == "") {
                err = true;
                showErrMsg({"ErrDivObj":error_keyskills, "ErrorMsg":"Please enter your Key Skills", "EleToFocus":keyskills, "StatusObj":status_keyskills, "ob":ob, "HName":"keyskills"});
        }

        if (ob && !err) {
                //keyskills.className = "";
		hideErrorCSS("keyskills","error_keyskills","status_keyskills");
                status_keyskills.src = Images_Path+"/correct.gif";
                status_keyskills.style.display = "";
               // opacity("status_salary", 100, 0, fd_tout);
        }
}

function v_PASSWORD(ob) {
	var password = document.getElementById("password");
	var error_password = document.getElementById("error_password");
	var status_password = document.getElementById("status_password");
	var params = new Array();
	var err = true;
	password.value = rm_trim(password.value);
	if ( password.value.length == 0 ) {
		params = { "ErrDivObj": error_password, "ErrorMsg": "Please enter a Password.", "EleToFocus": password, "StatusObj": status_password, "ob": ob, "HName": "Password" };
		showErrMsg(params);
		err = true;
		
	} else if ( password.value.length < 6 ) {
		params = { "ErrDivObj": error_password, "ErrorMsg": "Password chosen must be minimum 6 characters long.", "EleToFocus": password, "StatusObj": status_password, "ob": ob, "HName": "Password" };
		showErrMsg(params);
		err = true;
	} else if ( !isValidPassword(password.value)) {
		params = { "ErrDivObj": error_password, "ErrorMsg": "Special characters other than (Hyphen Underscore Dot @) are not allowed.", "EleToFocus": password, "StatusObj": status_password, "ob": ob, "HName": "Password" };
		showErrMsg(params);
		err = true;
	}
	if ( ob && !err ) {
		hideErrorCSS('password','error_password','status_password');
		status_password.style.display = '';
		status_password.src = Images_Path+"/correct.gif";
		////opacity("status_password", 100, 0, fd_tout);
	}
	//return err;
}

function v_CPASSWORD(ob) {
	var password = document.getElementById("password");
	var cpassword = document.getElementById("cpassword");
	var error_cpassword = document.getElementById("error_cpassword");
	var status_cpassword = document.getElementById("status_cpassword");
	var params = new Array();
	var err = false;
	password.value = rm_trim(password.value);
	cpassword.value = rm_trim(cpassword.value);
	if ( cpassword.value.length == 0 ) {
		params = { "ErrDivObj": error_cpassword, "ErrorMsg": "Please Re-Enter to confirm Password.", "EleToFocus": cpassword, "StatusObj": status_cpassword, "ob": ob, "HName": "Confirm Password" };
		showErrMsg(params);
		err = true;
	} else if ( cpassword.value != password.value ) {
		params = { "ErrDivObj": error_cpassword, "ErrorMsg": "Your Passwords entries do not match.", "EleToFocus": cpassword, "StatusObj": status_cpassword, "ob": ob, "HName": "Confirm Password" };
		showErrMsg(params);
		err = true;
	}
	if ( ob && !err ) {
		hideErrorCSS('cpassword','error_cpassword','status_cpassword');
		status_cpassword.style.display = '';
		status_cpassword.src = Images_Path+"/correct.gif";
		//opacity("status_cpassword", 100, 0, fd_tout);
	}
}
function v_CNAME(ob) {
	var cname = document.getElementById("cname");
	var error_cname = document.getElementById("error_cname");
	var status_cname = document.getElementById("status_cname");
	var params = new Array();
	var err = false;
	cname.value = rm_trim(cname.value);
	if (cname.value.length == 0 ) {
		err = true;
		params = { "ErrDivObj": error_cname, "ErrorMsg": "Please enter your Name.", "EleToFocus": cname, "StatusObj": status_cname, "ob": ob, "HName": "Name" };
		showErrMsg(params);
		//hideErrorCSS('cname','error_cname','status_cname');
	} else if ( cname.value.length > 0  &&  ! isValidName(cname.value) ) {
		params = { "ErrDivObj": error_cname, "ErrorMsg": "Only Charecters (including Space) are allowed.", "EleToFocus": cname, "StatusObj": status_cname, "ob": ob, "HName": "Name" };
		showErrMsg(params);
		err = true;
	}
	if ( ob && !err ) {
		hideErrorCSS('cname','error_cname','status_cname');
		status_cname.src = Images_Path+"/correct.gif";
		status_cname.style.display = '';
		//opacity("status_cname", 100, 0, fd_tout);
	}
}
function v_EMAIL(ob) {
	var email = document.getElementById("email");
	var error_email = document.getElementById("error_email");
	var status_email = document.getElementById("status_email");
	var params = new Array();
	var err = false;
	email.value = rm_trim(email.value);
	if ( email.value.length == 0 ) {
		params = {'ErrDivObj': error_email, "ErrorMsg": "Please enter a valid Email Id.", "EleToFocus":email, "StatusObj":status_email, "ob": ob, "HName": "Email" };
		showErrMsg(params);
		err = true;
	} else if ( email.value.length < 6 || !isValidEmail(email.value)) {
		params = {'ErrDivObj': error_email, "EleToFocus":email, "StatusObj":status_email, "ob": ob, "HName": "Email" };
		if ( email.value.length > max_email_disp_len ) {
			params['ErrorMsg'] = "< " + email.value.substring(0, max_email_disp_len ) + "... > is Not a Valid Email Id. Please Enter a Valid Email Id.";
		} else {
			params['ErrorMsg'] = "< " + email.value + " > is not a valid Email Id. Please enter a valid Email Id.";
		}
		showErrMsg(params);
		err = true;
	}
	if ( ob && !err ) {
		hideErrorCSS('email','error_email','status_email');
		CheckEmailAvailability('email',ob, err);
		status_email.style.display = '';
		status_email.src = Images_Path+"/correct.gif";
		//opacity("status_email", 100, 0, fd_tout);
	}
}
function v_COUNTRY(ob, src) {
		        var pattern = /[^a-zA-Z\s,.\-/]/;
        var err = false;
        var country = document.getElementById("country");
		var city = document.getElementById("city");
		var error_country = document.getElementById("error_country");
        var status_country = document.getElementById("status_country");
        error_country.style.display = "none";
        status_country.style.display = "none";
        //ocountry.value = rm_trim(ocountry.value);

        src = src ? src : 0;


        if ( country.value == -1 )  {
                err = true;
                showErrMsg({"ErrDivObj":error_country, "ErrorMsg":"Please select your Country.", "EleToFocus":country, "StatusObj":status_country, "ob":ob, "HName":"Country"});
				city.disabled=true;
				
				
        }
		else
		{
			city.disabled=false;
			
			}
       
        if (ob && !err && src != "trapCountry") {               
			hideErrorCSS('country','error_country','status_country');
			status_country.src = Images_Path+"/correct.gif";
             status_country.style.display = "";
        }
}
function v_CITY(ob) {
        var pattern = /[^a-zA-Z\s,.\-/]/;
        var err = false;
        var country = document.getElementById("country");
        //var ocountry = document.getElementById("ocountry");
        var city = document.getElementById("city");
        //var ocity = document.getElementById("ocity");
        var error_country = document.getElementById("error_country");
        var error_city = document.getElementById("error_city");
        var status_country = document.getElementById("status_country");
        var status_city = document.getElementById("status_city");
        error_country.style.display = "none";
        status_country.style.display = "none";
        error_city.style.display = "none";
        status_city.style.display = "none";
        //ocountry.value = rm_trim(ocountry.value);
        //ocity.value = rm_trim(ocity.value);
        if ( country.value == -1 )  {
                err = true;
                showErrMsg({"ErrDivObj":error_country, "ErrorMsg":"Please select your Country.", "EleToFocus":country, "StatusObj":status_country, "ob":ob, "HName":"Country"});
        }
        
        if ( city.value == -1 && city.disabled == false)  {
                if ( country.value == -1  )  {
                        err = true;
                        showErrMsg({"ErrDivObj":error_city, "ErrorMsg":"Please select your Current Location.", "EleToFocus":city, "StatusObj":status_city, "ob":ob, "HName":"City"});
                }
                else   {
                        err = true;
                        showErrMsg({"ErrDivObj":error_city, "ErrorMsg":"Please type your City Name in the Text Box.", "EleToFocus":city, "StatusObj":status_city, "ob":ob, "HName":"City"});
                }
        }
        
        if (ob && !err) {        
		hideErrorCSS('city','error_city','status_city');
		status_city.src = Images_Path+"/correct.gif";
		status_city.style.display = ""
        }
}
function trapCountry() {
        var country = document.getElementById("country");
	CountryChangedEvent("trapCountry");
	SetCountryAreaCode();
	v_COUNTRY(1, "trapCountry");
}

function trapCity() {
        var city = document.getElementById("city");
        var pattern = /(Other)/;
        if (pattern.test(city.options[city.selectedIndex].text)) {
                CityChangedEvent();
                v_COUNTRY(1);
                v_CITY(1);
        }
}

function v_RAREACODE(ob)
{
var err = false;
var landline = document.getElementById("landline");
var areacode = document.getElementById("areacode");	
var error_landline = document.getElementById("error_landline");
var status_landline = document.getElementById("status_landline");
error_landline.style.display = "none";
status_landline.style.display = "none";
areacode.value = rm_trim(areacode.value);
landline.value = rm_trim(landline.value);
if(areacode.value!="")
{
	var reg = /(^-?\d\d*$)/;
	if (reg.test(areacode.value)==false)  	
	{
		err = true;
		showErrMsg({"ErrDivObj":error_landline, "ErrorMsg":"Please enter a valid Area Code", "EleToFocus":landline, "StatusObj":status_landline, "ob":ob, "HName":"Landline Number"});
	}
	else if(areacode.value.length<2)
	{
		err = true;
		showErrMsg({"ErrDivObj":error_landline, "ErrorMsg":"Area Code can not be less than 2 digits", "EleToFocus":landline, "StatusObj":status_landline, "ob":ob, "HName":"Landline Number"});
	}
	
}
if (String(landline.value).length > 0)
	{
		v_RPHONE(0);
	}
	
}

function v_RPHONE(ob) {
	var err = false;
	
	var areacode = document.getElementById("areacode");
	var landline = document.getElementById("landline");
	var error_landline = document.getElementById("error_landline");
	var status_landline = document.getElementById("status_landline");
	error_landline.style.display = "none";
	status_landline.style.display = "none";
	
	areacode.value = rm_trim(areacode.value);
	landline.value = rm_trim(landline.value);

	if (  String(landline.value).length > 0 || String(areacode.value).length > 0) 
	{
		var reg = /(^-?\d\d*$)/;
		if ( reg.test(areacode.value)==false)  
		{
			err = true;
			showErrMsg({"ErrDivObj":error_landline, "ErrorMsg":"Please enter a valid Area Code", "EleToFocus":landline, "StatusObj":status_landline, "ob":ob, "HName":"Landline Number"});
			
		}
		else if ( reg.test(landline.value)==false)  
		{
			err = true;
			showErrMsg({"ErrDivObj":error_landline, "ErrorMsg":"Please enter a valid Landline Number", "EleToFocus":landline, "StatusObj":status_landline, "ob":ob, "HName":"Landline Number"});
			
		}
		else if(landline.value.length<6)
		{
			err = true;
			showErrMsg({"ErrDivObj":error_landline, "ErrorMsg":"Landline Number can not be less than 6 digits", "EleToFocus":landline, "StatusObj":status_landline, "ob":ob, "HName":"Landline Number"});
		}
		else if(areacode.value.length<2)
		{
			err = true;
			showErrMsg({"ErrDivObj":error_landline, "ErrorMsg":"Area Code can not be less than 2 digits", "EleToFocus":landline, "StatusObj":status_landline, "ob":ob, "HName":"Landline Number"});
		}
	}
	
}

function v_MPHONE(ob) {
	var err = false;
	
	var areacode = document.getElementById("areacode");
	var landline = document.getElementById("landline");
	var mphone = document.getElementById("mphone");
	var error_landline = document.getElementById("error_landline");
	var error_mphone = document.getElementById("error_mphone");
	var status_landline = document.getElementById("status_landline");
	var status_mphone = document.getElementById("status_mphone");
	error_landline.style.display = "none";
	error_mphone.style.display = "none";
	status_landline.style.display = "none";
	status_mphone.style.display = "none";
	
	areacode.value = rm_trim(areacode.value);
	landline.value = rm_trim(landline.value);
	mphone.value = rm_trim(mphone.value);

	v_RPHONE(ob);
	if (  String(landline.value).length == 0 &&  String(mphone.value).length == 0)  {
		err = true;
		param_EleToFocus = [mphone, areacode, landline];
		param_EleToFocus["isArray"] = 1;
		param_StatusObj = [status_landline, status_mphone];
		param_StatusObj["isArray"] = 1;
		showErrMsg({"ErrDivObj":error_mphone, "ErrorMsg":"Please enter at least one Contact Number", "EleToFocus":param_EleToFocus, "StatusObj":param_StatusObj, "ob":ob, "HName":"Contact Number"});
	}
	else if (  String(mphone.value).length > 0 && isValidPhone(mphone.value) == false ) {
		err = true;
		showErrMsg({"ErrDivObj":error_mphone, "ErrorMsg":"Please enter a valid Mobile Number", "EleToFocus":mphone, "StatusObj":status_mphone, "ob":ob, "HName":"Mobile Number"});
	}
	else if ( String(mphone.value).length > 0 && String(mphone.value).length < 10) {
		err = true;
		showErrMsg({"ErrDivObj":error_mphone, "ErrorMsg":"Mobile Number can not be less than 10 digits", "EleToFocus":mphone, "StatusObj":status_mphone, "ob":ob, "HName":"Mobile Number"});
	}

	if (ob && !err) {
		mphone.className = "";
		if (mphone.value == "") // don't show tick in case phone no. is empty
			status_mphone.src = "";//Images_Path+"/zero.gif";
		else {
			status_mphone.src = Images_Path+"/correct.gif";
			status_mphone.style.display = "";
		}
	}
}

var pattern = /[^a-zA-Z0-9\s&.,\-]/;
var pattern2 = /[^a-zA-Z0-9'\s&.,\-]/;


function onloadEvents()
{
	var username 	   = document.getElementById("username");
	var password = document.getElementById("password");
	var cpassword = document.getElementById("cpassword");
	var email = document.getElementById("email");
	var landline = document.getElementById("landline");
	var mphone = document.getElementById("mphone");

	var hlptxt = document.getElementsByName("hlptxt");
	var i = 0;
	for ( i=0; i < hlptxt.length; i++ )  {
		hlptxt[i].style.display = "none";
	}

	var country      = document.getElementById("country");
	
	var city         = document.getElementById("city");
	
	SetCountryAreaCode();

	createhintbox();
	document.getElementById("username").focus();
}

var ErrorCount = 0;
var max_email_disp_len = 25;
sleepSec = 0;
function validateForm()
{
	
	//document.getElementById("submitbtn").disabled = true;

	var error_topmsgdiv  = document.getElementById("error_topmsgdiv");
	var error_topmsgspan = document.getElementById("error_topmsgspan");

	var msg = '', msg1 = '';
	var length = 0;

	ErrorDetails = {};
	alreadyFocussed = false;

	CheckUsernameAvailability(0);
	v_PASSWORD(0);
	v_CPASSWORD(0);
	v_EMAIL(0);
	v_COUNTRY(0);
	v_CITY(0);
	v_RAREACODE(0);
	v_RPHONE(0);
	v_MPHONE(0);
	v_EXPERIENCE(0);
	v_SALARY(0);
	v_CNAME(0);	
	v_SPECIALIZATION(0);
	v_INDUSTRY(0);
	v_ROLE(0);
	v_KEYSKILLS(0);
	v_RESEXIST(0);
	v_SECCODE(0);
			

	for(idx in ErrorDetails ) {
		length++;
		msg1 = msg1 + ', ' + idx;
	}
	


	if (length == 0) { 		if (sleepSec<10 && document.forms["page1"].isuploading.value == 1) {

			return false;
		}
		else
			sleepSec = 0;
    }

	if ( length > 0 ) {
		error_topmsgdiv.style.display = '';
		msg = "&nbsp;<b>" + length+ " Error(s) </b> occured while validating. Please correct the fields marked in red below.";
		if ( length <=5 ) {
			//msg = msg + "<br><b>" + msg1.substring(2, msg1.length) + "</b>";
		}
		error_topmsgspan.innerHTML = msg;
		//document.getElementById("submitbtn").disabled = false;
		return false;
	} else {
		//document.getElementById("submitbtn").disabled = true; 		
		return true;
	}
}

function isValidPhone(Value, AllowDashPlus )
{
	if ( Value.length == 0 )
		return true;
	var pattern  = /[0-9]/g;
	var pattern1 = /[+]?[0-9]*$/g;
	var firstChar = Value.charAt(0);
	var retVal = false;
	if ( firstChar == "+" ||( firstChar >=0 && firstChar <= 9 ) ) {
	}else {
		retVal = false;
	}
	for(i=1; i< Value.length; i++ )  {
		firstChar = Value.charAt(i);
		if ( firstChar >= 0 || firstChar <= 9 ){
			retVal = true;
		} else {
			retVal = false;
		}
	}
	return retVal;
}

function isValidPassword(Password)
{
        var pattern = /[^a-zA-Z0-9@._-]+/;
        if ( pattern.test ( Password ) )
                return false;
        else
                return true;
}

function isValidName(Name)
{
        var pattern = /[^a-zA-Z\s]+/;
        if ( pattern.test ( Name ) )
                return false;
        else
                return true;
}

function isValidEmail(Email)
{
	var pattern = /^([a-zA-Z0-9_\-])+(\.([a-zA-Z0-9_\-])+)*@((\[(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5]))\]))|((([a-zA-Z0-9])+(([\-])+([a-zA-Z0-9])+)*\.)+([a-zA-Z])+(([\-])+([a-zA-Z0-9])+)*))$/;

	return  pattern.test(Email);
}

function isNumeric( Value)
{
        var pattern = /[^0-9]/;
	return ! pattern.test(Value );
}

function CountryChangedEvent()
{
	var country       = document.getElementById("country");
	//var ocountry      = document.getElementById("ocountry");
	var error_country = document.getElementById("error_country");
	var city          = document.getElementById("city");
	//var ocity         = document.getElementById("ocity");
	var error_city    = document.getElementById("error_city");

	error_country.style.display = "none";
	error_country.innerHTML = "";
	error_city.style.display = "none";
	error_city.innerHTML = "";

	if ( country.value == -1 ||  country.value == 11 ) {
		city.disablled = false;
		city.value = -1;
			
	}
	
	else  {
		city.value = -1;
		city.disabled = true;
		}
		
		if ( country.value != -1)
		{
			stchange(country.value);
		}
		else if(country.value == '-1')
			{
			document.getElementById('phoneexample').innerHTML="Count. Code-STD Code-Ph. No.";
			document.getElementById('mobileexample').innerHTML="";
			document.getElementById("status_city").style.display="none";
			document.getElementById('countrycode').value="";
			document.getElementById('mcountrycode').value="";
			}

}

function CityChangedEvent()
{
	var location=document.getElementById("location");
	var country = document.getElementById("country");
	//var ocountry = document.getElementById("ocountry");
	var city = document.getElementById("city");
	//var ocity = document.getElementById("ocity");
	var error_city = document.getElementById("error_city");

	error_city.style.display = "none";
	error_city.innerHTML = "";

	location.value=city.options[city.selectedIndex].text;
	
	var pattern = /(Other)/;
	if ( pattern.test(city.options[city.selectedIndex].text) )  {
		//ocity.style.display = "";
	} else {
		//ocity.style.display = "none";
	}
}


function ExpChangedEvent()
{
	
	var country = document.getElementById("country");
	
}


function SetCountryAreaCode()
{
	var country = document.getElementById("country");
	var city = document.getElementById("city");
	var countrycode = document.getElementById("countrycode");
	var areacode = document.getElementById("areacode");

	cityCode = new Array();
		cityCode['ahmedabad'] = "79";
		cityCode['bangalore'] = "80";
		cityCode['chennai'] = "44";
		cityCode['delhi'] = "11";
		cityCode['hyderabad'] = "40";
		cityCode['kolkata'] = "33";
		cityCode['mumbai'] = "22";
		cityCode['noida'] = "120";
		cityCode['pune'] = "20";
	
	if ( country.value == -1 )
	{
		countrycode.value = "";
		areacode.value = "";
		return;
	}

	var cityval = city.options[city.selectedIndex].text.toLowerCase();
	if ( cityval.indexOf("/") > -1 )  {
		var cityvals = cityval.split(" / ");
		cityval = cityvals[0];
	}
	if ( country.value == 11 ) {
		countrycode.value = "91";
		try {
			if ( cityCode[cityval] != null )
				areacode.value = cityCode[cityval];
			else if ( cityCode[cityvals[1]] != null )
				areacode.value = cityCode[cityvals[1]];
			else
				areacode.value = "";
		}catch(e) { areacode.value = ""; }
	} else  {
		if ( countrycode.value == "91" || countrycode.value == "-91" || countrycode.value == "+91" )
			countrycode.value = "";
		for ( cityIndex in cityCode )  {
			if ( areacode.value == cityCode[cityIndex] )  {
				areacode.value = "";
				break;
			}
		}
	}
}

function CheckMaxLength(ObjId, errObjId, statusObjId, MaxLen )
{
	var Obj = document.getElementById(ObjId);
	var text = rm_trim(Obj.value);
	var errObj = document.getElementById(errObjId);
	var statusObj = document.getElementById(statusObjId);
	var text1 = text.replace("\r\n","");
	if ( parseInt(text1.length) > parseInt(MaxLen) )  {
		Obj.value = text.substring(0,MaxLen);
		Obj.value = text;
		showErrMsg({"ErrDivObj":errObj, "ErrorMsg":"You can not enter more than " + MaxLen + " characters.", "EleToFocus":Obj, "StatusObj":statusObj, "ob":1, "HName":"Keywords"});
	}
}
function rm_trim(inputString)
{
        if (typeof inputString != "string") { return inputString; }

        var temp_str = '';
        temp_str = inputString.replace(/[\s]+/g,"");
        if(temp_str == '')
                return "";

        var retValue = inputString;
        var ch = retValue.substring(0, 1);
        while (ch == " ")
        {
                retValue = retValue.substring(1, retValue.length);
                ch = retValue.substring(0, 1);
        }
        ch = retValue.substring(retValue.length-1, retValue.length);
        while (ch == " ")
        {
                retValue = retValue.substring(0, retValue.length-1);
                ch = retValue.substring(retValue.length-1, retValue.length);
        }
        while (retValue.indexOf("  ") != -1)
        {
          retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
        }
        return retValue;
}



function SpecializationChangedEvent()
{
	var specialization = document.getElementById("specialization");
	//var ocountry      = document.getElementById("ocountry");
	var error_specialization = document.getElementById("error_specialization");
	var role          = document.getElementById("role");
	//var ocity         = document.getElementById("ocity");
	var error_role    = document.getElementById("error_role");

	error_specialization.style.display = "none";
	error_specialization.innerHTML = "";
	error_role.style.display = "none";
	error_role.innerHTML = "";

	if ( specialization.value == -1) {
		role.disablled = true;
		role.value = -1;
			
	}
	
	else  {
		role.value = -1;
		role.disabled = false;
		}
		
		if ( specialization.value != -1)
		{
			rolechange(specialization.value);
			}
}

function rolechange(str)
{
	//alert(str)
if (str.length==0)
  { 
  document.getElementById("txtHint").innerHTML=""
  return
  }
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
var url="getrole.php"
url=url+"?q="+str;
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=roleChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 

function roleChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 //alert(xmlHttp.responseText);
 var roleresponse=xmlHttp.responseText.split('#');
   var role=document.getElementById("role");
  clearListBox(role);
  var ind=roleresponse[0].split('`');
  var txt=roleresponse[1].split('`');
  
  for(var i=1;i<ind.length;i++)
	{
		//alert(txt[i-1]);
		role.options[i] = new Option(txt[i-1]);
		role.options[i].value = ind[i-1];


		}

	
 } 
}


function clearListBox(mylistbox) 
{ 
if(mylistbox == null)  
return 1;
while(mylistbox.length > 1)
{   mylistbox.remove(1);  }  
return 1;
}




function stchange(str)
{
	if(str=='1')
	{
		document.getElementById('phoneexample').innerHTML=" Example : +1-451-7498011";
		document.getElementById('mobileexample').innerHTML=" Example : +1-8046306302";
		document.getElementById('countrycode').value="+1";
		document.getElementById('mcountrycode').value="+1";
	}
	if(str=='2')
	{
		document.getElementById('phoneexample').innerHTML=" Example : +91-120-42416178";
		document.getElementById('mobileexample').innerHTML=" Example : +91-9818178000";
		document.getElementById('countrycode').value="+91";
		document.getElementById('mcountrycode').value="+91";
	}

if (str.length==0)
  { 
  document.getElementById("txtHint").innerHTML=""
  return
  }
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
var url="getstate.php"
url=url+"?q="+str;
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("citydiv").innerHTML=xmlHttp.responseText 
 
 } 
}

function GetXmlHttpObject()
{
var xmlHttp=null;try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

function v_RESEXIST(ob) {
	var resexist = document.getElementById("resexist");
	var error_resume = document.getElementById("error_resume");
	var status_resume = document.getElementById("status_resume");
	var fileresume = window.fileframe.document.getElementById("resume");
	var params = new Array();
	var err = false;
	resexist.value = rm_trim(resexist.value);
	if (resexist.value.length == 0 ) {
		err = true;
		params = { "ErrDivObj": error_resume, "ErrorMsg": "Please enter your Resume.", "EleToFocus": fileresume, "StatusObj": status_resume, "ob": ob, "HName": "Resume" };
		showErrMsg(params);
		
	} 
	if ( ob && !err ) {
		hideErrorCSS('resexist','error_resume','status_resume');
		status_resume.src = Images_Path+"/correct.gif";
		status_resume.style.display = '';
	}
}

function trackThis(str)
{
	var resexist = document.getElementById("resexist");
	var error_resume = document.getElementById("error_resume");
	var status_resume = document.getElementById("status_resume");
	var fileresume = window.fileframe.document.getElementById("resume");
	var ob="";
	var params = new Array();		
	if(str=="Invalid")
	{
		resexist.value="";
		err = true;
		params = { "ErrDivObj": error_resume, "ErrorMsg": "Please ensure that you are uploading MS-WORD file only.", "EleToFocus": fileresume, "StatusObj": status_resume, "ob": ob, "HName": "Resume" };
		showErrMsg(params);
	}
	if(str=="size")
	{
	
	resexist.value="";
	err = true;
		params = { "ErrDivObj": error_resume, "ErrorMsg": "Please ensure that your file do not exceed 150kb.", "EleToFocus": fileresume, "StatusObj": status_resume, "ob": ob, "HName": "Resume" };
		showErrMsg(params);
	}
	
	if(str=="success")
	{
	document.getElementById('error_resume').innerHTML="";
	resexist.value="success";
	status_resume.src = Images_Path+"/correct.gif";
	status_resume.style.display = '';
	}
}
			
function hidemonths(str)			
{
	
	if(document.getElementById(str).value=="00")
		document.getElementById('months').disabled=true;
		else
		document.getElementById('months').disabled=false;
}

function v_SECCODE(ob){
	var seccode = document.getElementById("seccode");
	var error_seccode = document.getElementById("error_seccode");
	var status_seccode = document.getElementById("status_seccode");
	var params = new Array();
	var err = false;
	seccode.value = rm_trim(seccode.value);
	if (seccode.value.length == 0 ) {
		err = true;
		params = { "ErrDivObj": error_seccode, "ErrorMsg": "Please enter the image text.", "EleToFocus": seccode, "StatusObj": status_seccode, "ob": ob, "HName": "Seccode" };
		showErrMsg(params);
		//hideErrorCSS('cname','error_cname','status_cname');
	} 
	if ( ob && !err ) {
		hideErrorCSS('seccode','error_seccode','status_seccode');
		//status_seccode.src = Images_Path+"/correct.gif";
		//status_seccode.style.display = '';
		//opacity("status_cname", 100, 0, fd_tout);
	}
}