function validatemini()
{	

	if (!validVisitorAge())  return;
 	if (!validSpouseAge()) return;
 	//added another check to ensure atleast a valid number of months or days are entered
	
	if(document.form1.monthsOfCoverage.value!='' && isNaN(document.form1.monthsOfCoverage.value))
	{
		alert('Coverage month has to be numeric. Kindly re-enter');
		document.form1.monthsOfCoverage.focus();
		return ;
	}

	if(document.form1.daysOfCoverage.value!='' && isNaN(document.form1.daysOfCoverage.value))
	{
		alert('Coverage days has to be numeric. Kindly re-enter');
		document.form1.daysOfCoverage.focus();
		return ;
	}
		//code added to ensure that 0 gets passed if no of months or days are not entered.
	if (document.form1.monthsOfCoverage.value=='') document.form1.monthsOfCoverage.value = 0;
	if (document.form1.daysOfCoverage.value=='') document.form1.daysOfCoverage.value = 0;
		
   if (document.form1.monthsOfCoverage.value==0 && document.form1.daysOfCoverage.value==0)
   {
		alert('Please enter a valid coverage period.'); 
		document.form1.monthsOfCoverage.focus(); 
		return;
   }
	 //end add
	if ((document.form1.monthsOfCoverage.value=='' && document.form1.daysOfCoverage.value=='')||
		 document.form1.monthsOfCoverage.value>12 || 
	 	(document.form1.monthsOfCoverage.value==12&&document.form1.daysOfCoverage.value>0)||		  
	    (document.form1.monthsOfCoverage.value==11&&document.form1.daysOfCoverage.value>30))
	{
		alert('Coverage period can not be blank or more than one year(12 months).'); 
		document.form1.monthsOfCoverage.focus(); 
		return;
	}
		if (!validCoveragePeriod())
	{
		alert('Coverage period cannot be more than 1 year(12 months)');
		document.form1.monthsOfCoverage.focus(); 
		return;
	}
	if(conditionalparameters())
	{
		document.form1.quote.disabled=true;
	  	document.form1.submit();
	}

}

function conditionalparameters()
{
	var a,s,x,d, cmnmsg;
	
	a=parseInt(document.form1.Age.value,10);
	s=parseInt(document.form1.spouseAge.value,10)?s!='':0;
	x=parseInt(document.form1.MaxPolicyLimit.value,10);
	cmnmsg = 'Please change your selection and then click "Get Quote"';
	
	if(x==75000)x=100000;
	if(x==150000)x=250000;
	d=parseInt(document.form1.Deductible.value,10);
	ct=document.form1.CountryofCitizenship[0].checked==true?parseInt(document.form1.CountryofCitizenship[0].value,10):parseInt(document.form1.CountryofCitizenship[1].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).<br/>'+ 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 amount has to be $25,000, $50,000 or $100,000(Non-US citizen) or $250,000(US citizen).<br/>'+ cmnmsg);
		 document.form1.MaxPolicyLimit.focus(); 
		 return false;
	}
	
	if ((a>70||s>70)&&x!=50000&&d==0)
	{
		alert('For travelers who are 70 yrs and above requiring a $0 deductible, the maximum coverage amount has to be $50,000.<br/>'+ cmnmsg);
	 	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.<br/>' + cmnmsg);
		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.<br/>'+ cmnmsg);
		document.form1.Deductible.focus(); 
	 	return false;	
	 }
	return true;
}

//This function takes the user to the Compare.asp page when the 'More Options' button is clicked.
function gomain()
{
	if (!validCoveragePeriod())
	{
		alert('Coverage period cannot be more than 1 year(12 months)');
		document.form1.monthsOfCoverage.focus(); 
		return;
	}
		document.form1.P.value=document.form1.Age.value;
		document.form1.S.value=document.form1.spouseAge.value;
		document.form1.mths.value = document.form1.monthsOfCoverage.value!=''?document.form1.monthsOfCoverage.value:0;
		document.form1.dys.value = document.form1.daysOfCoverage.value!=''?document.form1.daysOfCoverage.value:0;
		document.form1.x.value=document.form1.MaxPolicyLimit.value;
		document.form1.us.value=document.form1.CountryofCitizenship[0].checked==true?document.form1.CountryofCitizenship[0].value:document.form1.CountryofCitizenship[1].value;
  		document.form1.action='/results/visitormoreoptions/';		
		document.form1.submit();
}


