// Date validation function
// Checks whether a date is in the format dd/mm/yyyy
// If so, returns true, if not false.

function isValidDate(strDate)
{
	if (strDate.length < 10)
	{
		return false;
	}
	
	var strDay = strDate.substr(0, strDate.indexOf("/"))
	var strMonth = strDate.substr((strDate.indexOf("/") + 1), (strDate.lastIndexOf("/") - strDate.indexOf("/") - 1));
	var strYear = strDate.substr(strDate.lastIndexOf("/") + 1);
	var iDay = parseInt(strDay, 10);
	var iMonth = parseInt(strMonth, 10);
	var iYear = parseInt(strYear, 10);
	if (iDay < 1 || iDay > 31 || iMonth > 12 || iYear < 2002 || iYear > 2010 || isNaN(iDay) || isNaN(iMonth) || isNaN(iYear))
	{
		return false;
	}

	var dtDate = new Date('01/01/2003');
	dtDate.setYear(iYear);
	dtDate.setDate(iDay);
	dtDate.setMonth(iMonth - 1);

	// Check for dodgy dates like 31/04 or 35/12
	if (iDay != dtDate.getDate() || iMonth != dtDate.getMonth() + 1)
	{
		return false;
	}
	return true;

}
