// State Validation Script

 function validate_state(field) { 

var myform = document.test;

myform.vol_state.value = myform.vol_state.value.toUpperCase();

var temp = myform.vol_state.value;

 if ((temp == "AL") || (temp == "AK") || (temp == "AZ") || (temp == "AR") || (temp == "CA") || (temp == "CO") || (temp == "CT") || (temp == "DE") || (temp == "DC") || (temp == "FL") || (temp == "GA") || (temp == "HI") || (temp == "ID") || (temp == "IL") || (temp == "IN") || (temp == "IA") || (temp == "KS") || (temp == "KY") || (temp == "LA") || (temp == "ME") || (temp == "MD") || (temp == "MA") || (temp == "MI") || (temp == "MS") || (temp == "MN") || (temp == "MO") || (temp == "MT") || (temp == "NE") || (temp == "NM") || (temp == "NV") || (temp == "NH") || (temp == "NJ") || (temp == "NM") || (temp == "NY") || (temp == "NC") || (temp == "ND") || (temp == "OH") || (temp == "OK") || (temp == "OR") || (temp == "PA") || (temp == "RI") || (temp == "SC") || (temp == "SD") || (temp == "TN") || (temp == "TX") || (temp == "UT") || (temp == "VT") || (temp == "VA") || (temp == "WA") || (temp == "WV") || (temp == "WI") || (temp == "WY")) {}

 else{

   alert("Invalid State");
 
}

}

// Phone Number Validation Script

 function validate_phone(field) { 
 var valid = "1234567890-" 
 var ok = "yes"; 
 var temp; 
 for (var i=0; i<field.value.length; i++) { 
   temp = "" + field.value.substring(i, i+1); 
   if (valid.indexOf(temp) == "-1") ok = "no"; 
 } 
 if (ok == "no") { 
   alert("Invalid entry!  Only Numbers 1,2,3,4,5,6,7,8,9,0 and dashes are allowed."); 
   field.focus(); 
   field.select(); 
 } 

 } 


// Number Validation Script

 function validate_number(field) { 
 var valid = "1234567890" 
 var ok = "yes"; 
 var temp; 
 for (var i=0; i<field.value.length; i++) { 
   temp = "" + field.value.substring(i, i+1); 
   if (valid.indexOf(temp) == "-1") ok = "no"; 
 } 
 if (ok == "no") { 
   alert("Invalid entry!  Only Numbers 1,2,3,4,5,6,7,8,9,0 are allowed."); 
   field.focus(); 
   field.select(); 
 } 

 } 


// Email Validation Script

	function eMail(field) {
	var newString = field.value.match(/^[A-Za-z0-9-_\.]+@[A-Za-z0-9-_\.]+\.\w+/gi);
	var string1 = field.value

	if (string1 == "") {}

	else{
		
		if (!newString) {
		alert("The e-mail address you entered is not valid.  Please verify the information is correct and re enter it in the following format, XXXXXXX@XXXXXX.XXX");
		field.focus(); 
		field.select(); }
		else { }	
	}

}


// Social Security Number Validation Script

	function ssN(field) {
	var newString = field.value.match(/^\d{3}-\d{2}-\d{4}$/gi);
	var string1 = field.value

	if (string1 == "") {}

	else{
	  
		if (!newString) {
		alert("The social security number you entered is not valid.  Please verify the information is correct and re enter it in the following format, XXX-XX-XXXX");
	    	field.focus(); 
		field.select(); }
		else { }
	}

}


// Date Validation Script

	function dAtE(field) {
	var newString = field.value.match(/^(0[1-9]|1[012])\/(3[01]|0[1-9]|[12]\d)\/\d{4}/gi);
	var string1 = field.value

	if (string1 == "") {}

	else{

		if (!newString) {
		alert("The date you entered is not valid.  Please verify the information is correct and re enter it in the following format, MM/DD/YYYY");
	    	field.focus(); 
		field.select(); }
		else { }
	}

}

// MM/YYY Date Validation Script

	function dATE(field) {
	var newString = field.value.match(/^(0[1-9]|1[012])\/\d{4}/gi);
	var string1 = field.value

	if (string1 == "") {}

	else{

		if (!newString) {
		alert("The date you entered is not valid.  Please verify the information is correct and re enter it in the following format, MM/YYYY");
	    	field.focus(); 
		field.select(); }
		else { }
	}

}




// Month Validation Script

	function mOnth(field) {
	var newString = field.value.match(/^(0[1-9]|1[012])/gi);
	var string1 = field.value

	if (string1 == "") {}

	else{

		if (!newString) {
		alert("The month you entered is not valid.  Please verify the information is correct and re enter it in the following format, MM");
	    	field.focus(); 
		field.select(); }
		else { }
	}

}

// 2 Digit Year Validation Script

	function yEAR(field) {
	var newString = field.value.match(/\b[0]\d{1}$/gi);
	var string1 = field.value

	if (string1 == "") {}

	else{
	  
		if (!newString) {
		alert("The year you entered is not valid.  Please verify the information is correct and re enter it in the following format, YY");
	    	field.focus(); 
		field.select(); }
		else { }
	}

}

// Year Validation Script

	function yEAr(field) {
	var newString = field.value.match(/\b[12]\d{3}$/gi);
	var string1 = field.value

	if (string1 == "") {}

	else{
	  
		if (!newString) {
		alert("The year you entered is not valid.  Please verify the information is correct and re enter it in the following format, YYYY");
	    	field.focus(); 
		field.select(); }
		else { }
	}

}

// Currency Validation Script

	function cUrrency(field) {
	var newString = field.value.match(/^\d+(.\d{2})?$/gi);
	var string1 = field.value

	if (string1 == "") {}

	else{

		if (!newString) {
		alert("Please enter a valid US currency format. 999999.99");
	    	field.focus(); 
		field.select(); }
		else { }
	}

}


// Credit Card Validation Script

function checkCC(s) {

  var i, n, c, r, t;

  // First, reverse the string and remove any non-numeric characters.

  r = "";
  for (i = 0; i < s.length; i++) {
    c = parseInt(s.charAt(i), 10);
    if (c >= 0 && c <= 9)
      r = c + r;
  }

  // Check for a bad string.

  if (r.length <= 1)
    return false;

  // Now run through each single digit to create a new string. Even digits
  // are multiplied by two, odd digits are left alone.

  t = "";
  for (i = 0; i < r.length; i++) {
    c = parseInt(r.charAt(i), 10);
    if (i % 2 != 0)
      c *= 2;
    t = t + c;
  }

  // Finally, add up all the single digits in this string.

  n = 0;
  for (i = 0; i < t.length; i++) {
    c = parseInt(t.charAt(i), 10);
    n = n + c;
  }

  // If the resulting sum is an even multiple of ten (but not zero), the
  // card number is good.

  if (n != 0 && n % 10 == 0)
    return true;
  else
    return false;
}

function validateForm(field) {

  var s = field.value;

  if (checkCC(s))
    ;
  else
    alert("Please enter a valid credit card number.");
  return false;
}

// Client ID Validation Script

	function validate_cLientID(field) {
	var newString = field.value.match(/^\w{7}$/gi);
	var string1 = field.value

	if (string1 == "") {}

	else{
	  
		if (!newString) {
		alert("The format of the Client ID you entered is invalid. Your Client ID should be a combination of your last name and first name and 7 digits long. (Example: SMITHJO) If you don't have your Client ID please call 1-800-872-0067 or 202-872-0060 to obtain your Client ID from a representative at Clements.");
	    	field.focus(); 
		field.select(); }
		else { }
	}

}

// Commercial Client ID Validation Script

	function validate_cLientIDC(field) {
	var newString = field.value.match(/^[A-Z0-9-]{7}$/gi);
	var string1 = field.value

	if (string1 == "") {}

	else{
	  
		if (!newString) {
		alert("The format of the Client ID you entered is invalid. Your Client ID should be a combination of your last name and first name and 7 digits long. (Example: SMITHJO) If you don't have your Client ID please call 1-800-872-0067 or 202-872-0060 to obtain your Client ID from a representative at Clements.");
	    	field.focus(); 
		field.select(); }
		else { }
	}

}



// Name Validation Script

 function validate_naMe(field) { 
 var valid = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ " 
 var ok = "yes"; 
 var temp; 
 for (var i=0; i<field.value.length; i++) { 
   temp = "" + field.value.substring(i, i+1); 
   if (valid.indexOf(temp) == "-1") ok = "no"; 
 } 
 if (ok == "no") { 
   alert("Invalid entry!  Only letters A - Z are allowed. Please leave out any punctuation marks or numbers."); 
   field.focus(); 
   field.select(); 
 } 

 } 

// Locked Field Script

 function validate_locked_field(field) { 
 
   alert("You are trying to alter information in a locked field.  Should you require changes to your original quote, please return to the auto rater portion of our website and open a new quote.  If you have any questions, please contact us at 202-872-0060, or by email to service@clements.com.  Thank you."); 
 
 } 


// MA Auto Rater display message for Italy clients

 function validate_country(field) { 

var myform = document.test;
var temp = myform.post_country.value;
var temp1 = myform.client_occupation.value;

 if ((temp == "ITALY") && (temp1 == "ARMY")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 
 
} else if ((temp == "ITALY") && (temp1 == "CIVIL SERVANT")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "GOV EMPLOYEE")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "GOVT EMPLYEE")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "MIL DEPT OF DEF")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "MILITARY")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "MILITARY E1-6")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "MILITARY POLICE")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "NAVAL OFFICER")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "N/A")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "NOT LISTED")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "OFFICER")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "SENIOR OFFICER")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "US AIR FORCE")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "USAF")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "USMC")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "USGOV")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "USG")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "USG")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "US GOV EMMP")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "US GOVERMENTUS GOVERNEMENT")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "US GOVERNMENT")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "US GOVT EMPEE")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "US GOVT EMPLEE")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "US GOVT EMPLYEE")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "DOD")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} else if ((temp == "ITALY") && (temp1 == "DOD")) { 
   alert("Missions Abroad provides international automobile insurance for U.S. and Canadian government professionals abroad, and to U.S. military personnel working at embassies or consulates. All other U.S. military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

}  

 } 

// PA Auto Rater display message for Italy clients 

 function validate_country1(field) { 

var myform = document.test;
var temp = myform.post_country.value;
var temp1 = myform.client_employer.value;

 if ((temp == "ITALY") && (temp1 == "Military")) { 
   alert("Professionals Abroad provides international automobile insurance for professionals living outside their home country. All military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 
 
} else if ((temp == "ITALY") && (temp1 == "Other")) { 
   alert("Professionals Abroad provides international automobile insurance for professionals living outside their home country. All military personnel working at a government post or military base must contact Clements International to determine eligibility and obtain a rate quote.  Thank you."); 

} 

 } 

// Wheels Auto Rater questions validation

 function validate_country2(field) { 

var myform = document.test;
var temp = myform.post_country.value;

 if ((temp == "CHILE")) { 
   alert("Obligatory Mandatory Insurance is not provided by our policy.   This coverage must be purchased in Chile through a local agent.  Please contact us if you have any questions."); 
 
} 

 if ((temp == "IRELAND")) { 
   alert("Thank you for your interest in Clements International. Due to increased underwriting guidelines in Ireland, your ProfessionalsAbroad application cannot be processed online.  To continue the application process and obtain coverage, please contact our office directly at 1.202.872.0060. Clements International looks forward to meeting all of your global insurance needs."); 
 

 } 

}

 function validate_country_UK(field) { 

var myform = document.test;
var temp = myform.country.value;

 if ((temp == "UNITED KINGDOM")) { 
   alert("The effective date cannot be more than 10 days prior to today's date or more than 30 days after today's date."); 
 
} 


}


// MA Auto application country validation

 function validate_country3(field) { 

var myform = document.test;
var temp = myform.post_country.value;



 } 

// MA & PA HouseHold Umbrella Coverage Check

 function Umbrella(field) { 

var myform = document.form;
var temp_pre = myform.personliab.value;
var temp_ques = myform.pcel.value;

 if (((temp_pre == "500000") && (temp_ques == "Yes")) || ((temp_pre == "500000") && (temp_ques == "No")) || ((temp_pre == "300000") && (temp_ques == "No")) || ((temp_pre == "100000") && (temp_ques == "No")) || ((temp_pre == "25000") && (temp_ques == "No"))) {} 
 
else {

   alert("In order to purchase umbrella coverage, you must maintain Comprehensive Personal Liability Insurance at $500,000 and Automobile Liability coverage."); 
 
} 
  
}

// Household Effects credit card charge cant be less then 40% of premium

	function validate_amount(field) {
	var myform = document.form;
	var check_card_amount = field.value;
	var total_premium = myform.total_prem.value;

	if (total_premium == "") {

		physical_damage_premium = 0;

	}

	total_premium = (total_premium * 1);

	var forty_precent_of_total_premium =  Math.round (total_premium * .40) ;

	if (check_card_amount < forty_precent_of_total_premium) {

alert("We have encountered a problem while processing your payment.  You are applying for an insurance policy which requires a minimum deposit premium of 40% of the total premium.  Please revise your payment amount and resubmit your application");

		field.value = forty_precent_of_total_premium;
	   	field.focus(); 
		field.select();
	}


}

// MA Auto application country validation

 function validate_pa_ireland_country(field) { 

var myform = document.test;
var temp = myform.post_country.value;

 if ((temp == "4IRE")) { 
   alert("Thank you for your interest in Clements International. Due to increased underwriting guidelines in Ireland, your ProfessionalsAbroad application cannot be processed online.  To continue the application process and obtain coverage, please contact our office directly at 1.202.872.0060. Clements International looks forward to meeting all of your global insurance needs."); 
 
} 


 } 

