<!--
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;
	hidetextbox();
}

function resetform()
{
	document.form1.reset();
	temp.setFullYear(stref.getFullYear(),stref.getMonth()+1,stref.getDate()-1);
	setDates(stref,temp,1);
	questiondisplay('NONUSA');
	hidetextbox();
}

function validate()
{
	if (!validVisitorAge(document.form1))  return false;
 	if (!validSpouseAge(document.form1)) return false;
	if (!validStartDate(start, stref,document.form1)) return false;
	if (!validEndDate(endd, start,document.form1)) return false;
	if (!validMonthsOfCoverage(document.form1)) 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.eshorttermhealthinsurance.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"><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;
}

//-->
