function isDate(control, dateStr, dateFmt) {
	var matchArray = dateStr.match(/^(\d{2})-(\d{2})-(\d{4})$/);
// to match for format Y-m-d	/^(\d{4})-(\d{2})-(\d{2})$/

/*	(/^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/);
*/	if (matchArray == null) {
		setBGColour(control, '#fddbdb');
		alert("Please enter the date in the format "+dateFmt+". Your current selection reads: " + dateStr);
		return false;
	}
	if (dateFmt=="d/m/Y") {
		day = matchArray[1];
		month = matchArray[3];
	} else {
		day = matchArray[7];
		month = matchArray[5];
	}
	year = matchArray[1];
	if (month < 1 || month > 12) {
		setBGColour(control, '#fddbdb');
		alert("Month must be between 1 and 12.");
		return false;
	}
	if (day < 1 || day > 31) {
		setBGColour(control, '#fddbdb');
		alert("Day must be between 1 and 31.");
		return false;
	}
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		setBGColour(control, '#fddbdb');
		alert("Month "+month+" doesn`t have 31 days!");
		return false;
	}
	if (month == 2) {
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day > 29 || (day==29 && !isleap)) {
			setBGColour(control, '#fddbdb');
			alert("February " + year + " doesn`t have " + day + " days!");
			return false;
		}
	}
	setBGColour(control, '#ffffff');
	return true;
}
function setBGColour(control, colour) {
	control.style.backgroundColor=colour;
}
