function chkemail(emval)
{
        var posi = 0;
        var posj = 0;
        var iflg = "false";
        var jflg = "false";
        for(i=0;i<=emval.length;i++)
        {
                if(emval.substr(i, 1) == "\@")
                {
                        posi = i+1;
                        iflg = "true";
                }
                if(emval.substr(i, 1) == ".")
                {
                        posj = i+1;
                        jflg = "true";
                }
        }
        if(posi == "1" || (posi+1) == posj || posj == emval.length || iflg == "false" || jflg == "false")
        {
                return false;
        }
        else
        {
                return true;
        }
}

function validateLife(lifedetails)
 {
    
	lifedetails.onsubmit = function()
	{
        	if(lifedetails.insure_policy_type.options.selectedIndex==0)
	     {
	           alert("Please Select The Policy Type");
		       lifedetails.insure_policy_type.focus();
		        return false;
		 	 	 
		   } 
		    
			if(lifedetails.insure_required_for.options.selectedIndex==0)
	     {
	           alert("Please Select Insurance Cover For");
		       lifedetails.insure_required_for.focus();
		        return false;
		 	 	 
		   } 
		   
		   if(lifedetails.insure_year_protection.options.selectedIndex==0)
	     {
	           alert("Please Select Policy Term");
		       lifedetails.insure_year_protection.focus();
		        return false;
		 	 	 
		   } 

           if(lifedetails.do_smoke.options.selectedIndex==0)
	     {
	           alert("Please Select Smoking Option");
		       lifedetails.do_smoke.focus();
		        return false;
		 	 	 
		   } 
		   
		   if(lifedetails.apply_reason.options.selectedIndex==0)
	     {
	           alert("Please Select Reason For Applying");
		       lifedetails.apply_reason.focus();
		        return false;
		 	 	 
		   } 
	   
	return true;	   
     }
 
 }

function validateHealth(healthdetails)
 {
    
	healthdetails.onsubmit = function()
	{
        	if(healthdetails.mediclaim_required_for.options.selectedIndex==0)
	     {
	           alert("Please Select Health or Mediclaim Required For");
		       healthdetails.mediclaim_required_for.focus();
		        return false;
		 	 	 
		   } 
		    
			if(healthdetails.no_of_people.options.selectedIndex==0)
	     {
	           alert("Please Select No. Of People To Be Insured");
		       healthdetails.no_of_people.focus();
		        return false;
		 	 	 
		   } 
		   		   
		   if(healthdetails.apply_reason.options.selectedIndex==0)
	     {
	           alert("Please Select Reason For Applying");
		       healthdetails.apply_reason.focus();
		        return false;
		 	 	 
		   } 
	   
	return true;	   
     }
 
 }

 function validateAuto(autodetails)
 {
    
	autodetails.onsubmit = function()
	{
        	if(autodetails.vehicle_manf.options.selectedIndex==0)
	     {
	           alert("Please Select Auto Manufacturer's Name");
		       autodetails.vehicle_manf.focus();
		        return false;
		 	 	 
		   } 
		    
			if(autodetails.model_name.value==0)
	     {
	           alert("Please Provide Car Model Name and Version");
		       autodetails.model_name.focus();
		        return false;
		 	 	 
		   } 
		   
		   if(autodetails.day_m.options.selectedIndex==0)

	        {
	              
		          alert("Please Select Day Of Registration");

		            autodetails.day_m.focus();

		            return false;
        
	           }

	if(autodetails.month_m.options.selectedIndex==0)

	{

		alert("Please Select Month of Registration");

		autodetails.month_m.focus();

		return false;
		 }
		  	   		 					
	
	if(autodetails.year_m.options.selectedIndex==0)

	{

		alert("Please Select Year Of Registration");

		autodetails.year_m.focus();

		return false;
		
		}
            if(autodetails.idv_of_vehicle.value==0)
	     {
	           alert("Please Provide The Current Value Of The Vehicle");
		       autodetails.idv_of_vehicle.focus();
		        return false;
		 	 	 
		   } 
		   		   
		   if(autodetails.apply_reason.options.selectedIndex==0)
	     {
	           alert("Please Select Reason For Applying");
		       autodetails.apply_reason.focus();
		        return false;
		 	 	 
		   } 
	   
	return true;	   
     }
 
 }

 function validateChild(childForm)
 {
    
	childForm.onsubmit = function()
	{
        	if(childForm.no_child.options.selectedIndex==0)
	     {
	           alert("Please Select No. Of Children & Their Age");
		       childForm.no_child.focus();
		        return false;
		 	 	 
		   } 
		    
			if(childForm.child_ins_goal.options.selectedIndex==0)
	     {
	           alert("Please Select Your Ultimate Goal");
		       childForm.child_ins_goal.focus();
		        return false;
		 	 	 
		   } 
		   		   
		   if(childForm.apply_reason.options.selectedIndex==0)
	     {
	           alert("Please Select Reason For Applying");
		       childForm.apply_reason.focus();
		        return false;
		 	 	 
		   } 
	   
	return true;	   
     }
 
 }

 function validateRetire(retirementdetails)
 {
    
	retirementdetails.onsubmit = function()
	{
        	if(retirementdetails.curr_anual_exp.value=="")
	     {
	           alert("Please Provide You Current Annual Expenses");
		       retirementdetails.curr_anual_exp.focus();
		        return false;
		 	 	 
		   } 
		    
			if(retirementdetails.age_of_retire.options.selectedIndex==0)
	     {
	           alert("Please Select Age You Would Like To Retire");
		       retirementdetails.age_of_retire.focus();
		        return false;
		 	 	 
		   } 
		   		   
		   if(retirementdetails.apply_reason.options.selectedIndex==0)
	     {
	           alert("Please Select Reason For Applying");
		       retirementdetails.apply_reason.focus();
		        return false;
		 	 	 
		   } 
	   
	return true;	   
     }
 
 }

    function validateTravel(traveldetails)
 {
    
	traveldetails.onsubmit = function()
	{
        	if(traveldetails.traval_insure_required_for.options.selectedIndex==0)
	     {
	           alert("Please Select Travel Insurance Required ");
		       traveldetails.traval_insure_required_for.focus();
		        return false;
		 	 	 
		   } 
		    
			if(traveldetails.traveling_for.options.selectedIndex==0)
	     {
	           alert("Please Select The Duration Of Stay");
		       traveldetails.traveling_for.focus();
		        return false;
		 	 	 
		   } 
		    
			if(traveldetails.day_traval.options.selectedIndex==0)

	        {
	              
		          alert("Please Select Day ");

		            traveldetails.day_traval.focus();

		            return false;
        
	           }

	if(traveldetails.month_traval.options.selectedIndex==0)

	{

		alert("Please Select Month ");

		traveldetails.month_traval.focus();

		return false;
		 }
		  	   		 					
	
	if(traveldetails.year_traval.options.selectedIndex==0)

	{

		alert("Please Select Year ");

		traveldetails.year_traval.focus();

		return false;
		
		}
		   		
		   if(traveldetails.travel_country.value=="")
	     {
	           alert("Please Provide Country You Are Travelling");
		       traveldetails.travel_country.focus();
		        return false;
		 	 	 
		   } 
		   
	          if(traveldetails.element['travel_country'].value>40)
	     {
	           alert("Please Provide Country You Are Travelling");
		       traveldetails.travel_country.focus();
		        return false;
		 	 	 
		   } 
	return true;	   
     }
 
 }

 
function validateForm(contact)

{
 
	contact.onsubmit = function()
   {
             if(contact.elements['cust_fname'].value.length<1)

	{

		alert("Please Enter First Name");

		contact.cust_fname.focus();

		return false;

	}



       if(contact.elements['cust_lname'].value.length<1)

	{

		alert("Please Enter Last Name");

		contact.cust_lname.focus();

		return false;

	}
	
	if(contact.day.options.selectedIndex=="0")

	{
	    alert("Please enter day");
		contact.day.focus();
		return false;
        
	}

	if(contact.month.options.selectedIndex=="0")

	{

		alert("Please enter month");

		contact.month.focus();

		return false;
		 }
		  	   		 					
	
	if(contact.year.options.selectedIndex=="0")

	{

		alert("Please enter year");

		contact.year.focus();

		return false;
		
		}
		if(contact.cust_sex.options.selectedIndex==0)
	  {
	     alert("Please Select Your Gender From the List");
		 contact.cust_sex.focus();
		 return false;
		 	 	 
		}
		 	if(contact.cust_country.options.selectedIndex==0)
	  {
	     alert("Please Select a Country From the List");
		 contact.cust_country.focus();
		 return false;
		 	 	 
		}    		
		   
	if(contact.elements['cust_city'].value=="")
	  {
	     alert("Please Provide Your City Name");
		 contact.cust_city.focus();
		 return false;
		 	 	 
		} 
	if(contact.elements['cust_pincode'].value=="")
	  {
	     alert("Please Provide Your Pincode ");
		 contact.cust_pincode.focus();
		 return false;
		 	 	 
		} 	   
		
		if(contact.elements['cust_occup'].value=="")
	  {
	     alert("Please Provide Your Occupation Details");
		 contact.cust_occup.focus();
		 return false;
		 	 	 
		} 	
		
		if(contact.marital_status.options.selectedIndex==0)
	  {
	     alert("Please Select Your Martial Status From the List");
		 contact.marital_status.focus();
		 return false;
		 	 	 
		}
		
		if(!chkemail(contact.cust_email.value))
		
		{
		   alert("Please Enter Correct Email Address");
		 contact.cust_email.focus();
		 return false;
		 	 	 
		} 
			
	           
	
	if(contact.elements['cust_mob'].value=="")
		     {
	    			 alert("Please Provide Your Mobile Number");

					contact.cust_mob.focus();

					return false;

					    }
						      
											

	return true;
   
    
   
   }
   
}   
