/* =========================================================================

JavaScript Source File -- Created with SAPIEN Technologies PrimalScript 3.1

NAME: Image Enlarge for Gallery Tool

AUTHOR:  Marcel Marty, futurecom interactive ag
DATE  : 30.10.2007

COMMENT: Needs only the imageUrl as Parameter, but no Width and Height Params (will be automatically
         set by enlargeImage-Function.
         --> Possible use: <a href="javascript:enlargeImage('/some/directory/foo.jpg');">Enlarge</a>

============================================================================ */

var wstat
var ns4up = (document.layers) ? 1 : 0
var ie4up = (document.all) ? 1 : 0
var xsize = screen.width
var ysize = screen.height
var breite=560;
var hoehe=ysize/2
var xpos=(xsize-breite)/2
var ypos=(ysize-hoehe)/2
var myUrl
function popUp(myUrl) {
	wstat=window.open(myUrl,"","scrollbars=yes,status=no,toolbar=no,location=no,directories=no,resizable=no,menubar=no,width="+breite+",height="+hoehe+",screenX="+xpos+",screenY="+ypos+",top="+ypos+",left="+xpos)
}


function enlargeImage(myImageUrl)
{
	var myImageUrl, myImageWidth, myImageHeight;
	var myImage = new Image();
	myImage.onload = function LoadData() {
		myImageWidth = parseInt(myImage.width);
		myImageHeight = parseInt(myImage.height);
		displayImageInPopup(myImageUrl, myImageWidth, myImageHeight) 
	}
	myImage.src = myImageUrl;
	
}

function displayImageInPopup(bildurl, b, h)
{
	var eigenschaften, sbreite, shoehe, fenster, b, h;
	
	var FestePosition = "ja";  // "ja" oder "nein" eintragen
	VonLinks = 20;
	VonOben = 20;
	
	if(FestePosition == "ja") {
		x = VonLinks;
		y = VonOben;
	} 
	else 
	{
	// stellt die Bildschirmabmessungen fest
		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 = parseInt((sbreite-b)/2);
		y = parseInt((shoehe-h)/2);
	}
	
	eigenschaften="left="+x+",top="+y+",screenX="+x+",screenY="+y+",width="+b+",height="+h+",menubar=0,toolbar=0,location=0,status=0,scrollbars=0,resizable=0,hotkeys=0,titlebar=0";
	// DEBUG: alert(eigenschaften);
	
	fenster=window.open("","",eigenschaften);
	fenster.focus();
	fenster.document.open();
	
	with (fenster) {
	  document.write('<html><head>');
	  document.write('<scr' + 'ipt type="text/javascr' + 'ipt" language="JavaScr' + 'ipt">');
	  document.write("function click() { window.close(); } ");  
	  document.write("document.onmousedown=click ");
	  document.write('</scr' + 'ipt>');
	  document.write('</head>');
	  document.write('<' + 'body ');
	  document.write('marginwidth="0" marginheight="0" leftmargin="0" topmargin="0">');
	  document.write('<img src="'+ bildurl +'"border="0">');
	  document.write('</body></html>');
	  fenster.document.close();
	}
}
