	/*
	** function :		IsEmpty
	** parameter(s) :	value
	*/
	function IsEmpty (value)
	{
		// Return value.
		var bRetVal = false;
		
		// Check if the value is the empty string.
		if (value == null || value == "")
		{
			// Yes. This value is empty.
			
			// Set the return value.
			bRetVal = true;
		}
		
		// Exit the function.
		return bRetVal;
	}
	
	
	/*
	** function :		IsPositiveInteger
	** parameter(s) :	value
	*/
	function IsPositiveInteger (value)
	{
		// Return value.
		var bRetVal = true;

		// Convert the value to a string.	
		var strValue = value.toString();
		
		// Check each character of the input string (value).
		for (var i=0; i<strValue.length; i++)
		{
			// Capture the current character.
			var chCurrent = strValue.charAt(i);
			
			// Determine if the current character is within the numeric range.
			if (chCurrent < "0" || chCurrent > "9")
			{
				// NO. The input value is not a positive integer.
				bRetVal = false;
				break;
			}
		}
		
		// Exit the function.
		return bRetVal;
	}
	
	function cleanNumericField(n)
	{
		n = replace(replace(n, ",", ""), "$", "");
		return n;
	}
	
	/**********************************************************************************************************************
	Function:		IsValidTime
	Purpose:		Validate time as HH:MM:SS AM/PM format The seconds are optional as is AM/PM if military time is sent.
	Parameters:		timeStr	(string)
	**********************************************************************************************************************/
	function IsValidTime(timeStr) {
		// Checks if time is in HH:MM:SS AM/PM format.
		// The seconds and AM/PM are optional.
		
		var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;
		var error = '';
		
		var matchArray = timeStr.match(timePat);
		if (matchArray == null) {
			alert("Time is not in a valid format.");
			return false;
		}
		
		hour = matchArray[1];
		minute = matchArray[2];
		second = matchArray[4];
		ampm = matchArray[6];
		
		if (second=="") { second = null; }
		if (ampm=="") { ampm = null }
		
		if (hour < 0  || hour > 23) {
			error += "Hour must be between 1 and 12. (or 0 and 23 for military time)";
		}
		
		if (hour <= 12 && ampm == null) {
			if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time")) {
				error += "You must specify AM or PM.";
			}
		}
		
		if  (hour > 12 && ampm != null) {
			error += "You can't specify AM or PM for military time.";
		}
		
		if (minute<0 || minute > 59) {
			error += "Minute must be between 0 and 59.";
		}
		
		if (second != null && (second < 0 || second > 59)) {
			error += "Second must be between 0 and 59.";
		}
		
		if (error) {
			alert(error);
			return false;
		}
		else
			return true;
	}	
	
	function IsValidSimpleTime(timeStr) {
		// Checks if time is in HH:MM format.
		
		var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?/;
		var error = '';
		
		var matchArray = timeStr.match(timePat);
		if (matchArray == null) {
			alert("Time is not in a valid format.");
			return false;
		}
		
		hour = matchArray[1];
		minute = matchArray[2];
		second = matchArray[4];
		
		if (second=="") { second = null; }
		
		if (hour < 0  || hour > 12) {
			error += "Hour must be between 1 and 12.";
		}
		
		if (minute<0 || minute > 59) {
			error += "Minute must be between 0 and 59.";
		}
		
		if (second != null && (second < 0 || second > 59)) {
			error += "Second must be between 0 and 59.";
		}
		
		if (error) {
			alert(error);
			return false;
		}
		else
			return true;
	}	
	
	function getSelectedButton(buttonGroup) {			
		for (var i = 0; i < buttonGroup.length; i++) {
			if (buttonGroup[i].checked) {
				return i
			}
		}
		return -1; 
	}		