<!--
//------ cim
//------ sh_scripts.js / May 2005
//------ Author: Robert Mwangi (www.granas.ch)
//
		//-------------------------------------------------------------------------
		function fnCimAddFunctionToPageEventHandler(objFunction, strPageEventType)
			{
			    switch (strPageEventType.toLowerCase())
			        {
			            case "onload":
                            var objOldOnLoadFunction = window.onload;
                            if (typeof window.onload != 'function') window.onload = objFunction;
                            else {
                                    window.onload = function() {
                                        if (objOldOnLoadFunction) objOldOnLoadFunction();
                                        objFunction();
                                    }
                            }
                            break;
			            case "onunload":
                            var objOldOnUnLoadFunction = window.onunload;
                            if (typeof window.onunload != 'function') window.onunload = objFunction;
                            else {
                                    window.onunload = function() {
                                        if (objOldOnUnLoadFunction) objOldOnUnLoadFunction();
                                        objFunction();
                                    }
                            }
                            break;
                    }
			}
        //-------------------------------------------------------------------------
		function fnCimLoadFunctions()
			{
				fnCimLoadRoImages();
				fnCimChangeFontSize(0);
			}
		//-------------------------------------------------------------------------
		function fnCimClearFontSize()
			{
				fnCimDeleteCookie('cimChgFontSize');
				window.location.reload();
			}
		//-------------------------------------------------------------------------
		function fnCimPrintThis(strPageUrl)
			{
				fnCimOpenWindow(3, strPageUrl, 'popCimPrintThis', 700, 600);
			}
		//-------------------------------------------------------------------------
		function fnCimEmailThis(strPageUrl)
			{
				var blnHasQuerystring = (strPageUrl.indexOf("?") == -1);
				if(blnHasQuerystring) var strURL = "?cimEmailThisPageUrl=" + encodeURI(window.location.href) + "&cimEmailThisPageTitle=" + document.title;
				else var strURL = "&cimEmailThisPageUrl=" + encodeURI(window.location.href) + "&cimEmailThisPageTitle=" + document.title;
				fnCimOpenWindow(3, strPageUrl + strURL, 'popCimEmailThis', 700, 600);
			}
		//------------------------------------------------------------------------------
		function fnCimAddToFavorites(strContainerID)
			{
				if (document.getElementById(strContainerID)) var objContainer = document.getElementById(strContainerID);
				else return;
				var strAlertMessage = objContainer.innerHTML;
				var strUrl = window.location.href;
				var strPageTitle = document.title;
				if (g_blnIE5up) window.external.AddFavorite(strUrl, strPageTitle);
				else if (g_blnNS6up) window.sidebar.addPanel(strPageTitle, strUrl, "");
				else alert(strAlertMessage);
			}
		//------------------------------------------------------------------------------
		function fnCimMakeThisMyHomepage(objObject, strContainerID)
			{
				if (document.getElementById(strContainerID)) var objContainer = document.getElementById(strContainerID);
				else return;
				var strAlertMessage = objContainer.innerHTML;
				var strUrl = window.location.href;
				if (g_blnIE5up)
					{
						objObject.style.behavior = "url(#default#homepage)";
						objObject.setHomePage(strUrl);
					}
				else alert(strAlertMessage);
			}
		//-------------------------------------------------------------------------
		function fnCimSetClassName(strTargetID, blnIsMouseOver)
			{
			    if (!document.getElementById(strTargetID)) return;
			    var objTarget = document.getElementById(strTargetID);
				if (blnIsMouseOver) objTarget.className += 'Over';
				else objTarget.className = objTarget.className.replace(/Over/,'');
			}
		//-------------------------------------------------------------------------
		function fnCimChangeFontSize(intFontIncrease)
			{
				if (document.getElementById("divCimContentPanel")) var objContentPanel = document.getElementById("divCimContentPanel");
				else return false;
				var aryTags = new Array ("p", "div", "td", "a", "span", "li", "h1", "h2", "h3", "h4", "h5", "h6");
				var objTagCollection = null;
				var objTag = null;
				var intDefaultFontSize = 0;
				var intFontSize = 0;
				var intTempFontSize = 0;
				var intTagFontSize = 0;
				var blnHasSetCookie = false;
				//
				if (!fnCimGetCookie('cimChgFontSize') && intFontIncrease == 0) return false;
				if (fnCimGetCookie('cimChgFontSize')) intDefaultFontSize = parseInt(fnCimGetCookie('cimChgFontSize'));
				else intDefaultFontSize = 14;
				for (var i = 0; i < aryTags.length; i++)
					{
						objTagCollection = objContentPanel.getElementsByTagName(aryTags[i]);
						for (var j = 0; j < objTagCollection.length; j++)
							{
								objTag = objTagCollection[j];
								intFontSize = 0;
								intTempFontSize = 0;
								if (!isNaN(parseInt(objTag.style.fontSize))) intFontSize = parseInt(objTag.style.fontSize)
								if (intFontSize == 0) intFontSize = intDefaultFontSize;
								intFontSize += intFontIncrease;
								if (aryTags[i] == "li") objTag.style.lineHeight = Math.round(intFontSize * 1.2) + "px";
								else objTag.style.lineHeight = Math.round(intFontSize * 1.5) + "px";
								switch(aryTags[i])
									{
										case "h1": intTempFontSize = ((intFontIncrease >= 0) ? 4 : -4); break;
										case "h2": intTempFontSize = ((intFontIncrease >= 0) ? 3 : -3); break;
										case "h3": intTempFontSize = ((intFontIncrease >= 0) ? 2 : -2); break;
										case "h4": intTempFontSize = ((intFontIncrease >= 0) ? 1 : -1); break;
										case "h5": intTempFontSize = ((intFontIncrease >= 0) ? 1 : -1); break;
										case "h6": intTempFontSize = ((intFontIncrease >= 0) ? 1 : -1); break;
									}
								objTag.style.fontSize = intFontSize + intTempFontSize + "px";
								if (!blnHasSetCookie) fnCimSetCookie('cimChgFontSize', (intDefaultFontSize + intFontIncrease) + '');
								blnHasSetCookie = true;
							}
					}
			}
		//-------------------------------------------------------------------------
		function fnCimReloadCaptchaImage(strImageID, strFormFieldID)
            {
                if (!document.getElementById(strImageID)) return;
                var dtmDate = new Date();
                var intSec = dtmDate.getSeconds();
                var objImage = objImage = document.getElementById(strImageID);
                objImage.src = objImage.src + intSec;
                if (!document.getElementById(strFormFieldID)) return;
                document.getElementById(strFormFieldID).value = "";
                document.getElementById(strFormFieldID).focus();
            }
		//-------------------------------------------------------------------------
        function fnCimGetScreenScrollXYPos()
            {
                var intScrollPosX = 0, intScrollPosY = 0;
                if (typeof( window.pageYOffset ) == "number")
                    {
                        //--- Netscape compliant
                        intScrollPosY = window.pageYOffset;
                        intScrollPosX = window.pageXOffset;
                    }
                else if (document.body && (document.body.scrollLeft || document.body.scrollTop))
                    {
                        //--- DOM compliant
                        intScrollPosY = document.body.scrollTop;
                        intScrollPosX = document.body.scrollLeft;
                    }
                else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop))
                    {
                        //--- IE6 standards compliant mode
                        intScrollPosY = document.documentElement.scrollTop;
                        intScrollPosX = document.documentElement.scrollLeft;
                    }
                return [intScrollPosX, intScrollPosY];
            }
		//-------------------------------------------------------------------------
		function fnCimLoadRoImages()
			{
				var intImgSuffix;
				var objSwapOriginal, objSwapOver;
				//
				if (document.images)
					{
						for (i = 0; i < document.images.length; i++)
							{
								//--- _no.gif = normal image
								//--- _ro.gif = rollover image
								//---
								intImgSuffix = document.images[i].src.lastIndexOf("no.");
								if (intImgSuffix >= 0)
									{
										//--- original image
											objSwapOriginal = new Image();
											objSwapOriginal.src = document.images[i].src.substring(0, intImgSuffix) + "r" + document.images[i].src.substring(intImgSuffix + 1, document.images[i].src.length);
											document.images[i].objSwapOriginal = objSwapOriginal;
										//--- rollover image
											objSwapOver = new Image();
											objSwapOver.src = document.images[i].src;
											document.images[i].objSwapOver = objSwapOver;
									}
							}
					}
			}
		//-------------------------------------------------------------------------
		function fnCimToggleImg(strTarget, strAction)
			{
				if (document.images && strAction != "")
					{
						strAction = strAction.toLowerCase();
						switch(strAction)
							{
								case "over":
									if (document.images && document.images[strTarget].objSwapOriginal)
										{
											document.images[strTarget].src = document.images[strTarget].objSwapOriginal.src;
										}
									break;
								default:
									if (document.images && document.images[strTarget].objSwapOver)
										{
											document.images[strTarget].src = document.images[strTarget].objSwapOver.src;
										}
									break;
							}
					}
			}
    	//-------------------------------------------------------------------------
		function fnCimDialogToggleLayer(strFormFieldID, strContainerID)
			{
				var strDialogID = "";
				if (strFormFieldID != "" && document.getElementById(strFormFieldID)) strDialogID = document.getElementById(strFormFieldID).value;
				else if (strContainerID != "" && document.getElementById(strContainerID)) strDialogID = strContainerID;
				else return false;
				if (!document.getElementById(strDialogID)) return false;
				var objLayer = document.getElementById(strDialogID);
				var aryScreenScrollXYPos = fnCimGetScreenScrollXYPos();
				var intXPos=0; intYPos=0;
				var intWidth = parseInt(objLayer.style.width);
				var intHeight = parseInt(objLayer.style.height);
				if (isNaN(intWidth)) intWidth = 0;
				if (isNaN(intHeight)) intWidth = 0;
				intXPos = (document.body.offsetWidth - intWidth) / 2;
				intYPos = (document.body.offsetHeight - intHeight) / 2;
				objLayer.style.left = intXPos + aryScreenScrollXYPos[0] + "px";
			    objLayer.style.top = intYPos + aryScreenScrollXYPos[1] + "px";
				if (objLayer.style.display == "none") objLayer.style.display = "inline";
				else objLayer.style.display = "none";
			}
		//-------------------------------------------------------------------------
		function fnCimDialogDisplayMessageBox(strMessage)
			{
			    var strTarget = "cimModulesGridViewDialogContainerID_MessageBox";
			    var strMessageBoxLabelID = "labelContentMessageBox";
				if (!document.getElementById(strTarget)) return false;
				var strDialogID = document.getElementById(strTarget).value;
				if (!document.getElementById(strDialogID)) return false;
				var objLayer = document.getElementById(strDialogID);
				var aryScreenScrollXYPos = fnCimGetScreenScrollXYPos();
				var intXPos=0; intYPos=0;
				var intWidth = parseInt(objLayer.style.width);
				var intHeight = parseInt(objLayer.style.height);
				if (isNaN(intWidth)) intWidth = 0;
				if (isNaN(intHeight)) intWidth = 0;
				intXPos = (document.body.offsetWidth - intWidth) / 2;
				intYPos = (document.body.offsetHeight - intHeight) / 2;
				objLayer.style.left = intXPos + aryScreenScrollXYPos[0] + "px";
			    objLayer.style.top = intYPos + aryScreenScrollXYPos[1] + "px";
				objLayer.style.display = "inline";
				//
				var objSpanCollection = objLayer.getElementsByTagName("span");
				for (var i = 0; i < objSpanCollection.length; i++)
					{
						if(objSpanCollection[i].getAttribute("id").toLowerCase().indexOf(strMessageBoxLabelID.toLowerCase()) != -1)
							{
							    document.getElementById(objSpanCollection[i].getAttribute("id")).innerHTML = strMessage;
							    break;
							}
					}
			}
    	//-------------------------------------------------------------------------
		function fnCimToggleLayer(strTarget)
			{
				if (!document.getElementById(strTarget)) return false;
				var objLayer = document.getElementById(strTarget);
				if (objLayer.style.display == "none") objLayer.style.display = "inline";
				else objLayer.style.display = "none";
				return true;
			}
    	//-------------------------------------------------------------------------
		function fnCimShowLayer(strTarget)
			{
				if (!document.getElementById(strTarget)) return false;
				document.getElementById(strTarget).style.display = "inline";
				return true;
			}
    	//-------------------------------------------------------------------------
		function fnCimHideLayer(strTarget)
			{
				if (!document.getElementById(strTarget)) return false;
				document.getElementById(strTarget).style.display = "none";
				return true;
			}
		//-------------------------------------------------------------------------
		function fnCimCenterDialogContainer(strTarget, intWidth, intHeight)
			{
				if (!document.getElementById(strTarget)) return false;
				var objLayer = document.getElementById(strTarget);
				var aryScreenScrollXYPos = fnCimGetScreenScrollXYPos();
				var intXPos=0; intYPos=0;
				intXPos = (document.body.offsetWidth - intWidth) / 2;
				intYPos = (document.body.offsetHeight - intHeight) / 2;
				objLayer.style.left = intXPos + aryScreenScrollXYPos[0] + "px";
			    objLayer.style.top = intYPos + aryScreenScrollXYPos[1] + "px";
			}
		//-------------------------------------------------------------------------
		function fnCimRemoveFrames()
			{
				if (self != top)
					{
						top.location.href = location.href;
					}
			}
		//------------------------------------------------------------------------------
		function fnCimOpenWindow(intCaseNr, strPageToLoad, strWindowName, intWidth, intHeight) 
			{
				//--- initialize vars
					var intXPos=0; intYPos=0;
					intXPos = (screen.width - intWidth) / 2;
					intYPos = (screen.height - intHeight) / 2;
					if (isNaN(intCaseNr)) intCaseNr = 1;
					//
				//--- default window settings
					var strArgs = 	"width="  + intWidth + "," 
									+ "height=" + intHeight + ","
									+ "toolbar=no,";
					//
				//--- window settings
					switch (intCaseNr)
						{
							//---------------------------------------
								case 1:
									strArgs += 	"location=no,menubar=no,resizable=no,scrollbars=no,";
									if (g_blnIE5up) strArgs += "status=no,"
									if (g_blnNS6up) strArgs += "status=no,"
								break;
							//---------------------------------------
								case 2:
									strArgs += 	"location=no,menubar=no,resizable=yes,scrollbars=yes,";
									if (g_blnIE5up) strArgs += "status=yes,"
									if (g_blnNS6up) strArgs += "status=yes,"
								break;
							//---------------------------------------
								case 3:
									strArgs += 	"location=no,menubar=yes,resizable=yes,scrollbars=yes,";
									if (g_blnIE5up) strArgs += "status=yes,"
									if (g_blnNS6up) strArgs += "status=yes,"
								break;
							//---------------------------------------
								case 4:
									strArgs += 	"location=no,menubar=no,resizable=yes,scrollbars=no,";
									if (g_blnIE5up) strArgs += "status=yes,"
									if (g_blnNS6up) strArgs += "status=yes,"
								break;
							//---------------------------------------
								default:
									strArgs += 	"location=no,menubar=no,resizable=yes,scrollbars=yes,";
									if (g_blnIE5up) strArgs += "status=no,"
									if (g_blnNS6up) strArgs += "status=yes,"
								break;
						}
				//--- browser specific settings
					if (g_blnIE5up) strArgs += "left=" + intXPos + ",top=" + intYPos;
					if (g_blnNS6up) strArgs += "screenx=" + intXPos + ",screeny=" + intYPos;
					//
				//--- open window
					var objWindow = window.open(strPageToLoad, strWindowName, strArgs);
					if (objWindow) objWindow.focus();
			}
		//-------------------------------------------------------------------------
		function fnCimTrimText(strText)
			{ 
				strText.replace(/^\W+/,'').replace(/\W+$/,''); 
				return strText;
			}
		//------------------------------------------------------------------------------
		function fnCimSetCookie(strName, strValue, dtmExpires, strPath, strDomain, strSecure)
			{
				document.cookie = strName + "=" + escape(strValue) +
					((dtmExpires) ? ";expires=" + dtmExpires.toGMTString() : "") +
					((strPath) ? ";path=" + strPath : "") + 
					((strDomain) ? ";domain=" + strDomain : "") +
					((strSecure) ? ";secure" : "");
			}
		//------------------------------------------------------------------------------
		function fnCimGetCookie(strName)
			{
				var intStartPos = document.cookie.indexOf(strName + "=");
				var intLen = intStartPos + strName.length + 1;
				if ((!intStartPos) && (strName != document.cookie.substring(0, strName.length))) return null;
				if (intStartPos == -1) return null;
				var intEndPos = document.cookie.indexOf(";", intLen);
				if (intEndPos == -1) intEndPos = document.cookie.length;
				return unescape(document.cookie.substring(intLen, intEndPos));
			}
		//------------------------------------------------------------------------------
		function fnCimDeleteCookie(strName, strPath, strDomain)
			{
				if (fnCimGetCookie(strName))
					{
						document.cookie = strName + "=" +
						((strPath == null) ? "" : "; path=" + strPath) +
						((strDomain == null) ? "" : "; domain=" + strDomain) +
						"; expires=Thu, 01-Jan-70 00:00:01 GMT";
					}
			}
		//------------------------------------------------------------------------------
		function fnCimFieldMaxLength(objFormField, lngMaxChars, strAlertMsg)
            {
                if (strAlertMsg == "") strAlertMsg = "Please note:\nThis field can only contain " + lngMaxChars + " characters.";
                else strAlertMsg = strAlertMsg.replace(/\{0\}/,lngMaxChars);
                if (objFormField.value.length > lngMaxChars)
                    {
                        objFormField.value = objFormField.value.substring(0, lngMaxChars);
                        alert(strAlertMsg);
                        objFormField.focus();
                    }
            }
		//------------------------------------------------------------------------------
        function fnCimIsValidNumber(objFormField, strAlertMsg)
			{
                if (strAlertMsg == "") strAlertMsg = "Please enter a numeric value in this field.";
			    if(!objFormField.value) return false;
			    if(isNaN(objFormField.value))
			        {
			            alert(strAlertMsg);
			            objFormField.select();
			            objFormField.focus();
			            return false;
			        }
			    return true;
			}
		//------------------------------------------------------------------------------
		function fnCimOpacitySet(intOpacity, strTarget)
			{
				if (!document.getElementById(strTarget)) return false;
				var objLayer = document.getElementById(strTarget);
				if (objLayer.style.opacity) objLayer.style.opacity = (intOpacity / 100);
				if (objLayer.style.MozOpacity) objLayer.style.MozOpacity = (intOpacity / 100);
				if (objLayer.style.KhtmlOpacity) objLayer.style.KhtmlOpacity = (intOpacity / 100);
				if (objLayer.style.filter) objLayer.style.filter = "alpha(opacity=" + intOpacity + ")";
			}
		//------------------------------------------------------------------------------
		function fnCimOpacityTransform(strTarget, intOpacityBegin, intOpacityEnd, intMilliSeconds)
			{
				if (isNaN(intMilliSeconds)) intMilliSeconds = 1000;
				var intDelay = Math.round(intMilliSeconds / 100);
				var intCounter = 0;
				var i = 0;
				//
				if (intOpacityBegin > intOpacityEnd)
					{
					for (i = intOpacityBegin; i >= intOpacityEnd; i--)
						{
							setTimeout("fnCimOpacitySet(" + i + ",'" + strTarget + "')", (intCounter * intDelay));
							intCounter++;
						}
					}
				else if (intOpacityBegin < intOpacityEnd)
					{
						for (i = intOpacityBegin; i <= intOpacityEnd; i++)
							{
							setTimeout("fnCimOpacitySet(" + i + ",'" + strTarget + "')", (intCounter * intDelay));
							intCounter++;
						}
					}
			}
		//------------------------------------------------------------------------------
		function fnCimArticlesTickerStop()
			{
			    window.clearInterval(g_objCimArticlesTickerInterval);
				window.clearTimeout(g_objCimArticlesTickerTimeout);
			}
		//------------------------------------------------------------------------------
		function fnCimArticlesTickerFadeStart(strContainerID, strObjectIDsDelimited, intSeconds)
			{
				if (isNaN(intSeconds)) intSeconds = 1;
				var intMilliSeconds = intSeconds * 1000;
		        fnCimArticlesTickerFade(strContainerID, strObjectIDsDelimited, intMilliSeconds);
		        g_objCimArticlesTickerInterval = window.setInterval("fnCimArticlesTickerFade('" +  strContainerID + "','" +  strObjectIDsDelimited + "', " + intMilliSeconds + ")", intMilliSeconds * 6);
			}
		//------------------------------------------------------------------------------
		function fnCimArticlesTickerFade(strContainerID, strObjectIDsDelimited, intMilliSeconds)
			{
				if (!document.getElementById(strContainerID)) return false;
				var aryObjectIDs = strObjectIDsDelimited.split(";");
				if (aryObjectIDs.length < 1) return false;
				//
				var objContainer = document.getElementById(strContainerID);
				if (isNaN(intMilliSeconds)) intMilliSeconds = 1000;
				if (isNaN(g_intCimArticlesCurrentIndex)) g_intCimArticlesCurrentIndex = 0;
				if (document.getElementById(aryObjectIDs[g_intCimArticlesCurrentIndex]))
					{
						objContainer.innerHTML = document.getElementById(aryObjectIDs[g_intCimArticlesCurrentIndex]).innerHTML;
						fnCimOpacityTransform(strContainerID, 0, 100, intMilliSeconds);
						g_objCimArticlesTickerTimeout = setTimeout("fnCimOpacityTransform('" + strContainerID + "', 100, 0, " + intMilliSeconds + ")", intMilliSeconds * 4);
						if (g_intCimArticlesCurrentIndex == aryObjectIDs.length - 1) g_intCimArticlesCurrentIndex = 0;
						else g_intCimArticlesCurrentIndex++;
					}
			}
		//------------------------------------------------------------------------------
		function fnCimGridViewCheckBoxSelector(objCheckBox, strCompareString)
			{
			    if (!objCheckBox) return false;
			    if (strCompareString.length < 1) return false;
				if (!document.forms[0]) return false;
				var objForm = document.forms[0];
				var blnChecked = objCheckBox.checked;
				//
				for (var i = 0; i < objForm.elements.length; i++)
					{
						if((!objForm.elements[i].disabled) && (objForm.elements[i].name) && objForm.elements[i].name.toLowerCase().indexOf(strCompareString.toLowerCase()) != -1)
							{
								if (objForm.elements[i].type.toLowerCase() == "checkbox") objForm.elements[i].checked = blnChecked;
							}
					}
			}
		//------------------------------------------------------------------------------
		function fnCimModulesDialogsFilterOperatorsArray(strType)
			{
				var aryOperators = aryOperators = new Array("LIKE","=","<>");
				switch (strType.toLowerCase())
					{
						case "number":
							aryOperators = new Array("=","<",">","<=",">=","<>")
							break;
						case "date":
							aryOperators = new Array("=","<",">","<=",">=","<>")
							break;
						case "boolean":
							aryOperators = new Array("=","<>")
							break;
					}
				return aryOperators;
			}
		//------------------------------------------------------------------------------
		function fnCimModulesDialogsFilterColumnListItemClick(objFormField, strOperatorListBoxID, strColumnDataTypeLabelID)
			{
				if (!objFormField) return false;
				if (!fnCimShowLayer('cimModulesGridViewDialogsTableFilterExpression')) return false;
				if (!document.getElementById(strOperatorListBoxID)) return false;
				//
				if (!objFormField.options) return false;
				if (!objFormField.options[objFormField.selectedIndex].getAttribute) return false;
				else var strType = objFormField.options[objFormField.selectedIndex].getAttribute("cim_column_data_type");
				//
				var aryOperators = fnCimModulesDialogsFilterOperatorsArray(strType);
				var objExpressionListBox = document.getElementById(strOperatorListBoxID);
				var i = 0;
				for (i = objExpressionListBox.options.length - 1; i >= 0; i--)
					{
						if (objExpressionListBox.options[i] != null) objExpressionListBox.options[i] = null;
					}
				for (i = 0; i < aryOperators.length; i++)
					{
						objExpressionListBox.options[i] = new Option(aryOperators[i], aryOperators[i]);
					}
				if (document.getElementById(strColumnDataTypeLabelID)) document.getElementById(strColumnDataTypeLabelID).innerHTML = "(" + strType + ")";
			}
		//------------------------------------------------------------------------------
		function fnCimModulesDialogsFilterAddButtonClick(strColumnListBoxID, strOperatorRadioButtonID, strOperatorListBoxID, strKeywordTextBoxID, strExpressionListBoxID)
			{
				if (!document.forms[0]) return false;
				var objForm = document.forms[0];
				if (!document.getElementById(strColumnListBoxID)) return false;
				else var objColumnListBox = document.getElementById(strColumnListBoxID);
				if (!document.getElementById(strOperatorListBoxID)) return false;
				else var objOperatorListBox = document.getElementById(strOperatorListBoxID);
				if (!document.getElementById(strExpressionListBoxID)) return false;
				else var objExpressionListBox = document.getElementById(strExpressionListBoxID);
				if (!document.getElementById(strKeywordTextBoxID)) return false;
				else var objKeywordTextBox = document.getElementById(strKeywordTextBoxID);
				if (objKeywordTextBox.value == "")
					{
						fnCimModulesDialogsFilterActivateButtons("add", false);
						return false;
					}
				if (!objColumnListBox.options[objColumnListBox.selectedIndex].getAttribute) return false;
				else var strType = objColumnListBox.options[objColumnListBox.selectedIndex].getAttribute("cim_column_data_type");
				//
				var strBooleanOperator = "OR";
				for (var i = 0; i < objForm.elements.length; i++)
					{
						if (objForm.elements[i].type.toLowerCase() == "radio")
							{
								if (objForm.elements[i].id.toLowerCase().indexOf(strOperatorRadioButtonID.toLowerCase()) != -1)
									{
										if (objForm.elements[i].checked)
											{
												strBooleanOperator = objForm.elements[i].value;
												break;
											}
									}
							}
					}
				//
				var strExpression = strBooleanOperator + " " + objColumnListBox.options[objColumnListBox.selectedIndex].value + " " + objOperatorListBox.options[objOperatorListBox.selectedIndex].value + " ";
				var strKeyword = objKeywordTextBox.value;
				//
				switch (strType.toLowerCase())
					{
						case "number":
							if (isNaN(strKeyword))
								{
									alert("Numeric (0,1,2,...)");
									objKeywordTextBox.focus();
									objKeywordTextBox.select();
									return false;
								}
							strExpression += strKeyword
							break;
						case "date":
							strExpression += "'" + strKeyword + "'"
							break;
						case "boolean":
							if ((strKeyword.toLowerCase() == "true") || (strKeyword.toLowerCase() == "false")) strExpression += strKeyword;
							else
								{
									alert("Boolean (True, False)");
									objKeywordTextBox.focus();
									objKeywordTextBox.select();
									return false;
								}
							break;
						default:
							strExpression += "'" + strKeyword + "'"
					}
				//
				var intLen = objExpressionListBox.options.length;
				if (intLen > 0) objExpressionListBox.options[intLen] = new Option(strExpression, strExpression);
				else objExpressionListBox.options[0] = new Option(strExpression, strExpression);
				objKeywordTextBox.value = "";
				fnCimModulesDialogsFilterActivateButtons("add", false);
				fnCimModulesDialogsMoveUpDownBtnsContainer(strExpressionListBoxID);
			}
		//------------------------------------------------------------------------------
		function fnCimModulesDialogsFilterEditButtonClick(strColumnListBoxID, strOperatorRadioButtonID, strOperatorListBoxID, strKeywordTextBoxID, strExpressionListBoxID, strColumnDataTypeLabelID)
			{
				if (!document.forms[0]) return false;
				var objForm = document.forms[0];
				if (!document.getElementById(strColumnListBoxID)) return false;
				else var objColumnListBox = document.getElementById(strColumnListBoxID);
				if (!document.getElementById(strOperatorListBoxID)) return false;
				else var objOperatorListBox = document.getElementById(strOperatorListBoxID);
				if (!document.getElementById(strExpressionListBoxID)) return false;
				else var objExpressionListBox = document.getElementById(strExpressionListBoxID);
				if (!document.getElementById(strKeywordTextBoxID)) return false;
				else var objKeywordTextBox = document.getElementById(strKeywordTextBoxID);
				if (!objExpressionListBox.options) return false;
				if (objExpressionListBox.options.length < 1) return false;
				if (objExpressionListBox.selectedIndex == -1) return false;
				//
				var strExpression = objExpressionListBox[objExpressionListBox.selectedIndex].value;
				if (strExpression == "") return false;
				var aryExpression = strExpression.split(" ");
				if (aryExpression.length != 4) return false;
				//
				var strBooleanOperator = fnCimTrimText(aryExpression[0]);
				var strColumnName = fnCimTrimText(aryExpression[1]);
				var strOperator = fnCimTrimText(aryExpression[2]);
				var strKeyword = fnCimTrimText(aryExpression[3]);
				var strType = "string";
				var i = 0;
				//
				//--- select boolean operator
				for (i = 0; i < objForm.elements.length; i++)
					{
						if (objForm.elements[i].type.toLowerCase() == "radio")
							{
								if (objForm.elements[i].id.toLowerCase().indexOf(strOperatorRadioButtonID.toLowerCase()) != -1)
									{
										objForm.elements[i].checked = false;
										if (objForm.elements[i].value.toLowerCase() == strBooleanOperator.toLowerCase())
											{
												objForm.elements[i].checked = true;
											}
									}
							}
					}
				//
				//--- select column name
				for (i = 0; i < objColumnListBox.length; i++)
					{
						if (strColumnName.toLowerCase() == objColumnListBox[i].value.toLowerCase())
							{
								objColumnListBox[i].selected = true;
								strType = objColumnListBox[i].getAttribute("cim_column_data_type");
								break;
							}
					}
				//
				//--- select operator
				var aryOperators = fnCimModulesDialogsFilterOperatorsArray(strType);
				for (i = 0; i < objOperatorListBox.length; i++)
					{
						objOperatorListBox.options[i] = null;
					}
				for (i = 0; i < aryOperators.length; i++)
					{
						objOperatorListBox.options[i] = new Option(aryOperators[i], aryOperators[i]);
					}
				for (i = 0; i < objOperatorListBox.length; i++)
					{
						if (strOperator.toLowerCase() == objOperatorListBox[i].value.toLowerCase())
							{
								objOperatorListBox[i].selected = true;
								break;
							}
					}
				//
				//--- set keyword
				if (strType.toLowerCase() == "string" || strType.toLowerCase() == "date")
					{
						//--- remove apostrophe (') at beginning and end of the keyword
						strKeyword = strKeyword.substr(1, strKeyword.length - 2);
					}
				objKeywordTextBox.value = strKeyword;
				//
				if (document.getElementById(strColumnDataTypeLabelID)) document.getElementById(strColumnDataTypeLabelID).innerHTML = "(" + strType + ")";
			}
		//------------------------------------------------------------------------------
		function fnCimModulesDialogsFilterRemoveButtonClick(strExpressionListBoxID, intSelectedIndex)
			{
				if (!document.getElementById(strExpressionListBoxID)) return false;
				else var objExpressionListBox = document.getElementById(strExpressionListBoxID);
				if (!objExpressionListBox.options) return false;
				if (objExpressionListBox.options.length < 1)
					{
						fnCimModulesDialogsFilterActivateButtons("save", false);
						return false;
					}
				if (isNaN(intSelectedIndex) || intSelectedIndex == -1)
					{
						if (objExpressionListBox.selectedIndex == -1) return false;
						else intSelectedIndex = objExpressionListBox.selectedIndex;
					}
				if (objExpressionListBox.childNodes[intSelectedIndex]) objExpressionListBox.removeChild(objExpressionListBox[intSelectedIndex]);
				if (objExpressionListBox.options.length < 1) fnCimModulesDialogsFilterActivateButtons("save", false);
				fnCimModulesDialogsFilterActivateButtons("edit_remove", false);
				fnCimModulesDialogsMoveUpDownBtnsContainer(strExpressionListBoxID);
			}
		//-------------------------------------------------------------------------
		function fnCimModulesDialogsFilterSaveButtonClick(strHiddenFieldID, strExpressionListBoxID) 
			{
				if (!document.getElementById(strHiddenFieldID)) return false;
				else var objHiddenField = document.getElementById(strHiddenFieldID);
				if (!document.getElementById(strExpressionListBoxID)) return false;
				else var objExpressionListBox = document.getElementById(strExpressionListBoxID);
				if (objExpressionListBox.options.length < 1) return false;
				var strExpression = "";
				//
				objHiddenField.value = ""
				for (var i = 0; i < objExpressionListBox.options.length; i++) 
					{
						strExpression = objExpressionListBox.options[i].value;
						if (objHiddenField.value == "") objHiddenField.value = strExpression;
						else objHiddenField.value = objHiddenField.value + ";" + strExpression;
					}
				return true;
			}
		//------------------------------------------------------------------------------
		function fnCimModulesDialogsFilterKeywordTextbox(objFormField)
			{
				if (!objFormField) return false;
				if (!objFormField.value) return false;
				if (objFormField.value.length > 0) fnCimModulesDialogsFilterActivateButtons("add", true);
				else fnCimModulesDialogsFilterActivateButtons("add", false);
			}
		//------------------------------------------------------------------------------
		function fnCimModulesDialogsFilterNameTextbox(objFormField, strExpressionListBoxID)
			{
				if (!document.getElementById(strExpressionListBoxID)) return false;
				else var objExpressionListBox = document.getElementById(strExpressionListBoxID);
				if (!objExpressionListBox.options) return false;
				if (objExpressionListBox.options.length < 1)
					{
						fnCimModulesDialogsFilterActivateButtons("save", false);
						return false;
					}
				if (!objFormField) return false;
				if (!objFormField.value) return false;
				if (objFormField.value.length > 0) fnCimModulesDialogsFilterActivateButtons("save", true);
				else fnCimModulesDialogsFilterActivateButtons("save", false);
			}
		//------------------------------------------------------------------------------
		function fnCimModulesDialogsFilterActivateButtons(strState, blnEnableButton)
			{
				if (strState.toLowerCase() != "save")
					{
						if (!fnCimShowLayer('cimModulesGridViewDialogsTableFilterExpression')) return false;
					}
				if (!document.forms[0]) return false;
				var objForm = document.forms[0];
				var aryButtonIDs = new Array("buttonFilterAdd","buttonFilterEdit","buttonFilterRemove","buttonFilterSave");
				//
				for (var i = 0; i < objForm.elements.length; i++)
					{
						if (objForm.elements[i].type.toLowerCase() == "button")
							{
								switch (strState.toLowerCase())
									{
										case "add":
											if (objForm.elements[i].id.toLowerCase().indexOf(aryButtonIDs[0].toLowerCase()) != -1)
												{
													if (blnEnableButton) objForm.elements[i].disabled = false;
													else objForm.elements[i].disabled = true;
												}
											break;
										case "edit_remove":
											if ((objForm.elements[i].id.toLowerCase().indexOf(aryButtonIDs[1].toLowerCase()) != -1) || (objForm.elements[i].id.toLowerCase().indexOf(aryButtonIDs[2].toLowerCase()) != -1))
												{
													if (blnEnableButton) objForm.elements[i].disabled = false;
													else objForm.elements[i].disabled = true;
												}
											break;
										case "save":
											if (objForm.elements[i].id.toLowerCase().indexOf(aryButtonIDs[3].toLowerCase()) != -1)
												{
													if (blnEnableButton) objForm.elements[i].disabled = false;
													else objForm.elements[i].disabled = true;
												}
											break;
									}
							}
					}
			}
		//------------------------------------------------------------------------------
		function fnCimModulesDialogsMoveUpDownBtnsContainer(strExpressionListBoxID)
			{
				if (strExpressionListBoxID == "")
					{
						if (!document.getElementById('cimModulesGridViewDialogsMoveUpDownBtnsContainer')) return false;
						else document.getElementById('cimModulesGridViewDialogsMoveUpDownBtnsContainer').style.display = "inline";
						return;
					}
				if (!document.getElementById(strExpressionListBoxID)) return false;
				else var objExpressionListBox = document.getElementById(strExpressionListBoxID);
				if (!objExpressionListBox.options) return false;
				if (!document.getElementById('cimModulesGridViewDialogsMoveUpDownBtnsContainer')) return false;
				else var objLayer = document.getElementById('cimModulesGridViewDialogsMoveUpDownBtnsContainer');
				if (objExpressionListBox.options.length > 0) objLayer.style.display = "inline";
				else objLayer.style.display = "none";
			}
		//------------------------------------------------------------------------------
		function fnCimModulesDialogsMoveListItem(strExpressionListBoxID, strDirection)
			{
				if (!document.getElementById(strExpressionListBoxID)) return false;
				else var objExpressionListBox = document.getElementById(strExpressionListBoxID);
				if (!objExpressionListBox.options) return false;
				if (objExpressionListBox.options.length <= 1) return false;
				if (objExpressionListBox.selectedIndex == -1) return false;
				var intSelectedIndex = objExpressionListBox.selectedIndex;
				var intMoveToPosition = intSelectedIndex;
				var i = 0;
				var strListItemText1, strListItemText2;
				var strListItemValue1, strListItemValue2;
				//
				switch (strDirection.toLowerCase())
					{
						case "moveup":
							if (intSelectedIndex == 0) return false;
							intMoveToPosition = intSelectedIndex - 1;
							break;
						case "movedown":
							if (intSelectedIndex == objExpressionListBox.length - 1) return false;
							intMoveToPosition = intSelectedIndex + 1;
							break;
					}
				for (i = 0; i < objExpressionListBox.length; i++)
					{
						objExpressionListBox[i].selected = false;
					}
				strListItemText1 = objExpressionListBox[intSelectedIndex].text;
				strListItemValue1 = objExpressionListBox[intSelectedIndex].value;
				strListItemText2 = objExpressionListBox[intMoveToPosition].text;
				strListItemValue2 = objExpressionListBox[intMoveToPosition].value;
				objExpressionListBox[intMoveToPosition].text = strListItemText1;
				objExpressionListBox[intMoveToPosition].value = strListItemValue1;
				objExpressionListBox[intMoveToPosition].selected = true;
				objExpressionListBox[intSelectedIndex].text = strListItemText2;
				objExpressionListBox[intSelectedIndex].value = strListItemValue2;
			}
		//------------------------------------------------------------------------------
		function fnCimModulesDialogsFilterSavedFiltersListItemClick(strSavedFiltersListBoxID, strDeleteLinkID)
			{
				if (!document.getElementById(strSavedFiltersListBoxID)) return false;
				else var objSavedFiltersListBox = document.getElementById(strSavedFiltersListBoxID);
				if (!objSavedFiltersListBox.options) return false;
				if (objSavedFiltersListBox.options.length < 1) return false;
				if (objSavedFiltersListBox.selectedIndex == -1) return false;
				if (!document.getElementById(strDeleteLinkID)) return false;
				else var objHyperLink = document.getElementById(strDeleteLinkID);
				//
				if (objSavedFiltersListBox.selectedIndex > 0) objHyperLink.style.display = "inline";
				else objHyperLink.style.display = "none";
			}
	    //-------------------------------------------------------------------------

	//-->