  function addWindowOnload(f) {
    var prev=window.onload;
    window.onload=function(){ if(prev)prev(); f(); }
  }

  function addWindowOnunload(f) {
    var prev=window.onunload;
    window.onunload=function(){ if(prev)prev(); f(); }
  }

  function form_submit(p_this) {
    var frm = p_this;
    while (frm.tagName != 'FORM') {
      frm = frm.parentNode;
    }
    if (frm.tagName == 'FORM') {
      if (arguments.length > 1) {
        frm.action = arguments[1];
      }
      if (frm.onsubmit == undefined
          || frm.onsubmit()) frm.submit();
    }
  }

  function openwin_centered(aurl, awidth, aheight) {
    var ascroll = 1;
    if (arguments.length > 3) {
        ascroll = arguments[3];
    }
    width = awidth;
    height = aheight;
    leftpos = (screen.width - width) / 2;
    toppos = (screen.height - height) / 2;
    s = "resizable=0,scrollbars=" + ascroll + ",status=0,titlebar=0,toolbar=0,directories=0,menubar=0,screenX=" + leftpos + ",screenY=" + toppos + ",top=" + toppos + ",left=" + leftpos + ",width=" + width + ",height=" + height;
    win = window.open(aurl, "_blank", s);
  }

