function OpenNewForm(theForm)
{
 var myRef ;
 var strURL = ""; 
 
  strURL = "http://houseinsurancecc.com/Common/Landing.php";
     strURL = strURL + "?zip=" + document.getElementById('zip').value;
     if(document.getElementById('InsuranceType').value=='Auto' || document.getElementById('InsuranceType').value =='Home')
     {
  strURL = strURL + "&refby=620215";
     }
     else
     {
   strURL = strURL + "&refby=620215";  	
     }
     

 var strInsChecked='';	

 
    strURL = strURL + "&type=" + document.getElementById('InsuranceType').value;
	
    if(document.getElementById('InsuranceType').value=='Life')	
	strURL = 'life-popup.php?zip_code='+document.getElementById('zip').value;
	if(document.getElementById('InsuranceType').value=='Health')	
		{
			datetimepopup(strURL);
		}
		else{	
	  window.open(strURL,null,"fullscreen=yes, toolbars=yes, scrollbars=yes, menubar=yes, location=yes, width=1000,height=900");
	//}
	}
}


function redirect(theForm) 
{
	var strErr = "";

	if(document.getElementById('zip').value=="")
	{
		strErr = strErr + "Please enter zip code.\n";
		theForm.ZipCode.focus();
	}

     if (strErr != "")
     {
           alert(strErr);
           return false;
     }
     else
    {

		if(document.getElementById('InsuranceType').value =="0")
        	{
			    window.location="auto_results.html?zipcode=" + document.getElementById('zip').value;
	        }
		if(document.getElementById('InsuranceType').value =="1")
        	{
//			     datetimeredirection();	
				window.location='health_results.html?zipcode='+document.getElementById('zip').value;
	        }
		if(document.getElementById('InsuranceType').value =="2" || document.getElementById('InsuranceType').value =="4")
        	{
			    window.location="home_results.html?zipcode=" + document.getElementById('zip').value;
		}
		if(document.getElementById('InsuranceType').value =="3")
        	{
			    window.location="life_results.html?zipcode=" + document.getElementById('zip').value;
            	}	
        //window.location="auto_results.html?zipcode=" + document.getElementById('zip').value;	
     }
}

function ValidateForm(theForm)
{
	var strErr = "";
//	alert(theForm.InsuranceType.value);
	if(theForm.InsuranceType.value=="")
	{
		strErr = strErr + "Please select insurance type.\n";
		theForm.InsuranceType.focus();
	}
	
	if(theForm.ZipCode.value=="")
	{
		strErr = strErr + "Please enter zip code.\n";
		theForm.ZipCode.focus();
	}
	else
        {        
          if(theForm.ZipCode.value.length!=5)
        	{
          		strErr = strErr + "Please enter valid zip code.\n";
        		theForm.ZipCode.focus();
        	}
        }


     if (strErr != "")
     {
           alert(strErr);
           return false;
     }
     else
    {
           OpenNewForm(theForm);
     }
}	


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}



function datetimeredirection()
{
	var now = new Date();
	var hr= eval(now.getHours());
	var dday= eval(now.getDay());
	//Condition for 9AM to 6PM and Monday to Friday- LeadCo
//	alert(hr);
//	alert(dday);
	if ((hr>=9 && hr<18) && (dday>=1 && dday<=5))	 
	window.location='health-popup.php?zip_code='+document.getElementById('zip').value;
	else  
	window.location='health_results.html?zipcode='+document.getElementById('zip').value;
}

function datetimepopup(strURL)
{
	var now = new Date();
	var hr= eval(now.getHours()); 
	var dday= eval(now.getDay());
//	alert(hr);
//	alert(dday);
	if ((hr>=9 && hr<18) && (dday>=1 && dday<=5))	//Condition for 9AM to 6PM and Monday to Friday- LeadCo	
	{
	}
	else{
		window.open(strURL,null,"fullscreen=yes, toolbars=yes, scrollbars=yes, menubar=yes, location=yes, width=1000,height=900");
	}
}


