// JavaScript Document

function enquiry_check(){
	var rec_enq_check=0;
	var rec_company=document.getElementById("empenq_name").value;
	var rec_contact=document.getElementById("empenq_contact").value;
	var rec_email=document.getElementById("empenq_email").value;
	var rec_designation=document.getElementById("empenq_desig").value;
	var rec_city=document.getElementById("empenq_city").value;
	var rec_location=document.getElementById("empenq_location").value;
	var rec_location_other=document.getElementById("empenq_city_other").value;
	var telephone=document.getElementById("empenq_teloff").value;
	var mobile=document.getElementById("empenq_telmob").value;
	var rec_profile=document.getElementById("empenq_profile").value;
	var rec_vacancies=document.getElementById("empenq_vacancies").value;

	if(rec_company==''){
		document.getElementById("spn_empenq_name").style.color='red';
		rec_enq_check=rec_enq_check+1;
	}else{
		document.getElementById("spn_empenq_name").style.color='';
	}
	
	if(rec_contact==''){
		document.getElementById("spn_empenq_contact").style.color='red';
		rec_enq_check=rec_enq_check+1;
	}else{
		document.getElementById("spn_empenq_contact").style.color='';
	}
	
	if(rec_email==''){
		document.getElementById("spn_empenq_email").style.color='red';
		rec_enq_check=rec_enq_check+1;
	}else{
		if(rec_email == "" || rec_email.indexOf ('@', 1) == -1 || rec_email.indexOf ('.', 3) == -1) {
			document.getElementById("spn_empenq_email").style.color='red';
			rec_enq_check=rec_enq_check+1;
		}else{
			document.getElementById("spn_empenq_email").style.color='';
		}
	}
	
	if(rec_designation==''){
		document.getElementById("spn_empenq_desig").style.color='red';
		rec_enq_check=rec_enq_check+1;
	}else{
		document.getElementById("spn_empenq_desig").style.color='';
	}

	if(rec_city==0){
		document.getElementById("spn_empenq_city").style.color='red';
		rec_enq_check=rec_enq_check+1;
	}else if(rec_city=='Other'){
		if(rec_location_other==''){
			document.getElementById("spn_empenq_city").style.color='red';
			rec_enq_check=rec_enq_check+1;
		}else{
			document.getElementById("spn_empenq_city").style.color='';
		}
	}else{
		document.getElementById("spn_empenq_city").style.color='';
	}
	
	if(rec_location==''){
		document.getElementById("spn_empenq_location").style.color='red';
		rec_enq_check=rec_enq_check+1;
	}else{
		document.getElementById("spn_empenq_location").style.color='';
	}
	
	if(telephone=='' && mobile==''){
		document.getElementById("spn_empenq_teloff").style.color='red';
		rec_enq_check=rec_enq_check+1;
	}else{
		document.getElementById("spn_empenq_teloff").style.color='';
	}
	
	if(rec_profile==''){
		document.getElementById("spn_empenq_profile").style.color='red';
		rec_enq_check=rec_enq_check+1;
	}else{
		document.getElementById("spn_empenq_profile").style.color='';
	}
	
	if(rec_vacancies==''){
		document.getElementById("spn_empenq_vacancies").style.color='red';
		rec_enq_check=rec_enq_check+1;
	}else{
		document.getElementById("spn_empenq_vacancies").style.color='';
	}

	if(rec_enq_check>0){
		document.getElementById("spn_recenq_submit").innerHTML=rec_enq_check+' Fields to be completed.';
		return false;
	}else{
		return true;	
	}

}

function add_empenq_city(){
	var empenqcity=document.getElementById("empenq_city");
	var empenqloc_other=document.getElementById("empenqcity_other");

	if(empenqcity.options[empenqcity.selectedIndex].text=="Other"){
		empenqloc_other.style.display='';
	}else{
		empenqloc_other.style.display='none';
		document.getElementById("empenq_city_other").value="";
	}
	
}