// Source: JavaScript Codebook, Addison Wesley Verlag
function Popup4Image(){
  this.lastWidth = 0;
  this.lastHeight = 0;
  this.childWin = null;

  this.showImageInSize = showImageInSize;
  this.showImageWithNav= showImageWithNav;
}

function showImageWithNav(src, target, width, height, mode)
{
  if(document.layers || window.opera)
  {
    var x=y=-8;
  } 
  else
  {
  	var x=y=-0;
  }
  width += 8; height += 82;
  var html='<HTML><HEAD><title>LUPE</title>' +
		   '<meta http-equiv="imagetoolbar" content="no">' +
           ' <style type="text/css"> ' +
           '  body {margin-left:'+x+'px; margin-top:'+y+'px; ' +
           '        margin-right:0px; margin-bottom:0px; ' +
           '        overflow:hidden; } ' +
		   '  #navi { position:absolute; top:0px, left:0px; width:105px; height:30px; z-index:2; float:left; margin-top:5px; margin-left:5px; overflow:hidden;}  ' +
		   '  #bild { position:absolute; top:0px, left:0px; z-index:0; float:left;}' +
           ' </style> ' +
           '</HEAD>' +
           '<body>' +
           '<div id="navi"><iframe name="navframe" scrolling="no" frameborder=0 width=100 height=22 src="/js/viewimageiframe.php?mode=' + mode + '&src=' + src + '"></iframe></div>' +
		   '<div id="bild"><img src="' + src + '" border="0" onclick="fktNextimg()"></div>' +
		   '<script language="JavaScript" src="/js/viewimage.js" type="text/javascript"></script>' +
		   '<script language="JavaScript">' +
		   'var nexturl=""; var nextwidth=600; var nextheight=400; var nextexists=false;' +
		   'function fktNextimg() { if(nextexists==true) {  ' +
		   'popup.showImageWithNav(nexturl, "objImage", nextwidth, nextheight, "file"); } ' +
		   'else { self.close(); }' +
		   'return false; }' +
		   '</script>'
		   '</body> </html>';
// in Zeile 40 könnte auch eine Meldung kommen, statt das Fenster zu schließen 
// alert("Keine weiteren Bilder."); 
  if( this.childWin && !this.childWin.closed) 
  {
    diffX = width - this.lastWidth;
    diffY = height - this.lastHeight;	
    this.childWin.resizeBy(diffX, diffY);
  } 
  else 
  {
    if(!target) target="objImage";
    this.childWin = window.open(
                       "dummy.html",
                       target,
                       "width="+width+",height="+height+",resizable=1"
                                );
	this.childWin.resizeTo(width, height);
  }
  this.lastWidth = width;
  this.lastHeight = height;

  with(this.childWin.document)
  {
    open(); write(html); close();
  }
  this.childWin.resizeTo(width, height);
  this.childWin.focus();
}

function showImageInSize(src, target, width, height){
  if(document.layers || window.opera){
    var x=y=-8;
  } else{
  	var x=y=-0;
  }

  var html='<HTML><HEAD><title>LUPE</title>' +
           ' <style type="text/css"> ' +
           '   body {margin-left:'+x+'px; margin-top:'+y+'px; ' +
           '         margin-right:0px; margin-bottom:0px; ' +
           '         text-align : center;} ' +
           ' </style> ' +
           '</HEAD>' +
           '<body>' +
           '<img src="' + src + '" border="0" onclick="self.close();">' +
           '</body> </html>';

  if( this.childWin && !this.childWin.closed) 
  {
    diffX = width - this.lastWidth;
    diffY = height - this.lastHeight;
    this.childWin.resizeBy(diffX, diffY);
  } else {
    this.childWin = window.open(
                       "dummy.html",
                       target,
                       "width="+width+",height="+height+",resizable=1"
                                );
	this.childWin.resizeTo(width, height);
  }
  this.lastWidth = width;
  this.lastHeight = height;

  with(this.childWin.document){
    open(); write(html); close();
  }
  this.childWin.focus();
}
var popup = new Popup4Image();

