

// www.web-toolbox.net , W. Jansen
// Als Übergabeparameter wird die bildquelle,breite und höhe übergeben
// hand over parameters for source,width and height

function FotoWindow(bildurl,b,h){
	var eigenschaften,sbreite,shoehe,fenster,b,h;
	
	// stellt die Bildschirmabmessungen fest
	// find window size
	var ns6 = (!document.all && document.getElementById);
	var ie4 = (document.all);
	var ns4 = (document.layers);
	
	if(ns6||ns4) {
		sbreite = innerWidth;
		shoehe = innerHeight;
	}
	else if(ie4) {
		sbreite = document.body.clientWidth;
		shoehe = document.body.clientHeight;
	}
	
	x = (sbreite-b)/2;
	y = (shoehe-h)/2;
	
	eigenschaften="left="+x+",top="+y+",screenX="+x+",screenY="+y+",width="+b+",height="+h+",menubar=no,toolbar=no,statusbar=0";
	
	fenster=window.open("","",eigenschaften);
	fenster.focus();
	fenster.document.open();
	with (fenster) {
	  document.write("<html><head>");
	  // geändert 2004 für Mozilla
	  document.write('<scr' + 'ipt type="text/javascr' + 'ipt" language="JavaScr' + 'ipt">');
	  // bei click  schliessen , on click close
	  document.write("function click() { window.close(); } ");
	  document.write("document.onmousedown=click ");
	  // geändert 2004 für Mozilla
	  document.write('</scr' + 'ipt>');
	  document.write("<title>Klick um Fenster zu schließen</title></head>");
	  // bei Focusverlust schliessen, close if window looses focus
	  // Zeile geändert Aug 2003 (Dreamweaver machte Probleme)
	  document.write("<" + "body onblur='window.close()';");
	  document.write("marginwidth='0' marginheight='0' leftmargin='0' topmargin='0'>");
	  document.write("<center>");
	  document.write("<img src='"+ bildurl +"' border='0'>");
	  document.write("<center>");
	  document.write("</body></html>");
	  fenster.document.close();
	}
}
// Oeffnet ein Popup bestimmer Breite und Hoehe
function FensterOeffnen (Adresse, width, height) {
  Fenster1 = window.open(Adresse, "Detailansicht", "width="+width+",height="+height+",left=100,top=50, scrollbars=yes, resizable=yes");
  Fenster1.focus();
}
// Loescht den Inhalt aus einem Layer
function DelLayer(id)
{
	obj = (document.getElementById ? document.getElementById(id) : (document.all ? document.all[id] : (document.layers ? document.layers[id] : null)));
	document.getElementById(id).innerHTML = "";
	obj.style.visibility = 'hidden';
};

function openImageOverlay(imageurl)
{
	var browserName = navigator.appName;
	var isIE = (browserName == 'Microsoft Internet Explorer' && (parseInt(navigator.appVersion.substr(0,1)) < 7 || document.compatMode == 'BackCompat')); 
	var monitorWidth = !isIE ? window.innerWidth : window.document.documentElement.clientWidth;
	var monitorHeight = !isIE ? window.innerHeight : window.document.documentElement.clientHeight;
	var webWidth = window.document.body.clientWidth;
	var webHeight = 0;
	
	var foto= new Image();
	foto.src=(imageurl);
	var fotoWidth = foto.width;
	var fotoHeight = foto.height; 

	var layerWidth = parseInt((monitorWidth-fotoWidth)/2);
	var layerHeight = parseInt((monitorHeight-fotoHeight)/2); 
	
	if(layerWidth < 0)
	{
		layerWidth = parseInt((webWidth-fotoWidth)/2);
	}
	if(layerHeight < 0)
	{
		if(	document.documentElement && 
			document.documentElement.clientHeight && 
			(window.document.documentElement.clientHeight > webHeight)
		)
			webHeight = window.document.documentElement.clientHeight;
		if(document.body && (window.document.body.clientHeight > webHeight))
			webHeight = window.document.body.clientHeight; 
		if (window.innerHeight > webHeight)
			webHeight = window.innerHeight;
		layerHeight = parseInt((webHeight-680)/2);
	}

	document.getElementById('ol_content').style.width = fotoWidth;
	document.getElementById('ol_content').style.height = fotoHeight;
	document.getElementById('ol_content').style.left = layerWidth;
	document.getElementById('ol_content').style.top = layerHeight;
	document.getElementById('ol_content').style.display = 'block';
	document.getElementById('ol_content').innerHTML = '<img src=" ' + imageurl + '" border="0"><center><p class="closeImageOverlay" onclick="closeImageOverlay()" align="center">schließen</p></center>';
	
	//document.getElementById('ol_cover').style.opacity = (browserName == "AppleMAC-Safari" || browserName == "Opera" || browserName == "Netscape") ? '0.60;' :  '60;';
	document.getElementById('ol_cover').style.width = isIE ? webWidth + 'px' : '100%';
	document.getElementById('ol_cover').style.height = isIE ? '3500px' : '100%';
	document.getElementById('ol_cover').style.display = 'block';

}

function closeImageOverlay()
{
	document.getElementById('ol_cover').style.display = 'none';
	document.getElementById('ol_content').style.display = 'none';

}
