// JavaScript Document
function validmail(email1)
{
	invalidChars = " /:,;";
	if (email1 == "")
	{// cannot be empty
		alert("Invalid E-mail ID.");
		return false;
	}

for (i=0; i<invalidChars.length; i++)
	{	// does it contain any invalid characters?
		badChar = invalidChars.charAt(i);
		if (email1.indexOf(badChar,0) > -1)
		{
			return false;
		}
	}
	atPos = email1.indexOf("@",1)// there must be one "@" symbol
	if (atPos == -1)
	{
		alert("Invalid E-mail ID.");
		return false;
	}
	if (email1.indexOf("@",atPos+1) != -1)
	{	// and only one "@" symbol
		alert("Invalid E-mail ID.");
		return false;
	}
	periodPos = email1.indexOf(".",atPos)
	if (periodPos == -1)
	{// and at least one "." after the "@"
		alert("Invalid E-mail ID.");
		return false;
	}
	//alert(periodPos);
	//alert(email.length);
	if (periodPos+3 > email1.length)
	{		// must be at least 2 characters after the "."
		alert("Invalid E-mail ID.");
		return false;

	}
	return true;
}

function validmobile(mobile)
{

	atPos = mobile_no.indexOf("0")// there must be one "@" symbol
	if (atPos == 0)
	{
		alert("Mobile number cannot start with 0.");
		return false;
	}
	if(!checkData(Form.mobile_no, 'Mobile number', 10))
		return false;

return true;
}

function containsdigit(param)
{
	mystrLen = param.length;
	for(i=0;i<mystrLen;i++)
	{
		if((param.charAt(i)=="0") || (param.charAt(i)=="1") || (param.charAt(i)=="2") || (param.charAt(i)=="3") || (param.charAt(i)=="4") || (param.charAt(i)=="5") || (param.charAt(i)=="6") || (param.charAt(i)=="7") || (param.charAt(i)=="8") || (param.charAt(i)=="9") || (param.charAt(i)=="/"))
		{
			return true;
		}
	}
	return false;
}


function addCC()
{
		var ni = document.getElementById('myDiv');
		
		if(ni.innerHTML=="")
		{
		
			if(document.health_insurance_form.CC_Holder.value="on")
			{
				//alert(document.home_insurance_form.CC_Holder.value);
				ni.innerHTML = '<table border="0" align="center"><tr> <td colspan="2" align="center"  valign="top" class="formtext-hlt" width="" height="20" ><font class="formtext-hlt">I have an active credit card from ? </font><font size="1" color="#FF0000">*</font></td></tr><tr> <td colspan="4" class="bodyarial11" width="300"><table border="0" width="100%"> <tr><td class="formtext-hlt" width="60%"><input type="checkbox" id="From_Product" name="From_Product[]" class="noBrdr" value="Abn Ambro">&nbsp;ABN AMRO</td><td class="formtext-hlt" width="60%"><input type="checkbox" class="noBrdr" id="From_Product" name="From_Product[]" value="Amex">&nbsp;Amex</td><tr><td class="formtext-hlt"><input type="checkbox" id="From_Product" name="From_Product[]" class="noBrdr" id="From_Product" value="Canara Bank" >&nbsp;Canara Bank</td><td class="formtext-hlt"><input type="checkbox" name="From_Product[]" id="From_Product" class="noBrdr" value="Citi Bank" >&nbsp;Citi Bank</td></tr><tr><td class="formtext-hlt"><input type="checkbox" name="From_Product[]" class="noBrdr" id="From_Product" value="Deutsche bank">&nbsp;Deutsche Bank</td><td class="formtext-hlt"><input type="checkbox"  id="From_Product" name="From_Product[]" value="HDFC" class="noBrdr">&nbsp;HDFC</td></tr><tr><td class="formtext-hlt"><input type="checkbox" class="noBrdr" value="HSBC" name="From_Product[]" id="From_Product" >&nbsp;HSBC</td><td class="formtext-hlt"> <input type="checkbox" id="From_Product" name="From_Product[]" class="noBrdr" value="ICICI">&nbsp;ICICI</td></tr><tr><td class="formtext-hlt" colspan="2"><input type="checkbox" name="From_Product[]" value="Standard Chartered" id="From_Product" class="noBrdr" >&nbsp;Standard Chartered</td></tr><tr><td class="formtext-hlt"><input type="checkbox" id="From_Product" name="From_Product[]" class="noBrdr" value="SBi">&nbsp;SBI</td><td class="formtext-hlt"><input type="checkbox" name="From_Product[]" value="Others" id="From_Product" class="noBrdr" >&nbsp;Others</table></table>		';
				

			}
		}
		
		return true;

	}


function removeCC()
{
		var ni = document.getElementById('myDiv');
		
		if(ni.innerHTML!="")
		{
		
			if(document.health_insurance_form.CC_Holder.value="on")
			{
				
				ni.innerHTML = '';
				
			}
		}
		
		return true;

	}
	
function addCarPolicy()
{
		var ni = document.getElementById('myDivM');
		
		if(ni.innerHTML=="")
		{
		
			if(document.auto_insurance_form.buy_insurance_for.value="on")
			{
				//alert(document.home_insurance_form.CC_Holder.value);
				ni.innerHTML ='<table border="0" width="100%"><tr><td class="formtext-hlt" colspan="2" align="bottom" width="145">Existing Policy<font size="1" color="#FF0000">*</font></td></tr><tr><td class="formtext-hlt" colspan="2"><select name="insurancecompany"  class="formtext-hlt" ><option value="-1">Insurance Company</option><option value="1">Bajaj Allianz General Insurance</option><option value="2">ICICI Lombard General Insurance</option><option value="3">IFFCO Tokio General Insurance</option><option value="4">National Insurance</option><option value="5" >United India Insurance</option><option value="6">The New India Assurance</option> <option value="7" >The Oriental Insurance</option><option value="8">Reliance General Insurance</option><option value="9" >Royal Sundaram Alliance Insurance</option><option value="10">Tata AIG General Insurance</option><option value="11" >Cholamandalam MS General Insurance</option><option value="12">HDFC-Chubb General Insurance</option></SELECT></td></tr> <tr><td class="formtext-hlt" align="bottom" width="47%">Date of Renewal<font size="1" color="#FF0000">*</font></td><td width="53%" align="center"> <input name="renewal_date" type="text" size="14" class="formtext-hlt" class="input_g" id="renewal_date"   onfocus="this.select()" readonly/>&nbsp;&nbsp;<a href="javascript:NewCal(\'renewal_date\',\'yyyymmdd\')"><img src="images/cal.gif" width="16" height="18" border="0" alt="Pick a From date"></a></td></tr></table>';
				

			}
		}
		
		return true;

	}


function removeCarPolicy()
{
		var ni = document.getElementById('myDivM');
		
		if(ni.innerHTML!="")
		{
		
			if(document.auto_insurance_form.buy_insurance_for.value="on")
			{
				
				ni.innerHTML = '';
				
			}
		}
		
		return true;

	}


function valButton3() {
    var cnt = -1;
	var i;
    for(i=0; i<document.life_insurance_form.From_Product.length; i++) 
	{
        if(document.life_insurance_form.From_Product[i].checked)
		{
			cnt=i;
			
		}
    }
    if(cnt > -1)
	{ 
		return true;
	}
    else
	{
		return false;
	}
}		

function chkformLife()
{
var regMail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/
var dt,mdate;dt=new Date();

var alpha=/^[a-zA-Z\ ]*$/;
var alphanum=/^[a-zA-Z0-9]*$/;
var num=/^[0-9]*$/;
var space=/^[\ ]*$/;
var iChars ="/@#$%^&*()+=-[]\\\';,.{}|\":<>?!";




	if(document.life_insurance_form.full_name.value=="" || document.life_insurance_form.full_name.value=="Full Name" )
	{
		alert("Please fill your Full name.");
		document.life_insurance_form.full_name.focus();
		return false;
	}
	if(document.life_insurance_form.full_name.value!="")
	{
		 if(containsdigit(document.life_insurance_form.full_name.value)==true)
		{
			alert("Full Name contains numbers!");
			document.life_insurance_form.full_name.focus();
			return false;
		}
	}
  for (var i = 0; i <document.life_insurance_form.full_name.value.length; i++) {
  	if (iChars.indexOf(document.life_insurance_form.full_name.value.charAt(i)) != -1) {
  	alert ("Full Name has special characters.\n Please remove them and try again.");
	document.life_insurance_form.full_name.focus();

  	return false;
  	}
  }


if(document.life_insurance_form.mobile_no.value=="")
	{
		alert("Please fill your mobile number.");
		document.life_insurance_form.mobile_no.focus();
		return false;
	}
	if(isNaN(document.life_insurance_form.mobile_no.value)|| document.life_insurance_form.mobile_no.value.indexOf(" ")!=-1)
	{
		  alert("Enter numeric value");
		  document.life_insurance_form.mobile_no.focus();
		  return false;  
	}
	if (document.life_insurance_form.mobile_no.value.length < 10 )
	{
			alert("Please Enter 10 Digits"); 
			 document.life_insurance_form.mobile_no.focus();
			return false;
	}
	if ((document.life_insurance_form.mobile_no.value.charAt(0)!="9") && (document.life_insurance_form.mobile_no.value.charAt(0)!="8") && (document.life_insurance_form.mobile_no.value.charAt(0)!="7"))
	{
			alert("The number should start only with 9 or 8 or 7");
			 document.life_insurance_form.mobile_no.focus();
			return false;
	}


	if(document.life_insurance_form.email.value!="Email Id" || document.life_insurance_form.email.value!="")
	{
		if (!validmail(document.life_insurance_form.email.value))
		{
			alert("Please enter your valid email address!");
			document.life_insurance_form.email.focus();
			return false;
		}
	}

if (document.life_insurance_form.city.selectedIndex==0)
	{
		alert("Please enter City Name to Continue");
		document.life_insurance_form.city.focus();
		return false;
	}
	if((document.life_insurance_form.city.value=="Others") && (document.life_insurance_form.city_other.value=="" || document.life_insurance_form.city_other.value=="Other City"  ) || !isNaN(document.life_insurance_form.city_other.value))
	{
		alert("Kindly fill your Other City!");
		document.life_insurance_form.city_other.focus();
		return false;
	}
	for (var i = 0; i <document.life_insurance_form.city_other.value.length; i++)
	{
		if (iChars.indexOf(document.life_insurance_form.city_other.value.charAt(i)) != -1) {
			alert ("Other city has special characters.\n Please remove them and try again.");
			document.life_insurance_form.city_other.focus();
			return false;
		}
    }
	
	if(document.life_insurance_form.Net_Salary.value=="")
	{
		alert("Please enter Annual income to Continue");
		document.life_insurance_form.Net_Salary.focus();
		return false;
	}
	
		if(!document.life_insurance_form.accept.checked)
		{
			alert("Accept the Terms and Condition");
			document.life_insurance_form.accept.focus();
			return false;
		}

 
}



function valButton2() {
    var cnt = -1;
	var i;
    for(i=0; i<document.health_insurance_form.From_Product.length; i++) 
	{
        if(document.health_insurance_form.From_Product[i].checked)
		{
			cnt=i;
			
		}
    }
    if(cnt > -1)
	{ 
		return true;
	}
    else
	{
		return false;
	}
}


function chkformHI(Form)
{
var regMail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/
var dt,mdate;dt=new Date();

var alpha=/^[a-zA-Z\ ]*$/;
var alphanum=/^[a-zA-Z0-9]*$/;
var num=/^[0-9]*$/;
var space=/^[\ ]*$/;
var iChars ="/@#$%^&*()+=-[]\\\';,.{}|\":<>?!";


	if(document.health_insurance_form.full_name.value=="" || document.health_insurance_form.full_name.value=="Full Name" )
	{
		alert("Please fill your Full name.");
		document.health_insurance_form.full_name.focus();
		return false;
	}
	if(document.health_insurance_form.full_name.value!="" || document.health_insurance_form.full_name.value=="Full Name" )
	{
		 if(containsdigit(document.health_insurance_form.full_name.value)==true)
		{
			alert("Full Name contains numbers!");
			document.health_insurance_form.full_name.focus();
			return false;
		}
	}
  for (var i = 0; i <document.health_insurance_form.full_name.value.length; i++) {
  	if (iChars.indexOf(document.health_insurance_form.full_name.value.charAt(i)) != -1) {
  	alert ("Full Name has special characters.\n Please remove them and try again.");
	document.health_insurance_form.full_name.focus();

  	return false;
  	}
  }

	if(document.health_insurance_form.mobile_no.value=="")
	{
		alert("Please fill your mobile number.");
		document.health_insurance_form.mobile_no.focus();
		return false;
	}
	if(isNaN(document.health_insurance_form.mobile_no.value)|| document.health_insurance_form.mobile_no.value.indexOf(" ")!=-1)
	{
		  alert("Enter numeric value");
		  document.health_insurance_form.mobile_no.focus();
		  return false;  
	}
	if (document.health_insurance_form.mobile_no.value.length < 10 )
	{
			alert("Please Enter 10 Digits"); 
			 document.health_insurance_form.mobile_no.focus();
			return false;
	}
	if ((document.health_insurance_form.mobile_no.value.charAt(0)!="9") && (document.health_insurance_form.mobile_no.value.charAt(0)!="8") && (document.health_insurance_form.mobile_no.value.charAt(0)!="7"))
	{
			alert("The number should start only with 9 or 8 or 7");
			 document.health_insurance_form.mobile_no.focus();
			return false;
	}



 	if(document.health_insurance_form.email.value!="" )
	{
		if (!validmail(document.health_insurance_form.email.value))
		{
			alert("Please enter your valid email address!");
			document.health_insurance_form.email.focus();
			return false;
		}
	}

	

	if(document.health_insurance_form.day.value=="" || document.health_insurance_form.day.value=="dd")
	{
		alert("Please fill your day of birth.");
		document.health_insurance_form.day.focus();
		return false;
	}
	if(document.health_insurance_form.day.value!="")
	{
	 if((document.health_insurance_form.day.value<1) || (document.health_insurance_form.day.value>31))
	{
	alert("Kindly Enter your valid Date of Birth(Range 1-31)");
	document.health_insurance_form.day.focus();
	return false;
	}
	}
	if(!checkData(document.health_insurance_form.day, 'Day', 2))
		return false;
	
	if(document.health_insurance_form.month.value=="" ||document.health_insurance_form.month.value=="mm")
	{
		alert("Please fill your month of birth.");
		document.health_insurance_form.month.focus();
		return false;
	}
	if(document.health_insurance_form.month.value!="")
	{
	if((document.health_insurance_form.month.value<1) || (document.health_insurance_form.month.value>12))
	{
	alert("Kindly Enter your valid Month of Birth(Range 1-12)");
	document.health_insurance_form.month.focus();
	return false;
	}
	}
	if(!checkData(document.health_insurance_form.month, 'month', 2))
		return false;
	if(document.health_insurance_form.year.value=="" || document.health_insurance_form.year.value=="yyyy" )
	{
		alert("Please fill your year of birth.");
		document.health_insurance_form.year.focus();
		return false;
	}
		if(document.health_insurance_form.year.value!="")
	{
	  if((document.health_insurance_form.year.value < "1945") || (document.health_insurance_form.year.value >"1989"))
	{
		alert("Age Criteria! \n Applicants between age group 18 - 62 only are elgibile.");
		document.health_insurance_form.year.focus();
		return false;
		}
	}
	if(!checkData(document.health_insurance_form.year, 'Year', 4))
		return false;
	


if (document.health_insurance_form.city.selectedIndex==0)
	{
		alert("Please enter City Name to Continue");
		document.health_insurance_form.city.focus();
		return false;
	}
	if((document.health_insurance_form.city.value=="Others") && (document.health_insurance_form.city_other.value=="" || document.health_insurance_form.city_other.value=="Other City"  ) || !isNaN(document.health_insurance_form.city_other.value))
	{
		alert("Kindly fill your Other City!");
		document.health_insurance_form.city_other.focus();
		return false;
	}
	for (var i = 0; i <document.health_insurance_form.city_other.value.length; i++)
	{
		if (iChars.indexOf(document.health_insurance_form.city_other.value.charAt(i)) != -1) {
			alert ("Other city has special characters.\n Please remove them and try again.");
			document.health_insurance_form.city_other.focus();
			return false;
		}
    }


	if(!document.health_insurance_form.accept.checked)
		{
			alert("Accept the Terms and Condition");
			document.health_insurance_form.accept.focus();
			return false;
		}

}		







function chkformHISecond(Form)
{
var regMail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/
var dt,mdate;dt=new Date();

var alpha=/^[a-zA-Z\ ]*$/;
var alphanum=/^[a-zA-Z0-9]*$/;
var num=/^[0-9]*$/;
var space=/^[\ ]*$/;
var iChars ="/@#$%^&*()+=-[]\\\';,.{}|\":<>?!";
	
	if (document.health_insurance_form.member.selectedIndex==0)
	{
		alert("Please select no of individuals dependent on you.");
		document.health_insurance_form.member.focus();
		return false;
	}

	var myOption = -1;
	var i;
		for (i=document.health_insurance_form.CC_Holder.length-1; i > -1; i--) {
			if(document.health_insurance_form.CC_Holder[i].checked) {
				if(i==0)
				{
					btn2=valButton2();
					if(!btn2)
					{
						alert('Please select you have an active credit card from which bank.');
						return false;
					}
				}
					myOption = i;
			}
		}
	
		if (myOption == -1) 
		{
			alert("Please select are you a credit card holder from any bank");
			return false;
		}
}		







