function tab1()
{

  if(document.frm.hp1.value.length==3)
   {
	document.frm.hp2.focus()
	return
    }
}

function tab2()
{

  if(document.frm.hp2.value.length==3)
   {
	document.frm.hp3.focus()
	return
    }
}

function tab3()
{
   if(document.frm.wp1.value.length==3)
   {
	document.frm.wp2.focus()
	return
    }
}
function tab4()
{
    if(document.frm.wp2.value.length==3)
   {
	document.frm.wp3.focus()
	return
    }

}
/*function //SetErrorImage(strFieldName, blnIsError)
{
	if (blnIsError)
	{
		eval("document.frm."+strFieldName+"_ErrImg.src = \"images/star.gif\"");
	}
	else
	{
	eval("document.frm."+strFieldName+"_ErrImg.src = \"images/blnk.gif\"");
	}

}*/

function Validate()
{
      
if (document.frm.InsuranceType.selectedIndex=="")
	{
		alert("Please select the type of Insurance");
		////SetErrorImage("InsuranceType", true);

		document.frm.InsuranceType.focus();
		return;
	}
	else
    {
    	////SetErrorImage("InsuranceType", false);
	}


 if(document.frm.SubCategories.selectedIndex=="")
    {
	alert("Please select SubCategories Type");
	////SetErrorImage("SubCategories", true);
	document.frm.SubCategories.focus();
	return;
    }

if (document.frm.InsuranceType.value == "Long Term Care Insurance"||"Annuities Insurance"||"Health Insurance"||"Disability Insurance"||"Home Insurance"||"Auto Insurance"||"Life Insurance")
{
  if(document.frm.FName.value=="")
	{
		alert("Please enter your First Name ");
		//SetErrorImage("FName", true);
		document.frm.FName.select();
		document.frm.FName.focus();
		return;
	}
	else
    	{
    	//SetErrorImage("FName", false);
	}
	if(document.frm.LName.value=="")
	{
		alert("Please enter your Last Name ");
		//SetErrorImage("FName", true);
		document.frm.LName.select();
		document.frm.LName.focus();
		return;
	}
	else
    	{
    	//SetErrorImage("FName", false);
	}

	
	if(document.frm.month.value=="")
	{
		alert("Please enter Month in your Date of Birth ");
		//SetErrorImage("LName", true);
		
		document.frm.month.focus();
		return;
	}
	if(document.frm.day.value=="")
	{
		alert("Please enter date in your Date of Birth ");
		//SetErrorImage("LName", true);
		
		document.frm.day.focus();
		return;
	}
	if(document.frm.year.value=="")
	{
		alert("Please enter year in your Date of Birth ");
		//SetErrorImage("LName", true);
		document.frm.year.focus();
		return;
	}
	if (isNaN(document.frm.year.value))
	{
		alert("Please enter Valid Numeric  year in your Date of Birth ");
		//SetErrorImage("LName", true);
		document.frm.year.select();
		document.frm.year.focus();
		return;
	}
	
	if (document.frm.year.value.length != 4)
	{
		alert("Please enter  valid Four digit year in your Date of Birth ");
		//SetErrorImage("LName", true);
		document.frm.year.select();
		document.frm.year.focus();
		return;
	}
	
		if (document.frm.hp1.value=="" )
	{
		alert("Please enter your home phone number");
		//SetErrorImage("hp1", true);
		document.frm.hp1.select();
		document.frm.hp1.focus();
		return;
	}
	else
    {
    	//SetErrorImage("hp1", false);
	}


	  	if (document.frm.hp1.value=="" )
	{
		alert("Please enter your home phone number");
		//SetErrorImage("hp1", true);
		document.frm.hp1.select();
		document.frm.hp1.focus();
		return;
	}
   else
    {
    	//SetErrorImage("hp1", false);
	}
	  if(isNaN(document.frm.hp1.value))
	  {
	  	alert("Home phone number should be Numeric value");
		//SetErrorImage("hp1", true);
		document.frm.hp1.select();
		document.frm.hp1.focus();
		return;
	  }
	  else
    {
    	//SetErrorImage("hp1", false);
	}


	if(document.frm.hp2.value=="")
	{
		alert("Please enter your home phone number");
		//SetErrorImage("hp2", true);
		document.frm.hp2.select();
		document.frm.hp2.focus();
		return;
	}
	else
    {
    	//SetErrorImage("hp2", false);
	}

	  if(isNaN(document.frm.hp2.value))
	  {
	  	alert("Home phone number should be Numeric value");
		//SetErrorImage("hp2", true);
		document.frm.hp2.select();
		document.frm.hp2.focus();
		return;
	  }
	else
    {
    	//SetErrorImage("hp2", false);
	}

	if(document.frm.hp3.value=="")
	{
		alert("Please enter your home phone number");
		//SetErrorImage("hp3", true);
		document.frm.hp3.select();
		document.frm.hp3.focus();
		return;
	}
	else
    {
    	//SetErrorImage("hp3", false);
	}

	  if(isNaN(document.frm.hp3.value))
	  {
	  	alert("Home phone number should be Numeric value");
		//SetErrorImage("hp3", true);
		document.frm.hp3.select();
		document.frm.hp3.focus();
		return;
	  }
	  else
    {
    	//SetErrorImage("hp3", false);
	}


	if(document.frm.Email.value=="")
	{
   		alert("Please enter your Email ID");
		//SetErrorImage("Email", true);
		document.frm.Email.select();
		document.frm.Email.focus();
		return;
	}

	else
	{
	  var evalue=document.frm.Email.value;
      var emailPat = /^(\".*\"|\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
	  
	  var matchArray = evalue.match(emailPat);

		if(!emailPat.test(evalue))
		{
			alert("Your email address is invalid.  Please try again !!");
			//SetErrorImage("Email", true);
			document.frm.Email.select();
			document.frm.Email.focus();
  			return;
		}
		else
       {
    	//SetErrorImage("Email", false);
	   }
	}

	 if(document.frm.Street.value=="")
	{
   		alert("Please enter Street name");
		//SetErrorImage("Street", true);
		document.frm.Street.select();
		document.frm.Street.focus();
		return;
	}
	else
    {
    	//SetErrorImage("Street", false);
	}
      if(document.frm.City.value=="")
	  {
	  	alert("Please enter City name");
		//SetErrorImage("City", true);
		document.frm.City.select();
		document.frm.City.focus();
		return;
	  }
	  else
    {
    	//SetErrorImage("City", false);
	}
      if(document.frm.State.value=="")
	  {
	  	alert("Please select your state");
		//SetErrorImage("State", true);
	    document.frm.State.focus();
		return;
	  }
	  else
    {
    	//SetErrorImage("State", false);
	}
	if(	document.frm.Zip.value=="")
	{
	   alert(" Please Enter Zip");
	   document.frm.Zip.focus();
	   document.frm.Zip.select();
	   return false;
	}
	if(	isNaN(document.frm.Zip.value))
	{
	   alert(" Please Enter Valid Zip");document.frm.Zip.focus();
	   document.frm.Zip.select();
	   return false;
	}
	if(	document.frm.Zip.value.length<"5" || document.frm.Zip.value.length>"5")
	{
	   alert(" Please Enter Valid Zip");document.frm.Zip.focus();
	   document.frm.Zip.select();
	   return false;
	}
if(	document.frm.Zip.value=="00000")
	{
	   alert(" Please Enter Valid Zip");
	   document.frm.Zip.focus();
	   document.frm.Zip.select();
	   return false;
	}
	/*if (document.frm.Zip.value=="")
	{
		alert("Please enter Zipcode");
		//SetErrorImage("Zip", true);
		document.frm.Zip.select();
		document.frm.Zip.focus();
		return;
	}
	else
    {
    	//SetErrorImage("Zip", false);
	}

		if(isNaN(document.frm.Zip.value))
		{
			alert("Zip code should be Numeric value");
			//SetErrorImage("Zip", true);
			document.frm.Zip.select();
			document.frm.Zip.focus();
			return;
		}
		else
    {
    	//SetErrorImage("Zip", false);
	}
*/
  
	if (document.frm.InsuranceType.value == "Auto Insurance")
	{
	if (document.frm.claims.selectedIndex=="")
	{
		alert("Please select the type of Residency Status");
		////SetErrorImage("InsuranceType", true);
		document.frm.claims.focus();
		return;
	}
	
if ( ( document.frm.insured[0].checked == false )
    && ( document.frm.insured[1].checked == false ) )
    {
        alert ( "Select whether your Currently insuranced or not" );
		document.frm.insured[0].select();
		document.frm.insured[0].focus();
		return;
    }

if ( document.frm.insured[0].checked == true )
{
if (document.frm.comp_name.value=="")
	{
		alert("Please enter Company Name");
		//SetErrorImage("Zip", true);
		document.frm.comp_name.select();
		document.frm.comp_name.focus();
		return;
	}
if (document.frm.expmonth.selectedIndex=="")
	{
		alert("Please select the Expiration Month");
		////SetErrorImage("InsuranceType", true);

		document.frm.expmonth.focus();
		return;
	}
if (document.frm.expday.selectedIndex=="")
	{
		alert("Please select the Expiration Date");
		////SetErrorImage("InsuranceType", true);

		document.frm.expday.focus();
		return;
	}

if (document.frm.expyear.value=="year")
	{
		alert("Please enter the Expiration year");
		////SetErrorImage("InsuranceType", true);
		document.frm.expyear.select();
		document.frm.expyear.focus();
		return;
	}
	else
if(isNaN(document.frm.expyear.value))
	{
		alert(" Expiration year of Current Policy  should be numeric");
		document.frm.expyear.select();
		document.frm.expyear.focus();
		return;
	}
if (document.frm.mnts_comp.value=="")
	{
		alert("Please enter Number of Months with that Comapny");
		document.frm.mnts_comp.focus();
		return;
	}
else
if(isNaN(document.frm.mnts_comp.value))
	{
		alert(" Number of Months with that Comapny should be numeric");
		document.frm.mnts_comp.select();
		document.frm.mnts_comp.focus();
		return;
	}


}

if ( document.frm.insured[1].checked == true )
{

if (document.frm.notinsured_years.value=="")
	{
		alert("Please enter Number of years you had not been Insured ");
		document.frm.notinsured_years.focus();
		return;
	}
	
	else
if(isNaN(document.frm.notinsured_years.value))
	{
		alert(" Number of years you had not been Insured should be numeric");
		document.frm.notinsured_years.select();
		document.frm.notinsured_years.focus();
		return;
	}
	
if (document.frm.reason.value=="")
	{
		alert("Please enter Reason for not being Insured ");
		document.frm.reason.focus();
		return;
	}

}

if (document.frm.Current_policy_liablility.selectedIndex=="")
	{
		alert("Please select Current policy liablility limits");
		document.frm.Current_policy_liablility.focus();
		return;
	}

if (document.frm.Age_First_licensed.value=="")
	{
		alert("Please enter Age First licensed  ");
		document.frm.Age_First_licensed.focus();
		return;
	}
	else
if(isNaN(document.frm.Age_First_licensed.value))
	{
		alert(" Age First licensed should be numeric");
		document.frm.Age_First_licensed.select();
		document.frm.Age_First_licensed.focus();
		return;
	}

if (document.frm.fyear.value=="year")
	{
		alert("Please enter Year of vehicle insured  ");
		document.frm.fyear.select();
		document.frm.fyear.focus();
		return;
	}
	else
if(isNaN(document.frm.fyear.value))
	{
		alert(" Year of vehicle insured should be numeric");
		document.frm.fyear.select();
		document.frm.fyear.focus();
		return;
	}
	
if (document.frm.make.value=="make")
	{
		alert("Please enter Make of vehicle insured ");
		document.frm.make.select();
		document.frm.make.focus();
		return;
	}
if (document.frm.model.value=="model")
	{
		alert("Please enter Model of vehicle insured  ");
        document.frm.model.select();
		document.frm.model.focus();
		return;
	}
     	//SetErrorImage("SubCategories", false);
     }
}

//start life insurance
if (document.frm.InsuranceType.value == "Life Insurance")
{

	if(document.frm.weight.value=="")
	{
		alert("Please Enter \' weight '\ ");
		//SetErrorImage("LName", true);
		document.frm.weight.select();
		document.frm.weight.focus();
		
		return;
	}

	if(document.frm.Occupation.value=="")
	{
		alert("Please Select \' Occupation '\ ");
		//SetErrorImage("LName", true);
		//document.frm.Occupation.select();
		document.frm.Occupation.focus();
		
		return;
	}

if(document.frm.smoker.value=="")
	{
		alert("Please select \' Is Any Applicant A Smoker '\ ");
		//SetErrorImage("LName", true);
		document.frm.smoker.focus();
		return;
	}


  if ( ( document.frm.ratedordeclined[0].checked == false )
    && ( document.frm.ratedordeclined[1].checked == false ) )
    {
        alert ( "Please Check \' Have you been rated or declined for health or life insurance in the last 5 years?'\ " );
		document.frm.ratedordeclined[0].select();
		document.frm.ratedordeclined[0].focus();
		return;
    }

if ( ( document.frm.hospitalized[0].checked == false )
    && ( document.frm.hospitalized[1].checked == false ) )
    {
        alert ( "Please Check \' Have you been hospitalized in the last 5 years?'\ " );
		document.frm.hospitalized[0].select();
		document.frm.hospitalized[0].focus();
		return;
    }

if ( ( document.frm.dui[0].checked == false )
    && ( document.frm.dui[1].checked == false ) )
    {
        alert ( "Please Check \' Have you had a DUI/DWI in the last 5 years? '\ " );
		document.frm.dui[0].select();
		document.frm.dui[0].focus();
		return;
    }

if ( ( document.frm.resident[0].checked == false )
    && ( document.frm.resident[1].checked == false ) )
    {
        alert ( "Please Check \' Have you been a resident of the U.S. or Canada for the last 12 months? '\ " );
		document.frm.resident[0].select();
		document.frm.resident[0].focus();
		return;
    }

if ( ( document.frm.meds[0].checked == false )
    && ( document.frm.meds[1].checked == false ) )
    {
        alert ( "Please Check \' Do you currently take prescription medications? '\ " );
		document.frm.meds[0].select();
		document.frm.meds[0].focus();
		return;
    }

if ( ( document.frm.meds[0].checked == true )
    && ( document.frm.medsdes.value == "" ) )
    {
        alert ( "Please Enter \' If yes, please list medication names and dosages: '\ " );
		document.frm.medsdes.select();
		document.frm.medsdes.focus();
		return;
    }

if(document.frm.insnow.value=="")
	{
		alert("Please select \' Do you currently have a life insurance? '\ ");
		//SetErrorImage("LName", true);
		document.frm.insnow.focus();
		return;
	}

if((document.frm.insnow.value=="Yes") && ( document.frm.currentco.value == "" ) )
	{
		alert("Please select \' If so, with what company? '\ ");
		//SetErrorImage("LName", true);
		document.frm.currentco.focus();
		return;
	}

if(document.frm.spouse.value=="")
	{
		alert("Please select \' Do you want coverage for your spouse? '\ ");
		//SetErrorImage("LName", true);
		document.frm.spouse.focus();
		return;
	}

if(document.frm.children.value=="")
	{
		alert("Please select \' Do you want coverage for your children? '\ ");
		//SetErrorImage("LName", true);
		document.frm.children.focus();
		return;
	}

if ( ( document.frm.instype[0].checked == false )
    && ( document.frm.instype[1].checked == false ) && ( document.frm.instype[2].checked == false )  )
    {
        alert ( "Please Check \' What type of life insurance coverage are you interested in? '\ " );
		document.frm.instype[0].select();
		document.frm.instype[0].focus();
		return;
    }

if ( ( document.frm.instype[0].checked == true ) )
	{

if(document.frm.coverage1.value=="")
	{
		alert("Please select \' Term Coverage '\ ");
		//SetErrorImage("LName", true);
		document.frm.coverage1.focus();
		return;
	}

if(document.frm.option1.value=="")
	{
		alert("Please select \' Term Option '\ ");
		//SetErrorImage("LName", true);
		document.frm.option1.focus();
		return;
	}
	}

if ( ( document.frm.instype[1].checked == true ) )
	{

if(document.frm.coverage2.value=="")
	{
		alert("Please select \' Permanent Coverage '\ ");
		//SetErrorImage("LName", true);
		document.frm.coverage2.focus();
		return;
	}

if(document.frm.option2.value=="")
	{
		alert("Please select \' Permanent Option '\ ");
		//SetErrorImage("LName", true);
		document.frm.option2.focus();
		return;
	}


	}


if ( ( document.frm.instype[2].checked == true ) )
	{

if(document.frm.coverage3.value=="")
	{
		alert("Please select \' Other / Not Sure -  Coverage '\ ");
		//SetErrorImage("LName", true);
		document.frm.coverage3.focus();
		return;
	}
	}


if(document.frm.contacttime.value =="")
	{
		alert("Please select \' Best Time to Contact You '\ ");
		//SetErrorImage("LName", true);
		document.frm.contacttime.focus();
		return;
	}

if(document.frm.soonPolicy.value =="")
	{
		alert("Please select \' How soon do you need this policy? '\ ");
		//SetErrorImage("LName", true);
		document.frm.soonPolicy.focus();
		return;
	}

	}

 //end of  life insurance validation part

	var mail=document.frm.Email.value;
	if(confirm(""+mail+"\n Confirm Your email address!!")==false)
	{
	  //SetErrorImage("Email", true);
	  document.frm.Email.select();
	  document.frm.Email.focus();
	  return;
	}
	else
    {
    	//SetErrorImage("Email", false);
	}
	document.frm.method="post";
	document.frm.action="getquoteinsert.php"
	document.frm.submit();
}
