<!-- Hide from older browsers

daysPerMonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31)

function setDefaults(thisForm, noDays, closingTime) {
	thisForm.name.value = " "
	thisForm.password.value = " "

	now = new Date
	tmpMonth = now.getMonth()+1
	tmpYear = now.getYear();
	if (tmpYear % 4 == 0) //leapyear
		daysPerMonth[1] = 29;
	else daysPerMonth[1] = 28;

	thisForm.startDate.value = "" + tmpMonth+"/"+now.getDate()+"/"+now.getYear()
	tH = now.getHours()
	ampm = " AM"
	if (tH > 12)
	{
		ampm = " PM"
		tH -= 12;
	}
	if (tH < 10)
		tmpHours = "0" + tH;
	else	tmpHours = "" + tH;
	tM = now.getMinutes();
	if (tM < 10)
		tmpMinutes = "0" + tM;
	else	tmpMinutes = "" + tM;
	thisForm.startTime.value = "" + tmpHours + ":" + now.getMinutes() + ampm;
	tmpDate= now.getDate() + noDays;
	if (tmpDate > daysPerMonth[now.getMonth()]) {
		tmpDate -= daysPerMonth[now.getMonth()];
		tmpMonth += 1;
		if (tmpMonth > 12) {
			tmpMonth = 1;
			tmpYear += 1;
		}
	}
	thisForm.endDate.value = "" + tmpMonth+"/"+tmpDate+"/"+tmpYear
	thisForm.endTime.value = closingTime

}
function chkDate(fld) {
	re = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/
	ok = false;
	if( re.test(fld.value)) 
	{
		tmpMonth = eval(RegExp.$1)
		tmpDay = eval(RegExp.$2)
		tmpYear = eval(RegExp.$3)
		ok = true;
		if (tmpYear < 2004 || tmpYear > 2030) {
			alert ("Invalid Year (out of range 2004 - 2030) - \"" + tmpYear + "\"")
			ok = false;
		}		
		else 
			tmpYear = 2004
		if (tmpYear % 4 == 0) //leapyear
			daysPerMonth[1] = 29;
		else daysPerMonth[1] = 28;

		if (tmpMonth < 1 || tmpMonth > 12) {
			alert ("invalid Month (out of range 1-12) - \"" + tmpMonth + "\"")
			ok = false;
			tmpMonth = 1; // for date comparisions
		}
		tmpMonth --;
		if (tmpDay <1 ||  tmpDay > daysPerMonth[tmpMonth]) {
			alert ("invalid Day (out of range 1-"+daysPerMonth[tmpMonth]+ ") - \"" + tmpDay + "\"")
			ok = false;
		}
	}
	else 
		alert("invalid date format (should be mm/dd/yyyy) - \"" + fld.value + "\"")
	return ok

}
function chkTime(fld) {
	re = /^(\d{1,2})\:(\d{1,2})\s*([APap])([Mm])$/
	ok = false;
	if( re.test(fld.value)) 
	{
		tmpHour = eval(RegExp.$1)
		tmpMinute = eval(RegExp.$2)
		tmpAMPM = RegExp.$3 + RegExp.$4
//		alert ("read tmpHour = " + tmpHour + " tmpMinute = " + tmpMinute + tmpAMPM)
		ok = true;
		if (tmpHour < 1 || tmpHour >12) {
			alert ("Invalid Hour (out of range 1 - 12) - \"" + tmpHour + "\"")
			ok = false;
		}
		if (tmpMinute > 59) {
			alert ("invalid Minute (out of range 0-59) - \"" + tmpMinute + "\"")
			ok = false;
		}
	}
	else 
		alert("invalid time format (should be hh:mm AM/PM) - \"" + fld.value + "\"")
	return ok
}
function validForm(theForm)
{
	ok = true;
	re = /\s*(\S+)/
	if (!re.test(theForm.custName.value)) {
		alert("The Name field is required. It uniquely identifies the customer in the Database")
		ok = false;
	}
	else 	custName = RegExp.$1
	if (!re.test(theForm.password.value)) {
		alert("The password field is required.")
		ok = false
	}
	else 	custPassword = RegExp.$1
	ok = ok && chkDate(theForm.startDate) && chkDate(theForm.endDate) && 
			chkTime(theForm.startTime) && chkTime(theForm.endTime);
	if (ok)
		theForm.submit()
	else
		alert("errors in form - correct and resubmit")

}
function rtntoAdmin() {
	window.location = "AdminSpecLogin.htm";
}
function checkLogin() {
	logedin = false;
	if (document.cookie != "" ) {
		loginType = document.cookie.split("=")[0];
		if (loginType == "ALogin") 
			logedin = true;
		}
	if(!logedin) {
		self.document.clear();
		window.location = "AdminLogin.htm";   
		}	
}
function checkCustLogin() {
	logedin = false;
	if (document.cookie != "" ) {
		loginType = document.cookie.split("=")[0];
		if (loginType == "Login")
			logedin = true;
		}
	if (!logedin) {		
		self.document.clear();
		window.location = "custLogin.htm";   
		alert("Not currently logged in. Please Log in");
	}
}

//end hinding script from old browers -->
