	/*-----------------------------------------------------------+
	 | addLoadEvent: Add event handler to body when window loads |
	 +-----------------------------------------------------------*/
	function addLoadEvent(func) {
		var oldonload = window.onload;
		
		if (typeof window.onload != "function") {
			window.onload = func;
		} else {
			window.onload = function () {
				oldonload();
				func();
			}
		}
	}
	
	/*------------------------------------+
	 | Functions to run when window loads |
	 +------------------------------------*/
	addLoadEvent(function () {
		initChecklist();
	});
	
	/*----------------------------------------------------------+
	 | initChecklist: Add :hover functionality on labels for IE |
	 +----------------------------------------------------------*/
	function initChecklist() {
		if (document.all && document.getElementById) {
			// Get all unordered lists
			var lists = document.getElementsByTagName("ul");
			
			for (i = 0; i < lists.length; i++) {
				var theList = lists[i];
				
				// Only work with those having the class "checklist"
				if (theList.className.indexOf("checklist") > -1) {
					var labels = theList.getElementsByTagName("label");
					
					// Assign event handlers to labels within
					for (var j = 0; j < labels.length; j++) {
						var theLabel = labels[j];
						theLabel.onmouseover = function() { this.className += " hover"; };
						theLabel.onmouseout = function() { this.className = this.className.replace(" hover", ""); };
					}
				}
			}
		}
	}

	
	function doCaseHistorySearch() {
		var thisForm = document.getElementById("chSearchForm");
		return Spry.Utils.submitForm(thisForm, updateSearchResultsDiv);
	}

	
	function updateSearchResultsDiv(req) {
		Spry.Utils.setInnerHTML('searchResultsDiv', req.xhRequest.responseText);
	}
	
	
	function doNextRecordsSearch() {
		var thisForm = document.getElementById("hiddenNextXForm");
		return Spry.Utils.submitForm(thisForm, updateSearchResultsDiv);
	}	
	
	
	/*
	function openStoreWindow(srcPkID) {
		window.open("/index.cfm?pid=10393&cdid=" + srcPkID,"appWin", "menubar=no,width=1024,height=700,toolbar=no,scrollbars=yes,resizable=no,horizontalscroll=no");
	}
	*/

	function toggleDiv(divID) {
		/* var quotedDivName = srcPkId + "Div"; */
		if (document.getElementById(divID).style.display == 'none')
			document.getElementById(divID).style.display = 'block';
		else	
			document.getElementById(divID).style.display = 'none';
	}


	
	function checkAll(idList) {

			var indexArray = idList.split(",");
			var checkBoxItem = document.chSearchForm.elements["attributeIDList"];
			checkBoxItem[indexArray[1]].checked = true;
			
			for(var i=0; i< indexArray.length; i++){
				if (indexArray[i]-1 >=0){
					checkBoxItem[indexArray[i]-1].checked = true;
				}	
			}
			Spry.Utils.submitForm("chSearchForm", updateSearchResultsDiv);
	}

	
	function unCheckAll(idList) {
			var indexArray = idList.split(",");
			var checkBoxItem = document.chSearchForm.elements["attributeIDList"];
	
			for(var i=0; i<indexArray.length-1; i++){
				checkBoxItem[indexArray[i]-1].checked = false;
			}
			Spry.Utils.submitForm("chSearchForm", updateSearchResultsDiv);
	}			

	
