//##########Validates Checkbox###############
function oneChecked(form)
   {
   for (i=1; i<form.FirstCand.length; i++)
      {
      if (form.FirstCand[i].type == "checkbox")
         {
         if (form.FirstCand[i].checked){
            return true;
            }
         }
      }
   alert("You must check at least one of the boxes to indicate the first candicate's position sought.");
   return false;
   }
   //#############Validates second cand checkboxes####################
function twoChecked(form)
   {
   for (i=1; i<form.SecondCand.length; i++)
      {
      if (form.SecondCand[i].type == "checkbox")
         {
         if (form.SecondCand[i].checked){
            return true;
            }
         }
      }
   alert("You must check at least one of the boxes to indicate the second candicate's position sought.");
   return false;
   }
//#############Validates required fields####################
   function isReady(form) {


       var a = document.getElementById('ctl00_ContentPlaceHolder2_FirstCandName').value;
       var b = document.getElementById('ctl00_ContentPlaceHolder2_FirstCandPostcode').value;
       var c = document.getElementById('ctl00_ContentPlaceHolder2_FirstCandMobile').value;
       var d = document.getElementById('ctl00_ContentPlaceHolder2_FirstCandEmail').value;
       var e = document.getElementById('ctl00_ContentPlaceHolder2_FirstCandDateOfBirth').value;
       var f = document.getElementById('ctl00_ContentPlaceHolder2_FirstCandNationality').value;
       var g = document.getElementById('ctl00_ContentPlaceHolder2_FirstCandWorkVisa').selectedIndex;
       var h = document.getElementById('ctl00_ContentPlaceHolder2_FirstCandAvailable').value;
       var i = document.getElementById('ctl00_ContentPlaceHolder2_FirstCandPrevExp').value;
       var j = document.getElementById('ctl00_ContentPlaceHolder2_FirstCandQuals').value;
       var k = document.getElementById('ctl00_ContentPlaceHolder2_FirstCandPassport').value;

       var l = document.getElementById('ctl00_ContentPlaceHolder2_SecondCandName').value;
       var m = document.getElementById('ctl00_ContentPlaceHolder2_SecondCandPostcode').value;
       var n = document.getElementById('ctl00_ContentPlaceHolder2_SecondCandMobile').value;
       var o = document.getElementById('ctl00_ContentPlaceHolder2_SecondCandEmail').value;
       var p = document.getElementById('ctl00_ContentPlaceHolder2_SecondCandDateOfBirth').value;
       var q = document.getElementById('ctl00_ContentPlaceHolder2_SecondCandNationality').value;
       var r = document.getElementById('ctl00_ContentPlaceHolder2_SecondCandWorkVisa').selectedIndex;
       var s = document.getElementById('ctl00_ContentPlaceHolder2_SecondCandAvailable').value;
       var t = document.getElementById('ctl00_ContentPlaceHolder2_SecondCandPrevExp').value;
       var u = document.getElementById('ctl00_ContentPlaceHolder2_SecondCandQuals').value;
       var v = document.getElementById('ctl00_ContentPlaceHolder2_SecondCandPassport').value;

       if (a == "") {
           alert("Please enter the first applicant's name to continue.")
           return false
       }
       if (b == "") {
           alert("Please enter the first applicant's postcode to continue.")
           return false
       }
       if (c == "") {
           alert("Please enter the first applicant's mobile to continue.")
           return false
       }
       if (d == "") {
           alert("Please enter the first applicant's email address to continue.")
           return false
       }
       if (f == "") {
           alert("Please enter the first applicant's Nationality to continue.")
           return false
       }
       if (e == "") {
           alert("Please enter the first applicant's date of birth to continue.")
           return false
       }
       if (g == "") {
           alert("Please confirm that the first applicant has a work visa.")
           return false
       }
       if (h == "") {
           alert("Please enter the issuing country of your passport.")
           return false
       }
       if (i == "") {
           alert("Please enter the First application's availability to continue.")
           return false
       }
       if (j == "") {
           alert("Please describe the first applicant's previous experience to continue.")
           return false
       }
       if (k == "") {
           alert("Please outline the first applicant's qualifications to continue.")
           return false
       }
       if (l == "") {
           alert("Please enter the second applicant's name to continue.")
           return false
       }
       if (m == "") {
           alert("Please enter the second applicant's postcode to continue.")
           return false
       }
       if (n == "") {
           alert("Please enter the second applicant's mobile to continue.")
           return false
       }
       if (o == "") {
           alert("Please enter the second applicant's email address to continue.")
           return false
       }

       if (p == "") {
           alert("Please enter the second applicant's date of birth to continue.")
           return false
       }
       if (q == "") {
           alert("Please enter the second applicant's nationality to continue.")
           return false
       }
       if (r == "") {
           alert("Please confirm that the second applicant has a work visa.")
           return false
       }
       if (s == "") {
           alert("Please enter the second applicant's issuing country for their passport to continue.")
           return false
       }

       if (t == "") {
           alert("Please indicate the second applicant's availability to continue.")
           return false
       }
       if (u == "") {
           alert("Please describe the second applicant's previous experience to continue.")
           return false
       }
       if (v == "") {
           alert("Please outline the second applicant's qualifications to continue.")
           return false
       }


       if (echeck(document.getElementById('ctl00_ContentPlaceHolder2_FirstCandEmail').value) == false) {
           return false
       }

       if (echeck(document.getElementById('ctl00_ContentPlaceHolder2_SecondCandEmail').value) == false) {
           return false
       }

       return true;
   }
//######################################################################
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 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					
	}
//#################################################################################
