<!-- Begin

//Email address validation

function echeck(str) {
  var at="@"
  var dot="."
  var lat=str.indexOf(at)
  var lstr=str.length
  var ldot=str.indexOf(dot)
  if (str.indexOf(at)==-1){
     alert("Invalid E-mail ID")
     return false
  }
  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
     alert("Invalid E-mail ID")
     return false
  }
  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
      alert("Invalid E-mail ID")
      return false
  }
   if (str.indexOf(at,(lat+1))!=-1){
      alert("Invalid E-mail ID")
      return false
   }
   if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
      alert("Invalid E-mail ID")
      return false
   }
   if (str.indexOf(dot,(lat+2))==-1){
      alert("Invalid E-mail ID")
      return false
   }
   if (str.indexOf(" ")!=-1){
      alert("Invalid E-mail ID")
      return false
   }
   return true          
}

function ValidateForm(){
  var emailID=document.form.email  
  if ((emailID.value==null)||(emailID.value=="")){
    //alert("Please Enter your Email ID")
    //emailID.focus()
    //return false
  }
  if (echeck(emailID.value)==false){
    emailID.value=""
    emailID.focus()
    return false
  } 
  
  var emailIDD=document.form.emailConfirm  
  if ((emailIDD.value==null)||(emailIDD.value=="")){
    //alert("Please Enter your Email ID")
    //emailID.focus()
    //return false
  }
  if (echeck(emailIDD.value)==false){
    emailIDD.value=""
    emailIDD.focus()
    return false
  } 
  
  //Emails match
  if (emailID.value!=emailIDD.value){
	 alert("Emails don't match!")
	 emailID.focus()
     return false
  }else{  
	  //Passwords match
	  var pwdO=document.form.password;  
	  var pwdT=document.form.passwordConfirm; 
	  if (pwdO.value!=pwdT.value){
	  //if (document.form.password!=document.form.passwordConfirm){
		 alert("Passwords don't match!")
		 //pwdO.focus();
		 document.form.password.focus()
		 return false
	  }	  
	  //return true
	  document.form.submit();	
  }
  
 }


//Auto erase from text box
function doClear(theText) 
{
     if (theText.value == theText.defaultValue)
 {
         theText.value = ""
     }
 }


//Register form validation
function user_application() {	
	
	var themessage = "You are required to complete the following field: ";	
	
	if (document.form.fname.value=="") {
	themessage = themessage + " \n First Name";
	}		
	if (document.form.lname.value=="") {
	themessage = themessage + " \n Last Name";
	}	
	if (document.form.dt_day.value=="" || document.form.dt_month.value=="" || document.form.dt_year.value=="") {
	themessage = themessage + " \n Date Of Birth";
	}	
	
	var radio_choice = false;
	if ( (document.form.gender[0].checked) || (document.form.gender[1].checked) ){
	radio_choice = true; 
	}
	if (!radio_choice)
	{
	themessage = themessage + " \n Gender";
	}
	
	var radio_choice = false;
	if ( (document.form.mStatus[0].checked) || (document.form.mStatus[1].checked) || (document.form.mStatus[2].checked) ){
	radio_choice = true; 
	}
	if (!radio_choice)
	{
	themessage = themessage + " \n Marital Status";
	}
	
	if (document.form.countryResidence.value=="") {
	themessage = themessage + " \n Current Location";
	}		
	if (document.form.nationality.value=="") {
	themessage = themessage + " \n Nationality";
	}	
	if (document.form.mobile.value=="") {
	themessage = themessage + " \n Mobile";
	}	
	if (document.form.email.value=="") {
	themessage = themessage + " \n Email";
	}		
	if (document.form.emailConfirm.value=="") {
	themessage = themessage + " \n Confirm Email";
	}	
	if (document.form.password.value=="") {
	themessage = themessage + " \n Password";
	}		
	if (document.form.passwordConfirm.value=="") {
	themessage = themessage + " \n Confirm Password";
	}	
	if (document.form.CV.value=="") {
	themessage = themessage + " \n Attach CV";
	}
	//if (document.form.photo.value=="") {
	//themessage = themessage + " \n Attach Photo";
	//}
	if (document.form.highlevelEdu.value=="") {
	themessage = themessage + " \n Highest Level of Education";
	}	
	if (document.form.country.value=="") {
	themessage = themessage + " \n Country";
	}	
	if (document.form.careerlevel.value=="") {
	themessage = themessage + " \n Career Level";
	}	
	/*	
	if (document.form.jobCategory.value=="") {
	themessage = themessage + " \n Job Category";
	}
	if (document.form.jobPrefLocation.value=="") {
	themessage = themessage + " \n Jobseeker's Preferred Location";
	}*/	
	
	var radio_choice = false;
	if ( (document.form.empStatus[0].checked) || (document.form.empStatus[1].checked) || (document.form.empStatus[2].checked) ){
	radio_choice = true; 
	}
	if (!radio_choice)
	{
	themessage = themessage + " \n Employment Status";
	}
		
	var radio_choice = false;
	if ( (document.form.empType[0].checked) || (document.form.empType[1].checked) || (document.form.empType[2].checked) || (document.form.empType[3].checked)){
	radio_choice = true; 
	}
	if (!radio_choice)
	{
	themessage = themessage + " \n Employment Type";
	}
	
	//if (document.form.currSalary.value=="") {
	//themessage = themessage + " \n Current Salary";
	//}
	if (document.form.expSalary.value=="") {
	themessage = themessage + " \n Expected Salary";
	}
	if (document.form.availability.value=="") {
	themessage = themessage + " \n Availability";
	}
	if (document.form.skills.value=="") {
	themessage = themessage + " \n Key Skills";
	}
	
	/*var radio_choice = false;
	if ( (document.form.fLangValue[0].checked) || (document.form.fLangValue[1].checked) || (document.form.fLangValue[2].checked) || (document.form.fLangValue[3].checked) ){
	radio_choice = true; 
	}
	if (!radio_choice || document.form.firstLanguage.value=="")
	{
	themessage = themessage + " \n First Language";
	}*/
	if (document.form.firstLanguage.value=="") {
	themessage = themessage + " \n First Language";
	}
	
	if (document.form.hear.value=="") {
	themessage = themessage + " \n How did you hear about Palm Recruit?";
	}
	
	//alert if fields are empty and cancel form submit
	if (themessage == "You are required to complete the following field: ") {  	
	return ValidateForm();
	document.form.submit();		
	}
	else {
	alert(themessage);
	return false;
	} 

	
}

//  End -->
