// JavaScript Document


//#############Validates required fields####################
function isReady(form){

    var a = document.getElementById('ctl00_ContentPlaceHolder3_Name').value;
    var b = document.getElementById('ctl00_ContentPlaceHolder3_Postcode').value;
    var c = document.getElementById('ctl00_ContentPlaceHolder3_Mobile').value;
    var d = document.getElementById('ctl00_ContentPlaceHolder3_Email').value;
    var g = document.getElementById('ctl00_ContentPlaceHolder3_DateOfBirth').value;
    var h = document.getElementById('ctl00_ContentPlaceHolder3_Nationality').value;
    var i = document.getElementById('ctl00_ContentPlaceHolder3_WorkVisa').selectedIndex;
    var j = document.getElementById('ctl00_ContentPlaceHolder3_AvailabilityList').selectedIndex;
    var k = document.getElementById('ctl00_ContentPlaceHolder3_PrevExp').value;
    var l = document.getElementById('ctl00_ContentPlaceHolder3_Quals').value;

	if (a == "") {
	alert("Please enter your name to continue.")
	return false
	}			
	if (b == "") {
	alert("Please enter your postcode to continue.")
	return false
	}
	if (c == "") {
	alert("Please enter your mobile phone number to continue.")
	return false
	}
	if (d == "") {
	alert("Please enter your email address to continue.")
	return false
	}			
	if (g == "") {
	alert("Please enter your date of birth to continue.")
	return false
	}
	if (h == "") {
	alert("Please enter your nationality to continue.")
	return false
	}
	if (i == "") {
	alert("Please select your work visa type to continue.")
	return false
	}
	if (j == "") {
	alert("Please enter your available to continue.")
	return false
	}			
	if (k == "") {
	alert("Please select your previous work experience type to continue.")
	return false
	}
	if (l == "") {
	alert("Please select your qualifications to continue.")
	return false
	}

	return echeck (form.Email.value)
}
//##########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();
}

//######################################################################
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 Address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail address")
		    return false
		 }

 		 return true					
	}
//#################################################################################
