<!--
var globalDateField = null; 
var globalTimeField = null; 

function isDate(dateStr, src)
{
	//chkId no longer used need to remove from all pages before
	//removing from what is passed into the function!!!!
	globalDateField = src; 
	if(dateStr.substring(0,1) == 'E')
	{
		return false;
	}
	
	if (dateStr != "")
	{
		var datePat = /^(\d{1,2})(\/?|-?)(\d{1,2})(\/?|-?)(\d{4}|\d{2})$/;
		var matchArray = dateStr.match(datePat); // is the format ok?
		
		if (matchArray == null)
		{
			//document.mainForm.elements[chkId].value = "no";
			alert("Please enter date as either mm/dd/yyyy or mm-dd-yyyy.");
			setTimeout("globalDateField.focus(); globalDateField.select()", 0);
			return(false);
		}  // end null matchArray

		month = matchArray[1]; // parse date into variables
		day = matchArray[3];
		year = matchArray[5];

      //if year is 2 digits, put "20" on the front
      if (year.length == 2)
		{
		 	year = "20" + year;
		}

   	if (month < 1 || month > 12)
	 	{ // check month range
	 		//document.mainForm.elements[chkId].value = "no";
			alert("Month must be between 1 and 12.");
   	 	setTimeout("globalDateField.focus(); globalDateField.select()", 0);
        	return false;
    	}
	 	else if (day < 1 || day > 31)
	 	{
        //document.mainForm.elements[chkId].value = "no";
		  alert("Day must be between 1 and 31.");
        setTimeout("globalDateField.focus(); globalDateField.select()", 0);
        return false;
    	}
	 	else if ((month==4 || month==6 || month==9 || month==11) && day==31)
	 	{
        //document.mainForm.elements[chkId].value = "no";
		  alert("Month "+month+" doesn't have 31 days!");
        setTimeout("globalDateField.focus(); globalDateField.select()", 0);
        return false;
    	}
	 	else if (month == 2)
	 	{ // check for february 29th
        var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
        if (day > 29 || (day==29 && !isleap))
		  {
            //document.mainForm.elements[chkId].value = "no";
				alert("February " + year + " doesn't have " + day + " days!");
            setTimeout("globalDateField.focus(); globalDateField.select()", 0);
            return false;
        }
		  else
	 		{
				//document.mainForm.elements[chkId].value = "";
				globalDateField.value = month + "/" + day + "/" + year;
				return true; // date is valid
			}
    	}
	 	else
	 	{
			//document.mainForm.elements[chkId].value = "";
			globalDateField.value = month + "/" + day + "/" + year;
			return true; // date is valid
		}
  }
  else
  {
		//document.mainForm.elements[chkId].value = "";
		return true;
  }
} //end isDate fxn


function checkTime(timestr, src)
{
	globalTimeField = src;
	if(timestr.substring(0,1) == 'E')
	{
		return false;
	}
	
	//if(document.mainForm.elements[chkId].value != '')
	//{
		//return false;
	//}
	
	if(timestr == '')
	{
		return true;
	}
	
	//if (timestr == "" && document.mainForm.elements[rowId].value != '1/1/2000')
	//{
	//	if(document.mainForm.elements[rowId].value == '' && timestr == '')
	//	{
	//		return true;
	//	}
	//	else
	//	{
	//		alert("You have entered a date, please enter a time.");
	//		setTimeout("globalTimeField.focus(); globalTimeField.select()", 0);
	//		return false;
	//	}
	//}
	//if(document.mainForm.elements[rowId].value == '' && timestr != '')
	//{
	//	 	alert("You have entered a time, please enter a date.");
	//		document.mainForm.elements[rowId].focus();
	//		return false;
	//}
	//else
	//{
		var TimePtrn1 = /^(\s*)(\d{1,2})(:)(\d{2})(\s*)([a|p])(m?)$/;  //full time with am pm, excepts military also.
		var TimePtrn2 = /^(\s*)(\d{1,2})(\s*)([a|p])(m?)$/;  //just hr with am pm
		var TimePtrn3 = /^(\s*)(\d{1,2})(:?)(\d{2})$/;  //military or assumed business hr.
		var TimePtrn4 = /^(\d{1,2})$/; //just a digit 0 - 24
		var TimePtrn5 = /^(\s*)(\d{1,2})(\s*)(\d{2})(\s*)([a|p])(m?)$/; //military or assumed business hr, no : or am pm.
		
		var matchArray1 = timestr.match(TimePtrn1);
		var matchArray2 = timestr.match(TimePtrn2);
		var matchArray3 = timestr.match(TimePtrn3);
		var matchArray4 = timestr.match(TimePtrn4);
		var matchArray5 = timestr.match(TimePtrn5);

		//alert ("#1: " + matchArray1 + "\n" + "#2: " + matchArray2 + "\n" + "#3: " + matchArray3 + "\n" + "#4: " + matchArray4);
		if (matchArray1 == null && matchArray2 == null && matchArray3 == null && matchArray4 == null && matchArray5 == null)
		{
			alert ("Please enter a time in military or ##:##(a/p) format.");
			setTimeout("globalTimeField.focus(); globalTimeField.select()", 0);
			return false;
		}
		else
		{
			if (matchArray1 != null)	 //full time with a/p/am/pm
			{
				var hr = matchArray1[2];
				var min = matchArray1[4];
				var ap = matchArray1[6];
				
				if(hr.substring(0,1) == 0)
				{
					if(hr.substring(1,2) == 0 && ap == 'p')
					{
						alert ("This is not a valid PM time, please correct.");
						setTimeout("globalTimeField.focus(); globalTimeField.select()", 0);
						return false;
					}
					else if(hr.substring(1,2) != ":")
					{
						hr = hr.substring(1,2);
					}
				}
				
				if(hr > 24)
				{
					alert ("The hour must be standard or military time (0-24), please correct.");
					setTimeout("globalTimeField.focus(); globalTimeField.select()", 0);
					return false;
				}
				else if(hr > 12 && hr != 24 && ap == "a")
				{
					alert ("This is not an AM time, please correct.");
					setTimeout("globalTimeField.focus(); globalTimeField.select()", 0);
					return false;
				}
				else if (min < 00 | min > 59)
				{
					alert ("Please enter 0-59 for your minute value");
					setTimeout("globalTimeField.focus(); globalTimeField.select()", 0);
					return false;
				}
				else
				{
					//if here, we have valid hr and min
					//convert to standard time
					if(ap == "p" && hr > 12 && hr < 24)
					{
						hr = parseInt(hr) - 12;
					}
					else if(hr == 24)
					{
						hr = 12;
						ap = "a";
					}				
					else if(ap == "a" && (hr == 0 || hr == 00))
					{
						hr = 12;
					}
					
					//put the time together for db entry
					var time = hr + ":" + min + " " + ap + "m";
					globalTimeField.value = time;
				}
			}
			else if (matchArray2 != null)   //hr with am/pm
			{
				var hr = matchArray2[2];
				var min = "00";
				var ap = matchArray2[4];
				
				if(hr.substring(0,1) == 0 && (globalTimeField.value.substring(1,2) == "a" || document.mainForm.elements[src].value.substring(1,2) == "p"))
				{
					alert ("The hour must be greater than zero if using only one digit.");
					setTimeout("globalTimeField.focus(); globalTimeField.select()", 0);
					return false;
				}
				
				if(hr.substring(0,1) == 0)
				{
					hr = hr.substring(1,2);
				}
				
				if(hr > 24)
				{
					alert ("The hour must be standard or military time (0-24), please correct.");
					setTimeout("globalTimeField.focus(); globalTimeField.select()", 0);
					return false;
				}
				else if(hr > 12 && hr != 24 && ap == "a")
				{
					alert ("This is not an AM time, please correct.");
					setTimeout("globalTimeField.focus(); globalTimeField.select()", 0);
					return false;
				}
				else
				{
					//if here, we have valid hr and am/pm time
					//convert to standard time
					if(ap == "p" && hr > 12 && hr < 24)
					{
						hr = parseInt(hr) - 12;
					}
					else if(hr == 24)
					{
						hr = 12;
						ap = "a";
					}				
					else if(ap == "a" && (hr == 0 || hr == 00))
					{
						hr = 12;
					}
					
					//put the time together for db entry
					var time = hr + ":" + min + " " + ap + "m";
					globalTimeField.value = time;
				}
			}
			else if (matchArray3 != null)  // military or assumed business hr.
			{
				var hr = matchArray3[2];
				var min = matchArray3[4];
				var ap;
				
				if(hr.substring(0,1) == 0)
				{
					if(hr.substring(1,2) != ":")
					{
						hr = hr.substring(1,2);
					}
				}
				
				if (hr < 0 | hr > 24)
				{
					alert ("For this format, the hour must be 0-24");
					setTimeout("globalTimeField.focus(); globalTimeField.select()", 0);
					return false;
				}
				else if(min < 00 | min > 59)
				{
					alert ("Please enter 0-59 for your minute value");
					setTimeout("globalTimeField.focus(); globalTimeField.select()", 0);
					return false;
				}
				else
				{
					//if here = valid time.
					if(hr > 12 && hr < 24)
					{
						hr = parseInt(hr) - 12;
						ap = "p";
					}
					else if(hr > 0 && hr < 12)
					{
						ap = "a";
					}
					else if(hr == 24 || hr == 0 || hr == 00)
					{
						hr = 12;
						ap = "a";
					}
					else if(hr == 12)
					{
						ap = "p";
					}
					
					//put the time together for db entry
					var time = hr + ":" + min + " " + ap + "m";
					globalTimeField.value = time;
				}
			}
			else if (matchArray4 != null)   // just the military hr.
			{
				var hr = matchArray4[1];
				var ap;
				
				if(hr.substring(0,1) == 0)
				{
					hr = hr.substring(1,2);
				}
				
				if (hr < 0 | hr > 24)
				{
					alert ("For this format, the hour must be 0-24");
					setTimeout("globalTimeField.focus(); globalTimeField.select()", 0);
					return false;
				}
				else
				{
					//if here, we have valid hr
					//convert to standard time
					if(hr > 12 && hr < 24)
					{
						hr = parseInt(hr) - 12;
						ap = "p";
					}
					else if(hr > 0 && hr < 13)
					{
						ap = "a";
					}
					else if(hr == 24 || hr == 0 || hr == 00)
					{
						hr = 12;
						ap = "a";
					}
					
					//put the time together for db entry
					var time = hr + ":" + "00" + " " + ap + "m";
					globalTimeField.value = time;
				}
			}
			else if(matchArray5 != null)
			{
				var hr = matchArray5[2];
				var min = matchArray5[4];
				var ap = matchArray5[6];
				
				if(hr.substring(0,1) == 0)
				{
					if(hr.substring(1,2) == 0 && ap == 'p')
					{
						alert ("This is not a valid PM time, please correct.");
						setTimeout("globalTimeField.focus(); globalTimeField.select()", 0);
						return false;
					}
					else
					{
						hr = hr.substring(1,2);
					}
				}
				
				if(hr > 24)
				{
					alert ("The hour must be standard or military time (0-24), please correct.");
					setTimeout("globalTimeField.focus(); globalTimeField.select()", 0);
					return false;
				}
				else if(hr > 12 && hr != 24 && ap == "a")
				{
					alert ("This is not an AM time, please correct.");
					setTimeout("globalTimeField.focus(); globalTimeField.select()", 0);
					return false;
				}				
				else if (min < 00 | min > 59)
				{
					alert ("Please enter 0-59 for your minute value");
					setTimeout("globalTimeField.focus(); globalTimeField.select()", 0);
					return false;
				}
				else
				{
					//if here, we have valid hr and min
					//convert to standard time
					if(ap == "p" && hr > 12 && hr < 24)
					{
						hr = parseInt(hr) - 12;
					}
					else if(hr == 24)
					{
						hr = 12;
						ap = "a";
					}				
					else if(ap == "a" && (hr == 0 || hr == 00))
					{
						hr = 12;
					}
					
					//put the time together for db entry
					var time = hr + ":" + min + " " + ap + "m";
					globalTimeField.value = time;
				}
			}
			else
			{
				return true;
			}
		}
	//}
}
//end hide -->
