function ale() {
	if (document.form1.code.value!="99999") {
		if (document.form1.policytype[2].checked==true)	{
			if (document.form1.buildamt.value*.2 < document.form1.addliving.value) {
				alert("20% maximum for ALE on HOA");
				document.form1.addliving.value=document.form1.buildamt.value*.2;
				}
			}
		if (document.form1.policytype[3].checked==true && document.form1.limited.value=="N") {
			if (document.form1.buildamt.value*.2 < document.form1.addliving.value) {
				alert("20% maximum for ALE on HOB");
				document.form1.addliving.value=document.form1.buildamt.value*.2;
				}
			}
		}
	}

function chkprotection() {
	if (document.form1.protection.value==10) {
		window.alert("We are unable to write unprotected class 10 risks");
		document.form1.protection.select();
		document.form1.protection.focus();
		return false;
		}
	}

function chkeffdate() {
	if (!isDate(document.form1.effdate.value)) {
		//window.alert("Please enter a valid effective date.");
		document.form1.effdate.focus();
		return false;
		}
	return true;
	}

function surplusline(){
	if (document.form1.prior[0].checked==true && document.form1.surpluslines[1].checked==true){
		alert("We are unable to quote against a standard Company");
		document.location.href = "quotes.html";
		}
	}

function appwarning() {
	window.alert("Please wait as this application is 228K in size");
	}

function openpopup(){
	msgWindow=window.open("DWELLING.HTML","newwindow");
	}


function findzipcode(){
	if (document.form1.state.value=="TX") {
		document.form1.zipcodefind.value="T";
		document.form1.submit();
		}
	else {
		return true;
		}
	}

function ec_1(){
	if (document.form1.ec1[0].checked==true) {
		document.form1.ec2[1].checked=true
		}
	}

function ec_2(){
	if (document.form1.ec2[0].checked==true){
		document.form1.ec1[1].checked=true
		}
	}

function checknum(val){
	if (Number(val)){
		return true;
		}
	window.alert('Only Numbers allowed , NO Commas');
	}


function Number(val) {
	for (var i=0; i < val.length; i++) {
		if (!Digit(val.charAt(i))) {
			return false;
			}
		}
	return true;
	}

function Digit(num) {
	var string="1234567890.";
	if (string.indexOf(num) != -1) {
		return true;
		}
	return false;
	}

function submitit(){
	document.getElementById("b1").style.cursor='wait';
	}

function chksubmit(){
	var errorstr;
	errorstr=""
	if (chkeffdate()) {
		if (document.form1.age.value=="0"){
			errorstr=errorstr+"Age of dwelling must be selected";
			}
		if (document.form1.buildamt.value=="0"){
			errorstr=errorstr+"Amount of coverage must be filled in";
			}
		if (errorstr==""){
			return true
			}
		}
	myMsgBox(errorstr);
	return false
	}

function states(){
	if (document.form1.state.value=="TX"){
		document.getElementById("texas").style.display="";
		document.getElementById("gulfstates").style.display="none";
		document.getElementById("texasstate").style.display="";
		return true;
		}
	var x;
	var gulfstate="LA|FL|GA|NC|SC|MS|AL";
	var state=document.form1.state.value;
	x=state.search(gulfstate);
	if (x>-1){
		document.getElementById("gulfstates").style.display='';
		document.getElementById("texasstate").style.display="none";
		document.getElementById("texas").style.display="none";
		}
	else{
		document.getElementById("texas").style.display="none";
		document.getElementById("gulfstates").style.display="none";
		document.getElementById("texasstate").style.display="none";
		}
	if(document.form1.state.value=="OK"){
		document.getElementById("OK").style.display='';
		document.getElementById("texas").style.display="none";
		document.getElementById("gulfstates").style.display="none";
		document.getElementById("texasstate").style.display="none";
		}
	}


function second5(value) {
	document.getElementById("layer5").style.visibility="visible";
	}

function second6(value) {
	document.getElementById("layer5").style.visibility="hidden";
	}

function second0() {
	var typestruct=$('[name=typestruct]').fieldValue(); 
	var policytype=$('[name=policytype]').fieldValue(); 

  //alert("indexnum = "+indexnum);
	if (typestruct==2) {
		if (document.form1.state.value!="TX") {
			window.alert("Secondary/Vacation Homes are not allowed outside of Texas");
			document.form1.typestruct[0].checked=true;
			return false;
			}
		document.getElementById("secnightsdiv").style.visibility="visible";
		document.getElementById("secnightsdiv").style.display='';
		}
	else {
		document.getElementById("secnightsdiv").style.visibility="hidden";
		document.getElementById("secnightsdiv").style.display='none';
		}
	if (typestruct==3) {
		var temp=window.prompt('Will this be the only rental property on this policy for this year',"Yes");
		if (temp.toUpperCase()=="YES"){
			return true;
			}
		else{
			window.alert("Must use Rental Dwelling Program instead");
			document.location.href = "quotes.html";
			}
		if (document.form1.code.value!="99999") {
			document.form1.contamt.value=0;
			}
		}

	if (typestruct>2) {
		document.getElementById("medpayshow").style.visibility="hidden";
		document.form1.policytype.value=2;
		}

	document.form1.contamt.disabled=false;
	second4(-1);
	}

function second2(value){
	if (document.form1.business[0].checked==true){
		document.getElementById("layer2").style.display="";
		}
	else {
		document.getElementById("layer2").style.display="none";
		document.form1.business[0].checked=false;
		}
	}

function second3(value) {
	if (document.form1.alwiring[0].checked==true){
		document.getElementById("layer3").style.display="";
		document.form1.alwiring[1].checked=false;

		document.form1.pigtailed[0].checked=false;
		document.form1.pigtailed[1].checked=false;
		}
	else{
		document.getElementById("layer3").style.display="none";
		document.form1.alwiring[0].checked=false;

//alert("clear checked");
		document.form1.pigtailed[0].checked=false;
		document.form1.pigtailed[1].checked=false;
		}
	}


function second4(value){
	checkwater(false);
	replacecost(false);
	//indexnum=value;
	indexnum=$('[name=policytype]').fieldValue(); 

	if (indexnum>2 && "0"==document.form1.liability.value){
		document.form1.liability.value="25000";
		}
	
	if (indexnum==1){
		document.form1.type_policy.value="Dwelling F, EC, Vmm with Liability";
		document.form1.policytype[0].checked=true;
		document.form1.policytype.value=1;
		}
	
	if (indexnum==2){
		document.form1.type_policy.value="Dwelling F, EC, Vmm without Liability";
		document.form1.policytype.value=2;
		document.form1.policytype[1].checked=true;
		}
	
	if (indexnum==3){
		document.form1.type_policy.value="Homeowners HOA or HO1";
		document.form1.policytype[2].checked=true;
		document.form1.policytype.value=3;
		}
	
	if (indexnum==4){
		document.form1.type_policy.value="Homeowners HOB or HO2";
		document.form1.policytype[3].checked=true;
		document.form1.policytype.value=4;
		}
	
	
	// new case for "Habitat Homeowners Rates"
	// gibby - 20080806 - per Denise
	// if habitat question exists, show (or hide in else)
	if (document.getElementById("product")!=null) {
		if (indexnum==4) {
			//alert('show');
			document.getElementById("habitatdiv").style.display="inline";
			document.form1.habitat[1].checked=true;
			}
		else {
			document.getElementById("habitatdiv").style.display="none";
			document.form1.habitat[1].checked=true;
			//alert('hide');
			}
		}
	
	
	if (indexnum==5){
		document.form1.type_policy.value="Homeowners Limited HO8";
		document.form1.policytype.value=5;
		document.form1.policytype[4].checked=true;
		}
	
	if (indexnum==6){
		document.form1.type_policy.value="Homeowners Limited HO8 Prefered";
		document.form1.policytype.value=6;
		document.form1.policytype[5].checked=true;
		}
	
	if (indexnum==7){
		if (document.form1.state.value != "TX"){
			window.alert("HOC is only avaliable in TX");
			document.form1.policytype[2].checked=true;
			document.form1.policytype.value=3;
			return false;
			}
		document.form1.type_policy.value="Homeowners HOC or HO3";
		document.form1.policytype.value=7;
		document.form1.policytype[6].checked=true;
		}
	
	if (indexnum==8){
		document.form1.type_policy.value="Homeowners HOA Plus Water";
		document.form1.policytype.value=8;
		document.form1.policytype[7].checked=true;
		if (document.form1.state.value=="OK"){
			window.alert("Water is not available in Oklahoma");
			document.form1.policytype[2].checked=true;
			document.form1.policytype.value=3;
			}
		}
	
	if (indexnum==9){
		document.form1.type_policy.value="Homeowners HOA Premier";
		document.form1.policytype.value=9;
		document.form1.policytype[8].checked=true;
		if (document.form1.state.value=="OK"){
			window.alert("Water is not available in Oklahoma");
			document.form1.policytype[2].checked=true;
			document.form1.policytype.value=3;
			}
		}
	
	if (indexnum==10){
		document.form1.type_policy.value="Homeowners HOB Premier";
		document.form1.policytype.value=10;
		document.form1.policytype[9].checked=true;
		}
	
	
	if(document.form1.state.value!="TX" && indexnum<4){
		window.alert("No Dwelling Fire available in your state");
		document.form1.policytype.value=3;
		document.form1.policytype[2].checked=true;
		
		return false;
		}
	
	if (indexnum==8){
		covnum=document.form1.coverage.selectedIndex;
		if (document.form1.coverage.value=="RC") {
			window.alert("HOA Plus is only available for ACV, no RC");
			document.form1.coverage.value="ACV";
			replacecost(false);
			}
	
		if (document.form1.protection.value>9) {
			window.alert("HOA Plus is only available for protection classes 1-9");
			document.form1.policytype.value=3;
			document.form1.policytype[2].checked=true;
			}
	
	
		if(document.form1.age.value<1904)	{
			window.alert("HOA Plus is only available for Homes built in the last 100 years");
			document.form1.policytype.value=3;
			document.form1.policytype[2].checked=true;
			}
	  }
	
	if (indexnum==9) {
		if(document.form1.protection.value>6) {
			window.alert("HOA PREMIER is only available for protection clases 1-6");
			document.form1.policytype.value=3;
			document.form1.policytype[2].checked=true;
			}
		if(document.form1.credit.value>2)	{
			window.alert("HOA Premier is only available for Great and Good Credit");
			document.form1.policytype.value=3;
			document.form1.policytype[2].checked=true;
			}
		if (document.form1.age.value<1971) {
			window.alert("HOA Premier is only available for Homes built in the last 35 years");
			document.form1.policytype.value=3;
			document.form1.policytype[2].checked=true;
			}
		}
	
	if (indexnum==10) {
		if(document.form1.protection.value>5)	{
			window.alert("HOB PREMIER is only available for protection clases 1-5");
			document.form1.policytype.value=3;
			document.form1.policytype[2].checked=true;
			}
		if(document.form1.credit.value>2)	{
			window.alert("HOB Premier is only available for Great and Good Credit");
			document.form1.policytype.value=3;
			document.form1.policytype[2].checked=true;
			}
		if (document.form1.age.value<1971) {
			window.alert("HOB Premier is only available for Homes built in the last 35 years");
			document.form1.policytype.value=3;
			document.form1.policytype[2].checked=true;
			}
		}
	//alert("indexnum = "+indexnum);
	
	if (indexnum==2) {
		document.getElementById("liablimdiv").style.visibility="hidden";
		}
	else {
		document.getElementById("liablimdiv").style.visibility="visible";
		}
	
	if (indexnum<2) {
		document.getElementById("medpayshow").style.visibility="hidden";
		}
	else {
		document.getElementById("medpayshow").style.visibility="visible";
		}
	
	if (indexnum<3) {
		document.getElementById("texasstate").style.display="none";
		}
	else {
		document.getElementById("texasstate").style.display="";
		}
	
	if (indexnum<3) {
		document.getElementById("Replacediv").style.display="none";
		}
	else {
		document.getElementById("Replacediv").style.display="";
		}
	
	return false;
	}





function checkage(){
	if (document.form1.age.value<1900){
		window.alert("Enter the Year that the Dwelling was built ie 1997");
		document.form1.age.value=1990;
		return false;
		}
	if (document.form1.policytype.value==4 && document.form1.age.value<1953 && document.form1.limited.value=="N"){
		window.alert("Maximum age for HOB dwellings is 50 years");
		return false;
		}
	}

// mode = 1, use new jquery dialog popup for water
// slient, supress error messages and don't change focus
function contents(mode,silent) {
   if ( silent === undefined ) {
			silent = false;
			}
			
	if (checknum(document.form1.buildamt.value)==false) {
		return false;
		}
	
	if (document.form1.code.value!="99999"
			&& document.form1.buildamt.value<25000
			&& (document.form1.policytype[2].checked==true || document.form1.policytype[4].checked==true || document.form1.policytype[5].checked==true)) {
		if (!silent) window.alert("Minimum building value is $25000");
		document.form1.buildamt.value=25000;
		if (!silent) document.form1.buildamt.focus();
		if (!silent) return false;
		}
	
	if (document.form1.code.value!="99999"
			&& document.form1.buildamt.value<25000
			&& (document.form1.policytype[2].checked==false && document.form1.policytype[4].checked==false && document.form1.policytype[5].checked==false)) {
		if (!silent) window.alert("Minimum building value is $25000");
		document.form1.buildamt.value=25000;
		if (!silent) document.form1.buildamt.focus();
		if (!silent) return false;
		}

	checkwater(true && !silent, mode);
	
	if (document.form1.limited.value=='N') {
		if (document.form1.policytype[3].checked==true && document.form1.age.value<1953 ) {
			if (!silent) window.alert("Maximum age for HOB is 50, changing policy type to HOA");
			document.form1.policytype[2].checked=true;
			document.form1.policytype.value=3;
			}
		}
	
	if (document.form1.limited.value=='N') {
		if (document.form1.coverage.value=="ACV" && document.form1.policytype[3].checked==true ) {
			if (document.form1.age.value<1953 || document.form1.buildamt.value<75000) {
				//alert("habitat="+document.form1.habitat[0].checked);
				
				habitatobj = document.getElementById("habitat")
				coverageobj = document.getElementById("coverage")
				
			  if (habitatobj && habitatobj[0].checked==false && coverageobj.value=="RC") { 
			    if (!silent) window.alert("Minimium building value is $75,000 and maximum age is 50 years old with Replacement Cost");
			    document.form1.buildamt.value=75000;
			    if (!silent) document.form1.buildamt.focus();
			    }
			  else if (document.form1.buildamt.value<25000) {
			    if (!silent) window.alert("Minimium building value is $25,000 for Habitat");
			    document.form1.buildamt.value=25000;
			    if (!silent) document.form1.buildamt.focus();
			    }
			  }
			}
		}
	
	if (document.form1.limited.value=='N')  {
		if (document.form1.coverage.value=="RC" && document.form1.policytype[3].checked==true ) {
			if (document.form1.buildamt.value<75000 || document.form1.age.value<1953) {
				if (!silent) window.alert("Minimum building value is $75000 and maximum age is 50 years old");
				document.form1.buildamt.value=75000;
				if (!slient) document.form1.buildamt.focus();
				}
			}
		}
	
	if (document.form1.buildamt.value>500000 && document.form1.code.value!="99999") {
		if (!silent) window.alert("Maximum building value is $500,000, Please submit to Company for Quotes for Dwellings up to $5 Million");
		document.form1.buildamt.value=500000;
		return false;
		}
	
	if (document.form1.credit.value>3) {
		if (!silent) window.alert("Because of Credit, Replacement Coverage is not Available");
		document.form1.coverage.value="ACV";
		document.form1.rc.value=0;
		}
	
	if (document.form1.policytype.value<3) {
		document.form1.coverage.value="ACV";
		document.form1.rc.value=0;
		}
	
	if (document.form1.contamt.value < 75000) {
		if (document.form1.coverage.selectedIndex==1) {
			var currentDate=new Date()
			if (document.form1.age.value<currentDate.getFullYear()-50) {
				document.form1.coverage.value="ACV";
				if (!silent) myMsgBox('Because of value and age of Dwelling, Coverage is changed to ACV');
				document.form1.rc.value=0;
				}
			}
		}
	}
	
function checkwater(usepopup, mode) {
   if ( mode === undefined ) {
			mode = 0;
			}

	if (document.form1.limited.value=='N') {
		if (document.form1.policytype[3].checked==true //|| document.form1.policytype[7].checked==true
		  || document.form1.policytype[8].checked==true || document.form1.policytype[9].checked==true || document.form1.policytype[6].checked==true) {

			if (usepopup) { 
				if (mode>0){
					waterloaddata("#water1");
					$("#waterdlg").dialog("open");
					}
				else {
					var objwindows=window.open("water.html",null,"height=500,width=800");
					objwindows.focus();
					}
				}
	
			document.getElementById("waterdiv").style.display="";
			//document.form1.alwiring[1].checked=false;
	
		  }
		else {
			document.getElementById("waterdiv").style.display="none";
		  }
		if (document.form1.policytype[0].checked==true || document.form1.policytype[1].checked==true)	{
			if (usepopup) { 

				if (mode>0){
					waterloaddata("#water1dwell");
					$("#waterdwelldlg").dialog("open");
					}
				else {
					var objwindows=window.open("waterdwell.html",null,"height=500,width=800");
					objwindows.focus();
					}
				}	
				
			document.getElementById("waterdwelldiv").style.display="";
			//document.form1.alwiring[1].checked=false;
	
			}
		else {
			document.getElementById("waterdwelldiv").style.display="none";
			if (usepopup) { 
				if (!(mode>0)){
					document.form1.contamt.focus();
					}
				}
			}
		}
	}

// new jquery dlg load processor
function waterloaddata(destname) {
  currentval = $("#water").val();
  //alert(currentval);
	$(""+destname+" option").each(function(i){
    if (i==0 || $(this).val()==currentval) {
    	$(this).attr("selected", "selected");
    	};
    });
	}

function addstruc() {
	if (document.form1.policytype[2].checked==true){
		if (document.form1.addstruct.value>Math.floor(.1 * document.form1.buildamt.value)){
			document.form1.addstruct.value=Math.floor(.1 * document.form1.buildamt.value);
			}
		}
	if (document.form1.policytype[3].checked==true && document.form1.limited.value=="N"){
		if (document.form1.addstruct.value>Math.floor(.1 * document.form1.buildamt.value)){
			document.form1.addstruct.value=Math.floor(.1 * document.form1.buildamt.value);
			}
		}
	if (document.form1.policytype[3].checked==true && document.form1.limited.value=="Y"){
		if (document.form1.addstruct.value>Math.floor(.1 * document.form1.buildamt.value)){
			document.form1.addstruct.value=Math.floor(.1 * document.form1.buildamt.value);
			}
		}
	if (document.form1.policytype[4].checked==true) {
		if (document.form1.addstruct.value>Math.floor(.1 * document.form1.buildamt.value)) {
			document.form1.addstruct.value=Math.floor(.1 * document.form1.buildamt.value);
			}
		}
	if (document.form1.policytype[5].checked==true){
		if (document.form1.addstruct.value>Math.floor(.1 * document.form1.buildamt.value)){
			document.form1.addstruct.value=Math.floor(.1 * document.form1.buildamt.value);
			}
		}
	if (document.form1.policytype[6].checked==true){
		if (document.form1.addstruct.value>Math.floor(.1 * document.form1.buildamt.value)){
			document.form1.addstruct.value=Math.floor(.1 * document.form1.buildamt.value);
			}
		}
	}



function replacecost(activate) {
   if ( activate === undefined ) {
      activate = true;
   }

	if (document.form1.policytype[0].checked==true && document.form1.code.value!="99999") {
		if (document.form1.contamt.value>Math.floor(.4 * document.form1.buildamt.value))	{
			document.form1.contamt.value=Math.floor(.4 * document.form1.buildamt.value);
			}
		}
	
	if (document.form1.policytype[1].checked==true && document.form1.code.value!="99999") {
		if (document.form1.contamt.value>Math.floor(.4 * document.form1.buildamt.value)) {
			document.form1.contamt.value=Math.floor(.4 * document.form1.buildamt.value);
			}
		}
	if (document.form1.limited.value=='N') {
		if (document.form1.policytype[7].checked==true && document.form1.code.value!="99999") {
			if (document.form1.contamt.value>Math.floor(.5 * document.form1.buildamt.value)) {
				document.form1.contamt.value=Math.floor(.5 * document.form1.buildamt.value);
				}
			}
		}
	
	if (document.form1.limited.value=='N') {
		if (document.form1.policytype[8].checked==true && document.form1.code.value!="99999") {
			if (document.form1.contamt.value>Math.floor(.5 * document.form1.buildamt.value)) {
				document.form1.contamt.value=Math.floor(.5 * document.form1.buildamt.value);
				}
			}
		}
	if (document.form1.limited.value=='N') {
		if (document.form1.policytype[9].checked==true && document.form1.code.value!="99999") {
			if (document.form1.contamt.value>Math.floor(.6 * document.form1.buildamt.value)) {
				document.form1.contamt.value=Math.floor(.6 * document.form1.buildamt.value);
				}
			}
		}

	if (document.form1.policytype[2].checked==true && document.form1.code.value!="99999") {
		if (document.form1.contamt.value>Math.floor(.5 * document.form1.buildamt.value)) {
			document.form1.contamt.value=Math.floor(.5 * document.form1.buildamt.value);
			}
		}
	if (document.form1.policytype[3].checked==true && document.form1.code.value!="99999" && document.form1.limited.value=="N") {
		if (document.form1.contamt.value>Math.floor(.6 * document.form1.buildamt.value)) {
			document.form1.contamt.value=Math.floor(.6 * document.form1.buildamt.value);
			}
		}
	
	if (document.form1.policytype[3].checked==true && document.form1.code.value!="99999" && document.form1.limited.value=="Y") {
		if (document.form1.contamt.value>Math.floor(.3 * document.form1.buildamt.value)) {
			document.form1.contamt.value=Math.floor(.3 * document.form1.buildamt.value);
			}
		}

	if (document.form1.limited.value=='N') {
		if (document.form1.policytype[4].checked==true && document.form1.code.value!="99999"){
			if (document.form1.contamt.value>Math.floor(.3 * document.form1.buildamt.value)) {
				document.form1.contamt.value=Math.floor(.3 * document.form1.buildamt.value);
				}
			}
		}
	if (document.form1.limited.value=='N') {
		if (document.form1.policytype[5].checked==true && document.form1.code.value!="99999") {
			if (document.form1.contamt.value>Math.floor(.6 * document.form1.buildamt.value)) {
				document.form1.contamt.value=Math.floor(.6 * document.form1.buildamt.value);
				}
			}
		}

	if (checknum(document.form1.contamt.value)==false){
		document.getElementById("replacecostdiv").style.display="none";
		return false;
		}

  display="none";	
	if (document.form1.buildamt.value>74999
			&& document.form1.coverage.selectedIndex==1
			&& (document.form1.policytype[2].checked==true
			  || document.form1.policytype[3].checked==true
				|| document.form1.policytype[8].checked==true
				|| document.form1.policytype[7].checked==true
				|| document.form1.policytype[9].checked==true
				|| document.form1.policytype[6].checked==true)) {
	   var creditnum=document.form1.credit.selectedIndex;
	   var creditvalue=document.form1.credit[creditnum].value;
		if ((creditvalue=="1" || creditvalue=="2" || creditvalue=="3")
				&& (document.form1.typestruct[0].checked || document.form1.typestruct[1].checked)) {


			display="";


			
			//var temp=window.prompt('Is replacement cost on contents wanted',"Yes");
			//if (temp.toUpperCase()=="YES") {
			//	document.form1.rc.value=Math.floor(.5 * document.form1.buildamt.value);
			//	}
			//else {
			//	document.form1.rc.value=0
			//	}
			
			}
		}

//alert("display = " + display);
			document.getElementById("replacecostdiv").style.display=display;
			if (display=="") {
				if (activate) {
					document.form1.rc1[0].focus();
					}
				}
			else {
				document.form1.rc.value=0;
				}

	}
	
function rccheck	() {
	if (document.form1.rc1[0].checked) {
		document.form1.rc.value=Math.floor(.5 * document.form1.buildamt.value);
		}
	else {
		document.form1.rc.value=0;
		}
	}

function polfee() {
	if (document.form1.policyfee.value>200) {
		myMsgBox("Maximum of $200.00 Policy Fee")
		document.form1.policyfee.value=200;
		}
	}

function claimbox() {
	document.form1.claim.value="T"
	document.form1.submit();
	}

function showarchiveit(showit){
	//r=document.getElementById("renewalchk");
	//alert(r.value);
	if (showit) {
		document.getElementById("archiveitdiv").style.display="block";
		}
	else {
		document.getElementById("archiveitdiv").style.display="none";
		}
	}

function terrlist() {
	var objwindows=window.open("territory.html",null,"toolbar=no,height=500, menubar=no,status=no,location=no");
	}

function creditbox(){
	var objwindows=window.open("credit.html",null,"height=300,toolbar=no,menubar=no,status=no,location=no")
	}

function carrierbox() {
	var objwindows=window.open("carrier.html",null,"height=300,toolbar=no,menubar=no,status=no,location=no")
	}

function alarmdiscount() {
	if (document.form1.alarm[0].checked==true) {
		myMsgBox('5% discount Applies for Alarm');
		}
	}

function gulfmiles(){
	if (document.form1.gulf[0].checked==true) {
		document.getElementById("gulfloc").style.display="";
		}
	else {
		document.getElementById("gulfloc").style.display="none";
		}
	}

function coast(){
	if (document.form1.miles.value<=50) {
		myMsgBox("Because of location to Gulf or Atlantic Ocean, No EC coverage is provided")
		}
	else {
		myMsgBox("NO 1% Deductible Buyback is allowed because of location to Gulf or Atlantic Ocean")
		}
	}

function constructionchk() {
	if (document.form1.construct.selectedIndex==9) {
	  document.getElementById("MHMsg").style.display="";
		}
	else {
    document.getElementById("MHMsg").style.display="none";
		}
	}

function construction() {
	//if (document.form1.construct.selectedIndex==9) {
	if (document.form1.construct.value=='MH') {
		//myMsgBox("Mobile Homes must be without wheels, be on a permenent foundation, and be valued less than $100000");
		myMsgBox("Mobile Homes must be without wheels, be on a permenent foundation. Mobile Home must also be submited to company for approval. Risk in mobile home park prohibited.");
		}
	//if (document.form1.construct.selectedIndex==9) {
	if (document.form1.construct.value=='FH') {
		//myMsgBox('Manufactured Homes must be on a permenent foundation, be less than $100000 and less than 15 years old');
		myMsgBox('Manufactured Homes must be on a permenent foundation and less than 15 years old');
		}
	//if (document.form1.typestruct[2].checked==true && document.form1.construct.selectedIndex==9) {
	if (document.form1.typestruct[2].checked==true && document.form1.construct.value=='MH') {
		myMsgBox('Tenant Dwelling for Mobile Homes is not acceptable');
		document.form1.construct.value="FR";
		}
	}

function pigtailChk() {
	if (document.getElementById("pigtailedN").checked) {
		window.alert("We can't write non pigtailed wiring");
		}
	}


function myMsgBox(msg) {
	if (1==0) {
		stats ='toolbar=no,location=no,directories=no,status=no,menubar=no,'
		stats+= 'scrollbars=no,resizable=no,width=500,height=200'
		MsgBox = window.open ("","msgWindow",stats)
		MsgBox.document.write ("<BODY bgColor='yellow' text='black'>")
		MsgBox.document.write ("<H3><CENTER>",msg,"</CENTER></H3>")
		MsgBox.document.write ("<FORM><CENTER>")
		MsgBox.document.write ("<INPUT type='button' value='OK' onClick = 'self.close()'>")
		MsgBox.document.write ("</CENTER></FORM>")
		}
	else {
    //msg = '<div style="color:#000;text-align:center;"><h3>'+msg+'</h3></div>';
		revealModal(msg);
		}
	}

function chkclaim() {
	if (document.form1.claimamt.value>1000) {
		window.alert("You must submit before releasing to Insured because of claims");
		}
	}

function rentercheck()  {
	if (document.form1.policytype.value==1 && document.form1.typestruct.value==3) {
		window.alert("Liability is not offered on Rented to Others");
		document.form1.policytype.value=2;
		}
	}

function payments() {
	if (document.form1.state.value!="TX" && document.form1.payment.value==4) {
		window.alert("Direct Bill is not setup for this state");
		}
	}

function chkaddress(){
	//var objwindows=window.open("address.html",null,"height=300,toolbar=no,menubar=no,status=no,location=no")
	//myMsgBox('To avoid any additional inspection fees, please type the correct 911/ Physical Risk Address');
	//document.form1.insured.select();
	//document.form1.insured.focus();
	//<h1>Physical Risk Address</h1>
	//<h2><font color="red">To avoid any additional inspection fees, please type the correct 911/ Physical Risk Address</font></h2>Click on upper right X to close window</body></html>
	}

function chkpob(){
	var x;
	var tn="PO BOX";
	var cc=document.form1.address.value
	cc=cc.toUpperCase();
	x=cc.search(tn);
	if (x>-1) {
		window.alert("Post Office Boxes are not allowed for Physical/ 911 Risk Location Address");
		document.form1.address.focus();
		}
	var tn="P.O. BOX";
	var cc=document.form1.address.value
	cc=cc.toUpperCase();
	x=cc.search(tn);
	if (x>-1) {
		window.alert("Post Office Boxes are not allowed for Physical/ 911 Risk Location Address");
		document.form1.address.value="";
		document.form1.address.select();
		document.form1.address.focus();
		}
	var tn="P BOX";
	var cc=document.form1.address.value
	cc=cc.toUpperCase();
	x=cc.search(tn);
	if (x>-1) {
		window.alert("Post Office Boxes are not allowed for Physical/ 911 Risk Location Address");
		document.form1.address.value="";
		document.form1.address.select();
		document.form1.address.focus();
		}
	var tn="P O B";
	var cc=document.form1.address.value
	cc=cc.toUpperCase();
	x=cc.search(tn);
	if (x>-1) {
		window.alert("Post Office Boxes are not allowed for Physical/ 911 Risk Location Address");
		document.form1.address.value="";
		document.form1.address.select();
		document.form1.address.setfocus();
		}
	var tn="POB";
	var cc=document.form1.address.value
	cc=cc.toUpperCase();
	x=cc.search(tn);
	if (x>-1) {
		window.alert("Post Office Boxes are not allowed for Physical/ 911 Risk Location Address");
		document.form1.address.value="";
		document.form1.address.select();
		document.form1.address.focus();
		}
	}

function cover(){
	indexnum=document.form1.coverage.selectedIndex;
	if (document.form1.policytype[5].checked==true && indexnum==1) {
		window.alert("RC is not available on HOC, changing to ACV");
		document.form1.coverage.value="ACV";
		}

	second4();
	return true;
	}

function ChangeTitle(newtitle) {
	//var newtitle = document.form1.newtitle.value;
	var head1 = document.getElementById("popuptext");
	if (head1.hasChildNodes) {
		//head1.firstChild.nodeValue=newtitle;
		head1.innerHTML=newtitle;
		}
	}

function hover(event,id){
	var t;
	t="";
	if (id==0) {
	
	}

	if (id==1) {
	  //  msgWindow = window.open('','newWin','width=500,height=250,screenX=400,screenY=200,top=200,left=400');
	  //  msgWindow.location.href = 'dwellingfire.html';
	  
		t="<span class='bubble	_tooltip_title'>DWELLING FIRE</span>";
		t+="<span class='bubble_tooltip_body'>PERILS: FIRE, EC, VMM</br>";
		t+="LIMITS:  BLDG $500,000</br>";
		t+="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CONTENTS - Up to 40%</br>";
		t+="VALUATION: ACV</br>";
		t+="RATING: MANUAL +25%</br>";
		t+="LIABILITY: $0 to $300,000</span>";

		showIt(event,t);
		}

	if (id==2) {
    //msgWindow = window.open('','newWin','width=500,height=250,screenX=400,screenY=200,top=200,left=400');
    //msgWindow.location.href = 'dwellingfire.html';
		t="<span class='bubble_tooltip_title'>DWELLING FIRE</span>";
		t+="<span class='bubble_tooltip_body'>PERILS: FIRE, EC, VMM</br>";
		t+="LIMITS:  BLDG $500,000</br>";
		t+="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CONTENTS - Up to 40%</br>";
		t+="VALUATION: ACV</br>";
		t+="RATING: MANUAL +25%</br>";
		t+="LIABILITY: $0 to $300,000</span>";

		showIt(event,t);
		}

	if (id==3) {
    //msgWindow = window.open('','newWin','width=500,height=400,screenX=400,screenY=200,top=200,left=400');
    //msgWindow.location.href = 'hoa.html';

		t="<span class='bubble_tooltip_title'>HOA OR HO1</span>";
		t+="<span class='bubble_tooltip_body'>PERILS: FIRE, EC, VMM, BURGLARY</BR>";
		//t+="LIMITS:  BLDG $1,000,000</BR>";
		t+="LIMITS:  Bldg $25,000 to $500,000</br>";
		t+="CONTENTS - Up to 40%</BR>";
		t+="VALUATION: ACV or RC</BR>";
		t+="RATING: MANUAL +35%</BR>";
		t+="LIABILITY: $25,000 TO $300,000</BR>";
		t+="TO QUALIFY:  PC 1-9, AGE 0-100 YRS, ANY CONSTRUCTION, POOR TO EXCELLENT CREDIT.</BR>";
		t+="SUGGESTIONS:   MOST PEOPLE BUY THIS BASIC FORM</span>";

		showIt(event,t);
		}

	if (id==4) {
		//msgWindow = window.open('','newWin','width=500,height=400,screenX=400,screenY=200,top=200,left=400');
		//msgWindow.location.href = 'hob.html';
		
		t="<span class='bubble_tooltip_title'>HOB OR HO2</span>";
		t+="<span class='bubble_tooltip_body'>PERILS: ALL RISK BUILDING, BROAD NAMED PERILS INCLUDING WATER DAMAGE AND BURGLARY ON CONTENTS.</br> ";
		//t+="LIMITS:  BLDG $1,000,000</br>";
		t+="LIMITS:  Bldg $25,000 to $500,000</br>";
		t+="CONTENTS $500,000</br>";
		t+="VALUATION: ACV OR RC</br>";
		t+="RATING: MANUAL +25%</br>";
		t+="LIABILITY: $25,000 TO $300,000</br>";
		t+="TO QUALIFY:  PC 1-9, AGE 0-50 YRS, ANY CONSTRUCTION, GOOD CREDIT</br>";
		t+="SUGGESTIONS:   BROAD FORM FOR MOST OF YOUR BETTER HOMES</span>";

		showIt(event,t);
		}

	if (id==5) {
		//msgWindow = window.open('','newWin','width=500,height=400,screenX=400,screenY=200,top=200,left=400');
		//msgWindow.location.href = 'ho8sub.html';
		t="<span class='bubble_tooltip_title'>HO8 Limited Substandard</center></span>";
		t+="<span class='bubble_tooltip_body'>PERILS: FIRE, EC, VMM, $1000 BURGLARY</br>";
		t+="LIMITS:  BLDG $250,000</br>";
		t+="CONTENTS - Up to 30%</br>";
		t+="VALUATION: ACV</br>";
		t+="RATING: MANUAL +50%</br>";
		t+="LIABILITY: $25,000</br> ";
		t+="TO QUALIFY:  PC 1-9, AGE 0-100 YRS, ANY CONSTRUCTION, POOR  CREDIT. OR CLAIMS</br>";
		t+="SUGGESTIONS:   FOR CLIENTS WITH TOO MANY CLAIMS OR POOR CREDIT.</span>";

		showIt(event,t);
		}

	if (id==6) {
		//msgWindow = window.open('','newWin','width=500,height=400,screenX=400,screenY=200,top=200,left=400');
		//msgWindow.location.href = 'ho8.html';
		t="<span class='bubble_tooltip_title'>HO8 Limited Prefered</span>";
		t+="<span class='bubble_tooltip_body'>PERILS: FIRE, EC, VMM, $1000 BURGLARY</BR>";
		t+="LIMITS:  BLDG $500,000</BR>";
		t+="CONTENTS - Up to 30%</BR>";
		t+="VALUATION: ACV</BR>";
		t+="RATING: MANUAL +35%</BR>";
		t+="LIABILITY: $25,000 TO $300,000</BR>";
		t+="TO QUALIFY:  PC 1-9, AGE 0-100 YRS, ANY CONSTRUCTION, POOR TO EXCELLENT CREDIT.</BR>";
		t+="SUGGESTIONS:   FOR INSURED THAT WANT A INEXPENSIVE HO POLICY OR HAVE POOR CREDIT.</span>";

		showIt(event,t);
		}

	if (id==7) {
		//msgWindow = window.open('','newWin','width=500,height=400,screenX=400,screenY=200,top=200,left=400');
		//msgWindow.location.href = 'hoc.html';
		t="<span class='bubble_tooltip_title'>HOC OR HO3</span>";
		t+="<span class='bubble_tooltip_body'>PERILS: ALL RISK BUILDING  AND CONTENTS.</br>";
		//t+="LIMITS:  BLDG $1,000,000</br>";
		t+="LIMITS:  Bldg $200,000 to $500,000</br>";
		t+="CONTENTS - Up to 65%</br>";
		t+="VALUATION: RC</br>";
		t+="RATING: MANUAL +25%</br>";
		t+="LIABILITY: $25,000 TO $300,000</br>";
		t+="TO QUALIFY:  PC 1-5, AGE 0-35 YRS,  BEST CONSTRUCTION, GREAT CREDIT</br>";
		t+="SUGGESTIONS:   BROADEST FORM FOR YOUR BEST AND LARGEST HOMES.</span>";
		
		showIt(event,t);
		}

	if (id==8) {
		//msgWindow = window.open('','newWin','width=500,height=400,screenX=400,screenY=200,top=200,left=400');
		//msgWindow.location.href = 'hoaplus.html';
		
		t="<span class='bubble_tooltip_title'>HOA PLUS OR HO1  PLUS</span>";
		t+="<span class='bubble_tooltip_body'>PERILS: FIRE, EC, VMM, BURGLARY PLUS $5000 WATER DAMAGE</br>";
		//t+="LIMITS:  BLDG $1,000,000</br>";
		t+="LIMITS:  Bldg $25,000 to $500,000</br>";
		t+="CONTENTS - Up to 40%</br>";
		t+="VALUATION: ACV</br>";
		t+="RATING: MANUAL +25%</br>";
		t+="LIABILITY: $25,000 TO $300,000</br>";
		t+="TO QUALIFY:  PC 1-9, AGE 0-100 YRS, ANY CONSTRUCTION, GOOD TO EXCELLENT CREDIT.</br>";
		t+="SUGGESTIONS:   MOST PEOPLE BUY THIS BASIC FORM</span>";
		
		showIt(event,t);
		}

	if (id==9) {
		//msgWindow = window.open('','newWin','width=500,height=400,screenX=400,screenY=200,top=200,left=400');
		//msgWindow.location.href = 'hoapremier.html';
		
		t="<span class='bubble_tooltip_title'>HOA PREMIER OR HO1 PREMIER</span>";
		t+="<span class='bubble_tooltip_body'>PERILS: FIRE, EC, VMM, BURGLARY</br>";
		//t+="LIMITS:  BLDG $1,000,000</br>";
		t+="LIMITS:  Bldg $25,000 to $500,000</br>";
		t+="CONTENTS - Up to 40%</br>";
		t+="VALUATION: ACV</br>";
		t+="RATING: Very Competitive</br>";
		t+="LIABILITY: $25,000 TO $300,000</br>";
		t+="TO QUALIFY:  PC 1-6, AGE 0-35 YRS, GOOD  CONSTRUCTION, GREAT OR EXCELLENT CREDIT, NO CLAIMS.</br>";
		t+="SUGGESTIONS:   MOST PEOPLE BUY THIS BASIC FORM THAT HAVE GOOD CREDIT AND NO CLAIMS.</span>";
		
		showIt(event,t);
		}

	if (id==10) {
		//msgWindow = window.open('','newWin','width=500,height=400,screenX=400,screenY=200,top=200,left=400');
		//msgWindow.location.href = 'hobpremier.html';
		
		t="<span class='bubble_tooltip_title'>HOB PREMIER OR HO2 PREMIER</span>";
		t+="<span class='bubble_tooltip_body'>PERILS: ALL RISK BUILDING, BROAD NAMED PERILS INCLUDING UP TO $25,000 WATER DAMAGE";
		t+="AND BURGLARY ON CONTENTS.</BR> ";
		//t+="LIMITS:  BLDG $1,000,000</BR>";
		t+="LIMITS:  Bldg $25,000 to $500,000</br>";
		t+="CONTENTS - Up to 50%</BR>";
		t+="VALUATION: ACV OR RC</BR>";
		t+="RATING: Very Competitive</BR>";
		t+="LIABILITY: $25,000 TO $300,000</BR>";
		t+="TO QUALIFY:  PC 1-5, AGE 0-35 YRS, BEST CONSTRUCTION, GREAT CREDIT, NO CLAIMS</BR>";
		t+="SUGGESTIONS:   BROAD FORM FOR MOST OF YOUR BETTER HOMES</span>";
		
		showIt(event,t);
		}
	}


function showIt(event,t) {
	//ChangeTitle(t);
	//document.getElementById("styled_popup").style.display="block";
	showToolTip(event,t);
	}

function nohover(id) {
	//document.getElementById("styled_popup").style.display = "none";
	hideToolTip();
	//msgWindow.close();
	}

function selectpolicy() {
	if (document.getElementById("policy").style.display=='') {
		document.getElementById("policy").style.display="none";
		}
	else {
		document.getElementById("policy").style.display='';
		}
	}

function liab() {
	indexnum=document.form1.liability.selectedIndex;
	
	if ((document.form1.typestruct[2].checked==true || document.form1.typestruct[3].checked==true) && (indexnum>4)) {
		window.alert("Maximum $300,000 on Rental Dwellings");
		document.form1.liability.value="300000";
		}
	if (indexnum==6 && document.form1.buildamt.value<250000) {
		window.alert("$1,000,000 Liability is only availble if building is valued at least $250,000");
		document.form1.liability.value=500000;
		}
	}

function downloaddata(){
	marqueedata.startDownload(externalmarquee.src,displaydata)
	}

function displaydata(data){
	externalmarquee.innerHTML=data;
	window.onload=downloaddata;
	}

function displayFloodNotice(setVisible) {
	if (setVisible) {
			document.getElementById("floodnotice").style.display="inline";
			}
		else {
			document.getElementById("floodnotice").style.display="none";
		}
	}
	
function stringTrim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}


/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}

function checkform() {
	return chkeffdate();
	}