 function echeck(str) {
	    var error = "";
  var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   error = "Invalid E-mail\n";
		   return error;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   error = "Invalid E-mail\n";
		   return error;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		       error = "Invalid E-mail\n";
		   return error;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		     error = "Invalid E-mail\n";
		   return error;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		      error = "Invalid E-mail\n";
		   return error;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   error = "Invalid E-mail\n";
		   return error;
		 }
		
		 if (str.indexOf(" ")!=-1){
		     error = "Invalid E-mail\n";
		   return error;
		 }
		
		   return error; 
}	
function validate_bank() {
var reason = "";

  reason += echeck(document.TORG_Application.personalemail.value);
  reason += validatename();
  reason += validatephonenumber();
  reason += validatebankingexperience();
  reason += validatebank_worked();
  reason += validatebank_division();
  reason += validatecurrent_level();
  reason += validatework_frequency();
  reason += validateoibservice();
  reason += validateheard_about();
  
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }
else
{
   document.TORG_Application.submit();
   document.TORG_Application.action='apply2.php';
   }
}
function validatename() {
    var error = "";
 
    if (document.TORG_Application.name.value == "") 
	{
       
        error = "Please specify your name.\n"
    } 
    return error;  
}	
function validatephonenumber() {
    var error = "";
 
  if ( document.TORG_Application.phonenumber.value == "" )
    {
        error="Please specify your phone number.\n"
    } 
    return error;  
}	
function validatebankingexperience() {
    var error = "";
 
		 if ( document.TORG_Application.bankingexperience.value == "" )
    {
        error="Please specify your banking experience.\n"
    } 
    return error;  
}	 
function validatebank_worked() {
    var error = "";
 
		 if ( document.TORG_Application.bank_worked.value == "" )
    {
         error="Please specify which bank you worked at\n"
    } 
    return error;  
}	
function validatebank_division() {
    var error = "";
 
		 if ( document.TORG_Application.bank_division.value == "" )
    {
      error="Please specify the banking division you worked in.\n"
    } 
    return error;  
}	
function validatecurrent_level() {
    var error = "";
 
		 if ( document.TORG_Application.current_level.value == "" )
    {
         error="Please specify your current level within the bank.\n"
    } 
    return error;  
}	
function validatework_frequency() {
    var error = "";
 
		if ( document.TORG_Application.work_frequency.value == "" )
    {
         error="Please specify how often you wish to work.\n"
    } 
    return error;  
}	 	
function validateoibservice() {
    var error = "";
 
		 if (!document.TORG_Application.application_essays_edit.checked && !document.TORG_Application.interviewprep.checked && !document.TORG_Application.consultations.checked && !document.TORG_Application.cvs.checked  && !document.TORG_Application.coverletters.checked  && !document.TORG_Application.suitability_reports.checked   && !document.TORG_Application.numeracy_tutoring.checked && !document.TORG_Application.model_interview_ans.checked )
    {
         error="Please specify at least 1 OIB service.\n"
    } 
    return error;  
}	 
function validateheard_about() {
    var error = "";
 
	 if ( document.TORG_Application.heard_about.value == "" )
    {
        error="Please specify how you heard about us.\n"
    } 
    return error;  
}	

