function showProduct(num){
	//alert(num);
		switch(num)
		{
		case "1":
		  document.getElementById('baseCov1').style.display='block';
		  document.getElementById('view1').style.display='none';
		  document.getElementById('hide1').style.display='block';
		  document.getElementById('topButton1').style.display='block';
		  break;   
		case "2":
		  document.getElementById('baseCov2').style.display='block';
		  document.getElementById('view2').style.display='none';
		  document.getElementById('hide2').style.display='block';
		  document.getElementById('topButton2').style.display='block';
		  break;
		case "3":
		  document.getElementById('baseCov3').style.display='block';
		  document.getElementById('view3').style.display='none';
		  document.getElementById('hide3').style.display='block';
		  document.getElementById('topButton3').style.display='block';
		  break;
		/*default:
		  alert('one');*/
		}
}

function hideProduct(num){
		switch(num)
		{
		case "1":
		  document.getElementById('baseCov1').style.display='none';
		  document.getElementById('view1').style.display='block';
		  document.getElementById('hide1').style.display='none';
		  document.getElementById('topButton1').style.display='none';
		  break;   
		case "2":
		  document.getElementById('baseCov2').style.display='none';
		  document.getElementById('view2').style.display='block';
		  document.getElementById('hide2').style.display='none';
		  document.getElementById('topButton2').style.display='none';
		  break;
		case "3":
		  document.getElementById('baseCov3').style.display='none';
		  document.getElementById('view3').style.display='block';
		  document.getElementById('hide3').style.display='none';
		  document.getElementById('topButton3').style.display='none';
		  break;
		/*default:
		  alert('one');*/
		}
}

function showOptions(num){
	//alert(num);
		switch(num)
		{
		case "1":
		  document.getElementById('viewOp1').style.display='none';
		  document.getElementById('hideOp1').style.display='block';
		  document.getElementById('options1').style.display='block';
		  break;   
		case "2":
		  document.getElementById('viewOp2').style.display='none';
		  document.getElementById('hideOp2').style.display='block';
		  document.getElementById('options2').style.display='block';
		  break;
		case "3":
		  document.getElementById('viewOp3').style.display='none';
		  document.getElementById('hideOp3').style.display='block';
		  document.getElementById('options3').style.display='block';
		  break;
		/*default:
		  alert('one');*/
		}
}

function hideOptions(num){
		switch(num)
		{
		case "1":
		  document.getElementById('viewOp1').style.display='block';
		  document.getElementById('hideOp1').style.display='none';
		  document.getElementById('options1').style.display='none';
		  break;   
		case "2":
		  document.getElementById('viewOp2').style.display='block';
		  document.getElementById('hideOp2').style.display='none';
		  document.getElementById('options2').style.display='none';
		  break;
		case "3":
		  document.getElementById('viewOp3').style.display='block';
		  document.getElementById('hideOp3').style.display='none';
		  document.getElementById('options3').style.display='none';
		  break;
		/*default:
		  alert('one');*/
		}
}

function showAdditionals(num){
	//alert(num);
		switch(num)
		{
		case "1":
		  document.getElementById('viewAdd1').style.display='none';
		  document.getElementById('hideAdd1').style.display='block';
		  document.getElementById('add1').style.display='block';
		  break;   
		case "2":
		  document.getElementById('viewAdd2').style.display='none';
		  document.getElementById('hideAdd2').style.display='block';
		  document.getElementById('add2').style.display='block';
		  break;
		case "3":
		  document.getElementById('viewAdd3').style.display='none';
		  document.getElementById('hideAdd3').style.display='block';
		  document.getElementById('add3').style.display='block';
		  break;
		/*default:
		  alert('one');*/
		}
}

function hideAdditionals(num){
		switch(num)
		{
		case "1":
		  document.getElementById('viewAdd1').style.display='block';
		  document.getElementById('hideAdd1').style.display='none';
		  document.getElementById('add1').style.display='none';
		  break;   
		case "2":
		  document.getElementById('viewAdd2').style.display='block';
		  document.getElementById('hideAdd2').style.display='none';
		  document.getElementById('add2').style.display='none';
		  break;
		case "3":
		  document.getElementById('viewAdd3').style.display='block';
		  document.getElementById('hideAdd3').style.display='none';
		  document.getElementById('add3').style.display='none';
		  break;
		/*default:
		  alert('one');*/
		}
}

function validateProperty(){
	var problem = "N";
	var detail = "";
	var zipcode = document.getElementById('zip').value;
	var zipNum = IsNumeric(zipcode);
	var partnerFile = $("#partnerCSSfile").val();
	if( partnerFile == 'partnerCountrywide.css'){
			// CORE METRICS
			var corePageID = $("#corePageID").val();
			var coreStepNum = $("#coreStepNum").val();
			var coreStepName = $("#coreStepName").val();
			var coreCatID = $("#coreCatID").val();
			var errorCode = '';
	}
	
	if(document.getElementById('address1').value == ""){
		problem = "Y";
		detail += "Please provide your address.\n";
		document.getElementById('address1').focus();
		if( partnerFile == 'partnerCountrywide.css'){
			cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '300Addres1', coreCatID, 'Missing Property Address');
		}
	}
	
	if(document.getElementById('city').value == ""){
		problem = "Y";
		detail += "Please provide your city.\n";
		document.getElementById('city').focus();
		if( partnerFile == 'partnerCountrywide.css'){
			cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '300City', coreCatID, 'Missing Property City');
		}
	}
	
	if(document.getElementById('state').value == "--"){
		problem = "Y";
		detail += "Please provide your state.\n";
		document.getElementById('state').focus();
		if( partnerFile == 'partnerCountrywide.css'){
			cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '300State', coreCatID, 'Missing Property State');
		}
	}
	
	if(zipcode == ""){
		problem = "Y";
		detail += "Please provide your zip.\n";
		document.getElementById('zip').focus();
		if( partnerFile == 'partnerCountrywide.css'){
			cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '300ZipCodeAbsent', coreCatID, 'Missing Property Zip');
		}
	}
	
	if(!zipNum){
		problem = "Y";
		detail += "Your zip code must be numeric.\n";
		document.getElementById('zip').focus();
		if( partnerFile == 'partnerCountrywide.css'){
			cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '300ZipCodeNoneNumeric', coreCatID, 'Invalid Property Zip');
		}
	}
	
	//if(document.getElementById('yearBuilt').value == ""){
		//problem = "Y";
		//detail += "Please provide the year the property was constructed.\n";
		//document.getElementById('yearBuilt').focus();
		//if( partnerFile == 'partnerCountrywide.css'){
			//cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '300YearBuilt', coreCatID, 'Missing Property Year of Build');
		//}
	//}
	/*
	if(document.getElementById('homeSize').value == ""){
		problem = "Y";
		detail += "Please provide the square footage of the property.\n";
		document.getElementById('homeSize').focus();
		if( partnerFile == 'partnerCountrywide.css'){
			cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '300SquareFeet', coreCatID, 'Missing Property Square Footage');
		}
	}
	
	if(document.getElementById('yearsOwned').value == ""){
		problem = "Y";
		detail += "Please provide the number of years you've owned the property.\n";
		document.getElementById('yearsOwned').focus();
		if( partnerFile == 'partnerCountrywide.css'){
			cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '300YearsOwned', coreCatID, 'Missing Property Years Owned');
		}
	}
	*/
	if(!document.getElementById('applianceConditions').checked){
		//var applianceConditions = $("#applianceConditions").val();
		//alert(applianceConditions);
		//if(applianceConditions != 'Y'){
		problem = "Y";
		detail += "Please attest that all of your systems and appliances are currently in good working order.\n";	

	}
	
	if(problem == "Y"){
		alert(detail);
		return false;
	} else {
		//alert("thanks");
		return true;
	}
}

function showAppliance(){
	$('#propertyFormHidden').show();
}

function hideAppliance(){
	$('#propertyFormHidden').hide();
}

function IsNumeric(strString){ // checks for numeric strings
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}


function validatePayment(checkCreditCardInfo){
	var problem = "N";
	var detail = "";
	//var test = document.getElementById('appliancesRadioNo');
	document.getElementById('submitButtonUU').style.display = "none";
	var partnerFile = $("#partnerCSSfile").val();
	if( partnerFile == 'partnerCountrywide.css'){
		// CORE METRICS
		var corePageID = $("#corePageID").val();
		var coreStepNum = $("#coreStepNum").val();
		var coreStepName = $("#coreStepName").val();
		var coreCatID = $("#coreCatID").val();
		var errorCode = '';
	}

	if(document.getElementById('firstName').value == ""){
		problem = "Y";
		detail += "Please provide your first name.\n";
		document.getElementById('firstName').focus();
		if( partnerFile == 'partnerCountrywide.css'){
			cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400firstName', coreCatID, 'Missing Billing First Name');
		}
	}
	
	if(document.getElementById('lastName').value == ""){
		problem = "Y";
		detail += "Please provide your last name.\n";
		document.getElementById('lastName').focus();
		if( partnerFile == 'partnerCountrywide.css'){
			cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400lastName', coreCatID, 'Missing Billing Last Name');
		}
	}
	
	if(document.getElementById('address1').value == ""){
		problem = "Y";
		detail += "Please provide your billing address.\n";
		document.getElementById('address1').focus();
		if( partnerFile == 'partnerCountrywide.css'){
			cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400address1', coreCatID, 'Missing Billing Address 1');
		}
	}
	
	if(document.getElementById('city').value == ""){
		problem = "Y";
		detail += "Please provide your billing city.\n";
		document.getElementById('city').focus();
		if( partnerFile == 'partnerCountrywide.css'){
			cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400city', coreCatID, 'Missing Billing City');
		}
	}
	
	if(document.getElementById('state').value == ""){
		problem = "Y";
		detail += "Please provide your billing state.\n";
		document.getElementById('state').focus();
		if( partnerFile == 'partnerCountrywide.css'){
			cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400state', coreCatID, 'Missing Billing State');
		}
	}
	
	if(document.getElementById('state').value == "--"){
		problem = "Y";
		detail += "Please provide your billing state.\n";
		document.getElementById('state').focus();
		if( partnerFile == 'partnerCountrywide.css'){
			cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400invalidState', coreCatID, 'Invalid State Selection');
		}
	}
	
	if(document.getElementById('zip').value == "" || document.getElementById('zip').value.length < 5){
		problem = "Y";
		detail += "Please provide your billing zip code.\n";
		document.getElementById('zip').focus();
		if( partnerFile == 'partnerCountrywide.css'){
			cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400zip', coreCatID, 'Missing Billing Zip Code');
		}
	}else if (!IsNumeric(document.getElementById('zip').value)){
		problem = "Y";
		detail += "Please provide your billing zip code.\n";
		document.getElementById('zip').focus();
		if( partnerFile == 'partnerCountrywide.css'){
			cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400zip', coreCatID, 'Missing Billing Zip Code');
		}
	}
	
	if(document.getElementById('primaryPhone1').value == ""){
		problem = "Y";
		detail += "Please provide your primary phone number.\n";
		document.getElementById('primaryPhone1').focus();
		if( partnerFile == 'partnerCountrywide.css'){
			cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400primaryAreaCode', coreCatID, 'Missing Billing Primary Area Code');
		}
	}
	
	if(problem != "Y"){
		var l = document.getElementById('primaryPhone1').value.length;
		if(l < 3){
			problem = "Y";
			detail += "Please provide your primary phone number.\n";
			document.getElementById('primaryPhone3').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400invalidAreaCode', coreCatID, 'Invalid Billing Area Code');
			}
			
		}else if(document.getElementById('primaryPhone2').value == ""){
			problem = "Y";
			detail += "Please provide your primary phone number.\n";
			document.getElementById('primaryPhone2').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400Phone2', coreCatID, 'Missing Billing Phone 2 Field');
			}
		}
		
		if(problem != "Y"){
			var l = document.getElementById('primaryPhone2').value.length;
			if(l < 3){
				problem = "Y";
				detail += "Please provide your primary phone number.\n";
				document.getElementById('primaryPhone2').focus();
				if( partnerFile == 'partnerCountrywide.css'){
					cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400invalidPhone2', coreCatID, 'Invalid Billing Phone 2 Field');
				}
			}
		}
	}
	
	if(problem != "Y"){
		if(document.getElementById('primaryPhone3').value == ""){
			problem = "Y";
			detail += "Please provide your primary phone number.\n";
			document.getElementById('primaryPhone3').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400phone3', coreCatID, 'Missing Billing Phone 3');
			}
		}
		
		if(problem != "Y"){
			var l = document.getElementById('primaryPhone3').value.length;
			if(l < 4){
				problem = "Y";
				detail += "Please provide your primary phone number.\n";
				document.getElementById('primaryPhone3').focus();
				if( partnerFile == 'partnerCountrywide.css'){
					cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400invalidPhone3', coreCatID, 'Invalid Billing Phone 3');
				}
			}
		}
	}
	
	var e = document.getElementById('email').value;
	
	if(!checkemail(e)){
		problem = "Y";
		detail += "Please provide your email address.\n";
		document.getElementById('email').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400email', coreCatID, 'Invalid Billing Email Address');
			}
	}
	
	if (checkCreditCardInfo == 'Y'){
	
		if(document.getElementById('cardName').value == "" || document.getElementById('cardName').value == "First Name"){
			problem = "Y";
			detail += "Please provide the name on your credit card.\n";
			document.getElementById('cardName').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400cardFirstName', coreCatID, 'Missing Billing First Name on Card');
			}
		}
		
		if(problem != "Y"){
			if(document.getElementById('cardName2').value == "" || document.getElementById('cardName2').value == "Last Name"){
				problem = "Y";
				detail += "Please provide the name on your credit card.\n";
				document.getElementById('primaryPhone3').focus();
				if( partnerFile == 'partnerCountrywide.css'){
					cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400cardLastName', coreCatID, 'Missing Billing Last Name on Card');
				}
			}
		}
		
		if(document.getElementById('cardNumber').value == ""){
			problem = "Y";
			detail += "Please provide your credit card's number.\n";
			document.getElementById('cardNumber').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400cardNumber', coreCatID, 'Missing Billing Credit Card Number');
			}
		}
		
		if(document.getElementById('cardType').value == "--"){
			problem = "Y";
			detail += "Please select your type of credit card.\n";
			document.getElementById('cardType').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400cardType', coreCatID, 'Missing Billing Credit Card Type');
			}
		}

		if(document.getElementById('securityNum').value == ""){
			problem = "Y";
			detail += "Please provide the security code of your credit card.\n";
			document.getElementById('securityNum').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400cardSecurity', coreCatID, 'Missing Billing Card Security Number');
			}
		}
				
	}else{

		if(document.getElementById('loanNo').value == ""){
			problem = "Y";
			detail += "Please provide us with your loan number.\n";
			document.getElementById('loanNo').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400loanNumber', coreCatID, 'Missing Billing Loan Number');
			}
		}
		
		if(!document.getElementById('KUloanAuthorize').checked){
			problem = "Y";
			detail += "Please agree to let TotalProtect validate your loan number.\n";
			document.getElementById('KUloanAuthorize').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400loanAgreement', coreCatID, 'Missing Billing Agree to Terms');
			}
		}
		
		if(document.getElementById('fullName').value == ""){
			problem = "Y";
			detail += "Please provide us with your full name as a digital signature.\n";
			document.getElementById('fullName').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400digitalSignature', coreCatID, 'Missing Billing Digital Signature');
			}
		}
	}
		
	if(problem == "Y"){
		document.getElementById('submitButtonUU').style.display = "block";
		alert(detail);
		return false;
	} else {
		//alert("thanks");
		return true;
	}
}

function validatePaymentKU(checkCreditCardInfo){
	var problem = "N";
	var detail = "";
	//var test = document.getElementById('appliancesRadioNo');
	document.getElementById('submitButtonKU').style.display = "none";

	if(document.getElementById('KUfirstName').value == ""){
		problem = "Y";
		detail += "Please provide your first name.\n";
		document.getElementById('KUfirstName').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUfirstName', coreCatID, 'KU Missing Billing First Name');
			}
	}
	
	if(document.getElementById('KUlastName').value == ""){
		problem = "Y";
		detail += "Please provide your last name.\n";
		document.getElementById('KUlastName').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUlastName', coreCatID, 'KU Missing Billing Last Name');
			}
	}
	
	if(document.getElementById('KUaddress1').value == ""){
		problem = "Y";
		detail += "Please provide your billing address.\n";
		document.getElementById('KUaddress1').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUaddress', coreCatID, 'KU Missing Billing Address 1');
			}
	}
	
	if(document.getElementById('KUcity').value == ""){
		problem = "Y";
		detail += "Please provide your billing city.\n";
		document.getElementById('KUcity').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUcity', coreCatID, 'KU Missing Billing City');
			}
	}
	
	if(document.getElementById('KUstate').value == ""){
		problem = "Y";
		detail += "Please provide your billing state.\n";
		document.getElementById('KUstate').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUstate', coreCatID, 'KU Missing Billing State');
			}
	}
	
	if(document.getElementById('KUstate').value == "--"){
		problem = "Y";
		detail += "Please provide your billing state.\n";
		document.getElementById('KUstate').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUinvalidState', coreCatID, 'KU Invalid Billing State Selection');
			}
	}
	
	if(document.getElementById('KUzip').value == ""){
		problem = "Y";
		detail += "Please provide your billing zip code.\n";
		document.getElementById('KUzip').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUzip', coreCatID, 'KU Missing Billing Zip Code');
			}
	}
	
	if(document.getElementById('KUprimaryPhone1').value == ""){
		problem = "Y";
		detail += "Please provide your primary phone number.\n";
		document.getElementById('KUprimaryPhone1').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUareaCode', coreCatID, 'KU Missing Billing Area Code');
			}
	}
	
	if(problem != "Y"){
		var l = document.getElementById('KUprimaryPhone1').value.length;
		if(l < 3){
			problem = "Y";
			detail += "Please provide your primary phone number.\n";
			document.getElementById('KUprimaryPhone3').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUareaCodeInvalid', coreCatID, 'KU Invalid Billing Area Code');
			}
		}else if(document.getElementById('KUprimaryPhone2').value == ""){
			problem = "Y";
			detail += "Please provide your primary phone number.\n";
			document.getElementById('KUprimaryPhone2').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUphone2', coreCatID, 'KU Missing Billing Phone 2');
			}
		}
		
		if(problem != "Y"){
			var l = document.getElementById('KUprimaryPhone2').value.length;
			if(l < 3){
				problem = "Y";
				detail += "Please provide your primary phone number.\n";
				document.getElementById('KUprimaryPhone2').focus();
				if( partnerFile == 'partnerCountrywide.css'){
					cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUphone2Invalid', coreCatID, 'KU Invalid Billing Phone 2');
				}
			}
		}
	}
	
	if(problem != "Y"){
		if(document.getElementById('KUprimaryPhone3').value == ""){
			problem = "Y";
			detail += "Please provide your primary phone number.\n";
			document.getElementById('KUprimaryPhone3').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUphone3', coreCatID, 'KU Missing Billing Phone 3');
			}
		}
		
		if(problem != "Y"){
			var l = document.getElementById('KUprimaryPhone3').value.length;
			if(l < 4){
				problem = "Y";
				detail += "Please provide your primary phone number.\n";
				document.getElementById('KUprimaryPhone3').focus();
				if( partnerFile == 'partnerCountrywide.css'){
					cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUphone3Invalid', coreCatID, 'KU Invalid Billing Phone 3');
				}
			}
		}
	}
	
	var e = document.getElementById('KUemail').value;
	
	if(!checkemail(e)){
		problem = "Y";
		detail += "Please provide your email address.\n";
		document.getElementById('KUemail').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUemail', coreCatID, 'KU Invalid Billing Email');
			}
	}
	
	if (checkCreditCardInfo == 'Y'){
	
		if(document.getElementById('KUcardName').value == "" || document.getElementById('KUcardName').value == "First Name"){
			problem = "Y";
			detail += "Please provide the name on your credit card.\n";
			document.getElementById('KUcardName').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUcardFirstName', coreCatID, 'KU Missing Billing First Name on Card');
			}
		}
		
		if(problem != "Y"){
			if(document.getElementById('KUcardName2').value == "" || document.getElementById('KUcardName2').value == "Last Name"){
				problem = "Y";
				detail += "Please provide the name on your credit card.\n";
				document.getElementById('KUprimaryPhone3').focus();
				if( partnerFile == 'partnerCountrywide.css'){
					cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUcardLastName', coreCatID, 'KU Missing Billing Last Name on Card');
				}
			}
		}
		
		if(document.getElementById('KUcardNumber').value == ""){
			problem = "Y";
			detail += "Please provide your credit card's number.\n";
			document.getElementById('KUcardNumber').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUcardNumber', coreCatID, 'KU Missing Billing Card Number');
			}
		}
		
		if(document.getElementById('KUcardType').value == "--"){
			problem = "Y";
			detail += "Please select your type of credit card.\n";
			document.getElementById('KUcardType').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUcardType', coreCatID, 'KU Missing Billing Card Type');
			}
		}

		if(document.getElementById('KUsecurityNum').value == ""){
			problem = "Y";
			detail += "Please provide the security code of your credit card.\n";
			document.getElementById('KUsecurityNum').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUcardSecurity', coreCatID, 'KU Missing Billing Security Code');
			}
		}
				
	}else{

		if(document.getElementById('KUloanNo').value == ""){
			problem = "Y";
			detail += "Please provide us with your loan number.\n";
			document.getElementById('KUloanNo').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUloanNumber', coreCatID, 'KU Missing Billing Loan Number');
			}
		}
		
		//alert(document.getElementById('KUloanAuthorize').value);
		if( (!document.getElementById('KUloanAuthorize').checked) && (document.getElementById('KUloanAuthorize').value != 1) ){
			problem = "Y";
			detail += "Please agree to let TotalProtect validate your loan number.\n";
			document.getElementById('KUloanAuthorize').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUagreement', coreCatID, 'KU Missing Billing Agree to Terms');
			}
		}
		
		if(document.getElementById('KUfullName').value == ""){
			problem = "Y";
			detail += "Please provide us with your full name as a digital signature.\n";
			document.getElementById('KUfullName').focus();
			if( partnerFile == 'partnerCountrywide.css'){
				cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KUdigitalSignature', coreCatID, 'KU Missing Billing Digital Signature');
			}
		}
	}
		
	if(problem == "Y"){
		document.getElementById('submitButtonKU').style.display = "block";
		alert(detail);
		return false;
	} else {
		//alert("thanks");
		return true;
	}
}


function validatePaymentKK(){
	var problem = "N";
	var detail = "";
	
	document.getElementById('submitButtonKK').style.display = "none";

	if(document.getElementById('firstNameKK').value == ""){
		problem = "Y";
		detail += "Please provide your first name.\n";
		document.getElementById('firstNameKK').focus();
	}
	
	if(document.getElementById('lastNameKK').value == ""){
		problem = "Y";
		detail += "Please provide your last name.\n";
		document.getElementById('lastNameKK').focus();
	}
	
	if(document.getElementById('address1KK').value == ""){
		problem = "Y";
		detail += "Please provide your address.\n";
		document.getElementById('address1KK').focus();
	}	
	
	if(document.getElementById('cityKK').value == ""){
		problem = "Y";
		detail += "Please provide your city.\n";
		document.getElementById('cityKK').focus();
	}
	
	var stateObj = document.getElementById('stateKK');
	if(stateObj.options[stateObj.selectedIndex].value == "--"){
		problem = "Y";
		detail += "Please provide your state.\n";
		document.getElementById('stateKK').focus();
	}
	
	if(document.getElementById('zipKK').value.length < 5){
		problem = "Y";
		detail += "Please provide your zip.\n";
		document.getElementById('zipKK').focus();
	}

	var primary1Length = document.getElementById('primaryPhone1KK').value.length;
	var primary2Length = document.getElementById('primaryPhone2KK').value.length;
	var primary3Length = document.getElementById('primaryPhone3KK').value.length;

	if ( (primary1Length < 3) || (primary2Length < 3) || (primary3Length < 4) ){
		problem = "Y";
		detail += "Please provide your primary phone number.\n";
		document.getElementById('primaryPhone1KK').focus();
	}
	
	var e = document.getElementById('emailKK').value;
	
	if(!checkemail(e)){
		problem = "Y";
		detail += "Please provide a valid email address.\n";
		document.getElementById('emailKK').focus();
	}	

	if(document.getElementById('fullNameKK').value == ""){
		problem = "Y";
		detail += "Please provide your electronic signature.\n";
		document.getElementById('fullNameKK').focus();
	}	
	
	if(problem == "Y"){
		document.getElementById('submitButtonKK').style.display = "block";
		var partnerFile = $("#partnerCSSfile").val();
		if( partnerFile == 'partnerCountrywide.css'){
			//CORE METRICS
			var corePageID = $("#corePageID").val();
			var coreStepNum = $("#coreStepNum").val();
			var coreStepName = $("#coreStepName").val();
			var coreCatID = $("#coreCatID").val();
			cmCreateCustomError(corePageID, 'HomeWarranty', coreStepNum, coreStepName, '400KK', coreCatID, detail);
			alert("cmCreateCustomError has fired");
			//alert(corePageID+' HomeWarranty '+coreStepNum+" "+coreStepName+' errCode '+ coreCatID+" "+ detail);
		}
		alert(detail);
		return false;
	} else {
		//alert("thanks");
		return true;
	}	
}


function closeSesame(){
	document.getElementById('realPerks').style.display = "none";
	document.getElementById('realPerks2').style.display = "none";
}

function openSesame(){
	var browser=navigator.appName;
		var browserVer=parseInt(navigator.appVersion);
		var b_version=navigator.appVersion;
		
		//alert(browser+" | "+browserVer+" | "+b_version);
		
		if (browser=="Microsoft Internet Explorer"){
			var win6 = b_version.search("MSIE 6");
			if(win6 > 0){
				document.getElementById('realPerks2').style.display = "block";
			} else {
				document.getElementById('realPerks').style.display = "block";
			}
		}else{
			document.getElementById('realPerks').style.display = "block";
		}
}


function togglePaymentMethod(elem){
	
	if (elem == 'cc'){
		document.getElementById('ccForm').style.display = 'block';
		document.getElementById('loanForm').style.display = 'none';
	}else{
		document.getElementById('ccForm').style.display = 'none';
		document.getElementById('loanForm').style.display = 'block';
	}
}

function setRadio(id){
	document.getElementById(id).checked = true;
}


function checkemail(str){
	var testresults = false;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		if (filter.test(str)){
			testresults=true;
		}
	return (testresults);
}

function checkZipCode(partner){
	if(partner == 'partnerCountrywide.css'){ // Bank of America co-brand
		var r=confirm("By clicking this button you acknowledge that you have received, read and understand the Insurance Disclosure noted below.");
		if (r==true){
			  	//a call to this function should be placed inside of the onclick event handler for the form submit button
				var cookieName = "HOMEWAR_APP_EVT2";
				if ((getCookie(cookieName)==undefined)||((getCookie(cookieName))&&(getCookie(cookieName)==""))) {
					setCookie(cookieName,"T","/");
					//throw conversion event app view to start (action type = 2)
					cmCreateConversionEventTag('App View to Start', '2', 'Ins:App:Protect:HomeWarranty', null, null, null, 'HomeWarranty', null, null);
					//throw conversion event app start to submit (action type = 1)
					cmCreateConversionEventTag('App Start to Submit', '1', 'Ins:App:Protect:HomeWarranty', null, null, null, 'HomeWarranty', null, null);
				}
			return true;
		}else{
			alert("Please read the Insurance Disclosure below.");
			cmCreateCustomError('Ins:App:Protect:HomeWarranty;HomeWarranty:100:Overview', 'HomeWarranty', '100', 'Overview', '100Zip', 'Ins:App:Protect:HomeWarranty', 'Failed to acknowledge disclosure');
			return false;
		}
	}else{
		return true;
	}
}


   //a call to this function should be placed inside of the onclick event handler for the form submit button

function throwCmEventsOnClick ()
{
	var cookieName = "HOMEWAR_APP_EVT2";
	if ((getCookie(cookieName)==undefined)||((getCookie(cookieName))&&(getCookie(cookieName)==""))) {
		setCookie(cookieName,"T","/");
		//throw conversion event app view to start (action type = 2)
		//throw conversion event app start to submit (action type = 1)
	}
}

function autoAdvance(obj,len,next){
	var test = $(obj).val();
	if(test.length >= len){
		$('#'+next).focus();
	}
}

function clearFields(obj){
	$(obj).val("");
}

function repopulate(obj,newval){
	var val = $(obj).val();
	if(val == ""){
		$(obj).val(newval);
	}
}

