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

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

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

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

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

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

function validate_recruiter ( )
{
    var errors=0;

    if ( document.recruiterregistration.fldRecruiterName.value == "" )
    {
        alert ( "Please specify your name." );
        errors ++;
    }
	
    if ( document.recruiterregistration.fldRecruiterContactName.value == "" )
    {
        alert ( "Please specify your contact name." );
        errors ++;
    } 

	 if ( document.recruiterregistration.fldRecruiterAddr1.value == "" )
    {
        alert ( "Please specify your address." );
       errors ++;
    }
	 if ( document.recruiterregistration.fldRecruiterAddr4.value == "" )
    {
        alert ( "Please specify your town." );
       errors ++;
    }
	 if ( document.recruiterregistration.fldRecruiterAddr5.value == "" )
    {
        alert ( "Please specify your county." );
       errors ++;
    }
	 if ( document.recruiterregistration.fldRecruiterCountry.value == "" )
    {
        alert ( "Please specify your country." );
       errors ++;
    }
	 if ( document.recruiterregistration.fldRecruiterTel1.value == "" )
    {
        alert ( "Please specify your Contact telephone number." );
       errors ++;
    }
	 if ( document.recruiterregistration.fldRecruiterAgencyType.value == "" )
    {
        alert ( "Please specify your Agency Type" );
       errors ++;
    }
 if ( document.recruiterregistration.fldRecruiterEmail.value != document.recruiterregistration.fldRecruiterEmail2.value)
    {
        alert ( "Your email address does not match" );
        valid = false;
    }
	
 if ( document.recruiterregistration.password.value == document.recruiterregistration.username.value )
    {
        alert ( "Password and username can not be the same." );
        errors ++;
    } 
 if ( document.recruiterregistration.username.value == "" )
    {
        alert ( "Please specify your username." );
        errors ++;
    }
 if ( document.recruiterregistration.password.value.length < 9 )
    {
        alert ( "Password must be at least 8 digits." );
        errors ++;
    } 
 if ( document.recruiterregistration.password.value != document.recruiterregistration.password2.value)
    {
        alert ( "Your passwords do not match" );
        valid = false;
    }
 if ( !document.recruiterregistration.tandc.checked )
    {
        alert ( "Please confirm your acceptance of the terms and conditions." );
        errors ++;
    }
 if ( !document.recruiterregistration.atandc.checked )
    {
        alert ( "Please confirm your acceptance of the advertisers terms and conditions." );
        errors ++;
    }
 if ( document.recruiterregistration.referraltype.value=="" )
    {
        alert ( "Please state how you found us." );
        errors ++;
    }
 if (document.recruiterregistration.referraltype.value=="Magazine or Paper - specify" || document.recruiterregistration.referraltype.value=="On-line - specify" ||  document.recruiterregistration.referraltype.value=="Other")
    {
        if(document.recruiterregistration.referral.value=='')
         {
        alert ( "Please note specifically how you found us." );
        errors ++;
    	}	
    }
var emailID=document.recruiterregistration.fldRecruiterEmail
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		valid = false;
	}
	

     if(!errors)
   {
   document.recruiterregistration.action='recruiter-registration2.php';
   document.recruiterregistration.submit();
  
   }
}
  
function change_settings(select)
  {
   switch(select.options[select.selectedIndex].value)
   {
    case "Magazine or Paper - specify" :
	case "On-line - specify" :
	case "Other" :

    document.recruiterregistration.referral.disabled=false;
     break;
 
   }
   switch(select.options[select.selectedIndex].value)
   {
    case "Google" :
	case "Yahoo" :
	case "Other Search Engine" : 
	case "We contacted you":
	case "Referral":

    document.recruiterregistration.referral.disabled=true;
     break;
 
   }


  } 


