// Source: JavaScript Codebook, Addison Wesley Verlag
function Popup4Image()
{
  this.lastWidth = 0;
  this.lastHeight = 0;
  this.childWin = null;

  this.showImageInSize = showImageInSize;
}

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">' +
           '</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.lastWidth = width;
  this.lastHeight = height;
  
  with(this.childWin.document)
  {
    open(); write(html); close();
  }
  this.childWin.resizeTo(width, height);
  this.childWin.focus();
}
var popup = new Popup4Image();

function swDivpopup(filename, width, height)
{
	swDivPopup(filename, width, height)
}

function swDivPopup(filename, width, height)
{
	if(!$('swDivPopupContent'))
	{
		$('swDivPopup').innerHTML = '<div id="swDivPopupContent"></div>';
	}
	width  = parseInt(width);
	height = parseInt(height);	
	popup_content = "";
  filextension = filename.substring(filename.length-4).toLowerCase();
	if(filextension==".swf")
	{
		popup_content = "  <object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width="+width+" height="+height+" codebase=\"http://get.adobe.com/de/flashplayer/\"><param name=\"movie\" value=\""+filename+"\"><param name=\"quality\" value=\"high\"><param name=\"scale\" value=\"exactfit\"><param name=\"menu\" value=\"true\"><param name='wmode' value='transparent'><param name=\"bgcolor\" value=\"#000040\"><embed src=\""+filename+"\" wmode='transparent' width="+width+" height="+height+" quality=\"high\" scale=\"exactfit\" menu=\"true\" bgcolor=\"#000040\" swLiveConnect=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://get.adobe.com/de/flashplayer/\"></embed></object>";
    $('swDivPopupContent').innerHTML=popup_content+"<a href=\"#\" onclick=\"$('swDivPopupBackground').hide(); $('swDivPopup').hide(); return false;\"><img src=\"img/icon_close.png\" border=0 alt=\"\" align=\"top\"><br>Schlie&szlig;en</a>";
	}
	else if(filextension==".jpg" || filextension==".png"  || filextension==".gif" || filextension==".bmp")
	{
		popup_content = "<img src=\""+filename+"\" border=0 title=\"Anklicken, um die Ansicht zu schließen.\"  vspace=5 hspace=5>";		
    $('swDivPopupContent').innerHTML="<a href=\"#\" onclick=\"$('swDivPopupBackground').hide(); $('swDivPopup').hide(); return false;\">"+popup_content+"<img src=\"img/icon_close.png\" border=0 alt=\"\" align=\"top\"><br>Schlie&szlig;en</a>";
	}
	else
	{
		popup_content = "<iframe src='"+filename+"' width='"+width+"' height='"+height+"'></iframe>";
    $('swDivPopupContent').innerHTML="<a href=\"#\" onclick=\"$('swDivPopupBackground').hide(); $('swDivPopup').hide(); return false;\">"+popup_content+"<img src=\"img/icon_close.png\" border=0 alt=\"\" align=\"top\"><br>Schlie&szlig;en</a>";
	}
  $('swDivPopupBackground').show(); 
  $('swDivPopup').show();
}

if(!document.getElementById('swDivPopup'))
{
  document.write('<div id="swDivPopupBackground" style="display:none;"></div><div id="swDivPopup" style="display:none;"><div id="swDivPopupContent"></div></div>');
  document.write('<style type="text/css">#swDivPopupBackground {background-color:#FFFFFF;opacity:0.7;filter:Alpha(opacity=70);z-index:10;width:100%;height:100%;position:fixed;left:0px;top:0px;} #swDivPopup{position:fixed;z-index:11;width:100%;height:100%;left:0px;top:0px;overflow:auto;} #swDivPopupContent{display:table;background-color:#FFFFFF;padding:10px;text-align:center;top:30px;margin: 0 auto 0;} #swDivPopupContent iframe {background-color:#FFFFFF; }</style>');
}


