
	function IsValidDate(strDate) 
	{
		if(strDate == "")
		{
			return true;
		}
		
		// Checks for the following valid date formats:
		// MM-DD-YYYY or MM/DD/YYYY
		// Also separates date into month, day, and year variables
		var strDatePattern = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;

		// is the format ok?
		var aMatchArray = strDate.match(strDatePattern);
		if (aMatchArray == null)
		{
			// Invalid date Format
			//LHP alert('Invalid Date Format');
			alert('Invalid Date Format\n\nFormat should be MM/DD/YYYY.');
			return false;
		}

		// parse date into variables
		intMonth = aMatchArray[1];
		intDay = aMatchArray[3];
		intYear = aMatchArray[4];
		
		// check month range
		if (intMonth < 1 || intMonth > 12) 
		{ 
			alert('Month must be between 1 and 12');
			return false;
		}
		if (intDay < 1 || intDay > 31)
		{
			alert('Day must be between 1 and 31');
			return false;
		}
		if ((intMonth==4 || intMonth==6 || intMonth==9 || intMonth==11) && intDay==31)
		{
			alert('Month ' + intMonth + ' does not have 31 days.');
			return false;
		}

		// check for february 29th
		if (intMonth == 2)
		{
			var bolIsLeapYear = (intYear % 4 == 0 && (intYear % 100 != 0 || intYear % 400 == 0));
			if (intDay>29 || (intDay==29 && !bolIsLeapYear))
			{
				alert('February ' + intYear + ' does not have ' + intDay + ' days.');
				return false;
			}
		}

		// date is valid
		return true;
	}


	// ************************************************************
	// daysElapsed requires will return the number of days 
	// between two dates.  Make sure the input dates are of the
	// expected format: MM/DD/YY and/or MM/DD/YYYY.
	//
	//	daysElapsed("01/01/1995","07/01/04") returns -3469
	//	daysElapsed("07/01/04","01/01/1995") returns 3469
	// ************************************************************
	function daysElapsed(strDate1, strDate2) {
		var date1;
		var date2;
		
		try {
			// Convert the strings into date types
			date1 = new Date(strDate1);
			date2 = new Date(strDate2);
				
			var difference = 
				Date.UTC(date1.getFullYear(),date1.getMonth(),date1.getDate(),0,0,0) 
			  - Date.UTC(date2.getFullYear(),date2.getMonth(),date2.getDate(),0,0,0);
			//y2k function is elimated, Yang Li 01/31/2006
			//alert (date1.toString() + ', ' + date2.toString() + ', ' + difference);	
			//alert (strDate1 + ', ' + strDate2 + ', ' + difference/1000/60/60/24);  
			return difference/1000/60/60/24;
			
		} catch(err) {
			document.write("Internal Error occured in the daysElapsed function\n\nPlease contact the System Administrator if you continue receiving this error.");
		} // end try-catch block
	} // end function
			
	
	// ************************************************************
	// Make sure the year is a four digit year
	// either 20XX or 19XX.  The swing year is set at
	// 1960 for this function if no override is provided.
	// ************************************************************
	function y2k(year,swing) { 
		try {
			// Set the swing year if none is provided.
			if((swing==null) || (swing==0)) {
				swing = 60;
			} // end if
			
			// Make sure the year is numeric
			year = parseInt(year);
			
			// This check of year<1000 will make sure
			// that a 4 position year is returned.
			if(year<1000) {
				if(year<=swing) {
					return (year + 1900);
				} else {
					return (year + 2000);
				} // end if
			} else {
				return year;
			} // end if
			
		} catch(e) {
			document.write("Internal Error occured in the y2k function.\n\nPlease contact the System Administrator if you continue receiving this error.");
		} // end try-catch block
	} // end function
			
