function popup(source, title, width, height, posx, posy) {
  window.open(
    source,
    title,
    "width=" + width + "," +
    "height=" + height + "," +
    "left=" + posx + "," +
    "top=" + posy + "," +
    "scrollbars=no,toolbar=no,status=no,resizable=yes,menubar=no");
}

/**
 * Show a picture (source URL) in a new window.
 */
function showpicture(source) {
  margin   = 100;
  width    = screen.width;
  height   = screen.height;
  myWindow = window.open(source, "Bildanzeige", 
    "left=0,top=0,toolbar=no,status=no,menubar=no");
  myWindow.focus();
}

/**
 * Show a picture (source URL) in a new window.
 */
function showpictureexperimental(source) {
  margin   = 100;
  width    = screen.width;
  height   = screen.height;
  myWindow = window.open("", "Bildanzeige", 
    "width=100,height=100,left=0,top=0,scrollbars=no,toolbar=no,status=no,resizable=no,menubar=no");
  myWindow.document.write('<html>');
  myWindow.document.write('<head>');
  myWindow.document.write('<title>Bildanzeige</title>');
  myWindow.document.write('</head>');
  myWindow.document.write('<body style="margin:0px; padding=0px;">');
  myWindow.document.write('<img src="'+source+'" border="none"/>');
  
  corrx = myWindow.outerWidth - myWindow.innerWidth;
  corry = myWindow.outerHeight - myWindow.innerHeight;
    
  origWidth  = myWindow.document.images[0].width;
  origHeight = myWindow.document.images[0].height;
  
  scalingScreen  = width / height;
  scalingPicture = origWidth / origHeight;
      
  if (scalingScreen<scalingPicture)
  {
    // landscape oriented scaling
    newWidth  = width - (2 * margin);
    scaling   = newWidth / origWidth;
    newHeight = origHeight * scaling;
  }
  else
  {
    // portrait oriented scaling
    newHeight = height - (2 * margin);
    scaling   = newHeight / origHeight;
    newWidth  = origWidth * scaling;
  }
  
  myWindow.document.write('<script type="text/javascript">');
  myWindow.document.write('myImage        = new Image();');
  myWindow.document.write('myImage.src    = "'+source+'";');
  myWindow.document.write('myImage.width  = '+(newWidth - corrx)+';');
  myWindow.document.write('myImage.height = '+(newHeight - corry)+';');
  myWindow.document.write('document.images[0].src = myImage.src;');
  if (navigator.appVersion.indexOf("MSIE")==-1)
  {
    myWindow.document.write('document.images[0].width  = '+(newWidth - corrx)+';');
    myWindow.document.write('document.images[0].height = '+(newHeight - corry)+';');
  }
  
  myWindow.document.write('resizeTo('+newWidth+', '+newHeight+');');
  myWindow.document.write('moveTo('+((width-newWidth)/2)+', '+((height-newHeight)/2)+');');
  myWindow.document.write('</script>');
  myWindow.document.write('</body>');
  myWindow.document.write('</html>');
  myWindow.document.write('\n');
  
  myWindow.focus();
}

