
var isIE = true;
var isNS6 = false;

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		clickSubmitButton()
//	DESCRIPTION:	Click the submit button - but wrap it to insure no double-posting.
//
//	INPUTS:			None
//	RETURN:			True if clicked, else False.
//--------------------------------------------------------------------------------------------------------------
function clickSubmitButton(buttonID)
{
	var button = document.getElementById(buttonID);

	if (button != null)						// make sure we found the control
	{
		if (button.disabled == false)		// if button is not disabled, it's okay but block it for the next one...
		{
			button.disabled = true;			// prevent a double-post.
			return true;
		}
		else
			return false;
	}
	else
	{
		return true;
	}
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		clickButtonOnEnter()
//	DESCRIPTION:	Click a button if the enter key was pressed and the control is ready
//
//	INPUTS:			None
//	RETURN:			True if clicked, else False.
//--------------------------------------------------------------------------------------------------------------
function clickButtonOnEnter(buttonID, preventDoublePost)
{
	var button = document.getElementById(buttonID);

	if ((event.which == 13) || (event.keyCode == 13)) 
	{
		if (button != null)						// make sure we found the control
		{
			if (button.disabled == false)		// make sure it isn't disabled
			{
				button.focus();
				button.click();
				if (preventDoublePost == true)
					button.disabled = true;		// prevent a double-post by disabling the button
			}
		}
		return false;
	} 
	else 
		return true;
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		confirmAction()
//	DESCRIPTION:	Confirms action on client.
//
//	INPUTS:			None
//	RETURN:			True if confirmed, else False.
//--------------------------------------------------------------------------------------------------------------
function confirmAction(msg)
{
	if(window.confirm(msg))
		return true;
	else
		return false;
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		confirmLogoff()
//	DESCRIPTION:	Confirms action on client.
//
//	INPUTS:			None
//	RETURN:			True if confirmed, else False.
//--------------------------------------------------------------------------------------------------------------
function confirmLogoff(msg)
{
	if(window.confirm('Any changes to the current Funeral Home will be lost.\n\nClick OK to continue with Log off.\n\nClicking Cancel will return you to the maintenance screen to allow you to save your changes.'))
		return true;
	else
		return false;
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		confirmNewSearch()
//	DESCRIPTION:	Confirms action on client.
//
//	INPUTS:			None
//	RETURN:			True if confirmed, else False.
//--------------------------------------------------------------------------------------------------------------
function confirmNewSearch(msg)
{
	if(window.confirm('Any changes to the current Funeral Home will be lost.\n\nClick OK to continue with New Search.\n\nClicking Cancel will return you to the maintenance screen to allow you to save your changes.'))
		return true;
	else
		return false;
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		clickOkayToConfirm()
//	DESCRIPTION:	Confirms action on client. If the user clicks okay, it then clicks btnSubmit.
//
//	INPUTS:			msg - message to display in confirm message
//	RETURN:			btnSubmit.click if confirmed, else False.
//--------------------------------------------------------------------------------------------------------------
function clickOkayToConfirm(msg, buttonName) {

	var ControlToClick;
	
	ControlToClick = eval("window.document.frmPage." + buttonName);
	
	if(window.confirm(msg))
		ControlToClick.click();
	else
		return false;
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		confirmDelete()
//	DESCRIPTION:	Confirms delete request on client.
//
//	INPUTS:			keyCount		The number of records to delete.
//	RETURN:			True if confirmed, else False.
//--------------------------------------------------------------------------------------------------------------
function confirmDelete(keyCount)
{
	var msg;
	
	if (keyCount > 1)
	{
		msg = "Multiple items have been selected for deletion.\nAre you sure you want to delete the selected items?\n\nClick OK to continue with the deletion.";
		//msg = "You are requesting to delete multiple records.\nOnce deleted, it can not be undone.\n\nDo you wish to delete the selected records?";
	}
	else
	{
		msg = "Are you sure you want to delete the selected item?\n\nClick OK to continue with the deletion.";
		//msg = "You are requesting to delete the selected record.\nOnce deleted, it can not be undone.\n\nDo you wish to delete the record?";
	}

	return confirmAction(msg);
}


//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		confirmListBoxSelect()
//	DESCRIPTION:	Confirms select request on client for a specified listbox.
//
//	INPUTS:			listboxId			The page-level listbox identifier.
//	RETURN:			True if confirmed, else False.
//--------------------------------------------------------------------------------------------------------------
function confirmListBoxSelect(listboxId,msg)
{
    var optionList = document.getElementById(listboxId).options;
	var listboxSelectCount = -1;
	
	listboxSelectCount = optionList.selectedIndex;
	
	if (!(listboxSelectCount >= 0))	{
			window.alert(msg);
			return false;
	}
	else {
			return true;
	}
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		confirmCancel()
//	DESCRIPTION:	Confirms cancel request on client.
//
//	INPUTS:			None
//	RETURN:			True if confirmed, else False.
//--------------------------------------------------------------------------------------------------------------
function confirmCancel()
{
	return confirmAction("You are requesting to cancel the current operation.\nOnce cancelled, any changes will be lost.\n\nDo you wish to cancel your changes?");
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		confirmCancelSession()
//	DESCRIPTION:	Confirms cancel punchout session.
//
//	INPUTS:			url		Url to navigate to if cancel is confirmed.
//	RETURN:			True if confirmed, else False.
//--------------------------------------------------------------------------------------------------------------
function confirmCancelSession(url)
{
	var confirmed;
	
	confirmed = confirmAction("You are requesting to cancel the current session.\nOnce cancelled, any changes will be lost.\n\nDo you wish to cancel your changes?");
	
	if(confirmed)
	{
		if(url.length > 0)
		{
			document.location.href = url;
		}
	}

	return confirmed;
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		stringPadder()
//	DESCRIPTION:	Substring a string for an output string of an exact size
//
//	INPUTS:			an input string, the starting position and length.
//	RETURN:			a fixed length string
//--------------------------------------------------------------------------------------------------------------            
function stringPadder(inputValue, startPosition, outputLength)
{
	var returnValue = "";

	if (inputValue != null)
		returnValue = inputValue.substring(startPosition - 1, startPosition + outputLength - 1);

	// pad the results with spaces to insure our length is correct				
	for (var i = returnValue.length; i < outputLength; i++)
	{
		returnValue = returnValue + " ";
	}

	return returnValue;
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		findListboxValue()
//	DESCRIPTION:	Find listbox index for a specific value
//
//	INPUTS:			None
//	RETURN:			0 or matching index of matching value.
//--------------------------------------------------------------------------------------------------------------            
function findListboxValue(listboxControl, searchValue)
{
	var i;
	var retVal = 0;
	for (i = listboxControl.options.length - 1; i >= 0; i--) 
	{
		if (listboxControl.options[i].value == searchValue)
		{
			retVal = i;
			break;
		}
	}
	return retVal;
}

//----------------------------------------------------------------------------------------
//	FUNCTION:		copyDropdownList()
//	DESCRIPTION:	Copy the dropdown list items from one to another.
//
//	INPUTS:			ddlFrom & ddlTo
//	RETURN:			None
//-----------------------------------------------------------------------------------------
function copyDropdownList(ddlFrom, ddlTo) 
{
	while (ddlTo.options.length > 0) 
	{
		ddlTo[0] = null;
	}

	for (var i=0; i < ddlFrom.options.length; i++) 
	{
		ddlTo.options[i] = new Option(ddlFrom.options[i].text, ddlFrom.options[i].value);
	}
}

//----------------------------------------------------------------------------------------
//	FUNCTION:		clearDropdownList()
//	DESCRIPTION:	Clear the dropdown list items from control.
//
//	INPUTS:			ddlFrom & ddlTo
//	RETURN:			None
//-----------------------------------------------------------------------------------------
function clearDropdownList(control) 
{
	while (control.options.length > 0) 
	{
		control[0] = null;
	}
}
//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		swapImage()
//	DESCRIPTION:	Swaps a control current image.
//
//	INPUTS:			None
//	RETURN:			True if confirmed, else False.
//--------------------------------------------------------------------------------------------------------------
function swapImage(image, src)
{
	image.src = src;
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		Pop_Up_Mouse_Over()
//	DESCRIPTION:	Changes mouse cursor to a hand.
//
//	INPUTS:			None
//	RETURN:			True
//--------------------------------------------------------------------------------------------------------------
	function Pop_Up_Mouse_Over()
	{
	  document.body.style.cursor = "hand";
	  return true;
	}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		Pop_Up_Mouse_Out()
//	DESCRIPTION:	Changes mouse cursor back to normal.
//
//	INPUTS:			None
//	RETURN:			True
//--------------------------------------------------------------------------------------------------------------
	function Pop_Up_Mouse_Out()
	{
	  document.body.style.cursor = "auto";
	  return true;
	}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		openWindow()
//	DESCRIPTION:	Opens a browser window.
//
//	INPUTS:			url			Url
//					width		Window width
//					height		Window height
//					pMenubar	Window menubar switch
//					pSetFocus	Window set focus switch
//					scrollbars	Window scrollbar switch
//					resize		Window resize switch
//	RETURN:			None
//--------------------------------------------------------------------------------------------------------------
function openWindow(url, width, height, pMenubar, pSetFocus, scrollbars, resize) {

	var command;
	var browserName = navigator.appName;
	var browserVer = parseInt(navigator.appVersion);

	left_position = 0			// screen.availWidth - width - 10;
				
	if (((browserName == "Netscape") && (browserVer < 3)) || ((browserName == "Microsoft Internet Explorer") && (browserVer < 2))) 
	{
		alert("\n Sorry, but this feature is only available for Navigator 3.x, Explorer 4.x, and above. \n");			
	} 
	else 
	{
		remoteWin = window.open(url,"newWin",'toolbar=0,location=0,directories=0,status=0,left=' + left_position + ',top=0,menubar=' + pMenubar + ',scrollbars=' + scrollbars + ',resizable=' + resize + ',width=' + width + ',height=' + height);

		if (remoteWin != null) 
		{
			self.name = "dataWin";
		}
	}
			
	if (pSetFocus == 1) 
	{
		if (((browserName == "Netscape") && (browserVer >= 3)) || ((browserName == "Microsoft Internet Explorer") && (browserVer >= 4)))
			remoteWin.focus();
	}	
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		openNamedWindow()
//	DESCRIPTION:	Opens a browser window.
//
//	INPUTS:			url			Url
//					width		Window width
//					height		Window height
//					pMenubar	Window menubar switch
//					pSetFocus	Window set focus switch
//					scrollbars	Window scrollbar switch
//					resize		Window resize switch
//	RETURN:			None
//--------------------------------------------------------------------------------------------------------------
function openNamedWindow(windowName, url, width, height, pMenubar, pSetFocus, scrollbars, resize) {

	var command;
	var browserName = navigator.appName;
	var browserVer = parseInt(navigator.appVersion);

	left_position = (screen.availWidth / 2) - (width / 2);			// was 0;
	top_position = (screen.availHeight / 2) - (height / 2);			// was 0;
				
	if (((browserName == "Netscape") && (browserVer < 3)) || ((browserName == "Microsoft Internet Explorer") && (browserVer < 2))) 
	{
		alert("\n Sorry, but this feature is only available for Navigator 3.x, Explorer 4.x, and above. \n");			
	} 
	else 
	{
		remoteWin = window.open(url,windowName,'toolbar=0,location=0,directories=0,status=0,left=' + left_position + ',top=' + top_position + ',menubar=' + pMenubar + ',scrollbars=' + scrollbars + ',resizable=' + resize + ',width=' + width + ',height=' + height);

		if (remoteWin != null) 
		{
			self.name = "dataWin";
		}
	}
			
	if (pSetFocus == 1) 
	{
		if (((browserName == "Netscape") && (browserVer >= 3)) || ((browserName == "Microsoft Internet Explorer") && (browserVer >= 4)))
		{
			remoteWin.focus();
		}
	}	
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		openNormalWindow()
//	DESCRIPTION:	Opens a normal browser window (user defaults).
//
//	INPUTS:			url			Url
//					windowName	Window Name
//	RETURN:			None
//--------------------------------------------------------------------------------------------------------------
function openNormalWindow(url) {

	var command;
	var browserName = navigator.appName;
	var browserVer = parseInt(navigator.appVersion);
	var remoteWin;

	left_position = 0			// screen.availWidth - width - 10;
				
	if (((browserName == "Netscape") && (browserVer < 3)) || ((browserName == "Microsoft Internet Explorer") && (browserVer < 2))) 
	{
		alert("\n Sorry, but this feature is only available for Navigator 3.x, Explorer 4.x, and above. \n");			
	} 
	else 
	{
		remoteWin = window.open(url, "normalWindow");
	}
			
	if (((browserName == "Netscape") && (browserVer >= 3)) || ((browserName == "Microsoft Internet Explorer") && (browserVer >= 4)))
		remoteWin.focus();
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		openModalDialog()
//	DESCRIPTION:	Opens a modal dialog window.
//
//	INPUTS:			url			Url
//					width		Window width
//					height		Window height
//					top			Window top
//					left		Window left
//					center		Window center screen switch (Top & Left must be blank values)
//					scroll		Window scrollbar switch
//					statusbar	Window menubar switch
//					resize		Window resize switch
//					help		Help icon switch
//	RETURN:			None
//--------------------------------------------------------------------------------------------------------------
function openModalDialog(url, width, height, top, left, center, scroll, statusbar, resize, help) {

	var command;

	if (document.all) 
	{
		command = "scroll: " + scroll + "; dialogHeight: " + height + "px; dialogWidth: " + width + "px; dialogTop: " + top + "px; dialogLeft: " + left + "px; edge: Raised; center: " + center + "; help: " + help + "; resizable: " + resize + "; status: " + statusbar + ";"
		window.showModalDialog(url, "", command);
	} 
	else 
	{
		openWindow(url, width, height, statusbar, 1, 1, resize);
	}
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		openModelessDialog()
//	DESCRIPTION:	Opens a modeless dialog window.
//
//	INPUTS:			url			Url
//					width		Window width
//					height		Window height
//					top			Window top
//					left		Window left
//					center		Window center screen switch (Top & Left must be blank values)
//					scroll		Window scrollbar switch
//					statusbar	Window menubar switch
//					resize		Window resize switch
//					help		Help icon switch
//	RETURN:			None
//--------------------------------------------------------------------------------------------------------------
function openModelessDialog(url, width, height, top, left, center, scroll, statusbar, resize, help) {

	var command;
	
	if (document.all) 
	{
		command = "scroll: " + scroll + "; dialogHeight: " + height + "px; dialogWidth: " + width + "px; dialogTop: " + top + "px; dialogLeft: " + left + "px; edge: Raised; center: " + center + "; help: " + help + "; resizable: " + resize + "; status: " + statusbar + ";"
		window.showModelessDialog(url, "dialogWin", command);
		event.cancelBubble = true;
	} 
	else 
	{
		openWindow(url, width, height, statusbar, 1, 1, resize);
	}
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		openErrorDialog()
//	DESCRIPTION:	Opens a browser window to display the application common exception dialog.
//
//	INPUTS:			url			Url
//	RETURN:			None
//--------------------------------------------------------------------------------------------------------------
function openErrorDialog(url)
{
	openModalDialog(url, 550, 250, "", "", 1, 0, 0, 1, 0);	
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		openHelpDialog()
//	DESCRIPTION:	Opens a browser dialog window to display help.
//
//	INPUTS:			url			Url
//	RETURN:			None
//--------------------------------------------------------------------------------------------------------------
function openHelpDialog(url)
{
	openWindow(url, 550, 400, 0, 1, 1, 0);

	event.cancelBubble = true;			// in case container controls have f1 as well...
	
	// mmr: 2 problems with openModelessDialog:
	// 1. multiple windows keep opening for each f1 hit
	// 2. anchor tags were being ignored
	// openModelessDialog(url, 550, 400, 0, 0, 1, 0, 0, 0, 0);
	
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		openReportWindow()
//	DESCRIPTION:	Opens a browser window to display a report page.
//
//	INPUTS:			url			Url, zzz
//	RETURN:			None
//--------------------------------------------------------------------------------------------------------------
function openReportWindow(url, width, height)
{
	openNamedWindow("ReportWindow", url, width, height, 0, 1, 1, 0);
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		openHowToHelpDialog()
//	DESCRIPTION:	Opens a browser dialog window to display help.
//
//	INPUTS:			url			Url
//	RETURN:			None
//--------------------------------------------------------------------------------------------------------------
function openHowToHelpDialog(url)
{
	openModelessDialog(url, 700, 700, 0, 0, 1, 0, 0, 0, 0);
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		openF1Help()
//	DESCRIPTION:	Check for F1, if so open help dialog
//
//	INPUTS:			url			Url
//	RETURN:			None
//--------------------------------------------------------------------------------------------------------------
function openF1Help(url)
{
	if ((event.which == 112) || (event.keyCode == 112))			// if F1 - open the help file
	{
		openHelpDialog(url);
		return false;
	} 
	else 
	{
		return true;
	}
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		openFormDialog()
//	DESCRIPTION:	Opens a browser dialog window.
//
//	INPUTS:			url			Url
//	RETURN:			None
//--------------------------------------------------------------------------------------------------------------
function openFormDialog(url, width, height) 
{
//	openModalDialog(url, 800, 469, "", "", 1, 1, 0, 1, 0);	
	openModalDialog(url, width, height, "", "", 1, 1, 0, 1, 0);	
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		openFormWindow()
//	DESCRIPTION:	Opens a browser window.
//
//	INPUTS:			url			Url
//	RETURN:			None
//--------------------------------------------------------------------------------------------------------------
function openFormWindow(url) 
{
	openWindow(url, 800, 500, 1, 1, 1, 1);
}


//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		resizeWindow()
//	DESCRIPTION:	Resizes the current window to the specified height and width.
//
//	INPUTS:			width		New window width
//					height		New window height
//	RETURN:			None
//--------------------------------------------------------------------------------------------------------------
function resizeWindow(width, height)
{
	window.resizeTo(width, height);
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		resizeDialog()
//	DESCRIPTION:	Resizes the current dialog window to the specified height and width.
//
//	INPUTS:			width		New window width
//					height		New window height
//	RETURN:			None
//--------------------------------------------------------------------------------------------------------------
function resizeDialog(width, height)
{
	window.dialogHeight = height;
	window.dialogWidth = width;
}

//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		sleep()
//	DESCRIPTION:	Loops for specified period of milliseconds
//
//	INPUTS:			milliseconds	The number of milliseconds to sleep.
//	RETURN:			None
//--------------------------------------------------------------------------------------------------------------
function sleep(milliseconds)
{
	var now;
	var then;

	then = new Date().getTime();
	now = then;
	while((now-then)<milliseconds)
	{
		now = new Date().getTime();
	}
}


//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		isValidTime()
//	DESCRIPTION:	Checks if it a valid time 
//
//	INPUTS:			value of the text field
//	RETURN:			true or false
//--------------------------------------------------------------------------------------------------------------
function isValidTime(value) {
   var hasMeridian = false;
   var re = /^\d{1,2}[:]\d{2}([:]\d{2})?( [aApP][mM]?)?$/;
   if (!re.test(value)) { return false; }
   if (value.toLowerCase().indexOf("p") != -1) { hasMeridian = true; }
   if (value.toLowerCase().indexOf("a") != -1) { hasMeridian = true; }
   var values = value.split(":");
   if ( (parseFloat(values[0]) < 0) || (parseFloat(values[0]) > 23) ) { return false; }
   if (hasMeridian) {
      if ( (parseFloat(values[0]) < 1) || (parseFloat(values[0]) > 12) ) { return false; }
   }
   if ( (parseFloat(values[1]) < 0) || (parseFloat(values[1]) > 59) ) { return false; }
   if (values.length > 2) {
      if ( (parseFloat(values[2]) < 0) || (parseFloat(values[2]) > 59) ) { return false; }
   }
   return true;
}


	
/*******************************************************/
/*  Check Dirty Data                                   */
function CheckDirtyData(userControl, hiddenControl, dirtyDataControl)
{
			
	var theVisibleControl;
	var theHiddenControl;
				
	var hdnDirtyDataInd;
	hdnDirtyDataInd = document.getElementById(dirtyDataControl);
				
	if (hdnDirtyDataInd.value == 'Y') {
		// no need to check if dirty - it already is
	}
	else {
		// get handle to each control
		theVisibleControl = document.getElementById(userControl);
		theHiddenControl = document.getElementById(hiddenControl);
					
		switch (theVisibleControl.type) {
			case 'checkbox':
				// For check boxes, the event tied to this function is the onClick.
				// By nature of the check box and the onClick, the value changed and therefore,
				// there is no need to try and decifer values - the checkbox is dirty
				hdnDirtyDataInd.value = 'Y';
				break;
					
			default:
				// this works for text and drop down list controls.
				if (!(theVisibleControl.value == theHiddenControl.value)) {
					hdnDirtyDataInd.value = 'Y';
				}
				break;

		}
	}
	
	return true;
}



/*******************************************************/
/*  Check all and Individual Row CheckBoxes            */
/*******************************************************/
 
        function checkAll(e)
        {
            var theCheckBox = e;
            var theValue;

            theValue = theCheckBox.checked;
    
            var arrCtls = document.all.tags("INPUT");
	        for (i=0; i < arrCtls.length; i++) 
	        {
	          //If element is a checkbox type, and the id contains the string 'chkSelected'
		        if (arrCtls[i].type == "checkbox" && arrCtls[i].id.indexOf('chkSelected') != -1) 
		        {
			        //Toggle the checkbox 
    				arrCtls[i].checked = theValue;
		        }
	        }            
        }     
        
        function checkboxClicked()
        {
            var arrCtls = document.all.tags("INPUT");
	        for (i=0; i < arrCtls.length; i++) 
	        {
	          //If element is a checkbox type, and the id contains the string 'chkAllSelected'
		        if (arrCtls[i].type == "checkbox" && arrCtls[i].id.indexOf('chkAllSelected') != -1) 
		        {
			        //Toggle the checkbox 
    				arrCtls[i].checked = allCheckboxesAreChecked();
    				break;
		        }
	        }            
        }        
        
        function allCheckboxesAreChecked()
        {
            var theValue;
            
            var arrCtls = document.all.tags("INPUT");
	        for (i=0; i < arrCtls.length; i++) 
	        {
	          //If element is a checkbox type, and the id contains the string 'chkSelected'
		        if (arrCtls[i].type == "checkbox" && arrCtls[i].id.indexOf('chkSelected') != -1) 
		        {
			        //Toggle the checkbox 
    				theValue = arrCtls[i].checked;
    				if (theValue == false) {
				        return false;
			        } 
		        }
	        }                    
            
            return true;
        }

/*******************************************************/
/*  End of Check all and Individual Row CheckBoxes     */
/*******************************************************/


/********************************************************/
/*  This function makes a checkbox in a grid column act */
/*  like a radio button.                                */
/********************************************************/
function checkZIP(e)
{
    var theCheckBox = e;
    var theValue;

    theValue = theCheckBox.checked;

    var arrCtls = document.all.tags("INPUT");
    for (i=0; i < arrCtls.length; i++) 
    {
      //If element is a checkbox type, and the id contains the string 'chkSelected'
        if (arrCtls[i].type == "checkbox" && arrCtls[i].id.indexOf('chkSelected') != -1) 
        {
	        //Toggle the checkbox 
			arrCtls[i].checked = false;
        }
    }            
    
    theCheckBox.checked = theValue;
} 


function checkValidRange(objEvent, minRange, maxRange){

	var reValidChars = /\d/;	
	var strNewValue = "";
	var fldID = "";
	var blnWasNegative = false;
	
	var theField;

    if (isIE)
       	objInput = objEvent.srcElement; 
    else
       	objInput = objEvent.target;
       	
    fldID = objInput.id;

    theField = eval("theForm." + fldID);
    
	strValue = objInput.value;
	
    /* Check if the current value is negative  */
    if (strValue.substring(0, 1) == "-")
        blnWasNegative = true;
	
	if (strValue.length > 0) { 
		for (var i = 0; i < strValue.length; i++) {
			var oneChar = strValue.charAt(i)
			if (reValidChars.test(oneChar)) {
				strNewValue = strNewValue + oneChar;
			}
	 	}
	}
	
	if (blnWasNegative)
	{
	    strNewValue = strNewValue * -1;  	/* it is a negative number */
	}

    if ((strNewValue < minRange) || (strNewValue > maxRange))
    {
        if (!(confirmAction("Value is out of range. Range is: '" + minRange + "' to '" + maxRange + "'.\n\nPlease confrim with Funeral Home.\n\nIf it is correct, click OK. Otherwise, click Cancel to correct.")))
        {
	        theField.focus();
	        theField.select();
	    }
    }

}


//--------------------------------------------------------------------------------------------------------------
//	FUNCTION:		confirmPricesChanged()
//	DESCRIPTION:	Confirms action on client.
//
//	INPUTS:			None
//	RETURN:			True.
//--------------------------------------------------------------------------------------------------------------
function confirmPricesChanged()
{
	var hdnFldID = "";
	var theHdnField;
	var blnFldID = "";
	var theBlnField;

    var arrCtls = document.all.tags("INPUT");
    
     // Find the blnPricesUpdated control
    for (i=0; i < arrCtls.length; i++) 
    {
      //If element is a checkbox type, and the id contains the string 'hdnPricesCheckedDate'
        if (arrCtls[i].type == "hidden" && arrCtls[i].id.indexOf('blnPricesUpdated') != -1) 
        {
	        //Toggle the checkbox 
			blnFldID = arrCtls[i].id;
			break;
        }
    } 	

    theBlnField = eval("theForm." + blnFldID);
	
	if(window.confirm('Did Prices get updated during this update?\n\nClick OK to update Prices Checked Date.\n\nClicking Cancel will not update Prices Checked Date.'))
		{
		    // Find the hdnPricesChecckedDate control
	        for (i=0; i < arrCtls.length; i++) 
	        {
	          //If element is a checkbox type, and the id contains the string 'hdnPricesCheckedDate'
		        if (arrCtls[i].type == "hidden" && arrCtls[i].id.indexOf('hdnPricesCheckedDate') != -1) 
		        {
			        //Toggle the checkbox 
    				hdnFldID = arrCtls[i].id;
    				break;
		        }
	        }  

	        theHdnField = eval("theForm." + hdnFldID);

	    	var mth;
	    	var day;
	    	var year;

	        mth = new Date().getMonth() + 1;
	        day = new Date().getDate();
	        year = new Date().getYear();
	
            theHdnField.value = '' + mth + '-' + day + '-' + year;
            theBlnField.value = 'true';
        }
        else
        {
            theBlnField.value = 'false';
        }
    return true;		
}