function alrt(s) { var elm = document.getElementById('alert'); if (elm) { if (elm.value == "") elm.value = s; else { elm.value += "\n" + s; } } }; function aleert(s) { alert(s); }; var isIEResult = null; function isIE() { if (isIEResult == null) isIEResult = navigator.userAgent.toLowerCase().indexOf("msie") > -1; return isIEResult; }; function RefreshHref(node) { if (node.href != "") { var ri = node.href.indexOf("_rand="); if (ri > -1) { var bi = node.href.indexOf("#"); var bm = bi == -1 ? "" : node.href.substring(bi); node.href = node.href.substring(0,ri+6) + (new Date()).getTime() + bm; } } }; function FocusAndSelect(elm) { try { if (!elm.id) elm = document.getElementById(elm); elm.focus(); elm.select(); } catch (e) {} }; var re_25 = new RegExp( "%", "g" ); var re_26 = new RegExp( "&", "g" ); function escapex(str) { if (str.after) { return str.replace(re_25,"%25").replace(re_26,"%26"); } else return str; }; function Stack() { this.array = new Array(); this.push = function(o) { this.array.push(o); }; this.set = function(o) { if (this.array.length == 0) this.array.push(o); else this.array[this.array.length-1] = o; }; this.pop = function() { return this.array.pop(); }; this.peek = function(offset) { if (!offset) offset = 0; return this.array[this.array.length - 1 - offset]; }; this.hasItems = function() { return this.array.length > 0; }; this.length = function() { return this.array.length; }; }; String.prototype.trim = function() { var s = this; var i = 0; var j = s.length - 1; while (i < s.length && s.charAt(i) == " ") i++; while (j > i && s.charAt(j) == " ") j--; return s.substring(i,j+1); }; String.prototype.toBoolean = function() { return this.toLowerCase() == "true" || this.charAt(1) == "1"; }; String.prototype.toBool = function() { return this.toLowerCase() == "true" || this.charAt(1) == "1"; }; String.prototype.isNumber = function() { return !isNaN(this); }; String.prototype.after = function(delimiter, defaultValue) { var i = this.indexOf(delimiter); if (i == -1) return defaultValue; return this.substring(i + delimiter.length); }; String.prototype.before = function(delimiter,defaultValue) { var i = this.indexOf(delimiter); if (i == -1) return defaultValue; return this.substring(0,i); }; String.prototype.afterLast = function(delimiter,defaultValue) { var i = this.lastIndexOf(delimiter); if (i == -1) return defaultValue; return this.substring(i + delimiter.length); }; String.prototype.beforeLast = function(delimiter,defaultValue) { var i = this.lastIndexOf(delimiter); if (i == -1) return defaultValue; return this.substring(0,i); }; String.prototype.startsWith = function(subString) { return this.indexOf(subString) == 0; }; String.prototype.endsWith = function(subString) { return this.indexOf(subString) == this.length - subString.length; }; String.prototype.hasValue = function() { return this.trim().length > 0; }; function GhostForm() { this.form = document.createElement("FORM"); this.form = document.body.appendChild(this.form); this.addParameter = function(name, value) { var elm = OMgr.createElement("INPUT", name); elm.type = "hidden"; elm.value = value; this.form.appendChild(elm); }; this.submit = function(method) { if (!method) method = "POST"; this.form.method = method; this.form.submit(); }; }; function UrlAddress(url) { this.base = null; this.includeRandParameter = true; this.asHtml = true; this.paramNames = new Array(); this.paramValues = new Array(); this.addParam = function(name, value) { this.paramNames[this.paramNames.length] = name; this.paramValues[this.paramValues.length] = value; }; this.getParam = function(name) { for (var i = 0; i < this.paramNames.length; i++) { if (name == this.paramNames[i]) { return this.paramValues[i]; } } return null; }; this.removeParam = function(name) { for (var i = 0; i < this.paramNames.length; i++) { if (name == this.paramNames[i]) { this.paramNames[i] = null; this.paramValues[i] = null; break; } } }; this.parse = function(url) { if (url.startsWith("http") || url.endsWith(".html") || url.indexOf("?") > -1) { } else { url = "display.doms.jsp?pg=" + url; } this.base = url.before("?",url); var paramsStr = url.after("?",null); if (paramsStr != null) { var params = paramsStr.split("&"); for (var i = 0; i < params.length; i++) { var param = params[i]; var name = param.before("=").trim(); var value = param.after("=").trim(); this.addParam(name,unescape(value)); } } }; if (url) this.parse(url); this.toString = function() { var s = this.base; var first = true; for (var i = 0; i < this.paramNames.length; i++) { if (this.paramNames[i] != null) { if (first) {first = false; s = s + "?";} else s = s + "&"; s = s + this.paramNames[i] + "=" + escapex(this.paramValues[i]); } } if (this.asHtml) { if (first) {first = false; s = s + "?";} else s = s + "&"; s = s + "_sendhtml=true"; } if (this.includeRandParameter) { if (first) {first = false; s = s + "?";} else s = s + "&"; s = s + "_rand=" + (new Date()).getTime(); } return s; }; }; function Iterator() { this.elements = new Array(); this.index = -1; this.add = function(object) { this.elements[this.elements.length] = object; }; this.hasMore = function() { return this.index < this.elements.length; }; this.nextElement = function() { this.index++; return this.element[this.index]; }; this.rollUp = function() { this.index = -1; }; } function Accumulator(dlm) { this.str = ""; this.dlm = dlm; this.add = function(s) { if (this.str.length > 0) { this.str += this.dlm; } this.str += s; }; this.toString = function() { return this.str; }; }; var RegExp_Quotes = new RegExp( "'", "g" ); var RegExp_NewLines = new RegExp( "\n", "g" ); function PropertyAccumulator() { this.str = ""; this.add = function(name, value) { if (this.str.length > 0) { this.str += ", "; } if (value) { if (value.indexOf) { if (value.indexOf("'") > -1) value = value.replace(RegExp_Quotes,"\\'"); if (value.indexOf("\n") > -1) value = value.replace(RegExp_NewLines,"\\n"); } this.str += name + ":'" + value + "'"; } }; this.toString = function() { return this.str; }; }; function RequestParameterAccumulator(params) { this.str = ""; this.add = function(name, value) { if (value != null) { if (this.str.length > 0) { this.str += "&"; } this.str += name + "=" + escapex(value); } }; this.addObject = function(o) { if (o) { if (o.after) this.append(o); else { for (var p in o) { var pv = o[p]; if (pv) { this.add(p,pv); } } } } }; this.append = function(str) { if (str) { if (this.str.length > 0) { this.str += "&"; } this.str += str; } }; this.toString = function() { return this.str; }; this.addObject(params); }; function PageInfo(str) { this.name = null; this.lang = null; this.clang = null; this.charset = null; this.GS = null; this.DS = null; if (str) { var defs = str.split(";"); for (var i = 0; i < defs.length; i++) { var def = defs[i]; var n = def.before(":"); var v = def.after(":"); if (n && v) { if (n == "name") this.name = v; else if (n == "lang") this.lang = v; else if (n == "clang") this.clang = v; else if (n == "charset") this.charset = v; else if (n == "GS") this.GS = v; else if (n == "DS") this.DS = v; } } } if (!this.lang) this.lang = "en"; if (!this.clang) this.clang = this.lang == "ml" ? "en" : this.lang; if (!this.charset) this.charset = "iso-8859-1"; if (!this.GS) this.GS = "."; if (!this.DS) this.DS = ","; } function MoreMotionObject(node) { this.node = node; this.name = OMgr.getAttribute(node,"mo:name"); this.type = null; this.isMoreMotionObject = true; this.props = OMgr.getProps(node); if (!this.props) this.props = new Object(); this.saveProps = function() { if (this.node) { var pa = new PropertyAccumulator(); for (var p in this.props) { var pv = this.props[p]; if (pv) { pa.add(p,this.props[p]); } } this.node.setAttribute("mo:props",pa.toString()); } }; this.boolProp = function(propName) { var prop = eval("this.props." + propName); if (prop != null) { if (prop.toBool) return prop.toBool(); return prop == true; } return false; }; this.numberProp = function(propName, def) { var prop = eval("this.props." + propName); if (prop == null) prop = def; return prop * 1; }; this.setModified = function() {}; this.getIValue = function() {return ""}; this.setIValue = function() {}; }; function MoreMotionObjectManager() { this.idCounter = 0; this.getUniqueId = function(prefix) { if (prefix == null) prefix = "x"; return prefix + (new Date()).getTime() + "" + ++this.idCounter; }; this.getAttribute = function(node,attrName) { try { var attr = node.getAttribute(attrName); } catch (e) {} return attr; }; this.setAttribute = function(node, attrName, attrValue) { try { node.setAttribute(attrName, attrValue); } catch (e) {} }; this.getChildNode = function(parentNode, nodeName, elmName) { nodeName = nodeName.toUpperCase(); for (var i = 0; i < parentNode.childNodes.length; i++) { var node = parentNode.childNodes[i]; if (node.nodeType == 1) { if (node.nodeName == nodeName) { if (!elmName || node.name == elmName) return node; } if (node.hasChildNodes) { var n = this.getChildNode(node, nodeName, elmName) if (n) return n; } } } return null; }; this.getParentNode = function(node, nodeName) { nodeName = nodeName.toUpperCase(); var node = node.parentNode; while (node) { if (node.nodeName == nodeName) { return node; } node = node.parentNode; } return null; }; this.findChildObject = function(parentNode, nodeName, attrName, attrValue, depth) { var node = this.findChildNode(parentNode, nodeName, attrName, attrValue, depth); if (node) { return this.getObject(node); } return null; } this.findChildNode = function(parentNode, nodeName, attrName, attrValue, depth) { var prm = new Object(); if (nodeName && nodeName.startsWith("type:")) { prm.motype = nodeName.after(":"); if (prm.motype.startsWith(":")) { prm.stopOnSame = true; prm.motype = prm.motype.substring(1); } nodeName = null; } else { if (nodeName) nodeName = nodeName.toUpperCase(); } prm.nodeName = nodeName; prm.attrName = attrName; if (attrValue.endsWith("*")) { prm.generic = true; prm.attrValue = attrValue.before("*"); } else { prm.attrValue = attrValue; } if (depth == null) depth = 999; return this._findChildNode(parentNode, prm, depth); }; this._findChildNode = function(parentNode, prm, depth) { for (var i = 0; i < parentNode.childNodes.length; i++) { var node = parentNode.childNodes[i]; if (node.nodeType == 1) { var typeMatch = false; var doit = false; if (prm.nodeName) doit = node.nodeName == prm.nodeName; else if (prm.motype) { var attr = this.getAttribute(node,"mo:type"); if (attr && (attr == prm.motype)) typeMatch = true; doit = typeMatch; } else doit = true; if (doit) { var attr = this.getAttribute(node,prm.attrName); if (attr) { if ( (prm.generic && attr.startsWith(prm.attrValue)) || attr == prm.attrValue) { return node; } } } if (typeMatch == false && node.hasChildNodes && depth > 0) { var result = this._findChildNode(node, prm, depth - 1); if (result) { return result; } } } } return null; }; this.findParentObject = function(parentNode,attrName,attrValue) { var node = this.findParentNode(parentNode,attrName,attrValue); if (node) { return this.getObject(node); } return null; } this.findParentNode = function(node,attrName,attrValue) { var node = node.parentNode; while (node) { var attr = this.getAttribute(node,attrName); if (attr && (!attrValue || attr.startsWith(attrValue))) { return node; } node = node.parentNode; } return null; }; this.collectInputElements = function(elems, collector) { for (var i = 0; i < elems.length; i++) { collector[collector.length] = elems[i]; } }; this.getChildInputElements = function(node) { var elms = new Array(); this.collectInputElements(node.getElementsByTagName("input"),elms); this.collectInputElements(node.getElementsByTagName("select"),elms); this.collectInputElements(node.getElementsByTagName("textarea"),elms); return elms; }; this.getObjects = function(node, attrName, attrValue) { var objects = new Array(); this._collectObjects(objects, node, attrName, attrValue); return objects; }; this._collectObjects = function(objects, parentNode, attrName, attrValue) { for (var i = 0; i < parentNode.childNodes.length; i++) { var node = parentNode.childNodes[i]; if (node.nodeType == 1) { var attr = OMgr.getAttribute(node,attrName); if (attr && (!attrValue || attr == attrValue)) { objects[objects.length] = OMgr.getObject(node); } else if (node.hasChildNodes) { this._collectObjects(objects, node, attrName, attrValue); } } } }; this.getProps = function(node) { var attr = this.getAttribute(node,"mo:props"); if (attr) { eval("var props = {" + attr + "}" ); return props; } return null; }; this.getObject = function(node) { if (!node) return null; var type = this.getAttribute(node,"mo:type"); if (type) { try { eval("var obj = new " + type + "(node)"); obj.type = type; return obj; } catch (e) {} } return null; }; this.getObjectById = function(id) { var node = document.getElementById(id); if (node) { return this.getObject(node); } return null; }; this.initObjects = function(parentNode) { for (var i = 0; i < parentNode.childNodes.length; i++) { var node = parentNode.childNodes[i]; if (node.nodeType == 1) { var attr = this.getAttribute(node,"mo:needsInit"); if (attr != null) { var o = this.getObject(node); if (o && o.init) { o.init(); } } if (node.hasChildNodes) { this.initObjects(node); } } } }; this.setClass = function(node, classPrefix, classSuffix) { var buf = ""; var classNames = node.className.split(' '); for (var i = 0; i < classNames.length; i++) { var cls = classNames[i]; if (!cls.startsWith(classPrefix + "_") ) { if (buf == "") buf = cls; else buf += " " + cls; } } node.className = buf + " " + classPrefix + "_" + classSuffix; }; this.getThisPageInfo = function() { return new PageInfo( this.getAttribute(document.body,"mo:pageInfo") ); }; this.getPageInfo = function(node) { if (node == null) return this.getThisPageInfo(); var pinode = this.findParentNode(node,"mo:pageInfo"); if (pinode) return new PageInfo( this.getAttribute(pinode,"mo:pageInfo") ); return this.getThisPageInfo(); }; this.submitForm = function(node, action) { var frm = this.findParentNode(node,"form"); if (frm) { if (action) frm.action = action; if (frm._rand) frm._rand = (new Date()).getTime(); frm.submit(); } }; this.resetForm = function(node) { var frm = this.findParentNode(node,"form"); if (frm) frm.reset(); }; this.initialize = function(node) { if (!node) { node = document.body; } this.initObjects(node); }; this.getEnclosingObject = function(node) { var node = this.findParentNode(node,"mo:name"); if (node) { return this.getObject(node); } return null; }; var RegExp_parm1 = new RegExp( "%0", "g" ); var RegExp_parm2 = new RegExp( "%1", "g" ); var RegExp_parm3 = new RegExp( "%2", "g" ); this.resource = function(resId, parm1, parm2, parm3) { var result = CommonResources[resId]; if (!result) return resId; try { if (parm1 != null) result = result.replace( RegExp_parm1, parm1); } catch (e) {} try { if (parm2 != null) result = result.replace(RegExp_parm2, parm2); } catch (e) {} try { if (parm3 != null) result = result.replace(RegExp_parm3, parm3); } catch (e) {} return result; }; this.createElement = function(tagName, elmName) { if (WinMgr.isIE) { var s = "<" + tagName + " name='" + elmName + "' />"; return document.createElement(s); } else { var elm = document.createElement(tagName); elm.name = elmName; return elm; } }; }; var OMgr = new MoreMotionObjectManager(); function WindowManager() { var ua = navigator.userAgent.toLowerCase(); this.isGecko = ua.indexOf("gecko") > -1; this.isIE = ua.indexOf("msie") > -1; this.isOpera = ua.indexOf("opera") > -1; this.getRequestParam = function(parmName, defValue) { var parms = unescape(self.location.search).substring(1).split("&"); for (var i = 0; i < parms.length; i++) { var oneparm = parms[i].split("="); if (oneparm[0] == parmName) return oneparm[1]; } return defValue; }; this._boolParam = function(name, value) { return name + "=" + (value ? "1" : "0"); }; this._param = function(name, value) { return name + "=" + value; }; this.close = function(pagename) { if (pagename && pagename != '') { try { var winId = this.normalizeWinId(pagename); window.opener.WinMgr.saveDims(window, winId); } catch (e) {} } window.close(); window.opener.focus(); }; this.saveDims = function(w, winId) { if (!winId) return; this.setCookie(winId + "_left",w.screenLeft || w.screenX); this.setCookie(winId + "_top",w.screenTop || w.screenY); }; this.currentWinId = null; this.normalizeWinId = function(winId) { var s = ""; for (var i = 0; i < winId.length; i++) { var c = winId.charAt(i); if ("/.\\".indexOf(c) > -1) { if (s.length > 0) s += "_"; } else s += c; } return s; }; this.openWindow = function( props ) { var url = props.url; if (!url.addParam) url = new UrlAddress(url); var winId = props.winId; if (winId == null) winId = url.getParam("pg"); if (winId == null) winId = url.base; winId = this.normalizeWinId(winId); var x = props.left; if (!x) x = this.getCookie(winId + "_left"); if (!x || x == null) x = (screen.width - props.width) / 2; var y = props.top; if (!y) y = this.getCookie(winId + "_top"); if (!y || y == null) y = (screen.height - props.height) / 2; var a = new Accumulator(","); a.add(this._boolParam("toolbar",props.toolbar)); a.add(this._boolParam("scrollbars",props.scrollbars)); a.add(this._boolParam("location",props.location)); a.add(this._boolParam("status",props.status)); a.add(this._boolParam("menubar",props.menubar)); a.add(this._boolParam("resizable",props.resizable)); a.add(this._boolParam("status",props.status)); a.add(this._param("width",props.width)); a.add(this._param("height",props.height)); a.add(this._param("left",x)); a.add(this._param("top",y)); var w = window.open(url.toString(), winId, a.toString()); w.focus(); return w; }; this.getExpires = function(m) { if (m == null) return ""; if (!m) m = 365 * 24 * 60; var d = new Date(); var ed = d.getTime() + (m * 60 * 1000); d.setTime(ed); return ";expires=" + d.toGMTString(); }; this.setCookie = function(name, value, minutes, domain, path, secure) { var cookie = name + '=' + escape(value) + (path ? (";path=" + path) : "") + (domain ? (";domain=" + domain) : "") + this.getExpires(minutes) + (secure ? (";secure") : ""); try { document.cookie = cookie; } catch (e) {return false;} return true; }; this.getCookie = function(name) { var cookie = document.cookie; var start = cookie.indexOf(name); if(start == -1) return null; start += name.length + 1; var end = cookie.indexOf(";", start); if(end == -1) end = cookie.length; return unescape(cookie.substring(start, end)); }; this.expireCookie = function(name, domain, path) { var value = this.get(name); if (value == null) return false; var cookie = name + '=' + value + '; expires=Fri, 13-Apr-1970 00:00:00 GMT' + (path ? (";path=" + path) : "") + (domain ? (";domain=" + domain) : ""); try { document.cookie = cookie; } catch (e) {return false;} return true; }; }; var WinMgr = new WindowManager(); function Exception(code, arg1, arg2, arg3) { this.code = code; this.arg1 = arg1; this.arg2 = arg2; this.arg3 = arg3; this.object = null; this.elementToFocus = null; this.getMessageText = function() { return OMgr.resource(this.code , this.arg1, this.arg2, this.arg3); }; this.alert = function() { if (this.elementToFocus && this.object) { try { TabMgr.focusEnclosingTab(this.object.node); } catch(e) {} this.elementToFocus.focus(); } alert( this.getMessageText()); }; }; function Handler(name, caption) { this.run = function(obj) { this.handler(obj); }; this.setHandler = function(name, caption) { if (!name.substring) { this.handler = name; this.handlerName = ("" + name).before("{").after("function").trim(); this.handlerCaption = caption; return; } this.handlerName = name.before("(",name); if (caption) this.handlerCaption = caption; try { this.handler = eval(this.handlerName); } catch (e) { var parm1 = caption || this.handlerName; var parm2 = e.message; alert( OMgr.resource("INVALID_HANDLER", parm1, parm2) ); return false; } }; this.setHandler(name, caption); }; function EventHandler(name, caption) { this.base = Handler; this.base(name, caption); this.run = function(obj) { return this.handler(obj); }; }; function ErrorHandler(name, caption) { this.base = Handler; this.base(name, caption); this.run = function(ex, obj) { this.handler(ex, obj); }; }; function TextNode(node) { this.base = MoreMotionObject; this.base(node); this.isTextNode = true; this.aNode = null; this.textNode = null; this.wrapElements = function() { var n = this.node.childNodes[0]; if (n) { if (n.nodeType == 3) { this.textNode = n; } else { if (n.tagName && n.tagName == "A") { this.aNode = n; n = n.childNodes[0]; if (n && n.nodeType == 3) { this.textNode = n; } } } } }; this.wrapElements(); this.getANode = function() { if (!this.aNode) { var s = this.textNode ? this.textNode.nodeValue : ""; var aNode = document.createElement("A"); this.aNode = this.node.appendChild(aNode); if (this.textNode) this.node.removeChild(this.textNode); this.textNode = this.aNode.appendChild(document.createTextNode(s)); } return this.aNode; }; this.removeANode = function() { if (this.aNode) { var s = this.textNode.nodeValue; this.node.removeChild(this.aNode); this.aNode = null; this.textNode = this.node.appendChild(document.createTextNode(s)); } }; this.setValue = function(value) { this._setValue(node); }; this._setValue = function(value) { if (this.textNode) { this.textNode.nodeValue = value; } else { if (this.aNode) { this.textNode = this.aNode.appendChild(document.createTextNode(value)); } else { this.textNode = this.node.appendChild(document.createTextNode(value)); } } }; this.getValue = function() { return this.textNode ? this.textNode.nodeValue : ""; }; this.getHref = function() { return this.aNode ? this.aNode.href : ""; }; this.setHref = function(value) { if (value == "") { if (this.aNode) this.removeANode(); } else { this.getANode().href = value; } }; this.clear = function() { this.setHref(""); this.setValue(""); }; };