/************************************/
/*PopUp Calendar Initialization */

//Define calendar(s): addCalendar ("Unique Calendar Name", "Window title", "Form element's name", Form name")
//addCalendar("Calendar2", "Select Date", "AnotherDate", "_Main");

// default settings for English
// Uncomment desired lines and modify its values
// setFont("verdana", 9);
 setWidth(90, 1, 15, 1);
// setColor("#cccccc", "#cccccc", "#ffffff", "#ffffff", "#333333", "#cccccc", "#333333");
 //setFontColor("#333333", "#333333", "#333333", "#ffffff", "#333333");
 setFormat("mm/dd/yyyy");
//setSize(200, 200, -200, 16);

// setWeekDay(0);
// setMonthNames("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
//setDayNames("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
// setLinkNames("[Close]", "[Clear]");
/*End PopUp Calendar Initialization*/
/*****************************************/

// isFormattedDate() date validation function for dates of form mm/dd/yyyy - Wright Furman 8/10/2005
function isFormattedDate(DateField, FieldLabel, ErrorMessage) {
	//Checks to see if field containing date is formatted in mm/dd/yyyy, Month < 13, Day <32, Year is 4 digits.
	//Returns true/false and an error message if false
	ErrorMessage.Message = "";
	if (DateField.value == "") {
		ErrorMessage.Message = "Field " + FieldLabel + ":  You must enter a date value!";
		return false;
	}
	var DateString = DateField.value;
	//Test to see if the date was input with mm/dd/yyyy format.
	var Month = parseInt(DateString.substring(0, DateString.indexOf("/")));
	var DateRemainder = DateString.substring(DateString.indexOf("/")+1);
	var Day = parseInt(DateRemainder.substring(0, DateRemainder.indexOf("/")));
	//Month
	if (Month >12) {
		ErrorMessage.Message = "Field " + FieldLabel + ":  The month number may not be greater than 12.";
		return false;
	}
	//Day may not be greater than 31
	if (Day > 31) {
		ErrorMessage.Message = "Field " + FieldLabel + ":  You may not enter a day of the month over 31.";
		return false;
	}
	//Must enter 4 digit year
	if ( DateRemainder.substring(DateRemainder.indexOf("/")+1).length < 4 ) {
		ErrorMessage.Message = "Field " + FieldLabel + ":  You must enter a 4 digit year.";
		return false;
	}
	var Year = parseInt(DateRemainder.substring(DateRemainder.indexOf("/")+1));
	if (isNaN(Month) || isNaN(Day) || isNaN(Year)) {
		ErrorMessage.Message = "Field " + FieldLabel + ":  You must enter a valid date in format mm/dd/yyyy.";
		return false;
	}
	var oDate = new Date(Year, Month, Day);
	if (typeof(oDate) == "undefined") {
		ErrorMessage.Message = "Field " + FieldLabel + ":  You must enter a valid date in format mm/dd/yyyy.";
		return false;
	}
	return true;
}
