
														//today:0
														//tomorrow:1
														//day after tomorrow:2
														//after n days:n
var how_many_days_to_forward = 1 ;


/////////////////////////////////////////////////////////////Page One

function getDates()
		{var fd,fm,fy,td,tm,ty;
		fd=document.quoteform.frmdd[document.quoteform.frmdd.selectedIndex].value;
		fm=document.quoteform.frmmm[document.quoteform.frmmm.selectedIndex].value-1;
		fy=document.quoteform.frmyy[document.quoteform.frmyy.selectedIndex].value;
		if(validdate(fd,fm,fy)==false)return false;
		else{ 	start.setFullYear(fy,fm,fd);}
		
		td=document.quoteform.todd[document.quoteform.todd.selectedIndex].value;
		tm=document.quoteform.tomm[document.quoteform.tomm.selectedIndex].value-1;
		ty=document.quoteform.toyy[document.quoteform.toyy.selectedIndex].value;
		if(validdate(td,tm,ty)==false)return false;
		else{ 	endd.setFullYear(ty,tm,td);}
		//alert('Get---> Start--'+start.getDate()+':'+start.getMonth()+':'+start.getFullYear()+'\nEnd--'+endd.getDate()+':'+endd.getMonth()+':'+endd.getFullYear());
		return true;
		}
function setDates(start,endd)
		{document.quoteform.frmdd.value=start.getDate();
		 document.quoteform.frmmm.value=start.getMonth()+1;
		 document.quoteform.frmyy.value=start.getFullYear();
		 document.quoteform.todd.value=endd.getDate();
		 document.quoteform.tomm.value=endd.getMonth()+1;
		 document.quoteform.toyy.value=endd.getFullYear();
		//alert('Set---> Start--'+start.getDate()+':'+start.getMonth()+':'+start.getFullYear()+'\n*End--'+endd.getDate()+':'+endd.getMonth()+':'+endd.getFullYear());
		}
function MonthName(m)
		{
		var month=["January","February","March","April","May","June","July","August","September","October","November","December"];
		return month[m];
		}
function validdate(dd,mm,yy)
		{if((mm==3 || mm==5 || mm==8 || mm==10)&&dd>=31){//alert("4-6-9-11 > 30 This month can not have date 31.");
														return false;}
		else if(mm==1){if(((yy%4==0&&yy%100!=0)||(yy%400==0) )&&dd>29){//alert("Leap year but date > 29 does not exist.");
														return false;}
						else if(((yy%4!=0||yy % 100==0)&&(yy%400!=0))&&dd>28){//alert("Non Leap and date > 28 is not allowed.");
						return false;}
						}
		return true;
		}
function iniDoB()
		{temp.setFullYear(start.getFullYear(),start.getMonth(),start.getDate()+1);
			for(var i=0; document.quoteform.traveler?i < document.quoteform.traveler.value:i<1; i++)
				{document.getElementById("dobdd"+i).value=temp.getDate();
				 document.getElementById("dobmm"+i).value=temp.getMonth()+1;
				 document.getElementById("dobyy"+i).value=temp.getFullYear()-maxage[3]-1;}
		}
function setDoBLimit(c)
		{if(c||testdropdown()==false)		//c==true when product is changed
			{start.setFullYear(d.getFullYear(),d.getMonth(),d.getDate());
			endd.setFullYear(d.getFullYear(),d.getMonth(),d.getDate()+totaldays[0]-1);
			setDates(start,endd);}
		dbstart.setFullYear(start.getFullYear()-maxage[0],start.getMonth()-maxage[1],start.getDate()-maxage[2]+1);
		dbend.setFullYear(start.getFullYear()-minage[0],start.getMonth()-minage[1],start.getDate()-minage[2]-1);
		}
function showDoBdiv(n,c)
		{var longhtml=yoptrange=units="";
		setDoBLimit(c);
		for(var a=dbstart.getFullYear(); a<=dbend.getFullYear();a++)yoptrange=yoptrange+'<option value="'+a+'">'+a+'</option>';
		for(var i=0; i<n; i++)
				{longhtml=longhtml+'<div><select name="dobdd[]" id="dobdd'+i+'" onChange="setAge(this.id);"><option value="1" selected>01</option><option value="2">02</option><option value="3">03</option><option value="4">04</option><option value="5">05</option><option value="6">06</option><option value="7">07</option><option value="8">08</option><option value="9">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option><option value="29">29</option><option value="30">30</option><option value="31">31</option></select><select name="dobmm[]" id="dobmm'+i+'" onChange="setAge(this.id);"><option value="1" selected>JAN</option><option value="2">FEB</option><option value="3">MAR</option><option value="4">APR</option><option value="5">MAY</option><option value="6">JUN</option><option value="7">JUL</option><option value="8">AUG</option><option value="9">SEP</option><option value="10">OCT</option><option value="11">NOV</option><option value="12">DEC</option></select><select name="dobyy[]" id="dobyy'+i+'" onChange="setAge(this.id);">'+yoptrange+'</select>  OR age <input type="text"  name="trvage[]" id="trvage'+i+'" value="'+(maxage[3])+'" onKeyPress="return enableEvent(\'num\',event);" onChange="if(this.value==\'\'||this.value>(maxage[0]-1)||this.value<1){alert(\'Age of traveler should be numeric and in the available range.\'); this.value=\'\'; this.focus();}else setDoBlist(this.id,this.value);" size="1" maxlength="2">  years  ';
		if(checkedOption()=="DOMESTICTATA"){units=' with<br> CORE BENEFIT UNITS <SELECT name="units[]" id="units'+i+'" style="font-size:10px;"><OPTION selected  value="1" >CORE BENEFIT 1 UNITS</OPTION><OPTION value="2">CORE BENEFIT 2 UNITS</OPTION><OPTION value="3">CORE BENEFIT 3 UNITS</OPTION><OPTION value="4">CORE BENEFIT 4 UNITS</OPTION><OPTION value="5">CORE BENEFIT 5 UNITS</OPTION></SELECT>';
		if(i==0)units=units+' <font color="#0033CC" size="1"> *Core benefit 1 unit is equal to Rs.50,000 coverage</font>';}
		longhtml=longhtml+units+"</div>";
		}
		document.getElementById("dobtd").innerHTML=longhtml;
		iniDoB();
		}
function setDoBlist(i,v)
		{indexer=i.substring(6,i.length);
		temp.setFullYear(start.getFullYear(),start.getMonth(),start.getDate()+1);
		if(v<=maxage[0]&&getDates()){
		document.getElementById("dobdd"+indexer).value=temp.getDate();
		document.getElementById("dobmm"+indexer).value=temp.getMonth()+1;
		document.getElementById("dobyy"+indexer).value=temp.getFullYear()-v-1;}
		else {alert("Policy can not be issue for more than the age "+(maxage[0]-1)+" years."); document.getElementById("dobyy"+indexer).focus(); return;}
		}
function setAge(i)
		{indexer=i.substring(5,i.length);
		setDoBLimit(false);
		var YY = MM = DD = 0;
		if(validdate(document.getElementById("dobdd"+indexer).value,document.getElementById("dobmm"+indexer).value-1,document.getElementById("dobyy"+indexer).value)==true&&getDates())
				{//temp.setFullYear(document.getElementById("dobyy"+indexer).value,document.getElementById("dobmm"+indexer).value-1,document.getElementById("dobdd"+indexer).value);
				dob.setFullYear(document.getElementById("dobyy"+indexer).value,document.getElementById("dobmm"+indexer).value-1,document.getElementById("dobdd"+indexer).value);
				if(start.getFullYear()>=dob.getFullYear())
					{if(start.getMonth()>dob.getMonth())YY=start.getFullYear()-dob.getFullYear();
					if(start.getMonth()==dob.getMonth())
						{if(start.getDate() < dob.getDate())YY=start.getFullYear()-dob.getFullYear()-1;
						else	YY=start.getFullYear()-dob.getFullYear();}
					if(start.getMonth()<dob.getMonth())	YY=start.getFullYear()-dob.getFullYear()-1;
					}
			//	if(YY>70)moreThanSeventy=true;
				document.getElementById("trvage"+indexer).value=YY>0?YY:0;
			//	alert(temp+"   S=="+start+"  YY=="+YY);
				if(YY>=maxage[0]){/*document.getElementById("dobdd"+indexer).focus();*/ return;}
				}
		}
function diffOfDates()
		{if(testdropdown()==true&& start <= endd)
		{if(checkedOption()!="ANNUAL"&&checkedOption()!="HEALTH")
			{var days=0,flag=false;
			 temp=start;
			 while(flag==false)
				{if(temp.getDate()>=endd.getDate()&&temp.getMonth()>=endd.getMonth()&&temp.getFullYear()>=endd.getFullYear())flag=true;
				days++;
				temp.setDate(temp.getDate()+1);
				}
			if(days>0)document.quoteform.days.value=days;
			}
		else	{setendDate(totaldays[0]);	}
		for(var i=0; document.quoteform.traveler&&i<document.quoteform.traveler.value; i++){setAge("dobdd"+i);}
		}
		}
function testdropdown()
		{if(getDates()==true)
			{if(start<d||start > trvstart){document.quoteform.frmdd.focus(); return false;}
			if(endd < d|| endd > trvend){if(checkedOption()!="ANNUAL"&&checkedOption()!="HEALTH")document.quoteform.todd.focus(); return false;}
			}
		else return false;
		return true;
		}
function setendDate(diff)
		{if(testdropdown()==true&&diff>0)endd.setFullYear(start.getFullYear(),start.getMonth(),start.getDate()+parseInt(diff-1,10));
		//alert('Diff-'+diff+' D-'+endd.getDate()+' M-'+endd.getMonth()+' Y-'+endd.getFullYear());
		setDates(start,endd);
		}
function checkalllower()
		{totalunits=0;
			for(var i=0; document.quoteform.traveler&&i<document.quoteform.traveler.value; i++)
				{
				if(document.quoteform.totalunits){totalunits=totalunits+parseInt(document.getElementById("units"+i).value,10);}
				if(checkdob(document.getElementById("dobdd"+i).value,document.getElementById("dobmm"+i).value-1,document.getElementById("dobyy"+i).value)==false){document.getElementById("dobdd"+i).focus(); return false;}
				setAge("dobdd"+i);
				if(document.getElementById("trvage"+i).value==""||document.getElementById("trvage"+i).value>=maxage[0]){document.getElementById("dobdd"+i).focus(); return false;}
				}
		return true;
		}
function checkdob(dd,mm,yy)
		{if(validdate(dd,mm,yy)==true)temp.setFullYear(yy,mm,dd);
		 else {var isThisLeap=""; if(mm==1)isThisLeap=((yy%4==0&&yy%100!=0)||yy%400==0)?"in the leap year '"+yy+"'":"in the non-leap year '"+yy+"'";
		 alert("The selected date '"+dd+"' does not appear in the selected month '"+MonthName(mm)+"' "+isThisLeap+".");	return false;}
		 if(temp < dbstart || temp > dbend){alert("Please check the Date of Birth which should be between\n                  "+dbstart.getDate()+":"+MonthName(parseInt(dbstart.getMonth(),10))+":"+dbstart.getFullYear()+"  --and--   "+dbend.getDate()+":"+MonthName(parseInt(dbend.getMonth(),10))+":"+dbend.getFullYear()+"\nas well as the age of the traveler can not exceed "+(maxage[0]-1)+" years."); return false;}
		 return true;
		}
function checkedOption()
		{
		for(var i=0;document.quoteform.product.type!="undefined"&&i<=document.quoteform.product.length;i++)
		if(document.quoteform.product[i].checked)return document.quoteform.product[i].value;
		return document.quoteform.product.value;
		}
function setdiv(s)
		{if(s=="STUDENT")		{	totaldays=[2,365];		minage=[16,0,0];maxage=[36,0,0,35];	}
		else if(s=="ANNUAL")	{	totaldays=[365,365];	minage=[19,0,0];maxage=[71,0,0,70];	}
		else if(s=="ASIA")		{	totaldays=[2,14];		minage=[0,6,0];maxage=[71,0,0,70];	}
		else if(s=="DOMESTICTATA")	{	totaldays=[2,90];	minage=[0,6,0];maxage=[71,0,0,70];	}
		else if(s=="TRAVEL70")	{	totaldays=[2,180];		minage=[71,0,0];maxage=[80,0,0,71];	}
		else if(s=="TRAVEL")	{	totaldays=[2,180];		minage=[0,6,0];maxage=[71,0,0,70];	}
		
		document.getElementById("optDiv").innerHTML=s=="DOMESTICTATA"?'&nbsp; <input type="hidden" name="totalunits">':"&nbsp;";
		document.quoteform.days.value=totaldays[0];
		if(document.quoteform.destination){
		if(s=="ANNUAL"||s=="ASIA"||s=="DOMESTICTATA")document.quoteform.destination.value="";
		document.quoteform.destination.disabled=s=="ANNUAL"||s=="ASIA"||s=="DOMESTICTATA"?true:false;}
		document.quoteform.todd.disabled=s=="ANNUAL"?true:false;
		document.quoteform.tomm.disabled=s=="ANNUAL"?true:false;
		document.quoteform.toyy.disabled=s=="ANNUAL"?true:false;
		document.quoteform.days.disabled=s=="ANNUAL"?true:false;
		trvend.setFullYear(trvstart.getFullYear(),trvstart.getMonth(),trvstart.getDate()+totaldays[1]);
		document.quoteform.traveler.value=1;
		showDoBdiv(1,true);
		}
function setdiv_Bajaj(s)
		{if(s=="STUDENT")	{	totaldays=[1,365];		minage=[16,0,0];maxage=[36,0,0,35];	}
		else if(s=="ANNUAL"){	totaldays=[365,365];	minage=[18,0,0];maxage=[61,0,0,60];	}
		else if(s=="ASIA")	{	totaldays=[1,30];		minage=[0,6,0];maxage=[71,0,0,70];	}
		else if(s=="DOMESTIC"){	totaldays=[1,90];		minage=[18,0,0];maxage=[66,0,0,65];	}
		else				{	totaldays=[1,180];		minage=[0,6,0];maxage=[71,0,0,70];	}
		document.quoteform.days.value=totaldays[0];
		if(document.quoteform.destination){
		if(s=="ANNUAL"||s=="ASIA"||s=="DOMESTIC")
		{document.quoteform.destination.value=""; if(document.quoteform.choice)document.quoteform.choice.value="";}
		document.quoteform.destination.disabled=s=="ANNUAL"||s=="ASIA"||s=="DOMESTIC"?true:false;}
		if(document.quoteform.choice&&document.quoteform.choice.length){
		if(s!="TRAVEL")
			{document.quoteform.choice[0].checked=document.quoteform.choice[1].checked=document.quoteform.choice[2].checked=false;
			document.quoteform.choice[0].disabled=document.quoteform.choice[1].disabled=document.quoteform.choice[2].disabled=true;}
		else{document.quoteform.choice[0].disabled=document.quoteform.choice[1].disabled=document.quoteform.choice[2].disabled=false;}
			}
		document.quoteform.todd.disabled=s=="ANNUAL"?true:false;
		document.quoteform.tomm.disabled=s=="ANNUAL"?true:false;
		document.quoteform.toyy.disabled=s=="ANNUAL"?true:false;
		document.quoteform.days.disabled=s=="ANNUAL"?true:false;
		trvend.setFullYear(trvstart.getFullYear(),trvstart.getMonth(),trvstart.getDate()+totaldays[1]);
		document.quoteform.traveler.value=1;
		showDoBdiv(1,true);
		}

/////////////////////////////////////////////////////////////Page Three
function checkValueType(value,type)
		{var filter;
		if(type=="email")filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		else if(type=="postal")filter=/^[1-9]\d{5}$/;
		else if(type=="alphanum")filter=/^[^&'"<>]+$/;
		else if(type=="alpha")filter=/^[a-zA-Z ]+$/;
		else if(type=="passport")filter=/^[a-zA-Z0-9- ]+$/;
		else if(type=="num")filter=/(^-?\d\d*$)/;
		if(!filter.test(value)||trim(value)==""){return false;}
		return true;
		}
function trim(str){return str.replace(/(^[\s\xA0]+|[\s\xA0]+$)/g,"");}
function enableEvent(type,e)
		{var unicode=document.all? e.keyCode : e.which;
		if(type=="num")return (unicode>=48&&unicode<=57 ||unicode==8)?true:false;
		else if(type=="alpha")return (unicode>64&&unicode<91||unicode>96&&unicode<123 || unicode==32||unicode==8)?true:false;
		else if(type=="passport")return (unicode>64&&unicode<91||unicode>96&&unicode<123 || unicode>47&&unicode<58 || unicode==32||unicode==8|| unicode==45)?true:false;
		}
			
function fillDateList(listDisabled)
		{disabledString=listDisabled==true?('disabled="disabled"'):"";
		for(var a=start.getFullYear(),yearOptions=""; a<start.getFullYear()+3; a++)yearOptions=yearOptions+'<option value="'+a+'">'+a+'</option>';
		document.getElementById("frmSpan").innerHTML='<select name="frmyy" onChange="diffOfDates();">'+yearOptions+'</select>';
		document.getElementById("toSpan").innerHTML='<select '+disabledString+' name="toyy" onChange="diffOfDates();">'+yearOptions+'</select>';
		}
		
