var timeOut = 20000;		// Time out in 20 Seconds
var outLogin = false;

var spellUrl = 'SELF'; // URL to spell_checker.php
//------------- Function for reset the Combo List value

function cp_ClearTimeOut(p, id){

	if (p == "login"){
		showHide('null', id);		
		if (outLogin){	
			msgWithBorder('msgLgn','System is busy. Please try later.','error',3,2,false)
			outLogin = false;
		}
	}
	return true;
}

function showJobLayer(browser, spanID)
{
	closeAll(browser);
	//alert (spanID);
	if (document.getElementById('forwardJobMsg'))
		document.getElementById('forwardJobMsg').innerHTML = "";
	if (spanID != "")
	{
	 if (browser == "IE") {
		document.getElementById(spanID).style.display= 'block';
	 } 
	 else 
	 {
		document.getElementById(spanID).style.position='relative';
		document.getElementById(spanID).style.visibility='visible';
	 }
	}
	
	if(document.getElementById('tblJbApply'))
		showHide('tblJbApply#lnkFwdJb','lnkAppJb');
}

function hideJobLayer(browser, spanID)
{
document.getElementById('forwardJobMsg').innerHTML = "";
 if (browser == "IE") {
	document.getElementById(spanID).style.display= 'none';
 } 
 else 
 {
	document.getElementById(spanID).style.position='absolute';
	document.getElementById(spanID).style.visibility='hidden';
 }
	showHide('null','tblJbApply');

  // for i2c only due to rounded corner
  if(document.getElementById('jobLyrPanel'))
   document.getElementById('jobLyrPanel').style.display='none';
}

function closeAll(browser)
{
	for (i=1; i<5; i++)
	{
	 if (browser == "IE") {
		 if (document.getElementById('spanJobDetail_'+i))
			document.getElementById('spanJobDetail_'+i).style.display= 'none';
	 } 
	 else 
	 {
		if (document.getElementById('spanJobDetail_'+i))
		{
			document.getElementById('spanJobDetail_'+i).style.position='absolute';
			document.getElementById('spanJobDetail_'+i).style.visibility='hidden';
		 }
	 }
	}
	showHide('null','tblJbApply');
}

function checkValue()
{
	if (document.getElementById('friend_emails').value== "Enter comma separated emails")
		document.getElementById('friend_emails').value='';	
}

function forwardJob_cb(new_data)
{
	//alert (new_data);
	var str = new_data;
	pstr = str.split("##");
	var msgType = pstr[0];
	var msgString = pstr[1];
	var browser = pstr[2];

	if (msgType == "SUCCESS")
	{
		document.getElementById('spanFwdProcessing').style.display = 'none';
		if (browser == "IE")
			document.getElementById('spanJobDetail_1').style.display= 'none';
		else
			document.getElementById('spanJobDetail_1').style.display= 'none';
		
		msgWithBorder('forwardJobMsg',msgString,'success',6,0,false);		
	}
	else
	{
		document.getElementById('spanFwdProcessing').style.display = 'none';
		msgWithBorder('forwardJobMsg',msgString,'error',6,0,false);
	}	
}

function forwardJob()
{
	document.getElementById('forwardJobMsg').innerHTML = "";
	document.getElementById('spanFwdProcessing').style.display = '';
	//document.getElementById('rowForwardJob').style.display='';
	showHide('tblJbApply','null');

	var urName = document.frmForwardJob.ur_name.value;
	var urEmail = document.frmForwardJob.ur_email.value;
	var jobID = document.frmForwardJob.jid.value;
	var friend_emails = document.frmForwardJob.friend_emails.value;
	cpaint_call(spellUrl, 'POST', 'forwardJob', urName, urEmail, friend_emails, jobID, forwardJob_cb);
	return false;
}

//------------------------------ User Availability ----------------------------
function userAvailability_cb(new_data)
{
	//alert(new_data);
	var str = new_data;
	pstr = str.split("##");
	var msgType = trim(pstr[0]);			// Message Type
	var buttonID = pstr[1];			// ButtonID
	var msgSpan = pstr[2];			//	return Message span ID

	if(msgType == 'EMPTY')
	{
		document.getElementById(msgSpan).innerHTML = "You have selected an invalid username.";
	}
	else if (msgType == 'INVALIDID')
	{
		document.getElementById(msgSpan).innerHTML = "You have selected an invalid username.";
	}
	else if (msgType == 'LESSSIZE')
	{
		document.getElementById(msgSpan).innerHTML = "Username must be at least 4 characters.";
	}
	else if(msgType == 'FOUND')
	{
		document.getElementById(msgSpan).innerHTML = "Username is already in use.";
	}
	else if(msgType == 'NOTFOUND')
	{
		document.getElementById(msgSpan).innerHTML = "<span style='color: #5C8400; font-weight: bold; font-size: 11px; font-family:Arial'><b>Username is available.</span>";
	}
	document.getElementById(buttonID).disabled = false;
	setTimeout("clrLyr()",4000);
}

function userAvailability(userID, buttonID, msgSpanID)
{
	
	var userName = document.getElementById(userID).value;
	document.getElementById(buttonID).disabled = true;
	
	cpaint_call(spellUrl, 'POST', 'userAvailability', userName, buttonID, msgSpanID, userAvailability_cb);	
	return false;
}

//--------------------------- Apply Jobs for registered and logged in user
function registerOfficialEmail(email_id)
{
	document.getElementById('official_emailMsg').innerHTML = '';
	var email = document.getElementById(email_id).value;
	var off_domain = document.getElementById('off_domain').value;
	
	if(email=='')
	{
		msgWithBorder('official_emailMsg','Please enter your username.','error',0,0,false);
		return false;
	}

	if(off_domain=='')
	{
		msgWithBorder('official_emailMsg','Please select your offical domain from the drop down.','error',0,0,false);
		return false;
	}
	document.getElementById('official_emailProcessing').style.display = '';
	cpaint_call(spellUrl, 'POST', 'registerOfficialEmail', email, off_domain, registerOfficialEmail_cb);
}
function registerOfficialEmail_cb(new_data)
{
	var str, msgType, msgString, browser;
	var str = new_data;
	pstr = str.split("##");
	msgType = pstr[0];
	msgString = pstr[1];	
	email = pstr[2];
	//alert(msgType);
	document.getElementById('official_emailProcessing').style.display = 'none';
	document.getElementById('official_emailMsg').innerHTML = '';
	if (msgType == "SUCC")
	{	
		document.getElementById('spanJobDetail_int_reg').style.display = 'none';
		document.getElementById('spanJobDetail_int_confirm').style.display = '';
		document.getElementById('hidden_add_email').value = email;
	}
	else if (msgType == "ERROR")
	{
		msgWithBorder('official_emailMsg',msgString,'error',0,0,false);
		document.getElementById('hidden_add_email').value = '';
	}
}
function verifyOfficialEmail(vCode,hidden_email)
{
	document.getElementById('official_emailMsg').innerHTML = '';
	v_code = document.getElementById(vCode).value;
	hidden_email = document.getElementById(hidden_email).value;
	if(v_code=='')
	{
		msgWithBorder('official_emailMsg','Please Enter verification code','error',0,0,false);
		return false;
	}
	document.getElementById('official_emailProcessing').style.display = '';
	cpaint_call(spellUrl, 'POST', 'verifyOfficialEmail', v_code, hidden_email , verifyOfficialEmail_cb);
}
function verifyOfficialEmail_cb(new_data)
{
	document.getElementById('official_emailProcessing').style.display = 'none';
	var str, msgType, msgString, browser;
	var str = new_data;
	pstr = str.split("##");
	msgType = pstr[0];
	msgString = pstr[1];	
	browser = pstr[2];
	//alert(msgType);
	document.getElementById('official_emailMsg').innerHTML = '';
	if (msgType == "SUCC")
	{	
		location.href=location.href;
	}
	else if (msgType == "ERROR")
	{
		msgWithBorder('official_emailMsg',msgString,'error',0,0,false);
	}
}
//--------------------------- Apply Jobs for registered and logged in user
function ApplyJob4LoggedUser_cb(new_data)
{
//document.write(new_data);

	var str, msgType, msgString, browser, tb_require, tb_id;
	var str = new_data;
	pstr = str.split("##");
	
	msgType = pstr[0];
	msgString = pstr[1];	
	browser = pstr[2];
	tb_require = pstr[3];
	tb_id = pstr[4];
	
	document.getElementById('spanAppJob1Processing').style.display = 'none';
	document.getElementById('btnApply4LgdUsr').style.display = '';
	if (msgType == "SUCCESS")
	{
		document.getElementById('spanAppJob1Processing').style.display = 'none';
		if (browser == "IE")
		{
			document.all.Layer2.style.display = '';
			//document.all.spanAppJob1Processing.style.display = '';
		}
		else
		{
			document.getElementById('spanJobDetail_2').style.display= 'none';
			//document.getElementById('spanJobDetail_2').style.visibility= 'hidden';
			
		}
		
		if (tb_require == "Y")
			document.getElementById('spJobTest').style.display='';
		else
			msgWithBorder('forwardJobMsg',msgString,'success',0,0,false);
	}
	else if (msgType == "ERROR")
	{
		if (pstr[5] == "Pending")
		{
			if (browser == "IE")
			{
				document.all.Layer2.style.display = 'block';
			}else{
				document.getElementById('Layer2').style.visibility= 'hidden';
				document.getElementById('Layer2').style.position= 'absolute';
				
			}
			document.getElementById('spJobTest').style.display=''; 
			msgWithBorder('forwardJobMsg',msgString,'error',0,0,false); 
		}else{
			if(document.getElementById('spanFwdProcessing'))
				document.getElementById('spanFwdProcessing').style.display = 'none';
				
			msgWithBorder('forwardJobMsg',msgString,'error',0,0,false);
		}
		
		document.getElementById('submitImage_1').disabled = false;
	}
	
}

function un_op_upload(msg)
{
	msgWithBorder('forwardJobMsg',msg,'error',8,0,false);
	return false;
}
function ApplyJob4LoggedUser()
{
	/*alert('asdasdas');alert(document.getElementById('cnic').value);alert(document.getElementById('cnic2').value);alert(document.getElementById('cnic3').value);//tanveer*/
	document.getElementById('forwardJobMsg').innerHTML = "";


	var resumeID = document.ApplyJob1.resumeID.value;
	var resumeID2 = "";
	var curSal = expSal = curSalReq = expSalReq =  fSal ='';
	
	

	
	if(document.getElementById('pef_Re_hidden'))
	{
		msgWithBorder('forwardJobMsg','Please Upload Performance Evaluation Form','error',8,0,false);
		return false;
	}
	if(document.getElementById('app_cv1_op_hiddin'))
	{
		if(document.ApplyJob1.app_cv1_op_mode.value=='select')
		{
			
			if( document.ApplyJob1.resumeID_op.value == "")
			{
				msgWithBorder('forwardJobMsg','Please select your CV .','error',8,0,false);
				return false;
			}
			resumeID2 = document.ApplyJob1.resumeID_op.value;
			
		}
		else if(document.ApplyJob1.app_cv1_op_mode.value=='upload')
		{
			if( document.ApplyJob1.cv_Title1_op.value == "")
			{
				msgWithBorder('forwardJobMsg','Please select your CV Title.','error',8,0,false);
				return false;
			}
			
			if( document.ApplyJob1.app_cv1_op.value == "")
			{
				msgWithBorder('forwardJobMsg','Please select your CV to Upload.','error',8,0,false);
				return false;
			}
			resumeID2 = document.ApplyJob1.app_cv1_op_hiddin.value;
		}
	}
		
	//for un inernal jobs
	var what_agency = "";
	if(document.getElementById('what_agency'))
	{
		what_agency = document.ApplyJob1.what_agency.value;
		if(what_agency==''){
			msgWithBorder('forwardJobMsg','Please Select your agency.','error',8,0,false);
			return false;
		}
	}
	
	var what_job = "";
	if(document.getElementById('what_job'))
	{
		what_job = document.ApplyJob1.what_job.value;
		if(what_job==''){
			msgWithBorder('forwardJobMsg','Please Select your job type.','error',8,0,false);
			return false;
		}
	}
	
	var pension_id = "";
	if(document.getElementById('pension_id'))
	{
		pension_id = document.ApplyJob1.pension_id.value;
	}
	//for un inernal jobs - end
	

	
	if(resumeID==''){
		if(document.getElementById('cportalID') && document.getElementById('cportalID').value == '36179')
		msgWithBorder('forwardJobMsg','Please select your Bootcamp Form.','error',8,0,false); 
		else
		msgWithBorder('forwardJobMsg','Please select your CV.','error',8,0,false);
		return false;
	}
	
    // if salary range is required at the time of job application	  
	if(document.getElementById('isCurSalaryReq1') && document.getElementById('isExpSalaryReq1') )
	{
		if(document.getElementById('isCurSalaryReq1').value == 'Y')
		{		   
			 if(document.getElementById('currentSalary1') && document.getElementById('currentSalary1').value == '')
			 {		 
				 msgWithBorder('forwardJobMsg','Please select your current salary.','error',8,0,false); 
				 return false;
			 }
		 }
		 if(document.getElementById('isExpSalaryReq1').value == 'Y')
		 {			
			if(document.getElementById('expectedSalary1') && document.getElementById('expectedSalary1').value == '')
			{
				 msgWithBorder('forwardJobMsg','Please select your expected salary.','error',8,0,false);
				 return false;
			}					
		 }
	  
	  if(document.getElementById('isCurSalaryReq1').value == '')
	     curSalReq = 'N';
	  else
	     curSalReq = document.getElementById('isCurSalaryReq1').value;
		 
	  if(document.getElementById('isExpSalaryReq1').value == '')	 
		 expSalReq = 'N';
	  else	 
	  {
		 expSalReq = document.getElementById('isExpSalaryReq1').value;
	     if(document.getElementById('currentSalary1'))
	      curSal = document.getElementById('currentSalary1').value;	
		 if(document.getElementById('expectedSalary1'))  
	      expSal = document.getElementById('expectedSalary1').value;	
	     
		 fSal = curSalReq+'|~|'+curSal+'|~|'+expSalReq+'|~|'+expSal;	
	  }
		 
		 
	}
		
		
	
	var testCnt1 = testCnt2 = '';	
	if(document.getElementById('testCenter1A') && document.getElementById('testCenter2A')) // for PITB
	{		
		testCnt1    = document.getElementById('testCenter1A').value;
		testCnt2 = document.getElementById('testCenter2A').value;
		
		if(testCnt1 ==''){
			msgWithBorder('forwardJobMsg','Please select your test center.','error',8,0,false);
			return false;
		}	
		/*if(testCnt2 ==''){
			msgWithBorder('forwardJobMsg','Please select your alternate test center.','error',8,0,false);
			return false;
		}*/
		if(testCnt1 == testCnt2)
		{
			msgWithBorder('forwardJobMsg','Both test center cannot be same.','error',8,0,false);
			return false;
		}
		
	}

	var Technical = nonTechnical = '';
	if(document.getElementById('cportalID') && document.getElementById('cportalID').value == '15843') // for indus Motor
	{
		if(document.getElementById('Technical1'))
		{
			Technical    = document.getElementById('Technical1').value;
			nonTechnical = document.getElementById('nonTechnical1').value;
			if(Technical!='' && nonTechnical!=''){
				msgWithBorder('forwardJobMsg','Only one Department can be selected.','error',8,0,false);
				return false;
			}	
			if(Technical=='' && nonTechnical=='' ){
				msgWithBorder('forwardJobMsg','Please select your Department.','error',8,0,false);
				return false;
			}
			if(Technical == '')
			{
				 what_job = nonTechnical;
			}
			else
			{
				 what_job = Technical;	
			}
		}
	}
	
	
	var jobCat = pSkills = sSkills = pExp = sExp = addParam = '';
	if(document.getElementById('cportalID') && document.getElementById('cportalID').value == '1908') // for netsole
	{
		if(document.getElementById('jobCat1'))
		{
			var jobCat    = document.getElementById('jobCat1').value;
			var pSkills = document.getElementById('pSkills1').value;
			var pExp = document.getElementById('pExperience1').value;
			var sSkills = document.getElementById('sSkills1').value;
			var sExp = document.getElementById('sExperience1').value;
			var isSecReq = document.getElementById('isSecondarySkillsReq1').value;
			
			if(jobCat == '')
			{
			  msgWithBorder('forwardJobMsg','Please select job category.','error',8,0,false);
			  return false;	
			}
			 
			if(pSkills == ''){
				msgWithBorder('forwardJobMsg','Please select primary skills.','error',8,0,false);
				return false;
			}	
			
			if(pExp == '' ){
				msgWithBorder('forwardJobMsg','Please select experience for primary skills.','error',8,0,false);
				return false;
			}			
			
			if(isSecReq == 'Y')
			{
				if(sSkills == '' ){
					msgWithBorder('forwardJobMsg','Please select secondary skills.','error',8,0,false);
					return false;
				}
				
				if(pSkills == sSkills)
				{
				  msgWithBorder('forwardJobMsg','Secondary skills should be different from the primary skills.','error',8,0,false);
				  return false;					
				}
				
				if(sExp == '' ){
					msgWithBorder('forwardJobMsg','Please select experience for secondary skills.','error',8,0,false);
					return false;
				}		
				
			  addParam = 'portalID:'+document.getElementById('cportalID').value+'|~|'+isSecReq+'|~|'+jobCat+'|~|'+pSkills+'|~|'+pExp+'|~|'+sSkills+'|~|'+sExp;	
			}
			else
			  addParam = 'portalID:'+document.getElementById('cportalID').value+'|~|'+isSecReq+'|~|'+jobCat+'|~|'+pSkills+'|~|'+pExp;
			//addParam = 'portalID:'+document.getElementById('cportalID').value+'|~|'+'jobCat:'+jobCat+'###Y'+'|~|'+'pSkills:'+pSkills+'###Y'+'|~|'+'pExp:'+pExp+'###Y'+'|~|'+'sSkills:'+sSkills+'###Y'+'|~|'+'sExp:'+sExp+'###Y';
			
			//addParam = 'portalID:'+document.getElementById('cportalID').value+'|~|'+'jobCat:'+jobCat+'|~|'+'pSkills:'+pSkills+'|~|'+'pExp:'+pExp+'|~|'+'sSkills:'+sSkills+'|~|'+'sExp:'+sExp;
			
			
			
			//alert(addParam);
			
		}
	}

	
	
	var app_cover_letter = document.ApplyJob1.app_cover_letter.value;	

	var fld = hFrom=val=func=sa_jobCity=sa_isMultiCity='';	
	if(document.getElementById('hearFrom')){
		

		if( document.getElementById('sa_multiCity') && document.ApplyJob1.sa_multiCity.value=='Y' ){
			 var tmpC =  document.ApplyJob1.sa_jobCity.value;
			 sa_jobCity = tmpC;
			 sa_isMultiCity = 'Y';

			if(sa_jobCity==''){
				msgWithBorder('forwardJobMsg','Please select the city you want to apply for.','error',8,0,false);
				return false;			
			}
		}

		val = document.ApplyJob1.hearFrom.value;
		fld = 'hearFrom';
		if(val==''){
			if(document.getElementById('cportalID') && document.getElementById('cportalID').value == '36179')
			msgWithBorder('forwardJobMsg','Please specify how did you hear about this program.','error',8,0,false);
			else
			msgWithBorder('forwardJobMsg','Please specify how did you hear about this job.','error',8,0,false);
			
			return false;
		}
	//CNIC CHECK BY JAWADSALEEM
		if(document.getElementById('cnic'))
		{
			if(((document.getElementById('cnic').value).length < 5) || ((document.getElementById('cnic2').value).length < 7) ||  ((document.getElementById('cnic3').value).length < 1))
			{
				msgWithBorder('forwardJobMsg','CNIC number must be of 13 digits.','error',8,0,false);
				return false;
			}
			if((document.getElementById('cnic').value == '') || (document.getElementById('cnic2').value =='') || (document.getElementById('cnic3').value =='')){
				msgWithBorder('forwardJobMsg','Please Enter your CNIC number .','error',8,0,false);
				return false;
			}

			var cnicCat= document.getElementById('cnic').value + document.getElementById('cnic2').value + document.getElementById('cnic3').value ;
			var cnicLength= cnicCat.length;
			
			
				if((isNaN(document.getElementById('cnic').value) || (isNaN(document.getElementById('cnic2').value)) || (isNaN(document.getElementById('cnic3').value))))
				{
					msgWithBorder('forwardJobMsg','CNIC number must be numeric','error',8,0,false);
					return false;	
				}
		}
// END CNIC CHECK 


		var jobID;
		if (document.ApplyJob1.jid)
			jobID = document.ApplyJob1.jid.value;
		else if (document.ApplyJob2.jid)
			jobID = document.ApplyJob2.jid.value;
		else if (document.ApplyJob3.jid)
			jobID = document.ApplyJob3.jid.value;
		
			
	    var gpaOpt = 'N';
		var resultType=degree_level=uGPA=outOf='';		
		if(document.ApplyJob1.gpaOpt1 && document.ApplyJob1.gpaOpt1.value == 'Y') // gpa option necessory
		{
			resultType = document.ApplyJob1.result1.value
			gpaOpt = document.ApplyJob1.gpaOpt1.value;
			
			degree_level = document.ApplyJob1.degree_level1.value;
			if(degree_level==''){
				msgWithBorder('forwardJobMsg','Please Select Your Degree Level.','error',8,0,false);
				return false;
			}
		  //alert(document.ApplyJob1.GPA1.value);
		
			if(resultType=='GPA')
			{
				outOf = document.ApplyJob1.GPAOutOf1.value;
				fld = 'GPAOutOf1';
				if(outOf==''){
					msgWithBorder('forwardJobMsg','Please selet your total GPA.','error',8,0,false);
					return false;
				}	
				
				
				//uGPA = document.ApplyJob1.GPA1.value;
				if(document.getElementById('GPA1'))
				{
					uGPA = document.getElementById('GPA1').value;
					fld = 'GPA1';
					if(uGPA==''){
						msgWithBorder('forwardJobMsg','Please select your GPA.','error',8,0,false);
						return false;
					}
				}
				
				
			}
			else if(resultType=='Grade')
			{
				uGPA=uGrd = document.ApplyJob1.Grade1.value;
				fld = 'Grade1';
				if(uGrd==''){
					msgWithBorder('forwardJobMsg','Please enter your result Grade.','error',8,0,false);
					return false;
				}
			}
			else if(resultType=='Percentage')
			{
				uGPA=uPer= document.ApplyJob1.Percentage1.value;
				fld = 'Percentage1';
				if(uPer==''){
					msgWithBorder('forwardJobMsg','Please enter your result percentage.','error',8,0,false);
					return false;
				}
			}
			else if(resultType=='null')
			{
				fld = 'result1';
				msgWithBorder('forwardJobMsg','Please select your result in.','error',8,0,false);
				return false;

			}
		}
		if(document.getElementById('run_call_paint'))
		{
			if(document.getElementById('run_call_paint').value == 'no')
			{
				return true;
			}
		}

		var cnic= cnic1= cnic2= cnic3='';

		if (document.getElementById('cnic'))
			cnic1 = document.getElementById('cnic').value
		if (document.getElementById('cnic2'))
			cnic2 = document.getElementById('cnic2').value
		if (document.getElementById('cnic3'))
			cnic3 = document.getElementById('cnic3').value
		if(cnic1 != '' && cnic2 != '' && cnic3 !=' ')
			{
				 cnic = cnic1+cnic2+cnic3;	
			}
			//alert (cnic);
		cpaint_call(spellUrl, 'POST', 'ApplyJob4LoggedUser', app_cover_letter, resumeID,resumeID2, jobID,'',val,sa_jobCity ,sa_isMultiCity,gpaOpt,degree_level,resultType,uGPA,outOf,what_agency,what_job,pension_id,cnic,testCnt1,testCnt2,fSal,addParam,ApplyJob4LoggedUser_cb);			

	}
	
    if(document.getElementById('roster1')){		
		
		
		var deptType='';
		var deptTFlg='N';
		if(document.ApplyJob1.deptType)
		{
			if(document.ApplyJob1.deptType.value=='')
			{
			 deptType = document.ApplyJob1.deptType.value; 
			 deptTFlg = 'Y';
			 msgWithBorder('forwardJobMsg','Please select a department type.','error',8,0,false);
			 return false;
			}
		}
				//CNIC CHECK BY JAWADSALEEM
		if(document.getElementById('cnic'))
		{
			if(((document.getElementById('cnic').value).length < 5) || ((document.getElementById('cnic2').value).length < 7) ||  ((document.getElementById('cnic3').value).length < 1))
			{
				msgWithBorder('forwardJobMsg','CNIC number must be of 13 digits.','error',8,0,false);
				return false;
			}
			if((document.getElementById('cnic').value == '') || (document.getElementById('cnic2').value =='') || (document.getElementById('cnic3').value =='')){
				msgWithBorder('forwardJobMsg','Please Enter your CNIC number .','error',8,0,false);
				return false;
			}

			var cnicCat= document.getElementById('cnic').value + document.getElementById('cnic2').value + document.getElementById('cnic3').value ;
			var cnicLength= cnicCat.length;
			
			
				if((isNaN(document.getElementById('cnic').value) || (isNaN(document.getElementById('cnic2').value)) || (isNaN(document.getElementById('cnic3').value))))
				{
					msgWithBorder('forwardJobMsg','CNIC number must be numeric','error',8,0,false);
					return false;	
				}
		}
// END CNIC CHECK

		var cnic= cnic1= cnic2= cnic3='';

		if (document.getElementById('cnic'))
			cnic1 = document.getElementById('cnic').value
		if (document.getElementById('cnic2'))
			cnic2 = document.getElementById('cnic2').value
		if (document.getElementById('cnic3'))
			cnic3 = document.getElementById('cnic3').value
		if(cnic1 != '' && cnic2 != '' && cnic3 !=' ')
			{
				 cnic = cnic1+cnic2+cnic3;	
			}
			
		//alert(document.ApplyJob1.roster.length);
		//val = document.ApplyJob1.roster.value;
		val = document.getElementById('roster1').value;
		//alert(val);
		fld = 'roster';
		if(val==''){
			if(document.getElementById('cportalDir') && document.getElementById('cportalDir').value == 'uno')
			 msgWithBorder('forwardJobMsg','Please select a category.','error',8,0,false);
			else
			 msgWithBorder('forwardJobMsg','Please select a department.','error',8,0,false);
			
			return false;
		}		
		cpaint_call(spellUrl, 'POST', 'Apply4Department', app_cover_letter, resumeID, val,'',deptType,deptTFlg,cnic, ApplyJob4LoggedUser_cb);		
	}
	
	document.getElementById('spanAppJob1Processing').style.display = '';
	document.getElementById('btnApply4LgdUsr').style.display = 'none';	
	document.getElementById('submitImage_1').disabled = true;		
	showHide('tblJbApply','null');
	return false;
}

function validateJob4LoggedUser()
{
		
}
function success_message(spanID, message)
{
	
	var messageBar = '<table width="770" cellspacing="0" cellpadding="1"><tr><td><table width="770" cellpadding="1" cellspacing="0"><tr><td><table width="747" cellspacing="0" cellpadding="1"><tr><td bgcolor="#87BF00"><table width="770" cellpadding="3" cellspacing="0" bgcolor="#87BF00"><tr><td width="748" align="left" class="white11">'+message+'</td><td width="10" align="right" valign="top"><a href="javascript:;" onClick="close_message(\''+spanID+'\');"><img src="images/informationbar_iconclose.gif" width="13" height="13" border="0" /></a></td></tr></table></td></tr></table></td><td width="1" rowspan="2" bgcolor="#CCCCCC"></td></tr><tr><td height="2" bgcolor="#CCCCCC"></td></tr></table></td></tr></table>';
	document.getElementById(spanID).innerHTML = messageBar;
}

function error_message(spanID, message)
{
	
	document.getElementById(spanID).innerHTML = "<table width='100%' height='20' border='0' align='center' cellpadding='0' cellspacing='0'><tr><td align='left' valign='middle' bgcolor='#B90000' class='white11'>&nbsp;"+message+"</td></tr></table>";
}

function close_message(spanID)
{
	document.getElementById(spanID).innerHTML = "";
}

//--------------------------- CV upload ------------
function cvUpload_cb(new_data)
{
	//alert (new_data);
	var str = new_data;
	var spstr = str.split("##");
	var msgType = spstr[0];				// Message type either SUCCESS or ERROR
	var msgString = spstr[1];			// Message String
	var msgProcessSpan = spstr[2];		// Processing Bar Span
	var formName = spstr[3];			// Text Area where the string will return.
	var browser = spstr[4];				// User's Browser
	var errSpan = "forwardJobMsg";		// Text Area where the string will return.
	
	
	if (msgType == "SUCCESS")
	{
		//document.getElementById('hearFrom').style.display='none';
		if (browser == "IE")
			document.all.Layer2.style.display = 'block';
		else
			document.getElementById('Layer2').style.visibility = 'visible';
	    //alert(document.getElementById(formName).submit());		
		document.getElementById(formName).submit();
		//alert("Hello");
	}
	else
	{
		document.getElementById(msgProcessSpan).style.display = 'none';
		msgWithBorder(errSpan,msgString,'error',8,0,false);
	}
}

//function cvUpload(new_cv_Title, new_app_cv, new_cover_letter, spanProcessing, formName)
function cvUpload(new_cv_Title, new_app_cv, new_cover_letter,spanProcessing, formName)
{
	// tanveer
	
	document.getElementById('forwardJobMsg').innerHTML = "";
	
	var fld = hFrom=val=sa_isMultiCity=sa_jobCity=what_job=tech=nontech=testCnt1=testCnt2=cnicA=cnicB=cnicC=cnic='';
	var fSal = curSalReq = expSalReq = curSal= expSal = '';		
	
	if(document.getElementById('Technical2')){
		tech    = document.getElementById('Technical2').value;
		nontech = document.getElementById('nonTechnical2').value;
	}	
/* alert(document.getElementById('cnicA').value);alert(document.getElementById('cnicB').value);alert(document.getElementById('cnicC').value);*/
 
  if(document.getElementById('cnicA'))
  {
		cnicA = document.getElementById('cnicA').value;
		cnicB = document.getElementById('cnicB').value;
		cnicC = document.getElementById('cnicC').value;
	
		if(cnicA != '' && cnicB != '' && cnicC !=' ')
		{
			cnic  = cnicA+cnicB+cnicC;
		}
  }	

	var deptType='';
	var deptTFlg='N';
	

	if(document.getElementById('hearFrom')){
		val = document.ApplyJob2.hearFrom.value;
		fld = 'hearFrom';

		if( document.getElementById('sa_multiCity') && document.ApplyJob2.sa_multiCity.value=='Y' ){
			 var tmpC =  document.ApplyJob2.sa_jobCity.value;
			 sa_jobCity = tmpC;
			 sa_isMultiCity = 'Y';
		}


	}else if(document.getElementById('roster2')){
		//val = document.ApplyJob2.roster.value;
		//alert(document.getElementById('roster').value);
		val = document.getElementById('roster2').value;
		document.getElementById('hiddenRoster').value = val;
		fld = 'roster';
		
		if(document.ApplyJob2.deptType)
		{
			if(document.ApplyJob2.deptType.value=='')
			{
			 deptType = document.ApplyJob2.deptType.value; 
			 deptTFlg = 'Y';			 
			}
		}
	}


	document.getElementById(spanProcessing).style.display = '';
	showHide('tblJbApply','null');

	var cv_cover_letter = document.getElementById(new_cover_letter).value;
	var cv_Title = document.getElementById(new_cv_Title).value;
	var app_cv = document.getElementById(new_app_cv).value;
		
	if(cv_Title=='')
	{
		fld = 'cv_Title';
		msgWithBorder('forwardJobMsg','Please enter a CV title.','error',8,0,false);
		return false;
	}
	if(cv_cover_letter=='')
	{
		fld = 'cv_cover_letter';
		msgWithBorder('forwardJobMsg','Please enter your cover letter.','error',8,0,false);
		return false;
	}
    if(app_cv=='')
	{
		fld = 'app_cv';
		msgWithBorder('forwardJobMsg','Please select a CV.','error',8,0,false);
		return false;
	}
	
	
	 // if salary range is required at the time of job application	  
	if(document.getElementById('isCurSalaryReq2') && document.getElementById('isExpSalaryReq2') )
	{
		if(document.getElementById('isCurSalaryReq2').value == 'Y')
		{		   
			 if(document.getElementById('currentSalary2') && document.getElementById('currentSalary2').value == '')
			 {		 
				 msgWithBorder('forwardJobMsg','Please select your current salary.','error',8,0,false); 
				 return false;
			 }
		 }
		 if(document.getElementById('isExpSalaryReq2').value == 'Y')
		 {			
			if(document.getElementById('expectedSalary2') && document.getElementById('expectedSalary2').value == '')
			{
				 msgWithBorder('forwardJobMsg','Please select your expected salary.','error',8,0,false);
				 return false;
			}					
		 }
	  
	  if(document.getElementById('isCurSalaryReq2').value == '')
	     curSalReq = 'N';
	  else
	     curSalReq = document.getElementById('isCurSalaryReq2').value;
		 
	  if(document.getElementById('isExpSalaryReq2').value == '')	 
		 expSalReq = 'N';
	  else	 
		 expSalReq = document.getElementById('isExpSalaryReq2').value;
		 
	  if(document.getElementById('currentSalary2'))
	   curSal = document.getElementById('currentSalary2').value;
	  if(document.getElementById('expectedSalary2')) 
	   expSal = document.getElementById('expectedSalary2').value;	
	   
	  fSal = curSalReq+'|~|'+curSal+'|~|'+expSalReq+'|~|'+expSal;	
		 
		 
	}

	
	if(document.getElementById('cportalID') && document.getElementById('cportalID').value == '15843') // for indus Motor
	{
	
	
		if(tech!='' && nontech!=''){
			msgWithBorder('forwardJobMsg','Only one Department can be selected.','error',8,0,false);
			return false;
		}	
		if(tech=='' && nontech=='' ){
			msgWithBorder('forwardJobMsg','Please select your Department.','error',8,0,false);
			return false;
		}
		if(tech == '')
		{
			 what_job = nontech;
		}
		else
		{
			 what_job = tech;	
		}
	}

			//CNIC CHECK BY JAWADSALEEM
		if(document.getElementById('cnicA'))
		{
			if(((document.getElementById('cnicA').value).length < 5) || ((document.getElementById('cnicB').value).length < 7) ||  ((document.getElementById('cnicC').value).length < 1))
			{
				msgWithBorder('forwardJobMsg','CNIC number must be of 13 digits.','error',8,0,false);
				return false;
			}
			if((document.getElementById('cnicA').value == '') || (document.getElementById('cnicB').value =='') || (document.getElementById('cnicC').value =='')){
				msgWithBorder('forwardJobMsg','Please Enter your CNIC number .','error',8,0,false);
				return false;
			}

			var cnicCat= document.getElementById('cnicA').value + document.getElementById('cnicB').value + document.getElementById('cnicC').value ;
			var cnicLength= cnicCat.length;
			
			
				if((isNaN(document.getElementById('cnicA').value) || (isNaN(document.getElementById('cnicB').value)) || (isNaN(document.getElementById('cnicC').value))))
				{
					msgWithBorder('forwardJobMsg','CNIC number must be numeric','error',8,0,false);
					return false;	
				}
		}
// END CNIC CHECK
	if(document.getElementById('testCenter1B') && document.getElementById('testCenter2B')) // for PITB
	{
		testCnt1    = document.getElementById('testCenter1B').value;
		testCnt2 = document.getElementById('testCenter2B').value;
		
		if(testCnt1 ==''){
			msgWithBorder('forwardJobMsg','Please select your test center.','error',8,0,false);
			return false;
		}	
		/*if(testCnt2 ==''){
			msgWithBorder('forwardJobMsg','Please select your alternate test center.','error',8,0,false);
			return false;
		}	*/	
		if(testCnt1 == testCnt2)
		{
			msgWithBorder('forwardJobMsg','Both test center cannot be same.','error',8,0,false);
			return false;
		}
		
	}
	
    
	var jobCat = pSkills = sSkills = pExp = sExp = addParam = '';
	if(document.getElementById('cportalID') && document.getElementById('cportalID').value == '1908') // for netsol
	{
		if(document.getElementById('jobCat2'))
		{
			var jobCat    = document.getElementById('jobCat2').value;
			var pSkills = document.getElementById('pSkills2').value;
			var pExp = document.getElementById('pExperience2').value;
			var sSkills = document.getElementById('sSkills2').value;
			var sExp = document.getElementById('sExperience2').value;
			var isSecReq = document.getElementById('isSecondarySkillsReq2').value;
			
			document.getElementById('pSkillsHidden').value = pSkills;
			document.getElementById('sSkillsHidden').value = sSkills;
			
			if(jobCat == '')
			{
			  msgWithBorder('forwardJobMsg','Please select job category.','error',8,0,false);
			  return false;	
			}
			 
			if(pSkills == ''){
				msgWithBorder('forwardJobMsg','Please select primary skills.','error',8,0,false);
				return false;
			}	
			
			if(pExp == '' ){
				msgWithBorder('forwardJobMsg','Please select experience for primary skills.','error',8,0,false);
				return false;
			}			
			
			if(isSecReq == 'Y')
			{
				if(sSkills == '' ){
					msgWithBorder('forwardJobMsg','Please select secondary skills.','error',8,0,false);
					return false;
				}
				
				if(pSkills == sSkills)
				{
				  msgWithBorder('forwardJobMsg','Secondary skills should be different from the primary skills.','error',8,0,false);
				  return false;					
				}
				
				if(sExp == '' ){
					msgWithBorder('forwardJobMsg','Please select experience for secondary skills.','error',8,0,false);
					return false;
				}			
			
			  addParam = 'portalID:'+document.getElementById('cportalID').value+'|~|'+isSecReq+'|~|'+jobCat+'|~|'+pSkills+'|~|'+pExp+'|~|'+sSkills+'|~|'+sExp;
			}
			else			
			  addParam = 'portalID:'+document.getElementById('cportalID').value+'|~|'+isSecReq+'|~|'+jobCat+'|~|'+pSkills+'|~|'+pExp;
			
		}
	}

	
	
	if(document.ApplyJob2.hearFrom)
	{
		val = document.ApplyJob2.hearFrom.value;
		fld = 'hearFrom';
		if(val==''){
			msgWithBorder('forwardJobMsg','Please specify how did you hear about this job.','error',8,0,false);
			return false;
		}

	}
	
  

	var gpaOpt = 'N';
	var resultType=degree_level=uGPA=outOf='';
	if(document.ApplyJob2.gpaOpt2 && document.ApplyJob2.gpaOpt2.value == 'Y') // gpa option necessory
	{
		resultType = document.ApplyJob2.result2.value
		gpaOpt = document.ApplyJob2.gpaOpt2.value;
		degree_level = document.ApplyJob2.degree_level2.value;
		
		if(degree_level=='')
		{
			fld = 'degree_level';
			msgWithBorder('forwardJobMsg','Please Select Degree Level.','error',8,0,false);
			return false;
		}
			
		if(resultType=='GPA')
		{
			//uGPA = document.ApplyJob2.GPA2.value;
			if(document.getElementById('GPA2'))
			{			
				uGPA = document.getElementById('GPA2').value;			
				fld = 'GPA2';
				if(uGPA==''){
					msgWithBorder('forwardJobMsg','Please enter your result GPA.','error',8,0,false);
					return false;
				}
			}
			
			
			outOf = document.ApplyJob2.GPAOutOf2.value;
			fld = 'GPAOutOf2';
			if(outOf==''){
				msgWithBorder('forwardJobMsg','Please selet your total GPA.','error',8,0,false);
				return false;
			}	
		}
		else if(resultType=='Grade')
		{
			uGPA=uGrd = document.ApplyJob2.Grade2.value;
			fld = 'Grade2';
			if(uGrd==''){
				msgWithBorder('forwardJobMsg','Please enter your result Grade.','error',8,0,false);
				return false;
			}
		}
		else if(resultType=='Percentage')
		{
			uGPA=uPer= document.ApplyJob2.Percentage2.value;
			fld = 'Percentage2';
			if(uPer==''){
				msgWithBorder('forwardJobMsg','Please enter your result percentage.','error',8,0,false);
				return false;
			}
		}
		else if(resultType=='null')
		{
			fld = 'result2';
			msgWithBorder('forwardJobMsg','Please select your result in.','error',8,0,false);
			return false;

		}
	}
   

	//cpaint_call ('job-detail.php', 'POST', 'cvUpload', cv_Title, app_cv, cv_cover_letter, spanProcessing, formName,fld,val,sa_isMultiCity,sa_jobCity,cvUpload_cb);

	cpaint_call ('job-detail.php', 'POST', 'cvUpload', cv_Title, app_cv, cv_cover_letter, spanProcessing, formName,fld,val,sa_isMultiCity,sa_jobCity,gpaOpt,degree_level,uGPA,outOf,resultType,what_job,deptType,deptTFlg,testCnt1,testCnt2,cnic,fSal,addParam,cvUpload_cb);

	return false;	
}

// result type blocks
function resultBlocks(ele,cntrol,ids)
{
		
	if(ele.value=='null')
	{
		document.getElementById('GPAOutOf1').selectedIndex=0;
		document.getElementById('GPA1').selectedIndex=0;
		document.getElementById('selGPA'+cntrol).style.display = 'none';
		showHideBlock(ele.value,ids);
	}
	else
	{
		showHideBlock(ele.value+'Div'+cntrol,ids);
	}
}

function showHideBlock(show,hide){

	show = show.split('#');
	hide = hide.split('#');
	
	if(hide!='null'){
		for(i=0; i<hide.length; i++){
			if(document.getElementById(hide[i]))
				document.getElementById(hide[i]).style.display = 'none';
			else
				alert('Unable to hide: '+hide[i]);
		}
	}

	if(show!='null'){
		for(i=0; i<show.length; i++){
			if(document.getElementById(show[i]))
				document.getElementById(show[i]).style.display = '';
			else
				alert('Unable to show: '+show[i]);
		}
	}
}
//------------------------------ New User SignUp ------------------------
function cvUploadNewUser_cb(new_data)
{
	//alert (new_data);
	var str = new_data;
	var spstr = str.split("##");
	var msgType = spstr[0];				// Message type either SUCCESS or ERROR
	var msgString = spstr[1];			// Message String
	var browser = spstr[2];				// User's Browser
	var errSpan = "forwardJobMsg";		// Text Area where the string will return.
	if (msgType == "SUCCESS")
	{
		document.getElementById('spSrc_1').style.display='none';
		if (browser == "IE")
		{
			document.all.Layer1.style.display = 'block';
			
			if(document.ApplyJob3.sa_jobCity) document.ApplyJob3.sa_jobCity.style.display='none';
			if(document.ApplyJob3.hearFrom) document.ApplyJob3.hearFrom.style.display='none';

			if( document.getElementById('filterApp') && $GV('filterApp')=='Y' ){
				$SDDS('nu_gender','none');	$SDDS('nu_birthMonth','none');	$SDDS('nu_birthDay','none');	
				$SDDS('nu_birthYear','none');	$SDDS('nu_degree','none');	$SDDS('nu_experience','none');				
			}

		}
		else
		{
			document.getElementById('Layer1').style.visibility = 'visible';
			
		}		
		
		document.ApplyJob3.submit();
	}
	else
	{
		if(document.getElementById('imgWrk'))
			showHide('submitImage_3','imgWrk');
			
		msgWithBorder(errSpan,msgString,'error',8,0,false);
		showHide('submitImage_3','imgWrk_3');
		
	}
}

function cvUploadNewUser()
{
	document.getElementById('forwardJobMsg').innerHTML = "";
	showHide('tblJbApply','null');

	//var new_user_id = document.getElementById('new_user_id').value;
	//var new_user_password = document.getElementById('new_user_password').value;
	var new_user_email = document.getElementById('new_user_email').value;
	var new_user_firstname = document.getElementById('new_user_firstname').value;
	var new_user_lastname = document.getElementById('new_user_lastname').value;
	var cv_Title = document.getElementById('cv_Title2').value;
	var app_cv = document.getElementById('app_cv2').value;
	var sa_jbCity=filterApp=sa_multiCity=fltStr=jobID='';
	var fld=hFrom=val='';

	if(document.getElementById('hearFrom')){
		val = document.ApplyJob3.hearFrom.value;
		fld = 'hearFrom';
	}

	if(document.getElementById('roster')){
		val = document.ApplyJob3.roster.value;
		fld = 'roster';
	}
	
	
	if( document.getElementById('sa_multiCity') && document.ApplyJob3.sa_multiCity.value=='Y' ){
		sa_jbCity = document.ApplyJob3.sa_jobCity.value;
		sa_multiCity = 'Y';
	}
	
	if( document.getElementById('filterApp') && $GV('filterApp')=='Y' ){	
		fltStr = '||'+$GV('nu_gender')+'||'+$GV('nu_birthMonth')+'||'+$GV('nu_birthDay')+'||'+$GV('nu_birthYear')+'||'+$GV('nu_degree')+'||'+$GV('nu_experience');
		filterApp='Y';
		jobID=document.ApplyJob3.jid.value;
	}
	
	showHide('imgWrk_3','submitImage_3');
	var qry = new_user_firstname+"||"+new_user_lastname+"||"+new_user_email+"||"+cv_Title+"||"+app_cv+"||"+fld+"||"+val+'||'+sa_multiCity+'||'+sa_jbCity+'||'+jobID+'||'+filterApp+fltStr;

	cpaint_call ('job-detail.php', 'POST', 'cvUploadNewUser', qry, cvUploadNewUser_cb);
	return false;	
}

function usrLgn_cb1(data)
{
	 arr = data.split('##');	
	
	var isUser = '';
	var status = arr[0].replace(/^\s*|\s*$/g,"");
	var brow = arr[1];
	var v_url = arr[2];
	if(arr.length>3)
		isUser = arr[3];

	if(status=='fail'){
		msgWithBorder('msgLgn','Invalid username and/or password.','error',3,2,false);
		showHide('lgnBtn','lgnWrk');
	}else if(status=='notConfirmed'){
		document.location.href = 'chPass.php';
		return false;
	}else if(status=='blocked'){
		msgWithBorder('msgLgn',arr[3],'error',3,2,true);
		showHide('lgnBtn','lgnWrk');
	}else if(status=='success'){
		document.location.href = 'contest1.php';
	}
}

function usrLgn_cb(data){

	arr = data.split('##');	
	
	var isUser = '';
	var status = arr[0].replace(/^\s*|\s*$/g,"");
	var brow = arr[1];
	var v_url = arr[2];
	if(arr.length>3)
		isUser = arr[3];

	if(status=='fail'){
		msgWithBorder('msgLgn','Invalid username and/or password.','error',3,2,false);
		showHide('lgnBtn','lgnWrk');
	}else if(status=='notConfirmed'){
		document.location.href = 'chPass.php';
		return false;
	}else if(status=='blocked'){
		msgWithBorder('msgLgn',arr[3],'error',3,2,true);
		showHide('lgnBtn','lgnWrk');
	}else if(status=='success'){
		if(v_url != "")
		{
			document.location.href = v_url;	
			return true;
		}
		if(isUser!=''){

			if(isUser=='USEREXIST')
				document.location.href = 'old-user.php';
			else
				document.location.href = 'new-user.php';
				

			return false;
			
		}else if(document.getElementById('forRefresh') && document.getElementById('roster')){//check if its dropCV.php
			document.forRefresh.submit();
			return false;
		}else if(document.getElementById('forRefresh') && document.forRefresh.isLgn){//check if its job-detail.php
			document.forRefresh.isLgn.value='ajx';
			document.forRefresh.submit();
			return false;
		}        
		document.location.href = 'user-profile.php';
	}
	outLogin = false;
}

function usrLgn(returnFile,frm,brow){
	var timeOut = 20000;
	if(!outLogin){
		outLogin = true;	
		uid = trim(frm.user_id.value);
		pwd = trim(frm.password.value);
		rem = false;
		
		if(uid==''){
			msgWithBorder('msgLgn','Please enter username.','error',3,2,false)
			frm.user_id.focus();
			outLogin = false;
			return false;
		}
		
		if(pwd==''){
			msgWithBorder('msgLgn','Please enter password.','error',3,2,false)		
			frm.password.focus();
			outLogin = false;
			return false;
		}
				
		showHide('lgnWrk','lgnBtn');
	
		len = frm.elements.length;
		
		for (var i = 0; i < len; i++){
			 if(frm.elements[i].type=='checkbox' && frm.elements[i].checked==true){
				rem = true;
			}	
		}
		
		if(returnFile == 'contest1.php')
		{
		 cpaint_call(returnFile, 'POST', 'usrLgn',uid,pwd,rem,brow, usrLgn_cb1);
		 setTimeout("cp_ClearTimeOut('login', 'lgnWrk')", timeOut); 	
		}
		else
		{
		 cpaint_call(returnFile, 'POST', 'usrLgn',uid,pwd,rem,brow, usrLgn_cb);
		 setTimeout("cp_ClearTimeOut('login', 'lgnWrk')", timeOut);
		}
		//alert(' uid ' + uid + ' pwd ' + pwd + ' rem ' + rem + ' brow ' + brow + ' usrlgn_cb ' + usrLgn_cb); 		
		return false;
	}else{
		msgWithBorder('msgLgn','System is busy processing your previous request.','error',3,2,false);
	}
	
}

var tWin=0;
function cp_showTest(tid, testJid, cvId)
{
  if(tWin)
    if(!tWin.closed) tWin.close();

	var w, h;
	w = screen.width;	h = screen.height;
	var url = "tb-test.php?tbid="+tid+"&testJid="+testJid+"&testCvId="+cvId;
	
	tWin = open(url, 'tWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars,copyhistory=yes,width='+w+',height='+h+',left=0, top=0');
}

function clrLyr(){
	document.getElementById('userAvailability').innerHTML='';

}
//****************************** By Farman ***********************
function loadGPA(outOf,index)
{	
  if(outOf != '')
  {
	document.getElementById('selGPA'+index).innerHTML='Loading...';
	cpaint_call (spellUrl, 'POST', 'loadGPA', outOf, index ,loadGPA_cb);
  }
  else if(outOf == '')
  {
	document.getElementById('selGPA'+index).style.display='none';
	msgWithBorder('forwardJobMsg','Please select your total GPA.','error',8,0,false);  
  }
}

function loadGPA_cb(r)
{
	var str = r;
	var spstr = str.split("##");	
	document.getElementById('selGPA'+spstr[1]).style.display='';
	document.getElementById('selGPA'+spstr[1]).innerHTML=spstr[0];
	return;
}
//*****************************************************************=======


function loadSubDept(deptID,frmName) // user for care and indus motor
{
   if(deptID != '')	
   {
		cpaint_call (spellUrl, 'POST', 'loadSubDept', deptID,frmName, loadSubDept_cb);
   }
	
}

function loadSubDept_cb(resp)
{
	
	var str = resp;
	var spstr = str.split("||");
	var frmName = spstr[0];				// Message type either SUCCESS or ERROR
	var dept = spstr[1];		
	//alert(dept);
	//alert(document.ApplyJob1.roster.length);
	
	/*if(document.ApplyJob1.roster)
		alert(document.ApplyJob1.roster.selectedIndex);
	else
		alert('test2');*/
	
	if(frmName == 'ApplyJob1')
	{
	 document.getElementById('subDept1').style.display='';	 
	 //document.ApplyJob1.roster.options[1]= new Option('tan',1,true,true);	 	 
	 document.getElementById('subroster1').innerHTML=dept;
	}
	else
	{
	 document.getElementById('subDept2').style.display='';
	 //document.ApplyJob2.roster.innerHTML=dept;	
	 document.getElementById('subroster2').innerHTML=dept;
	}
	
	
}


function loadSubCat(value,name,frmType,action) // use for netsole
{
   if(value != '')	
   {
	 if(document.getElementById('skillImg'+frmType))
	 {
	  document.getElementById('skillArea'+frmType).style.display='none';
	  document.getElementById('skillImg'+frmType).style.display='';
	 }
	 cpaint_call (spellUrl, 'POST', 'loadSubCat', value, name, frmType, action, loadSubCat_cb);
   }
	
}

function loadSubCat_cb(resp) // use for netsole
{	
	var str = resp;
	var spstr = str.split("||");
	var name = spstr[0];
	var frmType = spstr[1];	
	var action = spstr[2];			
	var content = spstr[3];			
	
   if(action == 'subCat')
   {
     
	 if(document.getElementById('skillImg'+frmType))
	  document.getElementById('skillImg'+frmType).style.display='none';
	  
	 document.getElementById('skillArea'+frmType).style.display='';		  
     document.getElementById(name+'_'+frmType).innerHTML='<select name='+name+frmType+' id='+name+frmType+' >'+content+'</select>';		
	 //document.getElementById('sSkills'+'_'+frmType).innerHTML='<select name="sSkills" id="sSkills'+frmType+'" >'+content+'</select>';			
	 //document.getElementById(name+frmType).innerHTML=content;	 
	 if(document.getElementById(name+frmType).options.length>2)
	 {		 
	  document.getElementById('sSkillArea'+frmType).style.display='';	
	  //document.getElementById('sSkills'+frmType).innerHTML=content;	
	  document.getElementById('sSkills'+'_'+frmType).innerHTML='<select name="sSkills'+frmType+'" id="sSkills'+frmType+'" >'+content+'</select>';	
	  document.getElementById('isSecondarySkillsReq'+frmType).value='Y';	
	  
	 }
	 else
	 {
	  document.getElementById('sSkillArea'+frmType).style.display='none';
	  document.getElementById('isSecondarySkillsReq'+frmType).value='N';	
	 }
	 
   }	
}


/*

function loadSubCat_cb(resp) // use for netsole
{	
	var str = resp;
	var spstr = str.split("||");
	var name = spstr[0];
	var frmType = spstr[1];	
	var action = spstr[2];			
	var content = spstr[3];			
	
   if(action == 'subCat')
   {
     document.getElementById('skillArea'+frmType).style.display='';		  
     //document.getElementById(name+'_'+frmType).innerHTML='<select name='+name+' id='+name+frmType+' >'+content+'</select>';		
	 //document.getElementById('sSkills'+'_'+frmType).innerHTML='<select name="sSkills" id="sSkills'+frmType+'" >'+content+'</select>';			
	 document.getElementById(name+frmType).innerHTML=content;	 
	 if(document.getElementById(name+frmType).options.length>2)
	 {		 
	  document.getElementById('sSkillArea'+frmType).style.display='';	
	  document.getElementById('sSkills'+frmType).innerHTML=content;	
	  document.getElementById('isSecondarySkillsReq'+frmType).value='Y';	
	  
	 }
	 else
	 {
	  document.getElementById('sSkillArea'+frmType).style.display='none';
	  document.getElementById('isSecondarySkillsReq'+frmType).value='N';	
	 }
	 if(document.getElementById('skillImg'))
	  document.getElementById('skillImg').style.display='none';
   }	
}

*/
