
function app_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("Your email address appears incorrect. Please enter it in the format 'abc@xyz.com'")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Your email address appears incorrect. Please enter it in the format 'abc@xyz.com'")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   alert("Your email address appears incorrect. Please enter it in the format 'abc@xyz.com'")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   alert("Your email address appears incorrect. Please enter it in the format 'abc@xyz.com'")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   alert("Your email address appears incorrect. Please enter it in the format 'abc@xyz.com'")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   alert("Your email address appears incorrect. Please enter it in the format 'abc@xyz.com'")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		   alert("Your email address appears incorrect. Please enter it in the format 'abc@xyz.com'")
		    return false
		 }
 		 return true					
}



function validate_app_form1(){
	var Job_IDID=document.app_form1.Job_ID
	var First_NameID=document.app_form1.First_Name
	var Last_NameID=document.app_form1.Last_Name
	var Street_AddressID=document.app_form1.Street_Address
	var CityID=document.app_form1.City
	var ProvinceID=document.app_form1.Province
	var PostalID=document.app_form1.Postal
	var Home_PhoneID=document.app_form1.Home_Phone	
	var EmailID=document.app_form1.Email
	var Legally_EntitledID=document.app_form1.Legally_Entitled
	var Date_AvailableID=document.app_form1.Date_Available
	
	if ((Job_IDID.value==null)||(Job_IDID.value=="")||(Job_IDID.value=="CM_")){
		alert("Please enter one or more Job numbers, in the format 'CM 0123'")
		Job_IDID.focus()
		return false
	}
	
	if ((First_NameID.value==null)||(First_NameID.value=="")){
		alert("Please enter your first name")
		First_NameID.focus()
		return false
	}	
	
	if ((Last_NameID.value==null)||(Last_NameID.value=="")){
		alert("Please enter your last name")
		Last_NameID.focus()
		return false
	}	
	
	if ((Street_AddressID.value==null)||(Street_AddressID.value=="")){
		alert("Please enter your street address")
		Street_AddressID.focus()
		return false
	}	
	
	if ((CityID.value==null)||(CityID.value=="")){
		alert("Please enter your city")
		CityID.focus()
		return false
	}	
	
	if ((ProvinceID.value==null)||(ProvinceID.value=="")){
		alert("Please enter your province")
		ProvinceID.focus()
		return false
	}	
	
	if ((PostalID.value==null)||(PostalID.value=="")){
		alert("Please enter your postal code")
		PostalID.focus()
		return false
	}	
	
	if ((Home_PhoneID.value==null)||(Home_PhoneID.value=="")){
		alert("Please enter your home phone number")
		Home_PhoneID.focus()
		return false
	}	
	
	if ((Date_AvailableID.value==null)||(Date_AvailableID.value=="")){
		alert("Please enter your available starting date")
		Date_AvailableID.focus()
		return false
	}	
	
	if ((EmailID.value==null)||(EmailID.value=="")){
		alert("Please enter your email address")
		EmailID.focus()
		return false
	}  
	if (app_echeck(EmailID.value)==false){
		EmailID.value=""
		EmailID.focus()
		return false
	}
	return true
}


function validate_app_form3(){
	var Languages_SpokenID=document.app_form3.Languages_Spoken
	var Physical_RestrictionsID=document.app_form3.Physical_Restrictions
	var Worked_Choices_PreviouslyID=document.app_form3.Worked_Choices_Previously
	var Weekly_Hours_Can_WorkID=document.app_form3.Weekly_Hours_Can_Work
	var Full_NameID=document.app_form3.Full_Name
	var Date_TodayID=document.app_form3.Date_Today
	
	if ((Languages_SpokenID.value==null)||(Languages_SpokenID.value=="")){
		alert("Please enter your spoken languages")
		Languages_SpokenID.focus()
		return false
	}	
	
	if ((Weekly_Hours_Can_WorkID.value==null)||(Weekly_Hours_Can_WorkID.value=="")){
		alert("Please enter the number of weekly available hours")
		Weekly_Hours_Can_WorkID.focus()
		return false
	}	
	
	if ((Full_NameID.value==null)||(Full_NameID.value=="")){
		alert("Please enter your full name")
		Full_NameID.focus()
		return false
	}	
	
	if ((Date_TodayID.value==null)||(Date_TodayID.value=="")){
		alert("Please enter today's date")
		Date_TodayID.focus()
		return false
	}	
	return true
}