function daysInFebruary (year)
{
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function DaysArray(n) 
{
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(month, day, year)
{
    var daysInMonth = DaysArray(12)
	
	if (month < 1 || month > 12) {
		alert("Please enter a valid month")
		return false
	}
	
 	if (day < 1 || day > 31 || (month == 2 && day > daysInFebruary(year)) || day > daysInMonth[month]) {
		alert("Please enter a valid day")
		return false
	}	
    return true	
}

function isOldEnough(minAge, year, mon, day)
{
    var time = new Date()
    var curMonth = time.getMonth() + 1
    var curDay = time.getDate()
    var curYear = time.getFullYear()
    var badYear = curYear - minAge

    if (year >= badYear) {
	    if (year == badYear && ((mon < curMonth) || (mon == curMonth && day <= curDay))) 
		   return true
		else
		   return false		
	}		
	else 
	    return true
}

