//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+'';
for(var i=0; i or age years ';
if(checkedOption()=="DOMESTICTATA"){units=' with CORE BENEFIT UNITS
';
if(i==0)units=units+'
*Core benefit 1 unit is equal to Rs.50,000 coverage
*Core benefit 2 unit is equal to 2x50,000 Rs. coverage';}
longhtml=longhtml+units+"";
}
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()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")
{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 trvstart){document.quoteform.frmdd.focus(); return false;}
if(endd < d|| endd > trvend){if(checkedOption()!="ANNUAL")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=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"?' ':" ";
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=[2,365]; minage=[16,0,0];maxage=[36,0,0,20]; }
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=="DOMESTIC90"){ totaldays=[1,90]; minage=[18,0,0];maxage=[66,0,0,65]; }
else if(s=="DOMESTIC30"){ totaldays=[1,30]; minage=[0,6,0];maxage=[61,0,0,60]; }
else { totaldays=[1,180]; minage=[0,6,0];maxage=[71,0,0,70]; }
document.quoteform.days.value=totaldays[0];
fillDateList(false);
if(document.quoteform.destination){
if(s=="ANNUAL"||s=="ASIA"||s=="DOMESTIC90"||s=="DOMESTIC30")
{document.quoteform.destination.value=""; if(document.quoteform.choice)document.quoteform.choice.value="";}
document.quoteform.destination.disabled=s=="ANNUAL"||s=="ASIA"||s=="DOMESTIC90"||s=="DOMESTIC30"?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);
}
function fillDateList(listDisabled)
{disabledString=listDisabled==true?('disabled="disabled"'):"";
for(var a=start.getFullYear(),yearOptions=""; a'+a+'';
document.getElementById("frmSpan").innerHTML='';
document.getElementById("toSpan").innerHTML='';
}
/////////////////////////////////////////////////////////////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;
}