var popupWindow = false;
var NS4      = (document.layers);
var IE4      = (document.all);
var isMac    = (navigator.appVersion.indexOf("Mac")!=-1);

function konsole(url,width,height,screenX,screenY) {

  if (NS4 && !isMac) {                                            // use this script for Netscape4+ on a PC
    if(popupWindow && popupWindow.open && !popupWindow.closed) {  // prueft, ob konsole noch nicht geoeffnet, bzw. schon wieder geschlossen wurde
      popupWindow.close();
      popupWindow = window.open('','popupWindow','width=' + width + ',height=' + height + ',screenX=' + screenX + ',screenY=' + screenY + ', resizable=no, scrollbars=yes, toolbar=no, menubar=no, location=no, dependent=yes');
    }
    else
      popupWindow = window.open('','popupWindow','width=' + width + ',height=' + height + ',screenX=' + screenX + ',screenY=' + screenY + ', resizable=no, scrollbars=yes, toolbar=no, menubar=no, location=no, dependent=yes');
  }
  
  else if (IE4 && isMac) {                                        // use this script for InternetExplorer4+ on a Mac
    if(popupWindow && popupWindow.open && !popupWindow.closed) {  // prueft, ob konsole noch nicht geoeffnet, bzw. schon wieder geschlossen wurde
      popupWindow.close();
    }
    popupWindow = window.open('','popupWindow','width=' + width + ',height=' + height + ',top=' + screenX + ',left=' + screenY + ', resizable=no, scrollbars=yes, toolbar=no, menubar=no, location=no, dependent=yes');
  }
  
  else if (NS4 && isMac) {                                        // use this script for Netscape4+ on a Mac
    if(popupWindow && popupWindow.open && !popupWindow.closed) {  // prueft, ob konsole noch nicht geoeffnet, bzw. schon wieder geschlossen wurde
      popupWindow.close();
    // alert('hello');
    }
    popupWindow = window.open('','popupWindow','width=' + width + ',height=' + height + ',screenX=' + screenX + ',screenY=' + screenY + ', resizable=no, scrollbars=yes, toolbar=no, menubar=no, location=no, dependent=yes');
  }
  
  else {                                                          // use this script for InternetExplorer4+ on a PC and anything else
    if(popupWindow && popupWindow.open && !popupWindow.closed)    // prueft, ob konsole noch nicht geoeffnet, bzw. schon wieder geschlossen wurde
      popupWindow.resizeTo(width,height+20);
    else
      popupWindow = window.open('','popupWindow','width=' + width + ',height=' + height + ',top=' + screenX + ',left=' + screenY + ', resizable=no, scrollbars=yes, toolbar=no, menubar=no, location=no, dependent=yes');
  }
  
  if (popupWindow != null) {                                    // 'null' falls es nicht erstellt/geoeffnet werden kann (due to low memory, for example). 
    popupWindow.location.href = url;
    popupWindow.focus();                                 // holt das erzeugte Fenster in den Vordergrund
  }

}
