// JavaScript Document


//#############Validates required fields####################
function isReady(form){

if (form.Name.value == "") {
			alert("Please enter your name to continue.")
			return false
			}			

if (form.Phone.value == "") {
			alert("Please enter your phone number to continue.")
			return false
			}

return echeck(form.Email.value)

if (form.Email.value == "") {
				alert("Please enter your email address to continue")
				return false
			}
			
			return oneChecked(form)
}
//##########Validates Checkbox###############
function oneChecked(form)
   {
   for (i=0; i<form.Position.length; i++)
      {
      if (form.Position[i].type == "checkbox")
         {
         if (form.Position[i].checked){
            return true;
            }
         }
      }
   alert("You must check at least one of the four boxes to indicate which type of position you are offering.");
   return false;
   }
//#########Sets focus on availabilty field##############
function setFocus() {
  document.ImpClient.Name.focus();
}
//######### Validate Email Address ######################
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					
	}

