/// Validate page input
/// Check each input on page one by one, if validation fails on one input, popup a message box 
/// with detailed error message and then highlight the input control
function ValidatorOnSubmit()
{


 

  // -------------------- 
  // Clinic Chairperson:
  // -------------------- 
  if (isEmpty("txt_first_name"))
  {
    alert("Please enter the first name.");
    document.getElementById("txt_first_name").focus();
    return false;
  }
    if (isEmpty("txt_last_name"))
  {
    alert("Please enter the last name.");
    document.getElementById("txt_last_name").focus();
    return false;
  }
  // Chairperson's name should be alpha only - not required -By James
 // var txt_Chairperson = document.getElementById("txt_Chairperson");
 // if (!isAlpha(txt_Chairperson.value))
 // {
 //   alert("Chair person's name should be alphabet only.");
  //  txt_Chairperson.focus();
  //  return false;
 // }
  
  // -----------------------------
  // Chairperson Telephone number
  // -----------------------------
  // Area code is required and should be at least 3 digits
  var phoneArea = document.getElementById("txtphone1area_phone_office");
  if (isEmpty("txtphone1area_phone_office"))
  {
    alert("Please provide area code of the phone number.");
    phoneArea.focus();
    return false; 
  }
  if (phoneArea.value.length < 3)
  {
    alert("Area code of the phone number should have at least 3 digits.");
    phoneArea.focus();
    return false; 
  }
  
  // Phone number part 1 is required and should have 3 digits
  var phonePart1 = document.getElementById("txtphone1part1_phone_office");
  if (isEmpty("txtphone1part1_phone_office"))
  {
    alert("Please provide part 1 of the phone number.");
    phonePart1.focus();
    return false; 
  }
  if (phonePart1.value.length < 3)
  {
    alert("Part 1 of the phone number should have 3 digits.");
    phonePart1.focus();
    return false; 
  }
  
  // Phone number part 2 is required and should have at least 3 digits
  var phonePart2 = document.getElementById("txtphone1part2_phone_office");
  if (isEmpty("txtphone1part2_phone_office"))
  {
    alert("Please provide part 2 of the phone number.");
    phonePart2.focus();
    return false; 
  }
  if (phonePart2.value.length < 3)
  {
    alert("Part 2 of the phone number should have at least 3 digits.");
    phonePart2.focus();
    return false; 
  }
    
 
  // -------------------- 
  // Street No.
  // -------------------- 
  if (isEmpty("txt_StreetNo"))
  {
    alert("Please specify a street number.");
    document.getElementById("txt_StreetNo").focus();
    return false;
  }

  
  // -------------------- 
  // Street address
  // -------------------- 
  if (isEmpty("txt_Street"))
  {
    alert("Please specify detailed street address.");
    document.getElementById("txt_Street").focus();
    return false;
  }
  // Street address should be alpha only //not require -- James
  //var txt_Street = document.getElementById("txt_Street");
 // if (!isAlpha(txt_Street.value))
//  {
  //  alert("Street address should be alphabet only.");
   // txt_Street.focus();
  //  return false;
 // }  
  
  // -------------------- 
  // City
  // -------------------- 
  if (isEmpty("txt_City"))
  {
    alert("Please specify the city of the address.");
    document.getElementById("txt_City").focus();
    return false;
  }    
  // City should be alpha only //not require -- James
 // var txt_City = document.getElementById("txt_City");
 // if (!isAlpha(txt_City.value))
 // {
 //   alert("City name should be alphabet only.");
//    txt_City.focus();
//    return false;
//  } 
  
    
  // -------------------- 
  // Postal Code
  // -------------------- 
  if (isEmpty("txt_Zip"))


  {
    alert("Please specify the postal code of the address.");
    document.getElementById("txt_Zip").focus();
    return false;
  }    
  // Is a valid postal code
  var txt_Zip = document.getElementById("txt_Zip");
  if (!isValidZipCode(txt_Zip.value) && !isValidPostalCode(txt_Zip.value))
  {
    alert("Postal code is not valid.");
    txt_Zip.focus();
    return false;
  }   
  
  
  // -------------------- 
  // Email
  // -------------------- 
  if (isEmpty("txt_Email"))
  {
    alert("Please provide an Email address.");
    document.getElementById("txt_Email").focus();
    return false;
  }
  // Is a valid email address
  var txt_Email = document.getElementById("txt_Email");
  if (!isValidEmailAddress(txt_Email.value))
  {
    alert("Email address is not valid.");
    txt_Email.focus();
    return false;
  }  
  
  
  // --------------------
  // Host Association
  // --------------------  
  if (isEmpty("txt_club_name"))
  {
    alert("Please specify the local association.");
    document.getElementById("txt_club_name").focus();
    return false;
  }
  
   // Affiliate
  // -------------------- 
  var dp_prim_package = document.getElementById("dp_package");
  if (dp_prim_package.value == -1)
  {
    alert("Please select an package.");
    document.getElementById("dp_package").focus();
    return false;
  }  
  
 return true;
}


