function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
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 hello()
{
data="";

if (document.frm.InsuranceType.value == "Auto Insurance")
{
   document.getElementById("pop").style.display="";
}
else{
	 document.getElementById("pop").style.display="none";
}
}

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.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("LName", true);
		document.frm.LName.select();
		document.frm.LName.focus();
		return;
	}
	else
    {
    	//SetErrorImage("LName", 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 (document.frm.hp1.value=="" )
	{
		alert("Please enter your home phone number");
		//SetErrorImage("hp1", true);
		document.frm.hp1.select();
		document.frm.hp1.focus();
		return;
	}
   else
    {
    	
	  if(isNaN(document.frm.hp1.value))
	  {
	  	//alert(document.frm.hp1.value);
		alert("Home phone number should be Numeric value");
		alert("document.getElementsByName('hp1')[0].value.length");
		//SetErrorImage("hp1", true);
		document.frm.hp1.select();
		document.frm.hp1.focus();
		return;
	  }
	  
if (document.getElementsByName("hp1")[0].value.length <3 )
	{
		alert("Please enter Valid  home phone number");
		//SetErrorImage("hp1", true);
		document.frm.hp1.select();
		document.frm.hp1.focus();
		return;
	}
	phoneval=document.getElementsByName("hp1")[0].value
var phonePat=/^\d{3}$/;
var matchArray = phoneval.match(phonePat);
if(!phonePat.test(phoneval))
{
	   alert("Please Enter a Valid Phone Number ");
	 document.getElementsByName("hp1")[0].focus();
     return 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
    {
    	

	  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;
	  }
	  if (document.getElementsByName("hp2")[0].value.length <3 )
	{
		alert("Please enter Valid  home phone number");
		//SetErrorImage("hp1", true);
		document.frm.hp2.select();
		document.frm.hp2.focus();
		return;
	}
	phoneval=document.getElementsByName("hp2")[0].value
var phonePat=/^\d{3}$/;
var matchArray = phoneval.match(phonePat);
if(!phonePat.test(phoneval))
{
	   alert("Please Enter a Valid Phone Number ");
	 document.getElementsByName("hp2")[0].focus();
     return 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;
	}
	
	  if (document.getElementsByName("hp3")[0].value.length <4 )
	{
		alert("Please enter Valid  home phone number");
		//SetErrorImage("hp1", true);
		document.frm.hp3.select();
		document.frm.hp3.focus();
		return;
	}
	
	phoneval=document.getElementsByName("hp3")[0].value
var phonePat=/^\d{4}$/;
var matchArray = phoneval.match(phonePat);
if(!phonePat.test(phoneval))
{
	   alert("Please Enter a Valid Phone Number ");
	 document.getElementsByName("hp3")[0].focus();
     return false;

}
	  
var emailID=document.frm.Email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		//emailID.value=""
		emailID.focus()
		return 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;
	}
	
	zipval=document.getElementsByName("Zip")[0].value
var zipPat=/^\d{5}$/;
var matchArray = zipval.match(zipPat);
if(!zipPat.test(zipval))
{
	   alert("Please Enter a Valid Zip  Number ");
	 document.getElementsByName("Zip")[0].focus();
     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.getElementById("bst_time").value=="")
	{
		alert("Please select \' Best Time to Contact You '\ ");
		//SetErrorImage("LName", true);
		
		document.getElementById("bst_time").focus();
		return;
	}
  
	if (document.frm.InsuranceType.value == "Auto Insurance")
	{
	//	alert("hai");
	//	alert(document.getElementById("hasins").value);
	 if (document.getElementById("hasins").value=="")
	{
		alert("Please select \' Are you currently insured '\ ");
		////SetErrorImage("InsuranceType", true);
		document.getElementById("hasins").focus();
		return;
	}
     
if (document.getElementById("hasins").value=="1") 
{
	 //start
	 	if (document.getElementById("timenolapse").value=="")
	{
		alert("Please select \' How long have you continuously had auto insurance  '\ ");
		////SetErrorImage("InsuranceType", true);
		//document.getElementById("timenolapse.select();
		document.getElementById("timenolapse").focus();
		return;
	}
 if (document.getElementById("insco").value == "n/a")
	{
		alert("Please select \' Name of your insurance company '\ ");
		////SetErrorImage("InsuranceType", true);
		document.getElementById("insco").focus();
		return;
	}

if (document.getElementById("timewith").value=="")
	{
		alert("Please select \' How long have you had auto insurance with this company '\ ");
		////SetErrorImage("InsuranceType", true);
		document.getElementById("timewith").focus();
		return;
	}
//plocirenew
if (document.getElementById("policy_renew_mnt").value=="")
	{
		alert("Please select \' your policy renew Month '\ ");
		////SetErrorImage("InsuranceType", true);
		document.getElementById("policy_renew_mnt").focus();
		return;
	}

if (document.getElementById("policy_renew_day").value=="")
	{
		alert("Please select \' your policy renew Day '\ ");
		////SetErrorImage("InsuranceType", true);
		document.getElementById("policy_renew_day").focus();
		return;
	}

if (document.getElementById("policy_renew_year").value=="")
	{
		alert("Please select \' your policy renew Year '\ ");
		////SetErrorImage("InsuranceType", true);
		document.getElementById("policy_renew_year").focus();
		return;
	}
if (document.getElementById("curre_pay_2_ins").value=="")
	{
		alert("Please select \' How much do you currently pay for your insurance '\ ");
		////SetErrorImage("InsuranceType", true);
		document.getElementById("curre_pay_2_ins").select();
		document.getElementById("curre_pay_2_ins").focus();
		return;
	}

if(isNaN(document.getElementById("curre_pay_2_ins").value))
	{
		alert(" Please Enter the Valid numeric Value for  Currently Pay Insurance ");
		document.getElementById("curre_pay_2_ins").select();
		document.getElementById("curre_pay_2_ins").focus();
		return;
	}  


if (document.getElementById("howoften").value=="")
	{
		alert("Please select \' How often do you pay that premium? '\ ");
		////SetErrorImage("InsuranceType", true);
		//document.frm.howoften.select();
		document.getElementById("howoften").focus();
		return;
	}

if (document.frm.currentliab.value=="")
	{
		alert("Please select \' what is your current liability limit? '\ ");
		////SetErrorImage("InsuranceType", true);
		//document.frm.currentliab.select();
		document.frm.currentliab.focus();
		return;
	}



//end

}

if (document.getElementById("prefliab").value=="")
	{
		alert("Please select \' How much  coverage would you like to have?  '\ ");
		////SetErrorImage("InsuranceType", true);
		//document.getElementById("timenolapse.select();
		document.getElementById("prefliab").focus();
		return;
	}


if (document.getElementById("med").value=="")
	{
		alert("Please select \' How much  coverage would you like to have for Medical Payments?  '\ ");
		////SetErrorImage("InsuranceType", true);
		//document.getElementById("timenolapse.select();
		document.getElementById("med").focus();
		return;
	}







//liabbility form
if (document.getElementById("housing").value=="")
	{
		alert("Please select \' Do your own your own home?  '\ ");
		////SetErrorImage("InsuranceType", true);
		//document.getElementById("timenolapse.select();
		document.getElementById("housing").focus();
		return;
	}




if (document.getElementById("timeat").value=="")
	{
		alert("Please select \' How long have you been at your current address  '\ ");
		////SetErrorImage("InsuranceType", true);
		//document.getElementById("timenolapse.select();
		document.getElementById("timeat").focus();
		return;
	}

if (document.getElementById("credit").value=="")
	{
		alert("Please select \' How would you describe your credit history?  '\ ");
		////SetErrorImage("InsuranceType", true);
		//document.getElementById("timenolapse.select();
		document.getElementById("credit").focus();
		return;
	}


if (document.getElementById("income").value == "not given")
	{
		alert("Please select \' What is your approximate household income?  '\ ");
		////SetErrorImage("InsuranceType", true);
		//document.getElementById("timenolapse.select();
		document.getElementById("income").focus();
		return;
	}

//end of liability

//start of drivers information

if (document.getElementById("driver_Fname").value=="")
	{
		alert("Please Enter \' Driver's First Name?  '\ ");
		////SetErrorImage("InsuranceType", true);
		document.getElementById("driver_Fname").select();;
		document.getElementById("driver_Fname").focus();
		return;
	}

if (document.getElementById("driver_Lname").value=="")
	{
		alert("Please Enter \' Driver's Last Name?  '\ ");
		////SetErrorImage("InsuranceType", true);
		document.getElementById("driver_Lname").select();;
		document.getElementById("driver_Lname").focus();
		return;
	}


if (document.getElementById("statelic_1").value=="")
	{
		alert("Please select \' What State is this license for?  '\ ");
		////SetErrorImage("InsuranceType", true);
		//document.getElementById("timenolapse").select();;
		document.getElementById("statelic_1").focus();
		return;
	}

if (document.getElementById("licensestatus_1").value=="")
	{
		alert("Please select \' License Status  '\ ");
		////SetErrorImage("InsuranceType", true);
		//document.getElementById("timenolapse").select();;
		document.getElementById("licensestatus_1").focus();
		return;
	}

if(document.getElementById("driver_dobm").value=="")
	{
		alert("Please enter Month in your Date of Birth ");
		//SetErrorImage("LName", true);
		
		document.getElementById("driver_dobm").focus();
		return;
	}
	if(document.getElementById("driver_dobd").value=="")
	{
		alert("Please enter date in your Date of Birth ");
		//SetErrorImage("LName", true);
		
		document.getElementById("driver_dobd").focus();
		return;
	}
	if(document.getElementById("driver_doby").value=="")
	{
		alert("Please enter year in your Date of Birth ");
		//SetErrorImage("LName", true);
		document.getElementById("driver_doby").select();;
		document.getElementById("driver_doby").focus();
		return;
	}

if(isNaN(document.getElementById("driver_doby").value))
	{
		alert(" Please Enter the Valid numeric Value ");
		document.getElementById("driver_doby").select();;
		document.getElementById("driver_doby").focus();
		return;
	} 
if(document.getElementById("driver_doby").value.length != 4 )
	{
		alert("Please enter four digit  year in your Date of Birth ");
		//SetErrorImage("LName", true);
		document.getElementById("driver_doby").select();;
		document.getElementById("driver_doby").focus();
		return;
	}

if (document.getElementById("agelic_1").value=="")
	{
		alert("Please select \' How long has this driver been licensed in the U.S. or Canada?  '\ ");
		////SetErrorImage("InsuranceType", true);
		//document.getElementById("timenolapse").select();;
		document.getElementById("agelic_1").focus();
		return;
	}

if (document.getElementById("Marital_1").value=="not given")
	{
		alert("Please select  Marital Status  ");
		////SetErrorImage("InsuranceType", true);
		//document.getElementById("timenolapse").select();;
		document.getElementById("Marital_1").focus();
		return;
	}

if(document.getElementById("driver_Occupation").value=="")
	{
		alert("Please enter Driver Occupation ");
		//SetErrorImage("LName", true);
		//document.getElementById("driver_Occupation").select();;
		document.getElementById("driver_Occupation").focus();
		return;
	}

if ((document.getElementById("driver_Occupation").value == "Student") && (document.getElementById("driver_stud_gpa").value=="") )
	{
		alert("what is his/her GPA");
		//SetErrorImage("LName", true);
		//document.getElementById("driver_Occupation").select();;
		document.getElementById("driver_stud_gpa").focus();
		return;
	}


if (document.getElementById("education_1").value=="not given")
	{
		alert("Please select \' Education Level  '\ ");
		////SetErrorImage("InsuranceType", true);
		//document.getElementById("timenolapse").select();;
		document.getElementById("education_1").focus();
		return;
	}




if(document.getElementById("violations_dobm").value=="")
	{
		alert("Please Select violation-month ");
		//SetErrorImage("LName", true);
		
		document.getElementById("violations_dobm").focus();
		return;
	}
	if(document.getElementById("violations_doby").value=="")
	{
		alert("Please Select violation-Year ");
		//SetErrorImage("LName", true);
		
		document.getElementById("violations_doby").focus();
		return;
	}
	if(document.getElementById("violationtype_1").value=="")
	{
		alert("Please Select violation-Type ");
		//SetErrorImage("LName", true);
		
		document.getElementById("violationtype_1").focus();
		return;
	}


if(document.getElementById("vehicle_year").value=="")
	{
		alert("Please enter Vehicle Year ");
		//SetErrorImage("LName", true);
		document.getElementById("vehicle_year").focus();
		return;
	}


if(document.getElementById("automake_1").value=="")
	{
		alert("Please select \' Vehicle Make  '\ ");
		//SetErrorImage("LName", true);
		
		document.getElementById("automake_1").focus();
		return;
	}

if(document.getElementById("vehicle_year").value>1981){
if(document.getElementById("vehicle_modal").value=="")
	{
		alert("Please select Vehicle Model ");
		//SetErrorImage("LName", true);
		//document.getElementById("vehicle_modal").select();;
		document.getElementById("vehicle_modal").focus();
		return;
	}
	if(document.getElementById("vehicle_tri").value=="")
	{
		alert("Please select vehicle Trim ");
		//SetErrorImage("Select", true);
		//document.getElementById("vehicle_modal").select();;
		document.getElementById("vehicle_tri").focus();
		return;
	}
	if(document.getElementById("autovin").value=="")
	{
		alert("Please enter VIN (Vehicle Identification Number) ");
		//SetErrorImage("LName", true);
		//document.getElementById("vehicle_modal").select();;
		document.getElementById("autovin").focus();
		return;
	}
}

if(document.getElementById("autofuel_1").value=="none")
	{
		alert("Please select \' Type of fuel  '\ ");
		//SetErrorImage("LName", true);
		
		document.getElementById("autofuel_1").focus();
		return;
	}

if(document.getElementById("annualusage_1").value=="")
	{
		alert("Please enter Estimated Annual Usage (in miles) ");
		//SetErrorImage("LName", true);
		document.getElementById("annualusage_1").select();;
		document.getElementById("annualusage_1").focus();
		return;
	}

if(isNaN(document.getElementById("annualusage_1").value))
		{
			alert("Estimated Annual Usage should be Numeric value");
			//SetErrorImage("Zip", true);
			document.getElementById("annualusage_1").select();;
			document.getElementById("annualusage_1").focus();
			return;
		}


if(document.getElementById("autocompded_1").value=="")
	{
		alert("Please select \' Desired Comprehensive Deductible  '\ ");
		//SetErrorImage("LName", true);
		
		document.getElementById("autocompded_1").focus();
		return;
	}

if(document.getElementById("autocollded_1").value=="")
	{
		alert("Please select \' Desired Collision Deductible  '\ ");
		//SetErrorImage("LName", true);
		
		document.getElementById("autocollded_1").focus();
		return;
	}


if(document.getElementById("autolease").value=="")
	{
		alert("Please select \' Is this car Leased or Owned?  '\ ");
		//SetErrorImage("LName", true);
		
		document.getElementById("autolease").focus();
		return;
	}
//alert(document.getElementById("bst_time").value);
	

// End of Auto Information 

	 //}


// end of modifications done by srinivas


     }
	 String.prototype.trim1 = 
 function trimblanks() { return this.split(/\s/).join(''); };
	 
	 document.frm.method="post";
document.frm.action="getquoteinsert.php?automake_1="+document.getElementById("automake_1").value.trim1()+"&vehicle_modal="+document.getElementById("vehicle_modal").value+"&vehicle_tri="+document.getElementById("vehicle_tri").value;
	document.frm.submit();
}
