var theWindow = null;

function popupwindow(theUrl, theWidth, theHeight)
{
  if (!theWindow || theWindow.closed)
  {
    // Bildschirmgröße ermitteln und Fensterposition (links/oben) berechnen

    screenWidth = screen.width;
    screenHeight = screen.height;

    winWidth = theWidth;
    winHeight = theHeight;

    var X = (screenWidth - winWidth) / 2;
    var Y = (screenHeight - winHeight) / 2;

    winSettings = "toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width="+winWidth+",height="+winHeight+",";

    msIE = navigator.appName.indexOf("icrosoft");
    if (msIE == -1)
    {
      winSettings = winSettings+"screenX="+X+",screenY="+Y;
    }
    else
    {
      winSettings = winSettings+"left="+X+",top="+Y;
    }

    theWindow = window.open(theUrl,'theWindow',winSettings);
    theWindow.focus();
  }
  else
  {
    theWindow.focus();
  }
}

