<!--
var currCtry = '';
var currState = '';
var currSpec = '';

function toggleSection(id, newClass)
{
	var identity=elId(id);
	if (identity.className == "toggleshow") {
		identity.className="toggle";
	} else {
		identity.className= newClass;
	}
}

//Check Login Availability
function checkLid(lid, url, errId) {
    lid = Trim(lid);
    if (lid == null || lid == '') {
        // if user did not enter login id
        procLid('', errId);
    } else {
        var re = new RegExp(/^[a-z0-9\.\_\@\']*$/i);
        if (lid.match(re)) {
    		var str = 'ac=1&li=' + encodeURIComponent(lid);
            mkGetReq(url, str, 'procLid', errId);
        } else {
            procLid('0|bad_id', errId);
        }
    }
}

//Process Check Login Availability result
function procLid(responseText, errId) {
    
    if (responseText == null || responseText == '') {
    } else {
        // responseText format: valid(1)|$arrChk.message_id|loginID
        var result = responseText.split("|");
        var output = eval('$arrChk.' + result[1]);
        if (result[2]) {
            output = output.replace(/##LoginID##/g, result[2]);
        }
        setDivMsg(errId, output);
        setObjVisibility(errId, 'true');
    }
}

function initReq()
{
	var req = null;
	//find the most recent version on user machine
	var arr = ['MSXML2.XMLHttp.5.0', 'MSXML2.XMLHttp.4.0', 'MSXML2.XMLHttp.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'];
	if (window.XMLHttpRequest) 
	{
		req = new XMLHttpRequest();
		return req;
	} else {
		for (var i=0; i<arr.length; i++) {
			try {
				req = new ActiveXObject(arr[i]);
				return req;
			} catch (e) { }
		}
	}
	throw new Error("XmlHttp not supported.");
}

function mkGetReq(url, str, callBack, ele, imgEle)
{
	var request = initReq();
	if (request != null) 
	{
		request.onreadystatechange = function() 
		{
		if (request.readyState == 4 && request.status == 200) {
			if (request.responseText) {
				eval("var output = '" + request.responseText + "';");
				eval(callBack + "('" + output + "', '" + ele + "', '" + imgEle + "');");		
				return;
			} else {
				eval(callBack + "('', '" + ele + "', '" + imgEle + "');");
                return;			
            }
		}
		return;
		}
		request.open('GET', url + '?' + str, true);
		request.send(null);
	} 
}

//Check Email as Login ID
function checkEmailLid(lid, url, loginId, errId) {
	if (lid != '') {
		var str = 'ac=2&li=' + encodeURIComponent(lid);
		mkGetReq(url, str, 'procEmailLid', loginId, errId);
	}
}

var jsonLid = '';
var jsonErrId = '';
var currField = '';
// using json

function remoteCheckEmailLid(lid, url, loginId, errId) {
	if (lid != '') {
		var str = 'ac=2&op=json&li=' + encodeURIComponent(lid);
		jsonLid = loginId;
		jsonErrId = errId;
		currField = 'email';
        // The web service call
        var req  = url + '?' + str; 
        // Create a new request object
        bObj = new JSONscriptRequest(req); 
        // Build the dynamic script tag
        bObj.buildScriptTag(); 
        // Add the script tag to the page
        bObj.addScriptTag();
	}
}

function remoteCheckLid(lid, url, errId) {
    lid = Trim(lid);
    if (lid == null || lid == '') {
        procLid('', errId);
    } else {
		jsonErrId = errId;
		currField = 'login';
        var re = new RegExp(/^[a-z0-9\.\_\@\']*$/i);
		var str = 'ac=1&op=json&li=' + encodeURIComponent(lid);
        var req  = url + '?' + str; 
        if (lid.match(re)) {
            // Create a new request object
            bObj = new JSONscriptRequest(req); 
            // Build the dynamic script tag
            bObj.buildScriptTag(); 
            // Add the script tag to the page
            bObj.addScriptTag();
        } else {
            procLid('0|bad_id', errId);
        }
	}
}

function getJsonAvail(jsonData) {     
    var output = jsonData.ResultSet.Result[0].Response;
    if (currField == 'email')     procEmailLid(output, jsonLid, jsonErrId);
    else procLid(output, jsonErrId);
    // After getting response remove script tag
    bObj.removeScriptTag(); 
}

//Process Check Email as Login ID results
function procEmailLid(responseText, loginId, errId) {
    
    if (responseText == null || responseText == "") {
    } else {
        // responseText format: valid(1)|$arrChk.message_id|loginID
        var result = responseText.split("|");
        if (result[0] == 0) {
            // if login id already exists
            var output = $arrChk.same_email;
            if (result[2]) {
                output = output.replace(/##LoginID##/g, result[2]);
            }
            if (elId(loginId).style.display == 'none') {
                setObjVisibility(loginId, 'true');
                elId('login_id').value = '';
                setDivMsg(errId, output);
                setObjVisibility(errId, 'true');
                elId('login_id_flag').value = 1;
                showForm(8);
            }
        } else {
            setDivMsg(errId, '');
            elId('login_id').value = '';
            setObjVisibility(errId, 'false');
            setObjVisibility(loginId, 'false');
        }
        hideOverlay();
    }
}

function changeBox(divTip, divField, txtField) 
{
  setObjVisibility(divTip, 'false');//elId(divTip).style.display='none';
  setObjVisibility(divField, 'true');//elId(divField).style.display='';
  focusCtrl(elId(txtField));
}

function restoreBox(divTip, divField, txtField) 
{
	if(elId(txtField).value=='')
	{
	  setObjVisibility(divTip, 'true');//elId(divTip).style.display='';
	  setObjVisibility(divField, 'false');//elId(divField).style.display='none';
	} else {
		changeBox(divTip, divField, txtField);
	}
}

function setPLevel(ctl) {
	var frm = document.frmRegistration;
	var value = GetValueFromCtl(ctl);
	if (value == "0") {
		frm.position_level_code.selectedIndex = 5;	frm.company_name.value=""; frm.company_name.disabled=true; 
		frm.position_title.value=""; frm.position_title.disabled=true; frm.salary_currency_code.selectedIndex = 0; frm.salary_currency_code.disabled=true;
		frm.salary.value=""; frm.salary.disabled=true;
	} else {
		if (frm.position_level_code.selectedIndex == 5) frm.position_level_code.selectedIndex = 0;	
		frm.company_name.disabled=false; frm.position_title.disabled=false; //frm.dpt_field.disabled=false; 
		frm.salary_currency_code.disabled=false;frm.salary.disabled=false;
	}
}

function ShowTextBox()
{
	var textDiv = document.getElementById('copyResume');
	var upDiv = document.getElementById('uploadResume');
	var rdo = GetValueFromRdo(document.frmRegistration.uploaded);
	if (rdo == "2")
	{
        unsetErrorBlock('errUpload', '', '');  
		hideOverlay();
		if (textDiv) textDiv.style.display = 'block';
		if (upDiv) upDiv.style.display = 'none';
	}
	else if (rdo == "1")						
	{
		if (upDiv) upDiv.style.display = 'block';
		if (textDiv) textDiv.style.display='none';
	}
	else {
        unsetErrorBlock('errUpload', '', '');  
		if (upDiv) upDiv.style.display = 'none';
		if (textDiv) textDiv.style.display='none';	
	}
}	
function showYM(value, currYear) {
	setObjVisibility('expMonth', 'false');
	setObjVisibility('expYears', 'false');
	
	if (currYear - value <= 1)	{ setObjVisibility('expMonth','true'); elId('years_of_exp_text').value = '';}
	else if(value != '' && currYear - value > 30) { setObjVisibility('expYears', 'true'); elId('expMonth').selectedIndex = 0; }
	else { elId('expMonth').selectedIndex = 0; elId('years_of_exp_text').value = ''; }
    if (currYear - value < 3) {
			setObjVisibility('dvGraduation','true');
			setObjVisibility('dvGraduation2','true');
			//setObjVisibility('dvJDate','true');
			//setObjVisibility('dvLDate','true');
			setObjVisibility('dvGrade','true');
			setObjVisibility('dvGradeTwo', 'true')
    } else {
			setObjVisibility('dvGraduation','false');
			if (elId('grad_month'))  elId('grad_month').selectedIndex = 0;
			if (elId('average_grade'))  elId('average_grade').selectedIndex = 0;
			if (elId('average_grade0'))  elId('average_grade0').selectedIndex = 0;
			if (elId('average_grade1'))  elId('average_grade1').selectedIndex = 0;
			//if (elId('join_date_month'))  elId('join_date_month').selectedIndex = 0;
			//if (elId('left_date_month'))  elId('left_date_month').selectedIndex = 0;
			setObjVisibility('dvGraduation2','false');
			//setObjVisibility('dvJDate','false');
			//setObjVisibility('dvLDate','false');
			setObjVisibility('dvGrade','false');
			setObjVisibility('dvGradeTwo', 'false')
			setObjVisibility('cgpa1','false');
			setObjVisibility('cgpa2','false');
    }
}
function showExp(ctry, ctrl, arrEle) {
	value = GetValueFromRdo(ctrl);
	arrEle[3].checked = false; // uncheck intern first
	if(value != '') {
		if (value == 1) { 
			setObjVisibility('dvWorkSection','true');
			setObjVisibility('dvStudent','false');
			elId('years_of_exp').disabled = false;
			if (elId('grad_month'))  elId('grad_month').selectedIndex = 0;
			if (elId('average_grade'))  elId('average_grade').selectedIndex = 0;
			if (elId('average_grade0'))  elId('average_grade0').selectedIndex = 0;
			if (elId('average_grade1'))  elId('average_grade1').selectedIndex = 0;
			//if (elId('join_date_month'))  elId('join_date_month').selectedIndex = 0;
			//if (elId('left_date_month'))  elId('left_date_month').selectedIndex = 0;
			if (elName('cgpa')) elName('cgpa').value='';
			if (elName('cgpa_base')) elName('cgpa_base').value='';
			if (elId('cgpa0_field')) elId('cgpa0_field').value='';
			if (elId('cgpa1_field')) elId('cgpa1_field').value='';
			if (elId('cgpa_base0_field')) elId('cgpa_base0_field').value='';
			if (elId('cgpa_base1_field')) elId('cgpa_base1_field').value='';
		} else { 
			setObjVisibility('dvGraduation','true');
			setObjVisibility('dvGraduation2','true');
			//setObjVisibility('dvJDate','true');
			//setObjVisibility('dvLDate','true');
			setObjVisibility('dvGrade','true');
			setObjVisibility('dvGradeTwo', 'true')
			setObjVisibility('dvWorkSection','false');
			elId('years_of_exp').selectedIndex = 0;
			elId('years_of_exp').disabled = true;
			elId('months_of_exp').selectedIndex = 0;
			setObjVisibility('expMonth', 'false');
			setObjVisibility('expYears', 'false');
			setObjVisibility('errYExp', 'false');
			if (ctry=='100') setObjVisibility('dvStudent','true');
			showOverlay ('', '', '', '', ''); //hide overlay
            if (value == 3) {
                arrEle[3].checked = true;
            }
        }
	}
}

function suggest(ctry, ctryObj){
	if (isIE6OrAbove() && (ctry=='150'||ctry=='100'||ctry=='170'||ctry=='190'||ctry=='97')) {
		var arrCtry = eval('college'+ctry); 
		new AutoSuggest(document.getElementById('college'), arrCtry, ctry, ctryObj);
	}
}
function customCtry(ctry, msgCity, msgArea) { 
    if (ctry=='150' || ctry == '100' || ctry == '97' || ctry == '170' || ctry == '19' || ctry == '208') 
    { 
        setObjVisibility('ctryState', 'true'); 
        setObjVisibility('ctryCity', 'true'); 
        elId('lblCity').innerHTML = '<span class="asterisk">*</span>&nbsp;' + msgCity;
        // to overcome IE6 bug
        if (!isIE6OrAbove()) elId('lblCity').className = 'colLeft';
    } else if (ctry == '190') {
        setObjVisibility('ctryState', 'false'); 
        setObjVisibility('ctryCity', 'true'); 
        elId('lblCity').innerHTML = '<span class="asterisk">*</span>&nbsp;' + msgArea;
        // to overcome IE6 bug
        if (!isIE6OrAbove()) elId('lblCity').className = 'colLeft';
    } else { 
        setObjVisibility('ctryState', 'true'); 
        setObjVisibility('ctryCity', 'false'); 
    }
}

// defaulting for reg form
function onCountrySelect(frmReg, msgCity, msgArea)
{
    var ctry = frmReg.country_code.options[frmReg.country_code.selectedIndex].value;
    // initialize college auto suggest
    if (elId('institute_country_code')) suggest(ctry, elId('institute_country_code'));
    else    suggest(ctry);
    // populate state list
    if (currCtry != ctry) emptyLocationSelect(frmReg.state, ctry,frmReg.state_code, frmReg.city, frmReg.location_code);
    // populate education list 
    repopulateSelect(frmReg.qualification, ctry);
    // populate positon list 
    repopulatePositionSelect(frmReg.position_level_code, ctry);
    // populate nationality
    if(frmReg.nationality_code.selectedIndex == 0) frmReg.nationality_code.selectedIndex = this.selectedIndex;
    // show / hide state and city for diff countries
    customCtry(ctry, msgCity, msgArea); 
    // PH overseas job
    //showOverseas(ctry, 'dvOversea', 'overseas_job');
    currCtry = ctry;
}
function onStateSelect(frmReg, stateValue)
{
    if (currState != stateValue) {
        enterCity(stateValue, frmReg.city, frmReg.location_code, true);
    }
    currState = stateValue;
}
function onSpecSelect(frmReg, specValue, msgSelect)
{
    if (currSpec != specValue)  { repopulateRoleSelect(frmReg.primary_role, specValue, msgSelect); }
    if(specValue=='116') setObjVisibility('expSpec', 'true'); else setObjVisibility('expSpec', 'false');
    currSpec = specValue;
}
function onPositionSelect(positionValue)
{
    if(positionValue=='1' || positionValue=='2') 
        setObjVisibility('team', 'true'); 
    else 
        setObjVisibility('team', 'false');
}
// Copied from job search, for specialization box
function updateThis(what, bAvoid, bScan) {
    var selectedClassName = "labelSelected";
    var normalClassName = "labelNormal";

    if( what.checked == true ){what.parentNode.className = selectedClassName;}
	else{what.parentNode.className = normalClassName;}
	
	if(typeof(bAvoid) == 'undefined') bAvoid = false;
	updateThisDesc(what, bAvoid);	

	if(typeof(bScan) == 'undefined') bScan = false;
	if(bScan == false) updateThisDetail(what);	

	//check short list
	sSL = 'Sl' + what.id;
	oSl = elId(sSL);
	if(oSl != null) oSl.checked = what.checked;
}
function updateThisDesc(what, bAvoid)
{
	if(typeof(bAvoid) == 'undefined') bAvoid = false;
	sName = what.name;
	sName = sName.replace("[]","") + 'Sel';
	sDesc = trim(what.alt);
	if(sDesc == '') return;
	
	var oDiv = elId(sName);
	if(oDiv == null) return;

	sLegend = '<b>Your Selection: </b><br/>';
	
	sHtml = oDiv.innerHTML;
	if(typeof(sHtml) == 'undefined' || sHtml == '') {sHtml = ', ';} 
	else{ sHtml = sHtml.substring(27) ; sHtml = ', ' + sHtml + ', ';}	
	sSearch = ', ' + escapeHTML(sDesc) + ', ';
	if( what.checked == true && bAvoid == false && what.disabled == false)
	{		
		bFound = sHtml.search(sSearch);
		if(bFound == -1) sHtml = sHtml + sDesc + ', ';
	}
	else sHtml = sHtml.replace(sSearch, ', ') ;	 
	if(sHtml.length > 4){ sHtml = sHtml.substring(2, (sHtml.length - 2) ); sHtml = sLegend + sHtml;}
	else {sHtml = '';}
	oDiv.innerHTML = sHtml;
}
function uncheckAll(field) {
	field = elName(field);
    for (i = 0; i < field.length; i++) {
	field[i].checked = false ;
	updateThis(field[i], false, true);
    }
}
//Used in Quick Sign Up Form
function showWorkLocation(workLocationId, addMoreId) {	
	document.getElementById(workLocationId).style.display = ""; 
	document.getElementById(addMoreId).style.display = "none";		
}
// JSONscriptRequest -- a simple class for making HTTP requests
// using dynamically generated script tags and JSON
function JSONscriptRequest(fullUrl) {
    this.fullUrl = fullUrl; 
    this.noCacheIE = '&noCacheIE=' + (new Date()).getTime();
    this.headLoc = document.getElementsByTagName("head").item(0);
    this.scriptId = 'JscriptId' + JSONscriptRequest.scriptCounter++;
}
JSONscriptRequest.scriptCounter = 1;
JSONscriptRequest.prototype.buildScriptTag = function () {
    this.scriptObj = document.createElement("script");
    this.scriptObj.setAttribute("type", "text/javascript");
    this.scriptObj.setAttribute("charset", "utf-8");
    this.scriptObj.setAttribute("src", this.fullUrl + this.noCacheIE);
    this.scriptObj.setAttribute("id", this.scriptId);
}
JSONscriptRequest.prototype.removeScriptTag = function () {
    this.headLoc.removeChild(this.scriptObj);  
}
JSONscriptRequest.prototype.addScriptTag = function () {
    this.headLoc.appendChild(this.scriptObj);
}


//-->

