function validNumeric(val)
{
	if (String(parseInt(val)) != String(val))
		return false;	
	return true;
}

function validVisitorAge()
{
	if(document.form1.Age.value==''|| (!validNumeric(document.form1.Age.value))||
		document.form1.Age.value<1||document.form1.Age.value>99)
	{	
		alert('Visitor\'s Age is mandatory and it should be in numeric format in the range 1-99.');
		document.form1.Age.focus();
		return false;
	}
	return true;
}

function validSpouseAge()
{
	if(document.form1.spouseAge.value!=''&& (!validNumeric(document.form1.spouseAge.value)||
		document.form1.spouseAge.value<18||document.form1.spouseAge.value>99))
	{	
		alert('Spouse Age should be in numeric format in the range 18-99.');
		document.form1.spouseAge.focus();
		return false;
	}	
	return true;
}

function validStartDate(st, ref)
{
	if(getDates()==false||st < ref )
	{
		alert('Start Date should be valid and more than tommorrow\'s date.');
		document.form1.DepartureDay.focus(); 
		return false;
	}
	return true;
}

function validEndDate(ed, st)
{
	if(getDates()==false|| ed < st )
	{
		alert('End Date should be valid and more than Start Date as well as tommorrow\'s date.');
		document.form1.ReturnDay.focus(); 
		return false;
	}
	return true;
}

function validMonthsOfCoverage()
{
	if(document.form1.monthsOfCoverage.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 cannot be more than one year(12 months).'); 
		document.form1.ReturnDay.focus(); 
		return false;
	}
	return true;
}

function validDepChildrenAge()
{
	for(var i=0; i<6; i++)
	{
		if(document.getElementById("dependant"+i) != null)
		{
			if (document.getElementById("dependant"+i).value=='')
			{
				alert('Age of one or more dependant children is blank. Kindly enter.');
				return false;
			}
			if (!validNumeric(document.getElementById("dependant"+i).value))
			{
				alert('Dependendant children age has to be in the numeric format in the range 0-17');	
				return false;
			}
			if	(document.getElementById("dependant"+i).value < 0 ||document.getElementById("dependant"+i).value>18)
			{
				alert('Dependendant children age has to be in the range 0-17');	
				return false;
			}
		}
	}
	return true;
}

