// JavaScript Document
function checkForm() {
	// Speciality validation	
	if(document.frmSearch.Speciality[0].checked==false && document.frmSearch.Speciality[1].checked==false && document.frmSearch.Speciality[2].checked==false && document.frmSearch.Speciality[3].checked==false){
		alert('You must first select from the top three options before proceeding.');
		document.frmSearch.Speciality[0].focus();
		return false;
	}
	// City Location
	if(document.frmSearch.CityLocation.options[0].selected==true){
		alert('You must first select from the top three options before proceeding.');
		document.frmSearch.CityLocation.focus();
		document.frmSearch.CityLocation.className = "error";
		return false;
	}
	// Preference for days
	DayPreferences=new Array();
	DaysChecked=false;
	limit = document.frmSearch.day.length;
	counter=0;
	for(i=0;i<limit;i++){
		DaysChecked = DaysChecked || document.frmSearch.day[i].checked;
		if(document.frmSearch.day[i].checked){
			DayPreferences[counter] = document.frmSearch.day[i].value;
			counter++;
		}
	}
	if(DaysChecked==false) {
		alert('You must first select from the top three options before proceeding.');
		document.frmSearch.day[0].focus();
		return false;
	}
	else
	   document.frmSearch.DayPreferences.value = DayPreferences.join(",");

	// Proficiency
	var tmpPro='';
	arrProficiency=new Array();
	OptionsChecked=false;
	limit = document.frmSearch.tmpProficiency.length;
	counter=0;
	for(i=0;i<limit;i++){
		//OptionsChecked = OptionsChecked || document.frmSearch.tmpProficiency[i].checked;
		if(document.frmSearch.tmpProficiency[i].checked==true){
			tmpPro += document.frmSearch.tmpProficiency[i].value+',';
			//counter++;
		}
	}
	/*if(OptionsChecked) {
		if(arrProficiency.length > 1)
	    	document.frmSearch.Proficiency.value = arrProficiency.join(",");
		else
			document.frmSearch.Proficiency.value = arrProficiency[0];
	}*/
	
	//alert(document.frmSearch.Proficiency.value);
	if(tmpPro.length > 1) {
		tmpL = tmpPro.length;
		tmpPro = tmpPro.substr(0,tmpL-1);
	}
	document.frmSearch.Proficiency.value = tmpPro;
	//alert(document.frmSearch.Proficiency.value);

// Professional Background
	var tmpExperience='';
	arrTemp=new Array();
	OptionsChecked=false;
	limit = document.frmSearch.PrevExperience.length;
	counter=0;
	for(i=0;i<limit;i++){
		//OptionsChecked = OptionsChecked || document.frmSearch.PrevExperience[i].checked;
		if(document.frmSearch.PrevExperience[i].checked==true){
			tmpExperience += document.frmSearch.PrevExperience[i].value+',';
			//counter++;
		}
	}
	/*if(OptionsChecked) {
		if(arrTemp.length > 1)
	    	document.frmSearch.ProfessionalBackground.value = arrTemp.join(",");
		else {
			document.frmSearch.ProfessionalBackground.value = arrTemp[0];
		}
	}*/
	if(tmpExperience.length > 1) {
		tmpL = tmpExperience.length;
		tmpExperience = tmpExperience.substr(0,tmpL-1);
	}
	document.frmSearch.ProfessionalBackground.value = tmpExperience;
	//alert(document.frmSearch.ProfessionalBackground.value);
	
return true;
}

function clearText(obj){
	obj.value='';	
}

function selectThisCandidate(obj){
	//alert(obj.value);
	tmp = document.frmSearch.sid.value;
	if(tmp=="") tmp = obj.value;
	else{
		if(tmp.indexOf(obj.value)== -1)
			tmp = tmp+","+obj.value;
	}
	
	document.frmSearch.sid.value = tmp;
	//alert(document.frmSearch.sid.value);
	document.frmSearch.act.value = '1';
	document.frmSearch.submit();
}

function unSelectThisCandidate(obj){
	tmp = document.frmSearch.sid.value;
	tmpL = tmp.length;
	if(tmpL>1){
		tmpArr = tmp.split(",");
		tmp='';
		tmpArrL = tmpArr.length;
		for(i=0;i<tmpArrL;i++){
			if(tmpArr[i]!=obj.value)
			tmp += tmpArr[i]+",";
		}
		tmpL = tmp.length;
		tmp = tmp.substr(0,tmpL-1);
	}
	else tmp="";
	document.frmSearch.sid.value = tmp;
	//alert(document.frmSearch.sid.value);
	document.frmSearch.act.value = '1';
	document.frmSearch.submit();
}

function stepOne(){
	document.frmSearch.action = 'step_one.php';
	document.frmSearch.act.value = '0';
	document.frmSearch.submit();
}

function view_candidate_resume(resume, object) {
	if(object.disabled=='disabled') alert('You must first log in before this button will be enabled.');
	else location.href='/siteadmin/truncated_resume/'+resume;
}