/* Copyright (C) MOR YAZILIM. http://www.moryazilim.com
 * All rights reserved. This software is published under the terms of the
 * GNU Lesser General Public License. http://www.gnu.org/licenses/lgpl.txt
 */
var PENDING_EVENT_Q = 0;
var I18Nres = {};
var ProcessJsLinked = null;
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 RefreshLink(href) {
  OMgr.refreshLink(href);
}
function RefreshHref(node) {
  OMgr.refreshHref(node);
}
function RefreshAction(frm) {
  OMgr.refreshAction(frm);
}
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" );
var re_2B = new RegExp( "[+]", "g" );
function escapex(str) {
  if (str.after) {
    return str.replace(re_25,"%25").replace(re_26,"%26").replace(re_2B,"%2B");
  } 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(0) == "1";
};
String.prototype.toBool = function() {
  return this.toLowerCase() == "true" || this.charAt(0) == "1";
};
String.prototype.isNumber = function() {
  return !isNaN(this);
};
String.prototype.after = function(delimiter, defaultValue) {
  var i = this.indexOf(delimiter);
  if (i == -1) return defaultValue == null ? this : defaultValue;
  return this.substring(i + delimiter.length);
};
String.prototype.before = function(delimiter,defaultValue) {
  var i = this.indexOf(delimiter);
  if (i == -1) return defaultValue == null ? this : defaultValue;
  return this.substring(0,i);
};
String.prototype.afterLast = function(delimiter,defaultValue) {
  var i = this.lastIndexOf(delimiter);
  if (i == -1) return defaultValue == null ? this : defaultValue;
  return this.substring(i + delimiter.length);
};
String.prototype.beforeLast = function(delimiter,defaultValue) {
  var i = this.lastIndexOf(delimiter);
  if (i == -1) return defaultValue == null ? this : defaultValue;
  return this.substring(0,i);
};
String.prototype.startsWith = function(subString) {
  return subString == this.substring(0,subString.length);
};
String.prototype.endsWith = function(subString) {
  var diff = this.length - subString.length;
  return diff > -1 && this.substring(diff) == subString;
};
function GhostForm(form) {
  this.form = document.createElement("FORM");
  this.form = document.body.appendChild(this.form);
  if (form) {
    this.form.action = form.action;
    this.form.target = form.target || "";
    this.form.method = form.method;
  } else {
    this.form.method = "POST";
  }
  this.addParameter = function(name, value) {
    this.add(name, value);
  };
  this.submit = function(method) {
    if (method) this.form.method = method;
    this.form.removeChild(this.ref);
    this.form.submit();
    document.body.removeChild(this.form);
  };
  this.add = function(name, value) {
    var elm = OMgr.createElement("INPUT", name);
    elm.type = "hidden";
    elm.value = value || "";
    return this.form.appendChild(elm);
  };
  this.ref = this.add("__ref","*");
  this.push = function(name, value) {
    var elm = OMgr.createElement("INPUT", name);
    elm.type = "hidden";
    elm.value = value || "";
    return this.form.insertBefore(elm,this.ref);
  };
  this.addObject = function(o) {
    if (o) {
      if (o.after) this.append(o);
      else {
        for (var p in o) {
          var pv = o[p];
          if (pv != null) {
            this.add(p,pv);
          }
        }
      }
    }
  };
  this.append = function(str) {
    this.add(str.before("=",str),str.after("=",""));
  };
  this.toString = function() {
    return this.form.innerHTML;
  };
}
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?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 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.obj) this.obj[name] = escapex(value);
     else {
       if (this.str) this.str += "&";
       this.str += name + "=" + escapex(value);
     }
   }
  };
  this.push = function(name,value) {
   if (value != null) {
     if (this.obj) this.obj[name] = escapex(value);
     else {
       if (this.str) this.str = "&" + this.str;
       this.str = name + "=" + escapex(value) + this.str;
     }
   }
  };
  this.addObject = function(o) {
    if (o) {
      if (o.after) this.append(o);
      else {
        for (var p in o) {
          var pv = o[p];
          if (pv != null) {
            this.add(p,pv);
          }
        }
      }
    }
  };
  this.append = function(str) {
    if (str) {
      if (this.str.length > 0) {
        this.str += "&";
      }
      this.str += str;
    }
  };
  this.has = function(name) {
    return this.str.startsWith(name + "=") || this.str.indexOf("&" + name + "=") > -1;
  }
  this.toString = function() {
    return this.str;
  };
  this.addObject(params);
}
function PageInfo(str) {
  this.name = null;
  this.variant = 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 == "variant") this.variant = 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") || OMgr.getAttribute(node,"name");
  this.type = null;
  this.isMoreMotionObject = true;
  this.props = OMgr.getProps(node) || 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.setProp = function(propName, propValue) {
    this.props[propName] = propValue;
    this.saveProps();
  }
  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.charProp = function(propName, def) {
    var prop = eval("this.props." + propName);
    if (prop == null) prop = def || "?";
    return prop.charAt(0);
  };
  this.dynProp = function(propName, def) {
    var prop = eval("this.props." + propName);
    if (prop == null) prop = def;
    if (prop && prop.startsWith("*")) {
      try {
        eval("prop = " + prop.substring(1));
      } catch(e) {}
    }
    return prop;
  };
  this.setModified = function() {};
  this._iValue = null;
  this.getIValue = function() {
    if (this._iValue == null) {
      this._iValue = OMgr.getAttribute(this.node,"mo:iValue");
      if (this._iValue == null) this._iValue = "";
    }
    return this._iValue;
 };
  this.setIValue = function(value) {
    this._iValue = null;
    OMgr.setAttribute(this.node,"mo:iValue",value);
  };
  this.isFieldNode = function(node,name) {
    var nn = node.name;
    if (nn) {
      name = name || this.name;
      if (nn == name) return true;
      if (nn.startsWith("pf_") && nn.endsWith("_" + name)) {
        return true;
      }
    }
    return false;
  };
}
 function MoreMotionObjectManager() {
  this.cache = new Array();
  this.addToCache = function(key, object, area) {
    if (!area) area = "*page";
    this.cache[key] = {area:area,object:object};
  }
  this.getFromCache = function(key) {
    var value = this.cache[key];
    return value == null ? null : value.object;
  }
  this.releaseCache = function(area) {
    for (var name in this.cache) {
      var value = this.cache[name];
      if (value && value.area == area) {
        delete this.cache[name];
      }
    }
  }
  this.removeFromCache = function(key) {
    delete this.cache[key];
  }
  this.$ = function(id) {
    return document.getElementById(id);
  }
  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 {
      if (node.getAttribute) {
        var attr = node.getAttribute(attrName);
        return attr;
      }
    } catch (e) {}
    return "";
  };
  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 (!nodeName || node.nodeName == nodeName) {
          if (!elmName) return node;
          if (node.name == elmName) return node;
        }
        if (node.hasChildNodes && node.tagName != "SELECT") {
          var n = this.getChildNode(node, nodeName, elmName)
          if (n) return n;
        }
      }
    }
    return null;
  };
  this.getParentNode = function(node, nodeName) {
    nodeName = nodeName.toUpperCase();
    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);
    return node ? this.getObject(node) : 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 && 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) {
    var attr;
    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) {
          attr = this.getAttribute(node,"mo:type");
          if (attr && (attr == prm.motype)) typeMatch = true;
          doit = typeMatch;
        } else doit = true;
        if (doit) {
          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 && node.tagName != "SELECT" && depth > 0) {
          var result = this._findChildNode(node, prm, depth - 1);
          if (result) {
            return result;
          }
        }
      }
    }
    return null;
  };
  this.findParentObject = function(node,attrName,attrValue) {
    var parentNode = this.findParentNode(node,attrName,attrValue);
    return parentNode ? this.getObject(parentNode) : null;
  }
  this.findParentNode = function(node,attrName,attrValue) {
    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._collectInputs = function(inputs, parentNode) {
    for (var i = 0; i < parentNode.childNodes.length; i++) {
      var node = parentNode.childNodes[i];
      if (node.nodeType == 1) {
        if (node.tagName == "INPUT" || node.tagName == "BUTTON" || node.tagName == "TEXTAREA" || node.tagName == "SELECT") {
          if (node.type != "reset") {
            inputs[inputs.length] = node;
          }
        }
        else if (node.hasChildNodes) {
          this._collectInputs(inputs, node);
        }
      }
    }
  };
  this.getChildInputElements = function(node) {
    var inputs = new Array();
    this._collectInputs(inputs,node);
    return inputs;
  };
  this.getMoNodes = function(parentNode, types) {
    var nodes = new Array();
    this._collectNodes(nodes, parentNode, types);
    return nodes;
  };
  this._collectNodes = function(nodes, parentNode, types) {
    for (var i = 0; i < parentNode.childNodes.length; i++) {
      var node = parentNode.childNodes[i];
      if (node.nodeType == 1) {
        var doit = false;
        var type = OMgr.getAttribute(node,"mo:type");
        if (type) {
          if (types.after) {
            if (type == types) doit = true;
          } else {
            for (var j = 0; j < types.length; j++) {
              if (type == types[j]) doit = true;
            }
          }
          if (doit)
            nodes[nodes.length] = node;
        }
        if (!doit && node.hasChildNodes && node.tagName != "SELECT" && !OMgr.getAttribute(node,"mo:field")) {
          this._collectNodes(nodes, node, types);
        }
      }
    }
  };
  this.getObjects = function(parentNode, types, oldparam) {
    if (types == "mo:type" && oldparam) types = oldparam; 
    var nodes = new Array();
    this._collectNodes(nodes, parentNode, types);
    for (var i = 0; i < nodes.length; i++) {
      nodes[i] = OMgr.getObject(nodes[i]);
    }
    return nodes;
  };
  this.getProps = function(node) {
    var attr = this.getAttribute(node,"mo:props");
    if (attr) {
     try {
       if (attr.startsWith("*")) {
         eval("var props = " + attr.substring(1));
       } else {
         eval("var props = {" + attr + "}" );
       }
     } catch (e) {
       if (!OMgr._alerted) {
         alert('invalid mo:props definition. mo:props="' + attr + '"\n\n' + e.message);
         OMgr._alerted = true;
       }
       return null;
     }
      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);
    return node ? this.getObject(node) : null;
  };
  this.$$ = function(id) {
    var node = document.getElementById(id);
    return node ? this.getObject(node) : null;
  };
  this.initObjects = function(parentNode) {
    for (var i = 0; i < parentNode.childNodes.length; i++) {
      var node = parentNode.childNodes[i];
      if (node.nodeType == 1) {
        var o = this.getAttribute(node,"mo:needsInit") ? this.getObject(node) : null;
        if (o && o.init) {
          o.init();
        }
        if (node.hasChildNodes && node.tagName != "SELECT") {
          this.initObjects(node);
        }
        if (o && o.initAfter) {
          o.initAfter();
        }
      }
    }
  };
  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() {
    if (!this._thisPageInfo) this._thisPageInfo = new PageInfo( this.getAttribute(document.body,"mo:pageInfo") );
    return this._thisPageInfo;
  }
  this.getPageInfo = function(node) {
    if (node == null) return this.getThisPageInfo();
    if (node.after) node = document.getElementById(node);
    var pinode = this.findParentNode(node,"mo:pageInfo");
    if (pinode) return new PageInfo( this.getAttribute(pinode,"mo:pageInfo") );
    return this.getThisPageInfo();
  };
  this.submitForm = function(nodeOrFormName, action) {
    var frm = null;
   if (nodeOrFormName.after) frm = document.forms[nodeOrFormName];
    else frm = this.getParentNode(nodeOrFormName,"form");
    if (frm) {
      if (action) frm.action = action;
      if (frm._rand) frm._rand.value = (new Date()).getTime();
      frm.submit();
    }
  };
  this.resetForm = function(nodeOrFormName) {
    var frm = null;
    if (nodeOrFormName.after) frm = document.forms[nodeOrFormName];
    else frm = this.getParentNode(nodeOrFormName,"form");
    if (frm) frm.reset();
  };
  this.setDisabled = function(node, value) {
    if (node.after) node = document.getElementById(node);
    if (node) this._setDisabled(node,value);
  };
  this._setDisabled = function(node, value) {
    if (node.tagName == "INPUT" || node.tagName == "TEXTAREA" || node.tagName == "SELECT" ||  node.tagName == "BUTTON") {
      node.disabled = value;
      if (node.tagName == "BUTTON" || (node.tagName == "INPUT" && node.type == "button")) {
        if (WinMgr.isIE) {
          node.style.filter = value == true ? "alpha(opacity=80)" : "";
        } else {
          node.style.opacity = value == true ? 0.7 : 1;
        }
      }
    } else {
      for (var i = 0; i < node.childNodes.length; i++) {
        var n = node.childNodes[i];
        if (n.nodeType == 1) {
          this._setDisabled(n, value);
        }
      }
    }
  };
  this.refreshHref = function(node) {
    if (node.href != "") {
      node.href = this.refreshLink(node.href);
    }
  };
  this.refreshLink = function(href) {
    if (href == "") return "#";
    var ri = href.indexOf("_rand=");
    if (ri > -1) {
      var bi = href.indexOf("#");
      var bm = bi == -1 ?  "" : href.substring(bi);
      href = href.substring(0,ri+6) + (new Date()).getTime() + bm;
    }
    return href;
  };
  this.refreshAction = function(frm) {
    if (frm._rand) frm._rand.value = (new Date()).getTime();
  };
  this.setInitialOption = function(elm, value) {
    var values = [];
    if (elm.multiple) {
      value = value.split(",");
      for (var j = 0; j < value.length; j++) {
        values[value[j]] = "*";
      }
    }
    if (elm.after) elm = document.getElementById(elm);
    if (elm && value) {
      for (var i = 0; i < elm.options.length; i++) {
        elm.options[i].selected = false;
        var val = elm.options[i].value;
        if (val == value || values[val]) {
          elm.options[i].selected = true;
          elm.options[i].setAttribute("selected","true");
          if (!elm.multiple) return;
        }
      }
    }
  };
  this.initialize = function(node) {
    if (!node) {
      node = document.body;
    }
    this.initObjects(node);
  };
  this.getEnclosingObject = function(node) {
    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];
    try {
      if (!result) result = I18Nres.array_110[resId];
    } catch (e) {}
    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;
    }
  };
  this.setOpacity = function(node,ratio) {
    if (WinMgr.isIE) {
      node.style.filter = "alpha(opacity="+ratio+")";
    } else {
      node.style.opacity = ratio / 100;
    }
  };
  this.attachEvent = function(node,name,func) {
    if (window.addEventListener) {
      node.addEventListener(name, func, false);
    } else {
      node.attachEvent('on'+name, func);
    }
  };
  this.detachEvent = function(node,name,func) {
   if (window.removeEventListener) {
     node.removeEventListener(name, func, false);
   } else {
     node.detachEvent('on'+name, func);
   }
  };
  this.getStyle = function(node, style) {
    var camelStyle = OMgr.toCamelCase(style);
    var value = node.style[camelStyle];
    if (!value) {
      if (document.defaultView) {
        value = document.defaultView.getComputedStyle(node,"").getPropertyValue(style);
      } else if (node.currentStyle) {
        value = node.currentStyle[camelStyle];
      }
    }
    return value;
  }
  this.toCamelCase = function(str) {
    var arr = str.split("-");
    var ret = "";
    for (var i = 0; i < arr.length; i++) {
      var s = arr[i];
      if (i == 0) ret = s;
      else ret += s.charAt(0).toUpperCase() + s.substring(1);
    }
    return ret;
  };
}
 var OMgr = new MoreMotionObjectManager();
 function WinDims() {
   this.WW = null;
   this.WH = null;
   this.XO = null;
   this.YO = null;
   this.getCenterCoords = function(w,h) {
     var r = {};
     r.left = ((this.WW - w) / 2) + this.XO;
     r.top = ((this.WH - h) / 2) + this.YO;
     r.top = (r.top + "").before(".") * 1;
     r.left = (r.left + "").before(".") * 1;
     return r;
   }
 }
function WindowManager() {
  var UA = navigator.userAgent;
  this.isGecko = UA.indexOf("Gecko/") > -1 ? true : null;
  this.isFF3 = UA.indexOf("Firefox/3.") > -1 ? true : null;
  this.isIE = UA.indexOf("MSIE") > -1 ? true : null;
  this.isIEA6 = this.isIE && UA.indexOf("MSIE 5") == -1 && UA.indexOf("MSIE 6") == -1 ? true : null;
  this.isOpera = UA.indexOf("Opera/") > -1 ? true : null;
  this.isAWK = UA.indexOf("AppleWebKit") > -1 ? true : null;
  this.getDims = function() {
    var r = new WinDims();
    if (this.isIE) {
      var body = (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body;
      r.WW = body.clientWidth;
      r.WH = body.clientHeight;
      r.XO = body.scrollLeft;
      r.YO = body.scrollTop;
    } else {
      r.WW = window.innerWidth;
      r.WH = window.innerHeight;
      r.XO = window.pageXOffset;
      r.YO = window.pageYOffset;
    }
    return r;
  };
  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) {
      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;
  };
  this.rand = function() {
    return "_rand=" + (new Date()).getTime();
  };
  this.display = function(pageName,params,doc,omitRand) {
    doc = doc || document;
    if (pageName.indexOf("?") > -1) {
      doc.location.href = pageName;
      return;
    }
    if (pageName.startsWith("pg=")) pageName = pageName.substring(3);
    var acc = new RequestParameterAccumulator(params);
    var prms = acc.toString();
    var r = omitRand == true ? "" : "&_rand=" + this.rand();
    doc.location.href = "display.doms?pg=" + pageName + (prms ? "&" + prms : "") + r;
  }
  this.Display = function(pageName,params,doc) {
    this.display(pageName,params,doc,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(prm1, prm2, prm3) {
    return this.handler(prm1, prm2, prm3);
  };
  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;
    }
    return;
  };
  this.setHandler(name, caption);
}
function EventHandler(name, caption) {
  this.base = Handler;
  this.base(name, caption);
  this.run = function(prm1,prm2,prm3) {
    return this.handler(prm1,prm2,prm3);
  };
}
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.getChildNode = function(parentNode) {
    var nodes = parentNode.childNodes;
    for (var i = 0; i < nodes.length; i++) {
     var n = nodes[i];
     if (n.nodeType == 3 || (n.nodeType == 1 && n.tagName == "A") ) {
       return n;
     }
    }
    return null;
  }
  this.wrapElements = function() {
    var n = this.getChildNode(this.node);
    if (n) {
      if (n.nodeType == 3) {
        this.textNode = n;
      } else {
        if (n.tagName && n.tagName == "A") {
          this.aNode = n;
          n = this.getChildNode(n);
          if (n) {
            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(value);
  };
  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("");
  };
}
