function CheckDateFormat(dateStr)
{ 
	var regexp;
	regexp = /^\d\d\/\d\d\/\d\d$/;
	// if the date string matched the pattern, check to make sure month/day values are acceptable
	if(regexp.test(dateStr))
	{
		// split date into month, day, year strings
		var dateStr;
		dateStr = dateStr.split(/\//); // split string at /
		// check month
		if(dateStr[0] < 1 || dateStr[0] > 12)
		{
			alert("Month must be from 1 to 12.");
			return false;
		}
		// check day
		if(dateStr[1] < 1 || dateStr[1] > 31)
		{
			alert("Day must be from 1 to 31.");
			return false;
		}
		// get current date
		var today = new Date();
		// make input year 4 digits
		dateStr[2] = "20" + dateStr[2];
		if(dateStr[2] > today.getYear())
		{
			alert("Year must be for this year or a previous one.");
			return false;
		}					
	}		
	else
	{
		alert("Date must be in mm/dd/yy format.");
		return false;
	}
	return true; // date was in the correct format with acceptable values for month, day and year
}

// check to see if testDate is after afterDate
function IsAfterDate(testDate, afterDate)
{
	// split date into month, day, year strings
	var dateStr;
	testDate = testDate.split(/\//); // split string at /
	afterDate = afterDate.split(/\//); // split string at /
	
	// make year values 4 digits if neccessary
	if(testDate[2] < 1000)
		testDate[2] = "20" + testDate[2];
	if(afterDate[2] < 1000)
		afterDate[2] = "20" + afterDate[2];
			
	// convert values to integers
	testDate[0] = parseInt(testDate[0], 10);
	testDate[1] = parseInt(testDate[1], 10);
	testDate[2] = parseInt(testDate[2], 10);
	
	afterDate[0] = parseInt(afterDate[0], 10);
	afterDate[1] = parseInt(afterDate[1], 10);
	afterDate[2] = parseInt(afterDate[2], 10);	
			
	// testDate is in the year after afterDate, so it is after the date
	if(testDate[2] > afterDate[2]) { 
		return true; }
	// testDate is in the same year as afterDate, see if it's after by checking month/day
	else if(testDate[2] == afterDate[2])
	{ 
		// testDate's month occurs after afterDate so return
		if(testDate[0] > afterDate[0])
			return true;
		// testDate is in the same month as afterDate, see if the day is after
		else if(testDate[0] == afterDate[0])
			if(testDate[1] > afterDate[1]) // same month, year, but the day we are testing is on a day occuring after afterDate
				return true;
	}	
	return false; // testDate is before afterDate
}


// check to see if testDate is after or equal to afterDate
function IsAfterOrEqualDate(testDate, afterDate)
{
	// split date into month, day, year strings
	testDate = testDate.split(/\//); // split string at /
	afterDate = afterDate.split(/\//); // split string at /
	
	// make year values 4 digits if neccessary
	if(testDate[2] < 1000)
		testDate[2] = "20" + testDate[2];
	if(afterDate[2] < 1000)
		afterDate[2] = "20" + afterDate[2];
			
	// convert values to integers
	testDate[0] = parseInt(testDate[0], 10);
	testDate[1] = parseInt(testDate[1], 10);
	testDate[2] = parseInt(testDate[2], 10);
	
	afterDate[0] = parseInt(afterDate[0], 10);
	afterDate[1] = parseInt(afterDate[1], 10);
	afterDate[2] = parseInt(afterDate[2], 10);	
			
	// testDate is in the year after afterDate, so it is after the date
	if(testDate[2] > afterDate[2]) 
		return true;
	// testDate is in the same year as afterDate, see if it's after by checking month/day
	else if(testDate[2] == afterDate[2])
	{ 
		// testDate's month occurs after afterDate so return
		if(testDate[0] > afterDate[0]) { 
			return true; }
		// testDate is in the same month as afterDate, see if the day is after
		else if(testDate[0] == afterDate[0])
			if(testDate[1] >= afterDate[1]) // same month, year, but the day we are testing is on a day occuring after afterDate
				return true;
	}	
	return false; // testDate is before afterDate
}

// see if two dates refer to the same day
function IsSameDay(date1, date2)
{
	// split date into month, day, year strings
	date1 = date1.split(/\//); // split string at /
	date2 = date2.split(/\//); // split string at /

	// make year values 4 digits if neccessary
	if(date1[2] < 1000)
		date1[2] = "20" + date1[2];
	if(date2[2] < 1000)
		date2[2] = "20" + date2[2];
			
	// convert values to integers
	date1[0] = parseInt(date1[0], 10);
	date1[1] = parseInt(date1[1], 10);
	date1[2] = parseInt(date1[2], 10);
	
	date2[0] = parseInt(date2[0], 10);
	date2[1] = parseInt(date2[1], 10);
	date2[2] = parseInt(date2[2], 10);
		
	if(date1[0] == date2[0] && date1[1] == date2[1] && date1[2] == date2[2])
		return true; // same day
	else
		return false; // not the same day	
}

// not yet working
function GetCurrentDate()
{
	var today = new Date();
	//alert(today.getMonth() +"/"+ today.getDay() +"/"+ today.getYear());
	return today.getMonth() +"/"+ today.getDay() +"/"+ today.getYear();
}