function popCal(strFieldName)	{
	var win	= window.open("calendar.asp?bn="+strFieldName,"calendar","location=no,scrolling=no,status=no,width=213,height=230");
}

function checkForm(objForm)		{
	var bolPassed	=	true;
	if (objForm.Event_Name.value == "")	{
		bolPassed	=	false;
		alert("Please enter a name for this event.");
		objForm.Event_Name.focus();
	}
	else if (objForm.Event_Location.value == "")	{
		bolPassed	=	false;
		alert("Please enter a location for this event.");
		objForm.Event_Location.focus();
	}
	else if (objForm.Event_Start_Date.value == "")	{
		bolPassed	=	false;
		alert("Please enter a start date for this event.");
		objForm.Event_Start_Date.focus();
	} else if (objForm.Event_Contact_Phone.length <= 10)	{
		bolPassed	=	false;
		alert("Please include the area code with the contact phone number.");
		objForm.Event_Contact_Phone.focus();
	}

	if (bolPassed	==	true)	{
		objForm.submit();
	}
}




function doDuration(objFromBox,objUntilBox,objSelectedMonths)	{
	 // -------------------------------------------------------
	// Function to return the date that is daysToDetermine days
	//          from Start Date object.
	// Arguments:
	//    1. Start Date - user supplied date.
	//    2. the value selected from the duration box.
	//    3. display the date in the End Date textbox.
	// Called only if the user select weeks as their duration.
	// Author: Herman Simms 27 March 2001
	// -------------------------------------------------------
		var dtStartDate = new Date(objFromBox.value)

		if (isNaN(dtStartDate)) {
			alert('You must enter or select a start date first.');
			objSelectedMonths.options.value = 0;
			objFromBox.focus();
		}
		else {
			switch(objSelectedMonths.options[objSelectedMonths.selectedIndex].value) {
				case '1':
					var daysPlus = 7
					 whenWeek(dtStartDate,daysPlus, objUntilBox);
					break;
				case '2':
					var daysPlus = 14
					whenWeek(dtStartDate,daysPlus, objUntilBox);
					break;
				case '3':
					var daysPlus = 21
					whenWeek(dtStartDate,daysPlus, objUntilBox);
					break;
				case '5':
					objUntilBox.value = whenDay((dtStartDate.getMonth()+2), dtStartDate.getDate(), dtStartDate.getYear());
					break;
				case '6':
					objUntilBox.value = whenDay((dtStartDate.getMonth()+3), dtStartDate.getDate(), dtStartDate.getYear());
					break;
				case '7':
					objUntilBox.value = whenDay((dtStartDate.getMonth()+4), dtStartDate.getDate(), dtStartDate.getYear());
					break;
				case '8':
					objUntilBox.value = whenDay((dtStartDate.getMonth()+5), dtStartDate.getDate(), dtStartDate.getYear());
					break;
				case '9':
					objUntilBox.value = whenDay((dtStartDate.getMonth()+6), dtStartDate.getDate(), dtStartDate.getYear());
					break;
				case '10':
					objUntilBox.value = whenDay((dtStartDate.getMonth()+7), dtStartDate.getDate(), dtStartDate.getYear());
					break;
			}
		}

}


function whenDay(dtMonth, dtDay, dtYear) {
	// -------------------------------------------------------
	// Function to return the date that is daysToDetermine days
	//          from Start Date object.
	// Arguments:
	//    1. Start Date - user supplied date.
	//    2. the value selected from the duration box.
	//    3. display the date in the End Date textbox.
	// Called only if the user select weeks as their duration.
	// Author: Herman Simms 27 March 2001
	// -------------------------------------------------------
		if (dtMonth > 12) {
			dtMonth -= 12;
			dtYear += 1;
		}
		if ((dtMonth == 2) || (dtMonth == 02)) {
			if (dtYear % 4 == 0) {
				intTotalMonthDays = 29;
			}
			else {
				intTotalMonthDays = 28;
			}
		}
		//check days for April, June, September and November
		else if ((dtMonth == 4) || (dtMonth == 6) || (dtMonth == 9) || (dtMonth == 11)) {
			intTotalMonthDays = 30;
		}
		//the remaining months have 31 days in them.
		else {
			intTotalMonthDays = 31;
		}
		if (dtDay > intTotalMonthDays) {
			dtDay = intTotalMonthDays;
		}

		return dtMonth + "/" + dtDay + "/" + dtYear;
	}
	
	
	function whenWeek(dtStartDate, daysToDetermine, objUntilBox) {
	// -------------------------------------------------------
	// Function to return the date that is daysToDetermine days
	//          from Start Date object.
	// Arguments:
	//    1. Start Date - user supplied date.
	//    2. the value selected from the duration box.
	//    3. display the date in the End Date textbox.
	// Called only if the user select weeks as their duration.
	// Author: Herman Simms 27 March 2001
	// -------------------------------------------------------

		var newWeekDate = new Date()

		newWeekDate.setTime(dtStartDate.getTime()+(daysToDetermine * 1000 * 60 * 60 * 24));

		return objUntilBox.value = (newWeekDate.getMonth()+1) + "/" + newWeekDate.getDate()
											+ "/" + newWeekDate.getYear();
	}
	function isValidDate(objTextName, dtDate, objStartDate) {
	// -------------------------------------------------------
	// Function to check the date to ensure that it is valid.
	//			If not, then prompt the user and stop the
	//			process.
	// Arguments:
	//    1. calendar box object - user supplied date.
	// Called only if the user enters some date.
	// Author: Herman Simms 30 March 2001
	// -------------------------------------------------------

		var dtCurrentDate = new Date()

		intMonth = intDate = intYear = 0; // initialize the varibles to zero

		errCheck = false;  //month, day and/or year test.
		blnCheckDate = false;

		if (dtDate.length == 10) {
			if ((dtDate.substring(2,3) == "/") && (dtDate.substring(5,6) == "/")) {
				intMonth = dtDate.substring(0,2);
				intDate = dtDate.substring(3,5);
				intYear = dtDate.substring(6,10);
			}
		}
		else if (dtDate.length == 9) {
			intMonth = dtDate.substring(0,2);
			var strMonthBkSlash = intMonth.indexOf("/",0);

			if (strMonthBkSlash == 1) {
				intMonth = 0 + intMonth.substring(0,1);
			}
			if ((dtDate.substring(1,2) == "/") && (dtDate.substring(4,5) == "/")) {
				intDate = dtDate.substring(2,4);
			}
			else if ((dtDate.substring(1,2) != "/") && (dtDate.substring(4,5) == "/")) {
				intDate = 0 + dtDate.substring(3,4);
			}
			intYear = dtDate.substring(5,9);
		}
		else if (dtDate.length == 8) {
			intMonth = dtDate.substring(0,2);
			var strMonthBkSlash = intMonth.indexOf("/",0);

			if (strMonthBkSlash == 1) {
				intMonth = 0 + intMonth.substring(0,1);
			}
			if ((dtDate.substring(1,2) == "/") && (dtDate.substring(3,4) == "/")) {
				intDate = 0 + dtDate.substring(2,3);
				intYear = dtDate.substring(4,8);
			}
			else if ((dtDate.substring(1,2) != "/") && (dtDate.substring(3,4) != "/")) {
				intDate = dtDate.substring(3,5);
				intYear = dtDate.substring(6,8);
			}
		}

		sub = objTextName.name;
//			alert(objTextName.name);
		if ((objTextName.name == sub) || (objTextName.name == sub)) {
			if (dtDate.length != 0) {
				if (dtDate.length < 8) {
					errCheck = true;
				}
				else {
					blnCheckDate = true;
				}
			}
		}
		if (blnCheckDate == true) {
			//check the month and make sure that it is between 0 (Jan) and 11 (Dec)
			if ((intMonth <= 0) || (intMonth > 12) || (isNaN(intMonth))){
				errCheck = true;
			}
			//initialize the day variable for each given months in their day range.
			// check days for February also count for Leap Year
			if (intMonth == 02) {
				if (intYear % 4 == 0) {
					intTotalMonthDays = 29;
				}
				else {
					intTotalMonthDays = 28;
				}
			}
			//check days for April, June, September and November
			else if ((intMonth == 4) || (intMonth == 6) || (intMonth == 9) || (intMonth == 11)) {
				intTotalMonthDays = 30;
			}
			//the remaining months have 31 days in them.
			else {
				intTotalMonthDays = 31;
			}
			if ((intDate < 1) || (intDate > intTotalMonthDays) || (isNaN(intDate))) {
				errCheck = true;
			}
			//year must be of 4 numbers long.
			if ((intYear.length != 4) || (isNaN(intYear))) { //|| (intYear < dtCurrentDate.getYear())) {
				errCheck = true;
			}
		}
		if (errCheck == true) {
			alert("The date entered is not a invalid date. Ensure that the date\n" +
				  "is in MM/DD/YYYY format or Click the calendar button\n" +
				  "to add the date.");
			objTextName.select();
			objTextName.focus();
		}
		//check to see if the user end date is before the start.
		else if (objTextName.name == "e_" + sub) {
			ValidateEndDate(objTextName, objStartDate);
		}
	}

	function ValidateEndDate(dtEndDate, dtStartDate) {
	// -------------------------------------------------------
	// Function to check the end date to ensure that its value
	//			is not earlier than the start date. Prompt the
	//			user to check end date before processing.
	// Arguments:
	//    1. end date box object - user supplied date.
	//	  2. start date box object - user supplied date.
	//
	// Author: Herman Simms 30 March 2001
	// -------------------------------------------------------
		var dtEDCheck = new Date(dtEndDate.value)
		var dtSTCheck = new Date(dtStartDate.value)

		var dtDiff = dtEDCheck.getTime() - dtSTCheck.getTime();
		var dtDaysDiff = Math.floor(dtDiff / 1000 / 60 / 60 / 24);

		if (dtDaysDiff < 0) {
			alert('The end date can not start before its start date.  Check end date!');
			dtEndDate.select();
			dtEndDate.focus();
		}
	}
