﻿// JScript File
  function openWindow(url, name, params, width, height, top, left, center) {
    var x, y, w, h
    if (center) {
      //alert(window.top.screenX);
      if (window.top.screenX || window.top.screenX == 0) {
        x = window.top.screenX;
        y = window.top.screenY;
        w = window.top.outerWidth;
        h = window.top.outerHeight;
      } else {
        x = window.top.screenLeft;
        y = window.top.screenTop;
        w = window.top.document.body.offsetWidth;
        h = window.top.document.body.offsetHeight;
      }
      //alert(x + " " + w + "\n" + y + " " + h);
      left = Math.floor(x + ((w - width) / 2));
      top = Math.floor(y + ((h - height) / 2));
    }
    var params = 'height='+height+',width='+width+',top='+(top - 40)+',left='+left+(params?','+params:'');
    //alert(params)
    return window.open(url,name,params);
  }


  function removeParameter(url, name) {
    var regParam = new RegExp("(\\?|\\&)" + name.replace("\\", "\\\\").replace(".", "\.").replace("(","\(").replace(")","\)") + "=[^\\&]*(\\&?)");
    var ans = url.replace(regParam, "$1");
    if (ans.lastIndexOf("&") == ans.length - 1) 
      ans = ans.substr(0, ans.length - 1);
    if (ans.lastIndexOf("?") == ans.length - 1) 
      ans = ans.substr(0, ans.length - 1);
    regParam = new RegExp("(\\?|\\&)(\\%23|#).*");
    ans = ans.replace(regParam, "");
    return ans;
  }

  function replaceParameter(url, name, value) {
    var ans = removeParameter(url, name);
    return ans + (ans.indexOf("?") == -1 ? "?" : "&") + escape(name) + "=" + escape(value);
  }
