/*



Quote From Name: getQuoteForm

Insurance Type: Type

Zip code: zip

Are you currently insured Div (to show/hide): yes-no

Are you currently insured radio button Id Yes: QuoteBoxLeadHasInsurance1

Are you currently insured radio button Id No: QuoteBoxLeadHasInsurance0



*/



function ValidateForm()

{

	var strErr = "";



	if (document.getQuoteForm.Type.value == "none") {

		strErr = strErr + "You must select an insurance type.\n";

	}

	

	var tmpZip = trim(document.getQuoteForm.zip.value);

	document.getQuoteForm.zip.value = tmpZip;

	if (tmpZip.search(/^\d{5}/) == -1 ||  tmpZip.length > 5) {

		strErr = strErr + "Zip Code is required and must be in the format 00000.\n";

	}

	

	if ((document.getElementById("yes-no").className == "visible") 

			&& (! document.getElementById("QuoteBoxLeadHasInsurance1").checked) 

			&& (! document.getElementById("QuoteBoxLeadHasInsurance0").checked))

	{

	  strErr = strErr + "You must specify if your car is currently insured";

  }



	if (strErr != "") 

	{

		alert(strErr);

		return false;

	}

	

	return true;

}



function trim(str)

{

  return((" "+ str).replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,"$1"));

}





function insurance_type_change()

{

	if (document.getElementById("Type").value == "Auto")

	{

		document.getElementById("yes-no").className = "visible";

	}

	else

	{

		document.getElementById("yes-no").className = "invisible";

	}

}
