function iniForm()
{
		setDates(stref,temp,1);
                document.form1.NumberOfChildren.value = 0;
	hidetextbox();
}

function resetform()
{
 		document.form1.Age.value = "";
 		document.form1.spouseAge.value=""
 		document.form1.NumberOfChildren.value=0;
 		document.form1.MaxPolicyLimit.selectedIndex = 3;
 		document.form1.Deductible.selectedIndex = 1;
 		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(1);
		hidetextbox();
}

function validate()
{	
	var a;
	a=document.form1.Age.value;

	if(a==''||isNaN(a)||a<1||a>99)
	{
		alert("Student's Age is mandatory and it should be in numeric format in the range 18-99.");
		document.form1.Age.focus();
		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(conditionalparameters())
	{
		document.form1.quote.disabled=true;
		document.form1.resetquote.disabled=true;
		document.form1.submit();
	}
}
function questiondisplay4(s)
{

	if(s=="50000")
	{
			document.form1.Deductible.value= "101-250";
	}
	else
	{document.form1.Deductible.value="50-100";}

}
function questiondisplay7(s)
{
	if(s==1)
	{
		document.form1.CountryforCoverage.value=4;
		document.form1.MailingAddress.value="AL";
		document.form1.Residence.value="AL";
	}
	else
	{
		document.form1.CountryforCoverage.value=1;
		document.form1.MailingAddress.value="2";
		document.form1.Residence.value="2";
	}
}

function questiondisplay(s)
{
	if(s=="0")
	{
		document.getElementById("qs7aa").innerHTML='';
		document.getElementById("qs7a").innerHTML='';
		document.getElementById("qs7b").innerHTML='';
	}
	else
	{
		document.getElementById("qs7aa").innerHTML='12.';
		document.getElementById("qs7a").innerHTML='Are you registered for courses? ';
		document.getElementById("qs7b").innerHTML='<select name="Course" size="1"><option selected="selected" value="1">YES</option><option value="0">NO</option></select>';
	}
}


function showtextbox(n)
{
	hidetextbox();
	for(var i=0; i < n; i++)
	{
		document.getElementById("dtc"+i).innerHTML='<div style="font-size:7px; font-family:Arial, Helvetica, sans-serif; color:#000000" >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 conditionalparameters()
{
	var a,s,x,d;
	a=document.form1.Age.value;
	s=document.form1.spouseAge.value;
	x=parseInt(document.form1.MaxPolicyLimit.value,10);
	cmn_msg = 'Please change your selection and then click "Get Quote"';
	d=parseInt(document.form1.Deductible.value,10);

	if ((a>80||s>80)&&x >60000)
	{
		alert('For travelers who are 80 yrs and above, the maximum coverage amount has to be less than $60,000.\n\n'+ cnm_msg);
		document.form1.MaxPolicyLimit.focus(); 
		return false;
	}
	if ((a>70||s>70)&&x >100000)
	{
		alert('For travelers who are 70 yrs and above, the maximum coverage amount has to be less than $100,000.\n\n'+ cnm_msg);
		document.form1.MaxPolicyLimit.focus(); 
		return false;
	}
	if ((a>70||s>70)&&x!=60000&&d==0)
	{
		alert('For travelers who are 70 yrs and above requiring a $0 deductible, the maximum coverage amount has to be $60,000.\n\n'+ cnm_msg);
		document.form1.Deductible.focus(); 
		return false;	
	}
	if ((a<80||s<80) && d==0 && x==25000)
	{
		alert('For all travelers younger than 80 yrs requiring a $0 deductible, maximum policy coverage has to be greater than $25,000.\n\n'+ cnm_msg);
		document.form1.Deductible.focus(); 
		return false;	
	}
	if ((a>=80||s>=80) && d==0 && x!=25000)
	{
		alert('For all travelers older than 80 yrs requiring a $0 deductible, maximum policy coverage has to be $25,000 or lower.\n\n'+ cnm_msg);
		document.form1.Deductible.focus(); 
		return false;	
	}
	return true;
}