function ValidateForm(form)
{
   if(IsEmpty(form.firstName)) 
   { 
      alert('First Name is a required field.') 
      form.firstName.focus(); 
      return false; 
   } 
 
   if(IsEmpty(form.lastName)) 
   { 
      alert('Last Name is a required field.') 
      form.lastName.focus(); 
      return false; 
   } 
   
   if(IsEmpty(form.birthYear)) 
   { 
      alert('Birth Year is a required field.') 
      form.birthYear.focus(); 
      return false; 
   } 
   
   if (!IsNumeric(form.birthYear.value) || form.birthYear.value<1900 || form.birthYear.value>2007) 
   { 
      alert('Birth Year is not valid. Please correct the entry and try again.') 
      form.birthYear.focus(); 
      return false; 
      } 
      
   if(IsEmpty(form.birthCity)) 
   { 
      alert('Birth City is a required field.') 
      form.birthCity.focus(); 
      return false; 
   } 
   
   if(IsEmpty(form.birthCountry)) 
   { 
      alert('Birth Country is a required field. Please select your birth country from the drop down list. If you cannot find it, plese send an email to support@myusgreencard.com.') 
      form.birthCountry.focus(); 
      return false; 
   } 
   
   if(IsEmpty(form.address)) 
   { 
      alert('Street Address is a required field.') 
      form.address.focus(); 
      return false; 
   } 
   
   if(IsEmpty(form.addressCity)) 
   { 
      alert('City / Town Address is a required field.') 
      form.addressCity.focus(); 
      return false; 
   } 
   
   if(IsEmpty(form.firstName)) 
   { 
      alert('First Name is a required field.') 
      form.firstName.focus(); 
      return false; 
   } 
   
   if(IsEmpty(form.firstName)) 
   { 
      alert('First Name is a required field.') 
      form.firstName.focus(); 
      return false; 
   } 
   
   if(IsEmpty(form.firstName)) 
   { 
      alert('First Name is a required field.') 
      form.firstName.focus(); 
      return false; 
   } 
 
return true;
 
} 


function IsEmpty(aTextField) {
   if ((aTextField.value.length==0) ||
   (aTextField.value==null)) {
      return true;
   }
   else { return false; }
} 

function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }


function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 
}



