//7/14/09  removed old homeowners validation code to backup - mostly can be replaced w/IsNumeric()
function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;				  //form.name.value sent in
   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;
   }


//validator for first page of auto, business, homeowners and commercial auto forms
function Page1_Form_Validator()
{

  if (document.getElementById("FN").value == "") 
  {
    alert("Please enter a value for the \"Contact First Name\" field.");
    document.getElementById("FN").focus();
    return (false);
  }

  else if (document.getElementById("LN").value == "")
  {
    alert("Please enter a value for the \"Contact Last Name\" field.");
    document.getElementById("LN").focus();
    return (false);
  }
  else if (document.getElementById("EM").value == "")
  {
    alert("Please enter a value for the \"Contact E-mail\" field.");
    document.getElementById("EM").focus();
    return (false);
  }
  else if (document.getElementById("CA").value == "")
  {
	if (document.getElementById("CA").name == "Contact_StreetAddress") {
		alert("Please enter a value for the \"Current Street Address\" field.");
    }
	else if (document.getElementById("CA").name == "Your_StreetAddress") {
		alert("Please enter a value for the \"Your Street Address\" field.");
    }
	else {
         alert("Please enter a value for the \"Mailing Street Address\" field.");
	}
    document.getElementById("CA").focus();
    return (false);
  }
  else if ( (document.getElementById("CA2").value == "") && (document.getElementById("CA2").name == "Contact_UnitNumber"))
  {
	alert("Please enter a value for the \"Your Address Unit #\" field.");
	
    document.getElementById("CA2").focus();
    return (false);
  }

  else if (document.getElementById("CC").value == "")
  {
	if (document.getElementById("CC").name == "Contact_City") {
		alert("Please enter a value for the \"Current City\" field.");
    }
	else if (document.getElementById("CC").name == "Your_City") {
		alert("Please enter a value for the \"Your City\" field.");
    }
	else {
		alert("Please enter a value for the \"Mailing City\" field.");
	}
    document.getElementById("CC").focus();
    return (false);
  }
  else if (document.getElementById("ST").value == "")
  {
    alert("Please select one of the \"Mailing State\" options.");
    document.getElementById("ST").focus();
    return (false);
  }

  else if (document.getElementById("ZC").value == "")
  {
	if (document.getElementById("ZC").name == "Contact_ZipCode") {
		alert("Please enter a value for the \"Current Zip Code\" field.");
    }
	else if (document.getElementById("ZC").name == "Your_ZipCode") {
		alert("Please enter a value for the \"Your Zip Code\" field.");
    }
	else {
		alert("Please enter a value for the \"Mailing Zip Code\" field.");
	}
	document.getElementById("ZC").focus();
    return (false);
  }

  else if ( (document.getElementById("ZC").value != "") && (!IsNumeric(document.getElementById("ZC").value))  )
  {
	if (document.getElementById("ZC").name == "Contact_ZipCode") {
		alert("Please enter a numeric value for the \"Current Zip Code\" field.");
    }
	else if (document.getElementById("ZC").name == "Your_ZipCode") {
		alert("Please enter a numeric value for the \"Your Zip Code\" field.");
    }
	else {
		alert("Please enter a numeric value for the \"Mailing Zip Code\" field.");
	}

		document.getElementById("ZC").focus();
		return (false);
  }
	    
	  
	
  
  else if (document.getElementById("PA").value == "")
  {
	if (document.getElementById("PA").name == "PropAddress") {
		  alert("Please enter a value for the \"Property Address\" field.");
	}
	else if (document.getElementById("PA").name == "GaragingAddress"){
		alert("Please enter a value for the \"Garaging Address\" field.");
	}
	else
		alert("Please enter a value for the \"Location Address\" field.");
     
    document.getElementById("PA").focus();
    return (false);
  }
  else if ( (document.getElementById("PA2").value == "") && (document.getElementById("PA2").name == "PropUnitNumber"))
  {
	alert("Please enter a value for the \"Property Address Unit #\" field.");
	
    document.getElementById("PA2").focus();
    return (false);
  }

  else if (document.getElementById("PC").value == "")
  {
	if (document.getElementById("PC").name == "PropCity") {
		  alert("Please enter a value for the \"Property City\" field.");
	}
	else if (document.getElementById("PC").name == "GaragingCity"){
		alert("Please enter a value for the \"Garaging City\" field.");
	}
	else
		alert("Please enter a value for the \"Location City\" field.");
     
    document.getElementById("PC").focus();
    return (false);
  }
  else if (document.getElementById("PZC").value == "")
  {
	if (document.getElementById("PZC").name == "Property_ZipCode") {
		  alert("Please enter a value for the \"Property Zip Code\" field.");
	}
	else if (document.getElementById("PZC").name == "GaragingZipCode"){
		alert("Please enter a value for the \"Garaging Zip Code\" field.");
	}
	else
		alert("Please enter a value for the \"Location Zip Code\" field.");
     
    document.getElementById("PZC").focus();
    return (false);
  }
  else if ( (document.getElementById("PZC").value != "") && (!IsNumeric(document.getElementById("PZC").value))  )
  {
	if (document.getElementById("PZC").name == "Property_ZipCode") {
		alert("Please enter a numeric value for the \"Property Zip Code\" field.");
    }
	else if (document.getElementById("PZC").name == "GaragingZipCode") {
		alert("Please enter a numeric value for the \"Garaging Zip Code\" field.");
    }
	else {
		alert("Please enter a numeric value for the \"Location Zip Code\" field.");
	}

		document.getElementById("PZC").focus();
		return (false);
  }

  else
		showLayer('page2');

}
//Condo Certificate Form validator
function Page1_CondoForm_Validator()
{

  if (document.getElementById("FN").value == "") 
		  //if (theForm.Contact_FirstName.value == "")
  {
    alert("Please enter a value for the \"Unit Owner First Name\" field.");
    document.getElementById("FN").focus();
    return (false);
  }

  else if (document.getElementById("LN").value == "")
  {
    alert("Please enter a value for the \"Unit Owner Last Name\" field.");
    document.getElementById("LN").focus();
    return (false);
  }
  else if (document.getElementById("EM").value == "")
  {
    alert("Please enter a value for the \"Unit Owner E-mail\" field.");
    document.getElementById("EM").focus();
    return (false);
  }
  else if (document.getElementById("PA").value == "")
  {
	alert("Please enter a value for the \"Location Street Address\" field.");
    document.getElementById("PA").focus();
    return (false);
  }
  else if (document.getElementById("PC").value == "")
  {
	alert("Please enter a value for the \"Location City\" field.");
    document.getElementById("PC").focus();
    return (false);
  }
  else if (document.getElementById("PST").value == "")
  {
    alert("Please select one of the \"Location State\" options.");
    document.getElementById("PST").focus();
    return (false);
  }

  else if (document.getElementById("PZC").value == "")
  {
	alert("Please enter a value for the \"Location Zip Code\" field.");
	document.getElementById("PZC").focus();
    return (false);
  }
  
  else
	 return (true);

}
// Binder Form validator
function Page1_BinderForm_Validator()
{

  if (document.getElementById("FN").value == "") 
		  //if (theForm.Contact_FirstName.value == "")
  {
    alert("Please enter a value for the \"Contact First Name\" field.");
    document.getElementById("FN").focus();
    return (false);
  }

  else if (document.getElementById("LN").value == "")
  {
    alert("Please enter a value for the \"Contact Last Name\" field.");
    document.getElementById("LN").focus();
    return (false);
  }
  else if (document.getElementById("EM").value == "")
  {
    alert("Please enter a value for the \"Contact E-mail\" field.");
    document.getElementById("EM").focus();
    return (false);
  }
  else if (document.getElementById("CA").value == "")
  {
	alert("Please enter a value for the \"Mailing Street Address\" field.");
    document.getElementById("CA").focus();
    return (false);
  }
  else if (document.getElementById("CC").value == "")
  {
	alert("Please enter a value for the \"Mailing City\" field.");
    document.getElementById("CC").focus();
    return (false);
  }
  else if (document.getElementById("ST").value == "")
  {
    alert("Please select one of the \"Mailing State\" options.");
    document.getElementById("ST").focus();
    return (false);
  }

  else if (document.getElementById("ZC").value == "")
  {
	alert("Please enter a value for the \"Mailing Zip Code\" field.");
	document.getElementById("ZC").focus();
    return (false);
  }
  
  else
	 return (true);

}


// Liability Certificate Form validator
function Page1_LiabilityForm_Validator()
{

  if (document.getElementById("FN").value == "") 
  {
    alert("Please enter a value for the \"Certificate Holder First Name\" field.");
    document.getElementById("FN").focus();
    return (false);
  }

  else if (document.getElementById("LN").value == "")
  {
    alert("Please enter a value for the \"Certificate Holder Last Name\" field.");
    document.getElementById("LN").focus();
    return (false);
  }
  else if (document.getElementById("EM").value == "")
  {
    alert("Please enter a value for the \"Certificate Holder E-mail\" field.");
    document.getElementById("EM").focus();
    return (false);
  }
    
  else
	 return (true);
}

function CopyAddress()
{
	if (document.getElementById("CK").checked == true)
    {
		//alert("value is on");
		if (document.getElementById("CA").value != "")
		  {
			document.getElementById("PA").value = document.getElementById("CA").value;
		  }
		if (document.getElementById("CA2").value != "")
		  {
			document.getElementById("PA2").value = document.getElementById("CA2").value;
		  }
		if (document.getElementById("CC").value != "")
		  {
			document.getElementById("PC").value = document.getElementById("CC").value;
		  }
		if (document.getElementById("ZC").value != "")
		  {
			document.getElementById("PZC").value = document.getElementById("ZC").value;
		  }
		 
	    var state = document.getElementById("ST");
	    var pstate = document.getElementById("PST");
	    var stateval = state.options[state.selectedIndex].value;
		var pstateval = pstate.options[pstate.selectedIndex].value;
		pstate.selectedIndex =  state.selectedIndex;
        pstate.options[pstate.selectedIndex].value = state.options[state.selectedIndex].value; 
	}
	else
	{
		//alert("value is not on");
		document.getElementById("PA").value = "";
		document.getElementById("PA2").value = "";
		document.getElementById("PC").value = "";
		document.getElementById("PZC").value = "";

	}
   
   return;
}



