var ie=false;
if( navigator.appName=="Microsoft Internet Explorer" )
{
	ie=true;
}

function getScreenX()
{
		if( window.innerWidth )
			return window.innerWidth;
		else if( document.body.clientWidth )
			return document.body.clientWidth;
		else
			return document.documentElement.clientWidth;
}
	
function getScreenY()
{
		if( window.innerHeight )
			return window.innerHeight;
		else if( document.body.clientHeight )
			return document.body.clientHeight;
		else
			return document.documentElement.clientHeight;
}

function UpdateWinIE(objid, width, height)
{
	var div=document.getElementById(objid);
	if( div )
	{
		div.style.top=(document.body.scrollTop + Math.round(getScreenY()/2-(height/2)-10))+'px';		
		window.setTimeout('UpdateWinIE('+objid+', '+width+', '+height+')',5);
		div.style.width=width+"px";
	}	
}

function PopupZoomImg2(obj,fwidth, fheight)
{
	PopupZoomImg(obj, fwidth, fheight );
}

function PopupZoomImg(obj, fwidth, fheight)
{
	var div=document.createElement("div");
	
	div.id=Math.round(Math.random()*100000);
	div.className="SimpleWindow";
	
	if(ie==false)
		div.style.position="fixed";
	else
		div.style.position="absolute";
		
	var width=800;
	if( fwidth!=null )
		width=fwidth;
	
	var height=600;
	if( fheight!=null )
		height=fheight;
	
	var top_px=Math.round(getScreenY()/2-(height/2)-10);
	
	div.style.left=Math.round(getScreenX()/2-(width/2))+'px';
	div.style.top=top_px+'px';
	
	div.style.width=width+"px";
	div.style.height="20px";
	
	var title=document.createElement("div");
	
	title.className="WindowTitle";
	var text=document.createTextNode("Bildbetrachter: "+obj.id+".jpg");
	
	var bclose=document.createElement("a");
	
	bclose.href="javascript: RemoveZoomImg('"+div.id+"');";
	bclose.className="WindowClose";	
	
	title.appendChild(text);
	title.appendChild(bclose);
	div.appendChild(title);
	
	var closeimg=document.createElement("a");
	closeimg.href=bclose.href;
	
	var img=document.createElement("img");
	
	img.src=obj.name+obj.id+"_full.jpg";
	
	closeimg.appendChild(img);
	div.appendChild(closeimg);
	
	document.getElementsByTagName("body")[0].appendChild(div);
	
	if(ie==true)
	{
		window.setTimeout('UpdateWinIE('+div.id+', '+width+', '+height+')',5);
	}
}

function RemoveZoomImg(id)
{
	document.getElementsByTagName('body')[0].removeChild($(id));
}
	