	//---------------------------------------------------------
	//---         General JavaScript Code Library           ---
	//---------------------------------------------------------

	
	//---------------------------------------------------------
	function Trim(strString)
	{
		//trim Leading spaces
		while(''+strString.charAt(0)==' ')
			{strString=strString.substring(1,strString.length);}

		//trim trailing spaces
		while(''+strString.charAt(strString.length - 1) == ' ')
			{strString=strString.substring(0,strString.length - 1);}

		return strString;
	}


	//---------------------------------------------------------
	function Left(str, n){
		if (n <= 0)
			return "";
		else if (n > String(str).length)
			return str;
		else
			return String(str).substring(0,n);
	}


	//---------------------------------------------------------
	function Right(str, n){
		if (n <= 0)
		   return "";
		else if (n > String(str).length)
		   return str;
		else {
		   var iLen = String(str).length;
		   return String(str).substring(iLen, iLen - n);
		}
	}


	//--------------------------------------------------------------------
	// return the value of the radio button that is checked
	// return an empty string if none are checked, or
	// there are no radio buttons
	function getRdoCheckedValue(radioObj) {
		if(!radioObj)
			return "";
		var radioLength = radioObj.length;
		if(radioLength == undefined)
			if(radioObj.checked)
				return radioObj.value;
			else
				return "";
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				return radioObj[i].value;
			}
		}
		return "";
	}

	
	//--------------------------------------------------------------------
	// set the radio button with the given value as being checked
	// do nothing if there are no radio buttons
	// if the given value does not exist, all the radio buttons
	// are reset to unchecked
	function setRdoCheckedValue(radioObj, newValue) {
		if(!radioObj)
			return;
		var radioLength = radioObj.length;
		if(radioLength == undefined) {
			radioObj.checked = (radioObj.value == newValue.toString());
			return;
		}
		for(var i = 0; i < radioLength; i++) {
			radioObj[i].checked = false;
			if(radioObj[i].value == newValue.toString()) {
				radioObj[i].checked = true;
			}
		}
	}

	//--------------------------------------------------------------------
	// verify that the password meets our Password Policy standards
	//--------------------------------------------------------------------
	function verifyPasswordPolicy(l_password)
	{
		//password must be at least 8 characters long
		if (l_password.length < 8)
		{
			alert("Password must be at least 8 characters long.");
			return false;
		}

		//password must contain at least one letter - regular expression
		if (l_password.search(/[a-z]+/) <= -1 && l_password.search(/[A-Z]+/) <= -1)
		{
			alert("Password must contain at least one letter.");
			return false;
		}

		//password must contain at least one number - regular expression
		if (l_password.search(/[0-9]+/) <= -1)
		{
			alert("Password must contain at least one number.");
			return false;
		}

		//no violations found, return true
		return true;
	}
	function getPasswordPolicy(){return "Password must be at least 8 characters long and contain a mixture of letters and numbers.";}

	//--------------------------------------------------------------------
	function copy_text_to_clipboard(meintext)
	{
	  /*
		if (window.clipboardData) 
		{
			// the IE-manier
			window.clipboardData.setData("Text", meintext);
		}
		else if (window.netscape) 
		{ 
			netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
			var clip = Components.classes['@mozilla.org/widget/clipboard;1']
					 .createInstance(Components.interfaces.nsIClipboard);
			
			if (!clip) return;
		
			var trans = Components.classes['@mozilla.org/widget/transferable;1']
					  .createInstance(Components.interfaces.nsITransferable);
	
			if (!trans) return;

			trans.addDataFlavor('text/unicode');

			var str = new Object();
			var len = new Object();

			var str = Components.classes["@mozilla.org/supports-string;1"]
					.createInstance(Components.interfaces.nsISupportsString);

			var copytext=meintext;

			str.data=copytext;

			trans.setTransferData("text/unicode",str,copytext.length*2);

			var clipid=Components.interfaces.nsIClipboard;

			if (!clip) return false;

			clip.setData(trans,null,clipid.kGlobalClipboard);
		}

		//alert("Following info was copied to your clipboard:\n\n" + meintext);
		return false;
	  */
	}



	//---------------------------------------------------------
	function limitTextAreaLength(field, maxLimit)
	// add the following to a textarea tag:
	//         onKeyDown="javascript:limitTextAreaLength(this, max_characters_length);" 
	//         onKeyUp="javascript:limitTextAreaLength(this, max_characters_length);" 
	//         onChange="javascript:limitTextAreaLength(this, max_characters_length);"
	{
		var field_length;
		field_length = field.value.length;
		if (field_length > maxLimit) // if too long...trim it!
		{
			field.value = field.value.substring(0, (maxLimit));
		}
	}


	//---------------------------------------------------------
	function saveAsMe (filename)
	{
		alert(filename);
		document.execCommand('SaveAs',null,filename);
	}


	//----------------------------------------------------------
	function mouseOverBG(src,l_bgcolor) 
	{ 
		src.style.backgroundColor = l_bgcolor; 
		if (!src.contains(event.fromElement)) 
		{
		}
	}

	//----------------------------------------------------------
	function mouseOutBG(src,l_bgcolor) 
	{ 
		src.style.backgroundColor = l_bgcolor; 
		if (!src.contains(event.toElement)) 
		{  
		}
	}

	//----------------------------------------------------------
	function mouseOverCL(src,l_classname) 
	{ 
		if (!src.contains(event.fromElement)) 
		{
			src.className = l_classname; 
		}
	}

	//----------------------------------------------------------
	function mouseOutCL(src,l_classname) 
	{ 
		if (!src.contains(event.toElement)) 
		{  
			src.className = l_classname; 
		}
	}


	//------------------------------------------------------------------------ 
	function openPopupWindow(url,uid,width,height,l_extra) 
	{
		var l_win;
		var x = (640 - width)/2;
		var y = (480 - height)/2;
		if (screen)
		{
			y = (screen.availHeight - height)/2;
			x = (screen.availWidth - width)/2;
		}
		if(!l_extra){l_extra = 'scrollbars=yes,resizable=yes';}
		l_win = window.open(url,uid,'width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+','+l_extra);
		if (l_win) {l_win.focus();}
	}


	//------------------------------------------------------------------------ 
	function openModelessPopupWindow(url,uid,width,height) 
	{
		var ie = document.all;
		var x = (640 - width)/2;
		var y = (480 - height)/2;
		if (screen)
		{
			y = (screen.availHeight - height)/2;
			x = (screen.availWidth - width)/2;
		}
		var l_extra = 'scrollbars=yes,resizable=yes';
		if(ie)
		{
			//works in ie only
			window.showModelessDialog(url,uid,"dialogHeight: "+height+"px; dialogWidth: "+width+"px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: Yes; status: No;");
		}
		else
		{
			//for opera/firefox/etc
			window.open(url,uid,"height: "+height+"px; width: "+width+"px; top: px; left: px; center: Yes; help: No; resizable: Yes; status: No;");
		}
	}


	//------------------------------------------------------------------------ 
	function openModalPopupWindow(url,uid,width,height) 
	{
		var x = (640 - width)/2;
		var y = (480 - height)/2;
		if (screen)
		{
			y = (screen.availHeight - height)/2;
			x = (screen.availWidth - width)/2;
		}
		var l_extra = 'scrollbars=yes,resizable=yes';
		window.showModalDialog(url,uid,"dialogHeight: "+height+"px; dialogWidth: "+width+"px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: Yes; status: No;");
	}

	//------------------------------------------------------------------------ 
	function popUp(URL) {
		day = new Date();
		id = day.getTime();
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=1,width=400,height=550,left = 650,top = 400');");
	}

	var m_SelectBoxCollection = new Array();

	//------------------------------------------------------------------------ 
	// Hide all select boxes    
	function hideAllSelectBoxes()
	{
		/*
		if (document.all) // Only do this for IE
		{
			for (formIdx=0; formIdx<document.forms.length; formIdx++) 
			{
				var theForm = document.forms[formIdx];
				for(elementIdx=0; elementIdx<theForm.elements.length; elementIdx++)
				{
					window.status += theForm[elementIdx].type;
					if(theForm[elementIdx].type == "select-one") 
					{    theForm[elementIdx].style.visibility = "hidden";    }
				}
			}
		}
		*/
		
		for(var loop=0; loop < m_SelectBoxCollection.length; loop++)
		{
			m_SelectBoxCollection[loop].style.visibility = "hidden";
		}
		
		window.status=''; //m_SelectBoxCollection.length;
	}


	//------------------------------------------------------------------------ 
	// Unhide all select boxes
	function unhideAllSelectBoxes()
	{
		/*
		if (document.all) // Only do this for IE
		{
			for (formIdx=0; formIdx<document.forms.length; formIdx++) 
			{
				var theForm = document.forms[formIdx];
				for(elementIdx=0; elementIdx<theForm.elements.length; elementIdx++)
				{
					if(theForm[elementIdx].type == "select-one") 
					{    theForm[elementIdx].style.visibility = "visible";    }
				}
			}
		} 
		*/

		for(var loop=0; loop < m_SelectBoxCollection.length; loop++)
		{
			m_SelectBoxCollection[loop].style.visibility = "visible";
		}

		window.status=''; //m_SelectBoxCollection.length;
	}



	//------------------------------------------------------------------------ 
	// collect all page select boxes
	function collectSelectBoxes()
	{
		var formIdx;
		var elementIdx;
		if (document.all) // Only do this for IE
		{
			for (formIdx=0; formIdx<document.forms.length; formIdx++) 
			{
				var theForm = document.forms[formIdx];
				for(elementIdx=0; elementIdx<document.forms[formIdx].elements.length; elementIdx++)
				{
					if(document.forms[formIdx][elementIdx].type == "select-one" || document.forms[formIdx][elementIdx].type == "select-multiple") 
					{    
						//document.forms[formIdx][elementIdx].style.visibility = "visible";    
						m_SelectBoxCollection.push(document.forms[formIdx][elementIdx]);
					}
				}
			}
		} 
		window.status=''; //m_SelectBoxCollection.length;
	}


	//---------------------------------------------
	function msgResultsPopup(l_showhide, l_element)
	{
		//alert(l_element);
		if(l_showhide == "show")
		{
		  if(document.getElementById(l_element))
		  {
			//document.getElementById(divname).style.width="420px";
			document.getElementById(l_element).style.visibility="";
		  }
		}
		else
		{
		  if(document.getElementById(l_element))
		  {
			//document.getElementById(divname).style.width="420px";
			document.getElementById(l_element).style.visibility="hidden";
		  }
		}
	}


	//---------------------------------------------------------
	function showHelpBox(l_box_id)
	{
		var help_box = document.getElementById(l_box_id);

		if (help_box)
		{	
			help_box.style.display = "";
		}
	}
	//---------------------------------------------------------
	function hideHelpBox(l_box_id)
	{
		var help_box = document.getElementById(l_box_id);
		if (help_box)
		{	
			help_box.style.display = "none";
		}
	}
	//---------------------------------------------------------
	function showHideHelpBox(l_box_id)
	{
		var help_box = document.getElementById(l_box_id);
		if (help_box)
		{	
			if (help_box.style.display == "none")
			{
				showHelpBox(l_box_id);
			}
			else
			{
				hideHelpBox(l_box_id);
			}
		}
	}


	//---------------------------------------------------------
	function AlphaNumericUnderscoreValidation(l_field, l_form)
	{
		var c;
		var j;
		var frm = document.forms[l_form];
		for(j = 0; j < l_field.value.length; j++)
		{
		  c = l_field.value.charAt(j);
		  if(!((c >= "a" && c <= "z") || (c >= "A" && c <= "Z") || (c >= "0" && c <= "9") || (c == "_") || (c == " ")))
		  {
			l_field.focus();
			return false;
		  }
		}
		return true;
	}

	//---------------------------------------------------------
	function isNumeric(value, allow_decimal) 
	{ 
		if (allow_decimal==null) {allow_decimal=true;}

		if (allow_decimal) {if (value.match(/^\d+\.*\d*$/)==null) return false;}
		else {if (value.match(/^\d+$/)==null) return false;}
		
		return true; 
	}

	//--------------------------------------------------------------------
	function openNewWindow(l_url, width, height, l_title)
	{
		var frm;
		frm = document.forms.frmForm;
		var x = (640 - width)/2;
		var y = (480 - height)/2;

		if (screen)
		{
			y = (screen.availHeight - height)/2;
			x = (screen.availWidth - width)/2;
		}
		window.open(l_url, l_title, 'scrollbars=yes,resizable=yes,width='+width+', height='+height+', screenX='+x+', screenY='+y+', top='+y+', left='+x);	
	}

	//--------------------------------------------------------------------
	function openWindow(l_url, l_title)
	{
		window.open(l_url, l_title);	
	}


	//--------------------------------------------------------------------
	function isValidEmail(str) 
	{
		return (str.indexOf(".") > 0) && (str.indexOf("@") > 0);
	}


	//--------------------------------------------------------------------
	function isValidEmailAddress(emailAddress) {
		var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
		return pattern.test(emailAddress);
	}
	
	//--------------------------------------------------------------------
	function isDate(sDate) 
	{
		//validates date format: mm/dd/yy or mm/dd/yyyy
		// - "mm" must be 1-12, "dd" must be 1-31, "yyyy" must be 1900-2099
		var re = /^(0?[1-9]|1[012])\/(0?[1-9]|[12][0-9]|3[01])\/(19|20)?[0-9]{2}$/
		if (re.test(sDate)) 
		{
			var dArr = sDate.split("/");
			var d = new Date(sDate);
			return d.getMonth() + 1 == dArr[0] && d.getDate() == dArr[1] && (d.getYear() == dArr[2] || d.getFullYear() == dArr[2]);
		}
		else 
		{
			return false;
		}
	}
	
	//--------------------------------------------------------------------
	function isDateTime(sDateTime, bTimeRequired) 
	{
		//time is not required by default
		var bValidateDateAndTime = false;
		sDateTime = Trim(sDateTime); //trim the date/time string
		
		//if time is required or
		//if the string contains a space, we assume it is date + time
		//validate for date AND time, otherwise only validate for date
		if(bTimeRequired || sDateTime.indexOf(" ")>0){ bValidateDateAndTime = true; }
		
		if(bValidateDateAndTime)
		{
			//validates date and time format: mm/dd/yy hh:mm am/pm or mm/dd/yyyy hh:mm:ss am/pm
			// - "mm" must be 01-12, "dd" must be 01-31, "yyyy" must be 1900-2099
			// - "hh" must be 01-12, "mm" must be 00-59, "ss" must be 00-59 (optional)
			var re = /^(0?[1-9]|1[012])\/(0?[1-9]|[12][0-9]|3[01])\/(19|20)?[0-9]{2} (0?[1-9]|1[012])\:([0-5][0-9])(\:([0-5][0-9]))? ?(am|pm)?$/i
			return re.test(sDateTime);
		}
		else
		{
			//validates date format
			return isDate(sDateTime);
		}
	}


	//--------------------------------------------------------------------
	// JS Object used to store the last clicked checkbox for each set of
	// checkboxes. See method below for usage details.
	//--------------------------------------------------------------------
	var lastClickedIndexes = new Object();
	//--------------------------------------------------------------------
	// If called by a checkbox when the checkbox is clicked, will manage the
	// selection/deselection of a range of checkboxes when the Shift key
	// is held down during the click.
	//
	// @param clickedCheckbox - the checkbox originating the event
	// @param event - the onclick event itself
	//
	//
	// To use this you just write your checkbox with an onclick event that 
	//    calls the function, like this:
	//    <input type="checkbox" name="foo" value="bar" onclick="handleCheckboxRangeSelection(this,event);" />
	//--------------------------------------------------------------------
	function handleCheckboxRangeSelection(clickedCheckbox, event) 
	{
		// Find the position of the checkbox in the array of checkboxes
		var checkBoxes = document.getElementsByName(clickedCheckbox.name);
		var clickedIndex;

		for (i=0; i<checkBoxes.length; i++) {
			if (clickedCheckbox.value == checkBoxes[i].value) {
				clickedIndex = i;
				break;
			}
		}

		// Fetch the index of the last clicked checkbox for this set
		lastClickedIndex = lastClickedIndexes[clickedCheckbox.name];

		// If the shift key was pressed, and we have a previously
		// clicked checkbox, "click" the whole range
		if ((event.shiftKey == true) && (lastClickedIndex != null))  {
			startId = Math.min(lastClickedIndex, clickedIndex);
			endId   = Math.max(lastClickedIndex, clickedIndex);

			for (i=startId; i<=endId; i++) {
				checkBoxes[i].checked = clickedCheckbox.checked;
			}
		}

		// Store the new checkbox index as the last clicked one
		lastClickedIndexes[clickedCheckbox.name] = clickedIndex;
	}
	//--------------------------------------------------------------------

	
	//--------------------------------------------------------------------
	function maximizeWindow()
	{
		//-- Maximize Window --//
		top.window.moveTo(0,0);
		if (document.all) 
		{
			top.window.resizeTo(screen.availWidth,screen.availHeight);
		}
		else if (document.layers||document.getElementById) 
		{
			if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth)
			{
				top.window.outerHeight = screen.availHeight;
				top.window.outerWidth = screen.availWidth;
			}
		}
	}



	//-----------------------------------------------------
	function generic_showLoading()
	{
		if(document.getElementById('layLoading'))
		{
			document.getElementById('layLoading').style.display = "";
		}
		if(document.getElementById('layTitle'))
		{
			document.getElementById('layTitle').style.display = "none";
		}
		if(document.getElementById('layContent'))
		{
			document.getElementById('layContent').style.display = "none";
		}
		if(document.getElementById('imgLoading'))
		{
			document.getElementById('imgLoading').src = "images/loading.gif";
		}
		window.status = "please wait, performing requested action...";
		return false;
	}


	//-----------------------------------------------------
	function custom_showLoading(l_msg1, l_msg2, l_msg3, l_msg4, l_msg5)
	{
		var contentLayer = document.getElementById("layContent");
		if(contentLayer)
		{
			contentLayer.style.display = "none";
		}
		var loadLayer = document.getElementById("layLoading");
		if(loadLayer)
		{
			window.scrollTo(0,0);
			loadLayer.style.display = "";
		}
		var loadImg = document.getElementById("imgLoading");
		if(loadImg)
		{
			loadImg.src = "images/loading.gif";
		}
		
		//special case - hide content element layer
		var extraLayer = document.getElementById("boxHandle_elements");
		if (extraLayer)
		{
			extraLayer.style.display = "none";
		}
		
		if (undefined == l_msg1)  l_msg1 = "";
		if (undefined == l_msg2)  l_msg2 = "";
		if (undefined == l_msg3)  l_msg3 = "";
		if (undefined == l_msg4)  l_msg4 = "";
		if (undefined == l_msg5)  l_msg5 = "";
		
		if(l_msg1 == "")  l_msg1 = "processing request";
		if(l_msg2 == "")  l_msg2 = l_msg1;
		if(l_msg3 == "")  l_msg3 = l_msg2;
		if(l_msg4 == "")  l_msg4 = l_msg3;
		if(l_msg4 == "")  l_msg5 = l_msg4;

		setTimeout("custom_changeMsg('"+ l_msg1 +"')",0);
		setTimeout("custom_changeMsg('"+ l_msg2 +"')",6000);
		setTimeout("custom_changeMsg('"+ l_msg3 +"')",12500);
		setTimeout("custom_changeMsg('"+ l_msg4 +"')",25000);
		setTimeout("custom_changeMsg('"+ l_msg5 +"')",37000);

		return false;
	}
	//-----------------------------------------------------
	function custom_changeMsg(l_msg)
	{
		var loadMsg = document.getElementById("loadMsg");
		if (loadMsg)
		{
			if(l_msg == "") {l_msg = "please wait";}
			window.status = l_msg + "...";
			loadMsg.innerHTML = l_msg + "...";
		}
	}

	//-----------------------------------------------------
	function changeFieldColor(l_field_id)
	{
		var l_field = document.getElementById(l_field_id);
		if(l_field)
		{
			var l_color = l_field.value;
			var l_intHex = 0;
			var l_intValue = 0;

			//set field bg color
			l_field.style.backgroundColor = l_color;
			
			l_color = l_color.toLowerCase();
			l_color = l_color.replace("#", "");

			//convert hex color to a number - calculate sum of each character in hex string
			for (var i=0; i < l_color.length; i++)
			{
				l_strChar = l_color.charAt(i);
				if (l_strChar.length > 0)
				{
					switch (l_strChar)
					{
						case "a": l_intValue = 10; break;
						case "b": l_intValue = 11; break;
						case "c": l_intValue = 12; break;
						case "d": l_intValue = 13; break;
						case "e": l_intValue = 14; break;
						case "f": l_intValue = 15; break;
						default: l_intValue = parseInt(l_strChar);
					}
					l_intHex += l_intValue;
				}
			}
			//if sum of hex characters is over half of total possible (ffffff = 90)
			//set text color to black or white
			if(l_intHex > 45)
			{
				l_field.style.color = "#000000";
			}
			else
			{
				l_field.style.color = "#ffffff";
			}
		}
	}

	//-----------------------------------------------------
	function clearField(l_field_id)
	{
		var field = document.getElementById(l_field_id);
		if(field)
		{
			field.value = "";
		}
	}

	//-----------------------------
	function setImage(l_hidden_field, l_img)
	{
		if (document.getElementById(l_hidden_field))
		{
			if(document.getElementById(l_hidden_field).value == "")
			{
				document.getElementById(l_img).src = "images/no_image.gif";
			}
			else
			{
				document.getElementById(l_img).src = document.getElementById(l_hidden_field).value;
			}
		}
	}
	
	//-----------------------------
	function clearImage(l_hidden_field, l_img)
	{
		document.getElementById(l_hidden_field).value = "";
		document.getElementById(l_img).src = "images/no_image.gif";
	}

	//-----------------------------
	function modalDialogShowImage(url,width,height,l_hidden_field,l_img)
	{
		if (document.getElementById(l_hidden_field))
		{
			var r = window.showModalDialog(url,window,"dialogWidth:"+width+"px;dialogHeight:"+height+"px;edge:Raised;center:Yes;help:No;Resizable:Yes;Maximize:Yes");
			if (typeof r != "undefined" && r != "")
			{
				document.getElementById(l_hidden_field).value = r;
				document.getElementById(l_img).src = document.getElementById(l_hidden_field).value;
			}
			else
			{	
				//clearImage(l_hidden_field, l_img);
			}
		}
	}

	//-----------------------------
	function showHideDiv(divName)
	{
		var divObj = document.getElementById(divName);
		if (divObj)
		{
			//show div
			if (divObj.style.display == "none" || divObj.style.visibility == "hidden")
			{
				showDiv(divName);
			}
			//hide div
			else
			{
				hideDiv(divName);
			}
		}
	}

	//-----------------------------
	function showDiv(divName)
	{
		var divObj = document.getElementById(divName);
		if (divObj)
		{
			divObj.style.display = "";	
			divObj.style.visibility = "visible";			
		}
	}

	//-----------------------------
	function hideDiv(divName)
	{
		var divObj = document.getElementById(divName);
		if (divObj)
		{
			divObj.style.display = "none";	
			divObj.style.visibility = "hidden";			
		}
	}

	//----------------------------------------------------------
	function showAlt(l_obj)
	{
		if (l_obj)
		{
			var text = l_obj.nextSibling;
			if (l_obj.alt.length>0)
			{
				text.innerHTML = l_obj.alt;
				l_obj.alt = "";
			}
			text.className = "helpBox";
			text.style.zIndex = "1";
			text.style.position = "absolute";
			text.style.width = "200px";

			text.style.display = "";
		}
	}
	function hideAlt(l_obj)
	{
		if (l_obj)
		{
			var text = l_obj.nextSibling;
			text.style.display = "none";
		}
	}
	
	//----------------------------------------------------------
	function showImgPreview(l_field_id, l_div_id, l_no_img_div_id)
	{
		var field = document.getElementById(l_field_id);
		var div = document.getElementById(l_div_id);
		var divNoImg = document.getElementById(l_no_img_div_id);
		if (field && div && divNoImg)
		{
			if (field.value.length>0)	{div.style.visibility = "visible";}
			else						{divNoImg.style.visibility = "visible";}
		}
	}
	//----------------------------------------------------------
	function hideImgPreview(l_field_id, l_div_id, l_no_img_div_id)
	{
		var div = document.getElementById(l_div_id);
		var divNoImg = document.getElementById(l_no_img_div_id);
		if (div && divNoImg)
		{
			div.style.visibility = "hidden";
			divNoImg.style.visibility = "hidden";
		}
	}

	
	//----------------------------------------------------------
	function showElementTextBox(l_field, l_switch_txt, l_box_type, l_editor)
	{
		var frm = document.forms.frmForm;
		var rdoFieldAdv = document.getElementById(l_field+"_adv_0");
		var rdoFieldPlain = document.getElementById(l_field+"_adv_1");

		if (rdoFieldAdv && rdoFieldPlain)
		{
			if (l_box_type)
			{
				//plain text
				if (l_box_type == "plain")
				{
					loadPlainText(l_field, l_switch_txt, l_editor);
				}
				//advanced text
				else
				{
					loadAdvancedText(l_field, l_switch_txt, l_editor);
				}
			}
			else
			{
				//plain text
				if (rdoFieldPlain.checked)
				{
					loadPlainText(l_field, l_switch_txt, l_editor);
				}
				//advanced text
				else
				{
					loadAdvancedText(l_field, l_switch_txt, l_editor);
				}
			}
		}	
	}

	//----------------------------------------------------------
	function loadPlainText(l_field, l_switch_txt, l_editor)
	{
		var frm = document.forms.frmForm;
		var txtField = document.getElementById(l_field);
		var plainTextArea = document.getElementById(l_field+"_plain");
		var advancedTextArea = document.getElementById(l_field+"_advanced");

		if (frm && plainTextArea && advancedTextArea)
		{
			advancedTextArea.style.display = "none";
			plainTextArea.style.display = "";
			if (l_switch_txt==true && l_editor)
			{
				txtField.value = l_editor.getHTMLBody();
			}
		}	
	}
	//----------------------------------------------------------
	function loadAdvancedText(l_field, l_switch_txt, l_editor)
	{
		var frm = document.forms.frmForm;
		var txtField = document.getElementById(l_field);
		var plainTextArea = document.getElementById(l_field+"_plain");
		var advancedTextArea = document.getElementById(l_field+"_advanced");

		if (frm && plainTextArea && advancedTextArea)
		{
			plainTextArea.style.display = "none";
			advancedTextArea.style.display = "";
			if (l_switch_txt==true && l_editor)
			{
				l_editor.loadHTML(txtField.value);
			}
		}	
	}

	//----------------------------------------------------------
	function loadIFrameSource(l_frame_id, l_url)
	{
		var frame = document.getElementById(l_frame_id);
		if (frame)
		{
			if (frame.src != l_url)
			{
				frame.src = l_url;
			}
		}
	}


	//----------------------------------------------------------
	function GetAJAXResponse(loadurl, blnEvalStr, strEvalAfter)
	{
		var str = "";
		var xmlHttp = GetXmlHttpObject();
		var url = loadurl;
		var contin = true;
		var i;
		var end;

		xmlHttp.open("GET",url,true);
		xmlHttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
		xmlHttp.send(null);
		
		xmlHttp.onreadystatechange = function() {
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{
				//get response string
				str = xmlHttp.responseText;
				//alert(str);

				//evaluate the response string
				if (blnEvalStr==true) { eval(str); }

				//evaluate passed-in string
				if (strEvalAfter.length>0) { eval(strEvalAfter); }

			}
			//return the response string
			return str;
		}
		return str;
	}


	//----------------------------------------------------------
	function GetXmlHttpObject()
	{ 
		var objXMLHttp = null;
		if (window.XMLHttpRequest)
		{
			objXMLHttp = new XMLHttpRequest();
		}
		else if (window.ActiveXObject)
		{
			objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		return objXMLHttp;
	} 

	//----------------------------------------------------------
	function pausecomp(millis) 
	{
		var date = new Date();
		var curDate = null;

		do { curDate = new Date(); } 
		while(curDate-date < millis);
	} 

	//----------------------------------------------------------
	function addEvent( obj, type, fn ) 
	{
		if ( obj.attachEvent ) 
		{
			obj['e'+type+fn] = fn;
			obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
			obj.attachEvent( 'on'+type, obj[type+fn] );
		} 
		else
			obj.addEventListener( type, fn, false );
	}

	//----------------------------------------------------------
	function removeEvent( obj, type, fn ) 
	{
		if ( obj.detachEvent ) 
		{
			obj.detachEvent( 'on'+type, obj[type+fn] );
			obj[type+fn] = null;
		} 
		else
			obj.removeEventListener( type, fn, false );
	}

	// MsgBox Confirmation
	function confirmSubmit()
	{
	var agree=confirm("Are you sure you want to delete this item?");
	if (agree)
		return true ;
	else
		return false ;
	}

	//----------------------------------------------------------
	//	jquery zebra striping logic
	//  zebra stripes a table with the class: "search_results_table"
	//  also adds a hover highlight effect 
	//----------------------------------------------------------
	function zebraStripeResultsTable(){

		//----------------------------------------------------------
		//zebra striping - color alternating rows, skipping the first row (assumed to be a header row)
		//----------------------------------------------------------
		//apply zebra-striping style to alternating rows that use search_results_table class
		//(classes are defined in i_rebrand_variables.inc)
		//----------------------------------------------------------
		$(".search_results_table tr:not(:first):even").addClass("row1");
		$(".search_results_table tr:not(:first):odd").addClass("row2");
		
		//for search results rows, setup onHover highlight
		$(".search_results_table tr:not(:first)").hover(
		      function () {
		        highlightRow(this);
		      }, 
		      function () {
		        unhighlightRow(this);
		      }
		   );
				
		//----------------------------------------------------------

	}

	//----------------------------------------------------------
	function highlightRow(l_row)
	{
		//highlight the row
		//$(l_row).addClass("row_highlight");
		/*
		10/9/09 skl - had to change code to directly access the background color of the row
		- it is MUCH faster than changing the row's class, when the table has many rows
		- hard-coding colors = bad; but effeciency wins this battle
		*/
		l_row.style.backgroundColor = "#ffff99";
	}
	//----------------------------------------------------------
	function unhighlightRow(l_row)
	{
		//remove highlighting from row
		//$(l_row).removeClass("row_highlight");
		/*
		10/9/09 skl - had to change code to directly access the background color of the row
		- it is MUCH faster than changing the row's class, when the table has many rows
		- hard-coding colors = bad; but effeciency wins this battle
		*/
		l_row.style.backgroundColor = "";
	}

	//----------------------------------------------------------
	function selectClickedRow(l_table_id, l_selected_row)
	{
		//un-select any rows in the table
		$("#" + l_table_id + " tr").removeClass("row_select");
		//select the clicked row
		$(l_selected_row).addClass("row_select");
	}

	//----------------------------------------------------------
	function detectCapLock(e, l_div_name)
	{
		kc = e.keyCode?e.keyCode:e.which;
		sk = e.shiftKey?e.shiftKey:((kc == 16)?true:false);
		if(((kc >= 65 && kc <= 90) && !sk)||((kc >= 97 && kc <= 122) && sk))
		document.getElementById(l_div_name).style.visibility = 'visible';
		else
		document.getElementById(l_div_name).style.visibility = 'hidden';
	}
	
	//---------------------------------------------------------
	// expand/collapse a multi-select box and update plus/minus image
	//---------------------------------------------------------
	function expandCollapseSelBox(l_objBtn, l_selBoxID)
	{
		if ($(l_objBtn).attr("title")=="expand") 
		{
			$("#"+l_selBoxID).css("height","250px");
			$(l_objBtn).attr("title","collapse");
			$(l_objBtn).children("img").attr("src","images/minus_.gif").attr("alt","collapse").attr("title","collapse");
			$(l_objBtn).children("span").html("collapse list view");
		}
		else 
		{
			$("#"+l_selBoxID).css("height","60px");
			$(l_objBtn).attr("title","expand");
			$(l_objBtn).children("img").attr("src","images/plus_.gif").attr("alt","expand").attr("title","expand");
			$(l_objBtn).children("span").html("expand list view");
		}
	}
	
	//---------------------------------------------------------
	// expand/collapse an object and update plus/minus image
	//---------------------------------------------------------
	function expandCollapseObj(l_objBtn, l_objID)
	{
		if ($(l_objBtn).attr("title")=="expand") 
		{
			$("#"+l_objID).show();
			$(l_objBtn).attr("title","collapse");
			$(l_objBtn).children("img").attr("src","images/minus_.gif").attr("alt","collapse").attr("title","collapse");
			$(l_objBtn).children("span").html("collapse list view");
		}
		else 
		{
			$("#"+l_objID).hide();
			$(l_objBtn).attr("title","expand");
			$(l_objBtn).children("img").attr("src","images/plus_.gif").attr("alt","expand").attr("title","expand");
			$(l_objBtn).children("span").html("expand list view");
		}
	}

	//----------------------------------------------------------
	function initSmarshDatePicker(intObjID)
	{
		/* 
		initSmarshDatePicker() 
		- initializes an object as a jquery date picker control
		- it sets the datepicker options according to the smarsh standards
		- pages that call this method must include jquery.js, ui.core.js, and ui.datepicker.js
		
		Datepicker Control:
		- http://jqueryui.com/demos/datepicker
	    - dependent on ui.core.js and ui.datepicker.js
		*/
		//initializes the jquery datepicker control with the default smarsh settings
		$("#"+intObjID).datepicker({
	        //makes the month and year drop-down boxes
			changeMonth: true,
			changeYear: true,
			//animation settings
			showAnim: 'fadeIn',
			duration: 'fast',
	        //makes a calendar icon display next to the date field
	        //clicking either the icon or the field will display the date picker control
			buttonImage: 'images/calendar.png',
			buttonImageOnly: true,
			showOn: 'both',
			buttonText: 'Click to select a date. Format: mm/dd/yyyy.'
		}).attr("title","Click to select a date. Format: mm/dd/yyyy.");
	}
	
	//----------------------------------------------------------
	function initSmarshDateTimePicker(intObjID)
	{
		/* 
		initSmarshDateTimePicker() 
		- initializes an object as a jquery datepicker control with the timepicker add-on
		- it sets the date/time picker options according to the smarsh standards
		- pages that call this method must include jquery.js, ui.core.js, ui.datepicker.js, ui.slider.js, and ui.timepicker.js
		
		Datepicker Control:
		- http://jqueryui.com/demos/datepicker
	    - dependent on ui.core.js and ui.datepicker.js
	    
		Timepicker Control:
	    - http://milesich.com/timepicker/
	    - dependent on ui.core.js, ui.datepicker.js, ui.slider.js, and ui.timepicker.js
		*/
		//initializes the jquery date/time picker control with the default smarsh settings
	    $("#"+intObjID).datepicker({
	    	//"timepicker" options
	        showTime: true,
	    	duration: '', //animation does not work with timepicker, so it has to be turned off
	        constrainInput: false, //allows user to type time
	        //makes the month and year drop-down boxes
	        changeMonth: true,
	        changeYear: true,
	        //makes a calendar icon display next to the date field
	        //clicking either the icon or the field will display the date picker control
	        buttonImage: 'images/calendar.png',
	        buttonImageOnly: true,
	        showOn: 'both', 
	        buttonText: 'Click to select a date/time. Format: mm/dd/yyyy hh:mm am/pm.'
	     }).attr("title","Click to select a date/time. Format: mm/dd/yyyy hh:mm am/pm.");
	}
	