<!--

// STATE AND LOCATION
function emptyLocationSelect(objOtherState, strCountry, objStateSelect, objCitySelect, objLocationSelect)
{
    var NS4 = (document.layers) ? true : false;
    var temp = "";
	if(!NS4){ 	objStateSelect.style.display = 'none'; }
	if(strArrayList.indexOf("," + strCountry + ",") > -1) {
        while(objStateSelect.options.length > eval("ctry" + strCountry + ".length")){
		  objStateSelect.options[(objStateSelect.options.length-1)] = null;
        }
		objOtherState.disabled = true;
		objOtherState.value = '';
		for(i=0;i<eval("ctry" + strCountry + ".length");i++){
			temp = eval("ctry" + strCountry + "[i]");
			if(!NS4){
				objOtherState.size = 10
				objOtherState.style.display = 'none';
				objStateSelect.style.display = 'block';
			}
			else{
				objOtherState.disabled = true;
			}
			eval("objStateSelect.options[i] = new Option" + temp);
        }
    }else {
        while(objStateSelect.options.length > 1) {
		  objStateSelect.options[(objStateSelect.options.length-1)] = null;
        }
        if(!NS4){
			objStateSelect.options[0] = new Option("","00");
			objStateSelect.style.display = 'none';
			objOtherState.style.display = 'block';
			objOtherState.size = 20
			objOtherState.disabled = false;
        }else{
			objStateSelect.options[0] = new Option(Others,"00");
			objOtherState.disabled = false;
		}
	}
	objStateSelect.selectedIndex = 0;
	return true;
}

function enterCity(ld,  objCitySelect, objLocationSelect, cls){
	var id = ld.split(":") ;
	objLocationSelect.value = "";
	if(id[1] != null && id[1].length > 0){
		objLocationSelect.value = id[1];
			if(id[2] != null && id[2].length > 0 ){
				objCitySelect.value = "";
				objCitySelect.value = id[2];
		} else{
			if(cls == true) {
				objCitySelect.value = "";
			}
		}
	}else{
	   if(cls == true) {
		objCitySelect.value = "";
	   }
	}
}

function repopulateLocation(objMsiaState, data, startindex, endindex) {
	for(var i =0 ; i< objMsiaState.options.length; i++)
	{
		var tempVar =  data;
		if(objMsiaState.options[i].value == tempVar
		||  (objMsiaState.options[i].value.substring(startindex, endindex) == tempVar.substring(startindex, endindex)))
		{
			objMsiaState.selectedIndex = i;
			break;
		}
	}
   return i;
}

function populateDuplicateLocation(objMsiaState, data, strmsia, strloc, strcity){
	for(var i =0 ; i< objMsiaState.options.length; i++){
 		if(objMsiaState.options[i].value == data){
			objMsiaState.selectedIndex = i;
			break;
		}else{
			var tmpst =  strmsia;
			var tmplc =  strloc;
			var tmpct =  strcity;
				var d = objMsiaState.options[i].value.split(":");
			if(d[0] == tmpst && d[1] == tmplc){
				var c = d[2].toLowerCase();
				var tmpct = tmpct.toLowerCase();
				if ( c.indexOf(tmpct) >= 0 || tmpct.indexOf(c) >= 0 ){
					objMsiaState.selectedIndex = i;
						break;
				}
			}
		}
   }
   return i;
}

function populateOtherLocation(objMsiaState, objCity, objLocation, strmsia, strcity){
    for(var i =0 ; i< objMsiaState.options.length; i++){
	var tmpst = strmsia;
	var tmpct =  strcity;
				var d = objMsiaState.options[i].value.split(":");
			if(d[0] == tmpst){
			   if(d[2] != null && d[2].length > 0 ){
				var c = d[2].toLowerCase();
				var tmpct = tmpct.toLowerCase();
				if ( c.indexOf(tmpct) >= 0 || tmpct.indexOf(c) >= 0 ){
					objMsiaState.selectedIndex = i;
					break;
				}
				}
			}
		}
	if(i <  objMsiaState.options.length){
		enterCity(objMsiaState.options[i].value, objCity, objLocation, false)
   }
   return i;
}
	
// EDUCATION
function repopulateSelect(objEduSelect, strCountry){
		if(strCountry == '150' )  {	strCountry = 'myEdu'; } 
		else if (strCountry == '170')  {	strCountry = 'phEdu'; } 
        else if (strCountry == '100')  {	strCountry = 'inEdu'; } 
        else if (strCountry == '97') {	strCountry = 'idEdu'; } 
        else if (strCountry == '208')   { strCountry = 'thEdu'; }
        else{			strCountry = 'defaultEdu';		}		
               
        while(objEduSelect.options.length > 0){
			objEduSelect.options[(objEduSelect.options.length-1)] = null;
		}
        
		for(i=0;i<eval(strCountry + ".length");i++)	{
            temp = eval(strCountry + "[i]");  	
			eval("objEduSelect.options[i] = new Option" + temp);
		}
		
}		

function defaultCGPABase(oGr, oFd, sSel, dfV, orV)	{
	var strSel = oGr.options[oGr.selectedIndex].value;
	if (strSel == sSel)	{
		if (orV == null || orV == 0) oFd.value = dfV;
		else oFd.value = orV;
	}
}

function repopulateFieldSelect(oFd, oQf, sC, myField){
 	if(sC == "100" || sC == "150" || sC == "190")
 	{
    	populateFieldSelect(oFd, oQf, sC, myField);
  	}
  	else{
		for(var c=0;c < fd.length;c++)	{
			eval("oFd.options[c] = new Option" + fd[c]);
		}
	}
 }
 
function populateFieldSelect(oFd, oQf, sC, myField) {
	var len =  oFd.options.length;
	var strSel = oFd.options[oFd.selectedIndex].value;
	oFd.options.length = 0;
	if(sC == "100"){
		if(oQf == null || oQf.value == "1:0" || oQf.options.value == "1:0" || oQf.value == "0"){
			//oFd.options[0] = new Option("- Select a Qualification Level First -","", "");
			oFd.options[0] = new Option(myField[0],"", "");
		}
		else
		{
			for(var j=0; j< oQf.options.length; j++) {
				var val = oQf.options[j].value;
				var sq = val.split(":")
				if(oQf.options[j].selected && sq.length > 0) {
					if(sq[0] == 2){
						//oFd.options[0] = new Option("Any","0");
						oFd.options[0] = new Option(myField[1],"0");
					} else if(sq[0] == 3){
 						//oFd.options[0] = new Option("- Select Field -","0");
						//oFd.options[1] = new Option("Art","1");
                        //oFd.options[2] = new Option("Commerce","54");
                        //oFd.options[3] = new Option("Science","50");
                        oFd.options[0] = new Option(myField[2],"0");
						oFd.options[1] = new Option(myField[3],"1");
						oFd.options[2] = new Option(myField[4],"54");
						oFd.options[3] = new Option(myField[5],"50");
					}
					else  {
						var rl  = rs[sq[0]];
						var sh  = rl.split(",");
						if(sh.length == 1 && rl == 99){
							for(var t = 0; t < fd.length; t++){
								eval("oFd.options[t] = new Option" + fd[t]);
							}
						}
						else
						{
							for(var k=0; k < sh.length; k++) {
								eval("oFd.options[k] = new Option" + fd[sh[k]]);
							}
						}
 					}
				}
			}
		}
	}
	else{
  		if( (oQf.options.value=="1" || oQf.value=="1"
			|| oQf.options.value=="9" || oQf.value=="9")){
 			//oFd.options[0] = new Option("- Select Field -","0");
 			oFd.options[0] = new Option(myField[6],"0");
  			if(sC.toLowerCase() == "150"){
				//oFd.options[1] = new Option("Sciences","50");
				//oFd.options[2] = new Option("Arts","32");
				//oFd.options[3] = new Option("Others","44");
                oFd.options[1] = new Option(myField[7],"50");
                oFd.options[2] = new Option(myField[8],"32");
                oFd.options[3] = new Option(myField[9],"44");				
			}
			else{
				//oFd.options[1] = new Option("Mathematics & Sciences","50");
				//oFd.options[2] = new Option("Humanities","32");
				//oFd.options[3] = new Option("Others","44");
                oFd.options[1] = new Option(myField[10],"50");
                oFd.options[2] = new Option(myField[11],"32");
                oFd.options[3] = new Option(myField[12],"44");				
			}
		}
		else{
			for(var d=0;d < fd.length;d++){
				eval("oFd.options[d] = new Option" + fd[d]);
			}
		}
		oFd.selectedIndex = 0;
		for (var i=0; i < oFd.options.length; i++) {
			if (strSel == oFd.options[i].value) {
				oFd.selectedIndex = i;
				break;
			}
		}
	}
}

// POSITION
function repopulatePositionSelect(objPositionSelect, strCountry){
		if(strCountry == '170') {			
            strCountry = 'phPosition';		
        } else if(strCountry == '97') {
            strCountry = 'idPosition';		
        } else if(strCountry == '100') {
        	strCountry = 'inPosition';		
        } else if(strCountry == '208') {
        	strCountry = 'thPosition';		
        } else {	
        	strCountry = 'defaultPosition';		
        }
        while(objPositionSelect.options.length > 0) {
			objPositionSelect.options[(objPositionSelect.options.length-1)] = null;
		}
		for(i=0;i<eval(strCountry + ".length");i++)	{
			temp = eval(strCountry + "[i]");		
            eval("objPositionSelect.options[i] = new Option" + temp);
		}
}

// ROLE
function repopulateRoleSelect(objRole1, intSpec, msgSelect)
{
    //eval("objRole1.options[0] = new Option('- Select Role -','0','')" + temp);
    while(objRole1.options.length > 0) {
	   objRole1.options[(objRole1.options.length-1)] = null;
	}
	/*
    if (objRole2) {
        while(objRole2.options.length > 0) {
    	   objRole2.options[(objRole2.options.length-1)] = null;
    	}
    }
    */
    if (intSpec == undefined || intSpec == '' || eval("role" + intSpec) == undefined) {
        //tempArrName = "role0";
        //objRole1.options[0]  = new Option('- Select Role -','','');
        objRole1.options[0]  = new Option(msgSelect,'','');
        //if (objRole2)	objRole2.options[0]  = new Option('- Select Role -','','');
    } else {
        tempArrName = "role"+intSpec;
	    for(i=0;i<eval(tempArrName+".length");i++) {
	        temp = eval(tempArrName+"[i]");
	        eval("objRole1.options[i] = new Option" + temp);
	        //if (objRole2) eval("objRole2.options[i] = new Option" + temp);
	    }

    }
}

function showOverseas(ctry, overseasDiv, checkboxDiv)
{
	if (ctry == '170') {
		setObjVisibility(overseasDiv, 'true');
	} else {
		setObjVisibility(overseasDiv, 'false');
		elId(checkboxDiv).checked = false;
	}
}

function enableAll(ctrl)
{
	var intL = ctrl.length;
	for (var i=0; i<intL; i++) {
		ctrl[i].disabled=false;	
		sSelect(ctrl[i]);
	}
}
function disableAll(ctrl)
{
	var intL = ctrl.length;
	for (var i=0; i<intL; i++) {
		ctrl[i].checked = false;
		ctrl[i].disabled=true;	
		sSelect(ctrl[i]);
	}
}

function repopulateWL(objPLSelect, selState) {
	var arrState = ",50100,50300,50700,51200,40200,40800,41500,41800,42900,";
	if(selState != '') { 
		//selState = selState.substr(0,2);
		if (arrState.indexOf(selState) < 0) { 
			for(var i=0 ; i<objPLSelect.options.length; i++) { 
				if(objPLSelect.options[i].value == selState) { 
					objPLSelect.selectedIndex = i; 
					break; 
				} 
			} 
		} 
	} 
}

// multiple select
function mSelect(elsCurrent, currentId, strId, strGroupName){
	var strName=strId + currentId;   //eg state100
	var els=document.getElementsByTagName('input');
	var len=els.length;
	for(var intCount=0; intCount<len; ++intCount)
	{
		if ((els[intCount].name == strGroupName || els[intCount].name == strGroupName+'[]') && (String(els[intCount].id).indexOf(strName) >= 0))
		{			
			els[intCount].checked=elsCurrent.checked;
			els[intCount].disabled=elsCurrent.checked;
			setBg(els[intCount]);
		}
    }
}
// multiple select clear
function mClear(strName, HiddenFld){
	var els=document.getElementsByTagName('input');
	
	for(var i=0; i<els.length; ++i)
		if((els[i].name==strName+'[]' || els[i].name==strName)){
			els[i].checked=false;
			els[i].disabled=false;
			setBg(els[i]);
		}
}
// multiple has selected
function mHasSelected(strName){
	var els=document.getElementsByTagName('input');
	
	for(var i=0; i<els.length; ++i)
		if((els[i].name==strName+'[]' || els[i].name==strName) && els[i].checked)
			setBg(els[i]);
}

function setBg(els){
	var elParent=els.parentNode.parentNode;
	var strBackground=els.checked?'#ccc':'#fff';
	var strColour=els.checked?'#666':'#000';
	elParent.style['backgroundColor']=strBackground;
	elParent.style['color']=strColour;
}

function updateBg(els){	
	setBg(els);
}
// single select
function sSelect(oCtrl)
{
	var strName=oCtrl.name;
	updateShortList(strName, oCtrl);
	updateBg(oCtrl);
}

//strName = Loc,  oCtrl= elsCurrent
function updateShortList(strName, oCtrl, booFound)
{
	//define for alt name
	var intKey = getSListKey(strName);
	var strShortListName = getSListName(strName);

	//handle for alt name
	if(strShortListName != '')
	{
		var aObj = document.getElementsByName(strShortListName);
		if(aObj != null)
		{
			var strAltValue=oCtrl.value ;
			for(var i=0; i<aObj.length; i++)
			{
				if(aObj[i].value == strAltValue)
				{
					aObj[i].checked=oCtrl.checked;	
					if(typeof(booFound) != 'undefined') 
					{
						if(booFound) aObj[i].disabled=oCtrl.checked;
					}
					if(intKey == 2) setBg(aObj[i]);	
				}									
			}
		}
	}
}


function getSListKey(strName)
{
	var intKey = strName.charAt(strName.length -1);
	return intKey;
}

function getSListName(strName, intKey)
{
	var strShortListName = '';
	if(typeof(intKey) == 'undefined') intKey = getSListKey(strName);		
	if(intKey == 1) strShortListName = strName.substr(0,strName.length-1) + '2';
	else if(intKey == 2) strShortListName = strName.substr(0,strName.length-1) + '1';
	return strShortListName;
}


//-->
