
function validateForm() 
{
 var okSoFar=true
 
 with (document.phpformmailer)
 
 {
  var foundAt = email.value.indexOf("@",0)
  if (foundAt < 1 && okSoFar)
  {
    okSoFar = false
    alert ("Please enter a valid email address.")
    email.focus()
  }
  var e1 = email.value
  var e2 = email2.value
  if (!(e1==e2) && okSoFar)
  {
    okSoFar = false
    alert ("Email addresses you entered do not match.  Please re-enter.")
    email.focus()
  }
  if (thesubject.value=="" && okSoFar)
  {
    okSoFar=false
    alert("Please enter the subject.")
    thesubject.focus()
  }
  if (themessage.value=="" && okSoFar)
  {
    okSoFar=false
    alert("Please enter the details for your enquiry.")
    themessage.focus()
  }
  
  if (okSoFar==true)  submit();
 }
}


function my_validate_form()
{
	
	submit_is_a_go=false;
	form_points=0;
	error_array=new Array();
	final_error_string="";
	i=0;
	


	
	//let's go!

	if (!(document.getElementById("my_form").f_name.value!="")){
		error_array[i]="First Name";
		i++;	
	}//---------------------------------------------------First name
	
	if (!(document.getElementById("my_form").l_name.value!="")){
		error_array[i]="Last Name";
		i++;	
	}//---------------------------------------------------Last Name
	
	if (document.getElementById("my_form").country.value==document.getElementById("my_form").country[0].value){
	
	error_array[i]="Country";
	i++;	
	
	}
	
	if (document.getElementById("my_form").country.value==document.getElementById("my_form").country[1].value){
		
		if (document.getElementById("my_form").applicant_type.value=="Domestic"){
		if (!(document.getElementById("my_form").citizen[0].checked==true || document.getElementById("my_form").citizen[1].checked==true)){
		error_array[i]="Citizenship";
		i++;
		}
		}
		
		telephone_string=document.getElementById("my_form").Phone_2.value + document.getElementById("my_form").Phone_3.value;
		
		
		if (telephone_string.match(/^\d{10}$/)==null)
		{
		error_array[i]="Primary Phone number";
		i++;
		}

	}
	else if (document.getElementById("my_form").country.value!=document.getElementById("my_form").country[1].value)
	{
		
		telephone_string=document.getElementById("my_form").Phone_1.value + document.getElementById("my_form").Phone_2.value + document.getElementById("my_form").Phone_3.value;
		
		
		if (telephone_string.match(/^\d{13}$/)==null)
		{
		error_array[i]="Primary Phone number";
		i++;
		}		
	}//---------------------------------------------------Country, phone, citizen
		
	if (!(document.getElementById("my_form").email.value!="" && document.getElementById("my_form").email.value.indexOf("@", 0)>1 && document.getElementById("my_form").email.value.indexOf(".", 0)>1))
	{
		error_array[i]="Email";
		i++;	
	}//---------------------------------------------------Email
	
	position_is_checked=false;

	for (i1=0; i1<18; i1++)
	{
	if (document.getElementById("my_form").position_id[i1].checked==true){position_is_checked=true; break;}
	}
	
	if (position_is_checked==false)
	{
		error_array[i]="Position";
		i++;	
	}//---------------------------------------------------Position
	
	if (isBlank(document.getElementById("my_form").city.value))
	{
		error_array[i]="City";
		i++;	
	}//---------------------------------------------------City
	
	
		if (document.getElementById("my_form").country.value==document.getElementById("my_form").country[1].value){

		if (isBlank(document.getElementById("my_form").state.value))
			{
			error_array[i]="State";
			i++;	
			}
		}
	
	//---------------------------------------------------State
	
	if (!(!isBlank(document.getElementById("my_form").zip.value)&&isInteger(document.getElementById("my_form").zip.value)))
	{
		error_array[i]="Zip Code";
		i++;	
	}//---------------------------------------------------Zip Code
	
	
	//done, let's display mesage or submit
	
	
	if (!isBlank(error_array[0])){
		
	i=0;
	
	for (i=0; i<error_array.length; i++)
	{
		final_error_string+=error_array[i] + "\n";
	}
	
	alert ("Please correct the following fields:\n" + final_error_string);
	
	}
	else 
	{
	
		document.getElementById("my_form").submit();
	
	}
	
}

