// Title       : h.com popup
// Description : use to display a popup dialog
// Version     : 1.0
// Date        : 2003-04-22
// CVS-Info    : $Id: popwin.js,v 1.4 2008/03/18 08:36:56 richardw Exp $

function subwin(name) {
  tempwin = window.open("",name)
  tempwin.close()
  return false;
}

function window_left() {
  try {
    if((top != null) && (top.screenX != null)) return top.screenX;
  } catch (e1) {
    if((window != null) && (window.screenX != null)) return window.screenX;
  }
  try {
    if((top != null) && (top.screenLeft != null)) return top.screenLeft;
  } catch (e2) {
    if((window != null) && (window.screenLeft != null)) return window.screenLeft;
  }
  return 0;
}

function window_top() {
  try {
    if((top != null) && (top.screenY != null)) return top.screenY;
  } catch (e1) {
    if((window != null) && (window.screenY != null)) return window.screenY;
  }
  try {
    if((top != null) && (top.screenTop != null)) return top.screenTop;
  } catch (e2) {
    if((window != null) && (window.screenTop != null)) return window.screenTop;
  }
  return 0;
}

function window_width() {
  try {
    if((top != null) && (top.outerWidth != null)) return top.outerWidth;
  } catch (e1) {
    if((window != null) && (window.outerWidth != null)) return window.outerWidth;
  }
  if(screen.availWidth != null) return screen.availWidth;
  if(screen.width != null) return screen.width;
  return 0;
}

function window_height() {
  try {
    if((top != null) && (top.outerHeight != null)) return top.outerHeight;
  } catch (e1) {
    if((window != null) && (window.outerHeight != null)) return window.outerHeight;
  }
  if(screen.availHeight != null) return screen.availHeight;
  if(screen.height != null) return screen.height;
  return 0;
}

function getBrowserType() {
  var sBrowser = navigator.appName;
  var sVersion = parseInt(navigator.appVersion);
  var sDetail  = navigator.userAgent;

  if(sBrowser == "Netscape")  {
    if(sVersion == 2) return "Net2";
    if(sVersion >= 3 && sVersion < 4) return "Net3";
    if(sVersion >= 4) return "Net4";
 } else if(sBrowser == "Microsoft Internet Explorer") {
    if(sVersion >= 2 && sVersion <= 3)  {
      if(sDetail.indexof("3.") != -1) return "IE3";
      return "IE2";
    } else if(sVersion >= 4){
      if(navigator.appVersion.indexOf("MSIE 7") != -1){
      return "IE7";
      }
      else return "IE4";
    }
  }
  return null;
}


//=============================================================
// Oeffnet ein Popup - Fenster. Ist den Parametern posX oder posY
// ein negativer Wert zugeordnet, dann wird das Popup - Fenster
// anhand der Breite oder Hoehe des aufrufenden Fensters zentriert.
function popwin(winname, loc, posX, posY, width, height, resiz, scrollb, modal, status) {
  var sBrowVer = getBrowserType();
  if(posX < 0) {
    posX = (window_width() - width) / 2; if(posX < 0) posX = 0;
    if(sBrowVer.indexOf("IE") == -1) posX = window_left() + posX;
  }
  if(posY < 0) {
    posY = (window_height() - height) / 2; if(posY < 0) posY = 0;
    if(sBrowVer.indexOf("IE") == -1) posY = window_top() + posY;
  }
  if(resiz == null) resize = "1";
  if(scrollb == null) scrollb = "1";
  if(modal == null) modal = "0";
  if(status == null) status = "1";

  if(sBrowVer == "Net2" || sBrowVer == "Net3") {
    NewWindow = window.open("", winname, "height=" + height + ",width=" + width + ",screenX=" + posX + ",left=" + posX + ",screenY=" + posY + ",top=" + posY +",menubar=0,status=" + status + ",resizable=" + resiz + ",scrollbars=" + scrollb);
    NewWindow.location.href = loc;
    if(sBrowVer == "Net3") NewWindow.focus();
    return NewWindow;
  }
  if(sBrowVer == "Net4") {
    NewWindow = window.open("", winname, "height=" + height + ",width=" + width + ",screenX=" + posX + ",left=" + posX + ",screenY=" + posY + ",top=" + posY +",menubar=0,status=" + status + ",resizable=" + resiz + ",scrollbars=" + scrollb + (modal ? ",modal=yes" : ""));
    NewWindow.location.href = loc;
    NewWindow.focus();
    return NewWindow;
  }
  if(sBrowVer == "IE3") {
    NewWindow = window.open("", winname, "height=" + height + ",width=" + width + ",screenX=" + posX + ",left=" + posX + ",screenY=" + posY + ",top=" + posY + ",dependent=1,directories=0,fullscreen=0,location=0,menubar=0,channelmode=0,resizable=" + resiz + ",scrollbars=" + scrollb + ",status=" + status + ",toolbar=0");
    if(NewWindow != null) {
      if(NewWindow.opener == null) NewWindow.opener = self;
      NewWindow.location.href = loc;
    }
    return NewWindow;
  }
  if(sBrowVer == "IE4") {
    NewWindow = window.open("", winname, "height=" + height + ",width=" + width + ",screenX=" + posX + ",left=" + posX + ",screenY=" + posY + ",top=" + posY + ",dependent=1,directories=0,fullscreen=0,location=0,menubar=0,channelmode=0,resizable=" + resiz + ",scrollbars=" + scrollb + ",status=" + status + ",toolbar=0");
    NewWindow.location.href = loc;
    NewWindow.focus();
    return NewWindow;
  }
  if(sBrowVer == "IE7") {
    status = 'no';
    NewWindow = window.open("", winname, "toolbar=no,location=no,directories=no,status=" + status + ",menubar=no,scrollbars=" + scrollb + ",resizable=" + resiz + ",width=" + width + ",height=" + height + ",top=" + posY + ",left=" + posX );
    NewWindow.location.href = loc;
    NewWindow.focus();
    return NewWindow;
  }
  if(sBrowVer == null) {
    NewWindow = window.open("", winname, "height=" + height + ",width=" + width + ",screenX=" + posX + ",left=" + posX + ",screenY=" + posY + ",top=" + posY + ",dependent=1,directories=0,fullscreen=0,location=0,menubar=0,channelmode=0,resizable=" + resiz + ",scrollbars=" + scrollb + ",status=" + status + ",toolbar=0");
    NewWindow.location.href = loc;
    NewWindow.focus();
    return NewWindow;
  }
  return null;
}
