<!--
var flg = 0;
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.CountryofCitizenship.selectedIndex = 0;
	temp.setFullYear(stref.getFullYear(),stref.getMonth()+1,stref.getDate()-1);
	setDates(stref,temp,1);
	questiondisplay('NONUSA');
	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 For US citizens & Permanent Home Outside USA when seeking coverage in 'All incl USA', 
if (((document.form1.CountryofCitizenship.value=='1')  && (document.form1.CountryforCoverage.value =='3') && (flg=='0')))
{
	alert('Are you sure you want coverage in ALL countries including USA? When you select this option and click "Get Quote" you will be re-directed to our annual worldwide coverage plans section. If you are primarily looking for short term (not annual) coverage, please change the Country of Coverage selection to either "All excl USA" or "USA only".\n');
	flg = 1;
	document.form1.CountryforCoverage.focus();
	return false;
}	
	if(conditionalparameters())
	{
		document.form1.quote.disabled=true;
		document.form1.resetquote.disabled=true;
		if(document.form1.CountryofCitizenship.value == '1' && document.form1.CountryforCoverage.value == '1' && document.form1.Residence.value != 2)
			window.open('http://www.ztourists.com/buy/assurant-short-term-health-insurance/','_top');
               else if(document.form1.CountryofCitizenship.value == '1' && document.form1.CountryforCoverage.value == '3' && flg==1)
		{				
			document.form1.action="/results/globalmoreoptions/";
			document.form1.submit();
		}
		else
			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" onchange="priorCvgQuestion();">'+ getUSArrivalHTML() +'</select>';
		document.form1.MailingAddress.value="2";
		document.form1.Residence.value="2";
	}
}

function arrivaldisplay(s)
{
	if(s.value=="4")
	{
		document.getElementById("q11a").innerHTML='';
		document.getElementById("q11b").innerHTML='';
		document.getElementById("q11c").innerHTML='';
	}
	else
	{
		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 size="1" name="USarrival" onchange="priorCvgQuestion();">' + getUSArrivalHTML() +'</select> ' ;
	}
}

function conditionalparameters()
{
	var a,s,x,d, cmn_msg;
	
	a=parseInt(document.form1.Age.value,10);
	s=parseInt(document.form1.spouseAge.value,10)?s!='':0;
	x=parseInt(document.form1.MaxPolicyLimit.value,10);
	d=parseInt(document.form1.Deductible.value,10);
	
	if(x==0)x=25000;
	if(x==26000)x=60000;
	if(x==61000)x=75000; 
	if(x==76000)x=100000; 
	if(x==101000)x=499000; 	

	cmnmsg = 'Please change your selection and then click "Get Quote"';
	
	ct=document.form1.CountryofCitizenship.value;

	/*if ((a>80||s>80)&&((x >100000&&ct==1)||(x >50000&&ct==2)))
	{
		alert('For travelers who are 80 yrs and above, the maximum coverage amount has to be $25,000 or $50,000 or $100,000(US citizen and deductible $50).\n'+ cmnmsg);
		 document.form1.MaxPolicyLimit.focus();
		 return false;
	} */

	if ((a>79||s>79)&&(x >100000&&ct==1))
	{
		alert('For US citizens who are 80 yrs and above, the maximum coverage amount has to be $26,000 or $60,000 or $100,000 for a non-zero deductible; maximum coverage should be $25,000 or less for a $0 deductible.\n'+ cmnmsg);
		document.form1.MaxPolicyLimit.focus();
		return false;
	}

	if ((a>79||s>79)&&(x >75000&&ct==2))
	{
		alert('For Non US citizens who are 80 yrs and above, the maximum coverage has to be $26,000 or $60,000 or $75,000 for a non-zero deductible; maximum coverage should be $25,000 or less for a $0 deductible.\n'+ cmnmsg);
		 document.form1.MaxPolicyLimit.focus();
		 return false;
	}

	/*if ((a>70||s>70)&&((x >250000&&ct==1)||(x >100000&&ct==2)) )
	{
		alert('For travelers who are 70 yrs and above, the maximum coverage has to be $25,000, $50,000 or $100,000(Non-US citizen) or $250,000(US citizen).\n'+ cmnmsg);
		 document.form1.MaxPolicyLimit.focus(); 
		 return false;
	}*/
	if (((a>69 && a<80)||(s>69 && s<80))&& (x >1000000&&ct==1))
	{
		alert('For US citizens who are 70 yrs and above, the maximum coverage has to be $1,000,000 or less; For deductibles more than $1,000, maximum coverage has to be less than $500,000.\n'+ cmnmsg);
		 document.form1.MaxPolicyLimit.focus(); 
		 return false;
	}
	if (((a>69 && a<80)||(s>69 && s<80))&&(x >100000&&ct==2))
	{
		alert('For Non US citizens who are 70 yrs and above, the maximum coverage amount has to be $26,000, $60,000, $75,000 or $100,000.\n'+ cmnmsg);
		 document.form1.MaxPolicyLimit.focus(); 
		 return false;
	}
	if ((a>79||s>79) && d==0 && x>26000)
	{
		alert('For all travelers who are 80 yrs and above requiring a $0 deductible, maximum policy coverage has to be $25,000.\n'+ cmnmsg);
		 document.form1.Deductible.focus(); 
		 return false;	
	}
	if ((a>79||s>79) && d>2500 && x>26000)
	{
		alert('For all travelers who are 80 yrs and above requiring deductible above 2500, maximum policy coverage has to be $25,000.\n'+ cmnmsg);
		 document.form1.Deductible.focus(); 
		 return false;	
	}
	if ( ((a>69&&a<80)||(s>69&&s<80)) && d==0  && x==25000)
	{
		alert('For all travelers between 70-79 yrs requiring a $0 deductible, maximum policy coverage has to be $26,000 or more.\n'+ cmnmsg);
		document.form1.Deductible.focus();
		return false;
	} 
	if ( ((a>69&&a<80)||(s>69&&s<80)) && d>101 && x==25000)
	{
		alert('For all travelers between 70-79 yrs requiring deductible above 101, maximum policy coverage has to be $26,000 or more.\n'+ cmnmsg);
		document.form1.Deductible.focus();
		return false;
	} 	

	switch(x)
	{
		case 25000:
			if ((a<70 || s<70)&& d>101)
			{
				alert('For travelers younger than 70yrs, the deductible has to be $250 or less.\n'+ cmnmsg);
				document.form1.Deductible.focus(); 
				return false;	
			}
			break;
		case 60000:
			if ((a<80 || s<80)&& d>5000)
			{
				alert('For travelers younger than 80yrs, the deductible has to be $5000 or less.\n'+ cmnmsg);
				document.form1.Deductible.focus(); 
				return false;	
			}
			break;
		case 100000:
	  		if ((a<70 || s<70)&& d>5000)
			{
				alert('For travelers younger than 70yrs, the deductible has to be $5000 or less.\n'+ cmnmsg);
				document.form1.Deductible.focus(); 
				return false;	
			}
			break;

		case 499000:
			if ((a<70)&& d>5000)
			{
				alert('For travelers younger than 70yrs, the deductible has to be $5000 or less.\n'+ cmnmsg);
				document.form1.Deductible.focus(); 
				return false;	
			}	
			break;	
		case 500000:	  	
			if ((a<70) && d > 5000)
			{
				alert('For all travelers younger than 70 yrs, the deductible has to be $5000 or less\n'+ cmnmsg);
				document.form1.Deductible.focus(); 
				return false;	
			}
			break;	
	}
	return true;
}

//This function displays the question for prior insurance coverage if the Non US citizen applicant/spouse's age > 65
//and seeks coverage in or including USA and arrived in the US less than 30 days ago.
function priorCvgQuestion()
{
	var age, sage, usarr, ctz, cvg;
	age = document.form1.Age.value;
	sage = document.form1.spouseAge.value;
	if (document.form1.USarrival)
		usarr = document.form1.USarrival.value;
	else
		usarr = -1;
	cvg = document.form1.CountryforCoverage.value;

	if ((age >=65 || sage >= 65) && usarr < 5 && (cvg != 4))
	{		
		var text = "<input type='radio' name='PriorCoverage' checked='checked' value='1'> Yes &nbsp; &nbsp";
		text += "<input type='radio' name='PriorCoverage' value='0'> No";
		document.getElementById("q12a").innerHTML="12.";
		document.getElementById("q12b").innerHTML= "Has the applicant/spouse aged 65 or more been covered by international travel insurance during the last 30 days?";
		document.getElementById("q12c").innerHTML= text;		
	}
	else
	{
		document.getElementById("q12a").innerHTML="";
		document.getElementById("q12b").innerHTML= "";
		document.getElementById("q12c").innerHTML= "";
	}
}
//-->

