var isIE = document.all ? 1 : 0; var userAgent = navigator.userAgent.toLowerCase(); var isMac = (userAgent.indexOf("Mac") > -1); var isWin = (userAgent.indexOf("Win") > -1); var isSafari = (userAgent.indexOf("Safari") > -1); var DOM = ((document.getElementById) && (!isIE)) ? 1 : 0; var isNS = document.layers ? 1 : 0; var swcChildWinB; var isChildWinOpen = false; var isLoading = false; var isChildBeingOpen = false; var isSelfBeingClose = false; var testQueryFocus = false; var testEmailFocus = false; var testMsgFocus = false; var testDetailFocus = false; var xCord = 0; var yCord = 0; var xCorddp = 0; var yCorddp = 0; var editActiveLayer = 0; var activeRepeatLayer = 5; var activeSearchLayer = 11; function updateIsChildWinOpenVar(newVal) { isChildWinOpen = newVal; } function checkChildWinOpen() { return isChildWinOpen; } function checkChildWindowsOpen() { var timeOut = 100; if (isIE && isMac) { timeOut = 400; } type = typeof swcChildWin; if (type != "undefined") { window.setTimeout("checkChildWindowsOpen2()", timeOut); } type = typeof swcChildWinB; if (type != "undefined") { window.setTimeout("checkChildWindowsOpenB2()", timeOut); } return true; } function checkChildWindowsOpen2() { type = typeof swcChildWin; if (type != "undefined") { if (!(swcChildWin.closed)) { swcChildWin.focus(); } } return true; } function onUnloadCloaseChildWindow() { type = typeof swcChildWin; if (type != "undefined") { if (!(swcChildWin.closed)) { isChildBeingOpen = false; swcChildWin.close(); } } type = typeof swcChildWinB; if (type != "undefined") { if (!(swcChildWinB.closed)) { swcChildWinB.onUnloadCloaseChildWindow(); swcChildWinB.close(); } } return true; } function closeChildWin() { if (isChildBeingOpen) { return checkChildWindowsOpen(); } type = typeof swcChildWin; if (type != "undefined") { if (!(swcChildWin.closed)) { swcChildWin.close(); } } return true; } function closeOpenWindow() { if (opener.focus) opener.focus(); self.close(); return true; } function checkChildWindowsOpenB2() { type = typeof swcChildWinB; if (type != "undefined") { if (!(swcChildWinB.closed)) { swcChildWinB.focus(); } } return true; } function openUrl(url, name) { isChildBeingOpen = true; if (isIE) { var xPos = self.screenLeft + 10; var yPos = self.screenTop + 10; } else { var xPos = self.screenX + 10; var yPos = self.screenY + 10; } var winProp = setWinProperties(xPos, yPos, 0, 0, true, true, true, true, false); var helpwin = window.open(url,name,winProp); isChildBeingOpen = false; return false; } function setWinProperties(xPos, yPos, width, height, isDependent, putToolbar, putScrollbar, isResizable, putStatusBar) { var winProp = "screenX="; winProp += xPos.toString(); winProp += ",screenY="; winProp += yPos.toString(); winProp += ",left="; winProp += xPos.toString(); winProp += ",top="; winProp += yPos.toString(); if (width > 0) { winProp += ",Width="; winProp += width.toString(); } if (height > 0) { winProp += ",Height="; winProp += height.toString(); } if (putToolbar) winProp += ",toolbar=yes"; else winProp += ",toolbar=no"; if (putScrollbar) winProp += ",scrollbars=yes"; else winProp += ",scrollbars=no"; if (isResizable) winProp += ",resizable=yes"; else winProp += ",resizable=no"; if (putStatusBar) winProp += ",status=yes"; else winProp += ",status=no"; if (isDependent) winProp += ",dependent"; return winProp; } function isNumeric(s) { for(var i = 0; i < s.length; ++i) { var c = s.charAt(i); if ((c < '0') || c > '9') { return false; } } return true; } function RemoveSpace(numStr) { var retVal = numStr; var tmpVal = numStr; for(var i = 0; i < tmpVal.length && tmpVal.charAt(i) == ' '; ++i) {} if (i < tmpVal.length) { retVal = tmpVal.substring(i, tmpVal.length); tmpVal = retVal; } for(i = tmpVal.length-1; i > 0 && tmpVal.charAt(i) == ' '; --i) {} if (i >= 0) { retVal = tmpVal.substring(0, i+1); tmpVal = retVal; } if (isNumeric(tmpVal)) retVal = tmpVal; else retVal = numStr; return retVal; } function findMouseCord(evt) { if ((isNS) || (DOM)) { xCord = evt.pageX; yCord = evt.pageY; xCorddp = evt.screenX; yCorddp = evt.screenY; } else if (isIE) { xCord = event.x; yCord = event.y; xCorddp = event.screenX; yCorddp = event.screenY; } } function initMouseClicks() { if (document.layers) { document.captureEvents(Event.MOUSEMOVE); } document.onmousemove = findMouseCord; } function openDatePicker(url, theForm, dayName, monthName, yearName, width, dependent) { if (checkChildWinOpen()) { return false; } updateIsChildWinOpenVar(true); isChildBeingOpen = true; if (isIE) { findMouseCord(document.onmousemove); } xCord = xCorddp + 20; yCord = yCorddp - 112; dayDate = eval(theForm + "." + dayName + ".value"); monthDate = eval(theForm + "." + monthName + ".selectedIndex+1"); yearDate = eval(theForm + "." + yearName + ".value"); url += "&date=" + yearDate + "/" + monthDate + "/" + dayDate; var winProp = setWinProperties(xCord, yCord, width, 260, dependent, false, false, false, false, false); var name = "SWC_ChildWin"; type = typeof swcChildWin; if (type != "undefined") { if (swcChildWin.closed) { swcChildWin = window.open(url,name,winProp); } } else { swcChildWin = window.open(url,name,winProp); } swcChildWin.focus(); return true; } function openTimePicker(url, yPosition, isDependent) { if (checkChildWinOpen()) { return false; } updateIsChildWinOpenVar(true); isChildBeingOpen = true; if (isIE) { findMouseCord(document.onmousemove); } xCord = xCorddp + 20; yCord = yCorddp - yPosition; var winProp = setWinProperties(xCord, yCord, 215, 245, isDependent, false, false, false, false); var name = "SWC_ChildWin"; type = typeof swcChildWin; if (type != "undefined") { if (swcChildWin.closed) { swcChildWin = window.open(url,name,winProp); } } else { swcChildWin = window.open(url,name,winProp); } swcChildWin.focus(); return true; } function validate_TEXTAREA_Limit(fieldId, warnVarId, maxsize, alertMsg, removeFocus) { if ((document.getElementById(fieldId).value.length >= maxsize) && (document.getElementById(warnVarId).value == "on") ) { document.getElementById(warnVarId).value = "off"; alert(alertMsg); document.getElementById(fieldId).focus(); return false; } if (removeFocus) { if (fieldId == 'owcIVarEmailAddress') { unsetFieldFocus(3); } else if (fieldId == 'owcIVarEmailText') { unsetFieldFocus(2); } else if (fieldId == 'owcIVarDetails') { unsetFieldFocus(1); } } return true; } function setFieldFocus(field) { if (field == 0) testQueryFocus = true; else if (field == 1) testDetailFocus = true; else if (field == 2) testMsgFocus = true; else if (field == 3) testEmailFocus = true; return false; } function unsetFieldFocus(field) { if (field == 0) testQueryFocus = false; else if (field == 1) testDetailFocus = false; else if (field == 2) testMsgFocus = false; else if (field == 3) testEmailFocus = false; return false; } function CST_MakeLayerObj(childLayer, parentLayer) { if (DOM) { parentLayer = document.createElement('div'); parentLayer.id = childLayer; document.body.appendChild(parentLayer); return childLayer; } else { parentLayer = (!parentLayer) ? '':'document.'+parentLayer+'.'; this.css = (isNS) ? eval(parentLayer+'document.'+childLayer) :eval('document.all.'+childLayer+'.style'); this.scrollHeight = isNS ? this.css.document.height :eval('document.all.'+childLayer+'.offsetHeight'); this.top=(isNS)?eval(this.css.top):eval(this.css.pixelTop); return this; } } function setChildWinStatus(isOpened, hasChildren) { type = typeof opener; if ( (isIE && type != "undefined") || (!isIE && opener)) { if ((typeof opener.isChildWinOpen) == "boolean") { opener.updateIsChildWinOpenVar(isOpened); } if ((typeof opener.isChildBeingOpen) == "boolean") { if (isOpened == false) opener.isChildBeingOpen = false; } } if (hasChildren && (isOpened == false)) { isSelfBeingClose = true; onUnloadCloaseChildWindow(); } return true; } function truncateField(alertMsg, fieldId, maxLength, removeFocus) { var testArray = document.getElementById(fieldId).value; var charSize = 0; var arraySize = 0; var currIndex = 0; var truncatedString = ""; var currChar = testArray.charCodeAt(currIndex); while (currChar && (arraySize <= maxLength)) { charSize = getBytesInChar(currChar); arraySize = arraySize + charSize; if (arraySize <= maxLength) { if (currChar == '13') { // don't count the carriage return only presented in IE arraySize = arraySize - charSize; } else { truncatedString = truncatedString + testArray.charAt(currIndex); } } currIndex++; currChar = testArray.charCodeAt(currIndex); } if (arraySize > maxLength) { alert(alertMsg); document.getElementById(fieldId).value = truncatedString; document.getElementById(fieldId).focus(); return false; } if (removeFocus) { if (fieldId == 'owcIVarEmailAddress') { unsetFieldFocus(3); } else if (fieldId == 'owcIVarEmailText') { unsetFieldFocus(2); } else if (fieldId == 'owcIVarDetails') { unsetFieldFocus(1); } } return true; } function getBytesInChar(codeChar) { var charSize = 0; if ((codeChar >= 0) && (codeChar <= 127)) charSize = 1; else if ((codeChar >= 128) && (codeChar <= 2047)) charSize = 2; else if (codeChar >= 2048) charSize = 3; return charSize; } function setViewGridChildWinStatus(isOpened, hasChildren, IE_viewGridId, DOM_viewGridId, viewGridClass) { if(!isOpened && isIE) { var tmp= IE_viewGridId + "='" + viewGridClass + "';"; } var tmp = "opener.document.getElementById('" + DOM_viewGridId + "').className ='" + viewGridClass + "';"; var type = typeof opener; if (isIE) { if ( (type == "object") && ((typeof opener.isSelfBeingClose) == "boolean")) { if (opener.isSelfBeingClose == false) eval(tmp); } } else { if (opener && ((typeof opener.isSelfBeingClose) == "boolean")) { if (opener.isSelfBeingClose == false) eval(tmp); } } if (opener) { if ((typeof opener.isChildBeingOpen) == "boolean") opener.isChildBeingOpen = false; setChildWinStatus(isOpened, hasChildren); } return true; } function normalKeyPress() {return true;} function ignoreEnterKey(e) { var keycode; if (window.event) keycode = window.event.keyCode; else if (e) keycode = e.which; else return true; if (keycode == 13) { if (document.entryedit_form) { if (testQueryFocus == true) {return false;} if (testDetailFocus == true) {return true;} if (testMsgFocus == true) {return true;} if (testEmailFocus == true) {return true;} } return false; } return true; } function onButtonFocus() {document.onkeypress = normalKeyPress;} function onButtonBlur() {document.onkeypress = ignoreEnterKey;}