<!--

function showtextbox(n)
{
	hidetextbox();
	for(var i=0; i < n; i++)
	{
		document.getElementById("dtc"+i).innerHTML='<div class="formSmallFont">Age Child '+(i+1)+'</div><input size="2" name="dependant'+i+'" id="dependant'+i+'" onKeyPress="return numbersonly(event);" maxlength="2">';
	}
	restorevalues(n)
}

function restorevalues(d)
{
	//for(var i=0; i<d; i++)
	//	document.getElementById("dependant"+i).value = hidden[i+18]!=""?hidden[i+18]:"";
}

function hidetextbox()
{
	for(var i=0; i <= 5; i++)
		document.getElementById("dtc"+i).innerHTML='';
}

function setdropDowns(MM,DD)
{
	if(getDates()==true)
	{
		endd.setFullYear(start.getFullYear(),start.getMonth()+parseInt(MM,10),start.getDate()+parseInt(DD,10)-1);
		setDates(start,endd,0);	//	!! Surprised !! 0 for non-initialization
		setperiods();
	}
}
//function called on window onload
function iniForm()
{	
	setDates(stref,temp,1);
                document.form1.NumberOfChildren.value = 0;
setperiods();
	hidetextbox();
}

function resetform()
{
 		document.form1.Age.value = "";
 		document.form1.spouseAge.value=""
 		document.form1.NumberOfChildren.value=0;
 		document.form1.MaxPolicyLimit.selectedIndex = 1;
 		document.form1.Deductible.selectedIndex = 2;
 		document.form1.CountryforCoverage.selectedIndex = 0;
 		document.form1.MailingAddress.selectedIndex = 0;
 		document.form1.Residence.selectedIndex = 0;
 		//document.form1.Research.selectedIndex = 0;
 		//document.form1.Course.selectedIndex = 0;
 		document.form1.CountryofCitizenship.selectedIndex = 0;

	temp.setFullYear(stref.getFullYear(),stref.getMonth()+1,stref.getDate()-1);
	setDates(stref,temp,1);
	questiondisplay('NONUSA');
	//showhideArea("2");	
	hidetextbox();
}

function validate()
{
	if (!validVisitorAge())  return false;
 	if (!validSpouseAge()) return false;
	if (!validStartDate(start, stref)) return false;
	if (!validEndDate(endd, start)) return false;
	if (!validMonthsOfCoverage()) return false;
	if (!validDepChildrenAge()) return false;
	
	if(conditionalparameters())
	{
		document.form1.quote.disabled=true;
		document.form1.resetquote.disabled=true;
		document.form1.submit();
	}
}

//This function populates the contents of the tags q11a,b and c
//a - the question number on the form
//b - question to be asked to the user
//c - options from which the user can select the answer.

//Input param - s- country code (USA, NON-USA)
function questiondisplay(s)
{
	if(s=='USA')
	{
		document.form1.CountryforCoverage.value=4;
		document.getElementById("q11a").innerHTML='';
		document.getElementById("q11b").innerHTML='';
		document.getElementById("q11c").innerHTML='';
		document.form1.MailingAddress.value="AL";
		document.form1.Residence.value="AL";
	}
	else
	{
		document.form1.CountryforCoverage.value=1;
		document.getElementById("q11a").innerHTML='11. ';
		document.getElementById("q11b").innerHTML='If traveler already in USA, how   long has the traveler been in USA</div><div style="padding-top:2px"><font face="Arial, Helvetica, sans-serif" size=1 bgcolor="#f0f8ff">Choose your latest entry to USA.</font>';
		document.getElementById("q11c").innerHTML='<select name="USarrival" size="1"><option selected="selected" value="5">Not in USA yet</option><option value="0">Most recent US entry is within last 3 months</option><option value="1">Most recent US entry is within last 12 months</option><option value="2">Most recent US entry is within last 18 months</option><option value="3">Most recent US entry is within last 24 months</option><option value="4">Most recent US entry is more than 2 years ago</option></select>';
		document.form1.MailingAddress.value="2";
		document.form1.Residence.value="2";
	}
}


function conditionalparameters()
{
	var a,s,x,d,k,eighty, msg70;
	
	a=parseInt(document.form1.Age.value,10);
	eighty=a>=80?true:false;
	msg70=a<=80||s<=80?' between 70 to 79 years':' 80 years and above';
	s=parseInt(document.form1.spouseAge.value,10)?s!='':0;
	x=parseInt(document.form1.MaxPolicyLimit.value,10);
	
	if(x==0)x=25000; 
	if(x==51000)x=100000; 
	if(x==101000)x=490000;
	if(x==500000)x=999000;

	d=parseInt(document.form1.Deductible.value,10);
	if(d==50)d=100; if(d==101)d=250;
	
	ct=document.form1.CountryofCitizenship.value;
	
		var restrict=["80-1--0--100000","80-2--0--100000","80-2--100--100000","80-1--250--100000","80-1--500--100000","80-1--1000--100000","80-1--2500--100000","80-2--500--100000","80-2--1000--100000","80-2--2500--100000","80-1--0--490000","80-1--100--490000","80-1--250--490000","80-1--500--490000","80-1--1000--490000","80-1--2500--490000","80-2--0--490000","80-2--100--490000","80-2--250--490000","80-2--500--490000","80-2--1000--490000","80-2--2500--490000","80-1--0--500000","80-1--100--500000","80-1--250--500000","80-1--500--500000","80-1--1000--500000","80-1--2500--500000","80-2--0--500000","80-2--100--500000","80-2--250--500000","80-2--500--500000","80-2--1000--500000","80-2--2500--500000","80-1--0--1000000","80-1--100--1000000","80-1--250--1000000","80-1--500--1000000","80-1--1000--1000000","80-1--2500--1000000","80-2--0--1000000","80-2--100--1000000","80-2--250--1000000","80-2--500--1000000","80-2--1000--1000000","80-2--2500--1000000","70-1--0--25000","70-2--0--25000","70-1--250--25000","70-1--500--25000","70-2--500--25000","70-1--1000--25000","70-2--1000--25000","70-1--2500--25000","70-2--2500--25000","70-2--0--100000","70-2--0--490000","70-2--100--490000","70-2--250--490000","70-2--500--490000","70-2--1000--490000","70-2--2500--490000","70-2--0--500000","70-2--100--500000","70-2--250--500000","70-2--500--500000","70-2--1000--500000","70-1--1000--500000","70-2--2500--500000","70-1--2500--500000","70-2--0--1000000","70-2--100--1000000","70-2--250--1000000","70-2--500--1000000","70-2--1000--1000000","70-2--2500--1000000","70-1--1000--1000000","70-1--2500--1000000"];
	
	k=restrict[2];
	for(var i=0; i<restrict.length; i++)
	{
		k=restrict[i];
		if(
			   (
					(
					  eighty==true&& (a>=parseInt(k.substring(0,2))||s>=parseInt(k.substring(0,2)))
					  &&parseInt(k.substring(0,2))==80
					 )||
					(
						 eighty==false && (a>=parseInt(k.substring(0,2))||s>=parseInt(k.substring(0,2)))
					 )
				)
		   		&& ct==parseInt(k.substring(3,4)) && d==parseInt(k.substring(k.indexOf("--")+2,k.lastIndexOf("--"))) &&
				x==parseInt(k.substring(k.lastIndexOf("--")+2,k.length))
			)
		{  //beginning of if statements
			alert('There are no products available for travelers who are '+msg70+' , with maximum coverage of $'+k.substring(k.lastIndexOf("--")+2,k.length)+' and deductible $'+k.substring(k.indexOf("--")+2,k.lastIndexOf("--"))+'.\n\nPlease change your selection and then click "Get Quote".');	
			document.form1.MaxPolicyLimit.focus(); 
			return false;
		} //end of if statements
	} //end of for loop
	return true;
}

//-->
