
function getImageWidth(myImage) {
  return document.images[myImage].width;
}

function getImageHeight(myImage) {
  return document.images[myImage].height;
}

function show_image(name, mode) {
  if (document.images) {
    document.images[name].src=eval(name + mode + '.src');
  }
}

function make_remote(url, wname, params) {
  var remote=window.open(url, wname, params);
  if(remote != null){
    remote.opener=self;
    if (navigator.appName=="Netscape" && parseInt(navigator.appVersion)>=4) {
      remote.moveTo(100,100);
      remote.focus();
    }
  }else{
  }
}

function make_remote_tool(url, wname, width, height, center, scroll) {
  var scroll_flag = (scroll != 0) ? 'yes': 'no';
  var params = 'width=' + width + ',height=' + height + ',scrollbars=' + scroll_flag + ',resizable=' + scroll_flag + ',toolbar=no,location=no,menubar=no,status=no';
  make_remote(url, wname, params);
}

function make_remote_modeless(url, wname, width, height, center, scroll) {
  if (window.showModelessDialog) {
    var params = 'dialogWidth:' + width + 'px;dialogHeight:' + height + 'px;center:' + center + ';scroll:' + scroll + ';help:0;status:0';
    var remote2=window.showModelessDialog(url, wname, params);
    remote2.opener=self;
  }
  else {
    make_remote_tool(url, wname, width-6, height-32, center, scroll);
  }
}

function make_remote_modal(url, wname, width, height, center, scroll) {
  if (window.showModalDialog) {
    var params = 'dialogWidth:' + width + 'px;dialogHeight:' + height + 'px;center:' + center + ';scroll:' + scroll + ';help:0;status:0';
    var remote2=window.showModalDialog(url, wname, params);
    remote2.opener=self;
  }
  else {
    make_remote_tool(url, wname, width-6, height-32, center, scroll);
  }
}

function set_row_color(theRow, color) {
  if (typeof(theRow.style) == 'undefined' || typeof(theRow.cells) == 'undefined') {
    return false;
  }

  var row_cells_cnt = theRow.cells.length;
  for (var c = 0; c < row_cells_cnt; c++) {
    theRow.cells[c].bgColor = color;
  }

  return true;
}

function add_field(form, fieldType, fieldName, fieldValue) {
  if (document.getElementById) {
    var input = document.createElement('INPUT');
      if (document.all) { // what follows should work 
                          // with NN6 but doesn't in M14
        input.type = fieldType;
        input.name = fieldName;
        input.value = fieldValue;
      }
      else if (document.getElementById) { // so here is the
                                          // NN6 workaround
        input.setAttribute('type', fieldType);
        input.setAttribute('name', fieldName);
        input.setAttribute('value', fieldValue);
      }
    form.appendChild(input);
  }
}

var qqs = location.search.substring(1);
var qnv = qqs.split('&');
var qprefix = "";
for(i = 0; i < qnv.length; i++)
{
  if (qnv[i].indexOf("postprefix") >= 0) {
    eq = qnv[i].indexOf('=');
    qprefix = unescape(qnv[i].substring(eq + 1));
    break;
  }
}
var url = new Object();
if (qprefix != "") {
  for(i = 0; i < qnv.length; i++)
  {
    eq = qnv[i].indexOf('=');
    url[qnv[i].substring(0,eq).replace(qprefix, "")] = unescape(qnv[i].substring(eq + 1));
  }
}
else {
  for(i = 0; i < qnv.length; i++)
  {
    eq = qnv[i].indexOf('=');
    url[qnv[i].substring(0,eq)] = unescape(qnv[i].substring(eq + 1));
  }
}

var QeWindowWidth = 630, QeWindowHeight = 460;

function init_window_dim()
{
  if (parseInt(navigator.appVersion)>3) {
    if (navigator.appName=="Netscape") {
      QeWindowWidth = window.innerWidth;
      QeWindowHeight = window.innerHeight;
    }
    if (navigator.appName.indexOf("Microsoft")!=-1) {
      if( document.documentElement &&
         ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        QeWindowWidth = document.documentElement.clientWidth;
        QeWindowHeight = document.documentElement.clientHeight;
      }
      else {
        if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
          //IE 4 compatible
          QeWindowWidth = document.body.clientWidth;
          QeWindowHeight = document.body.clientHeight;
        }
      }
    }
  }
}

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}