/*******************************
IMAGEPOP
(c) 2003, Peter Bailey, http://www.peterbailey.net
Modified by Skyzyx Genesis, http://www.skyzyx.com

- Works in IE5+, Gecko 0.94+ (maybe earlier?)
- Downlevel for Opera.
- Probably works in KHTML browsers
*******************************/

function imgPop(imageURL)
{
	max_width = 1000;
	max_height = 700;
	if (document.getElementById && navigator.userAgent.toLowerCase().indexOf('opera') == -1)
	{
		var imgWin = window.open('about:blank','imgWin','width=200, height=200, left=100, top=100');

		with (imgWin.document)
		{   writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"');
   			writeln('"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
			writeln('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl" lang="nl">');
			writeln('<head><title>Loading...</title>');
			writeln('<style type="text/css"><!-- body { margin: 0px; } --></style></head>');
			writeln('<body onload="self.focus();"><img id="pic" style="display:none" /></body></html>');
			close();		
		}

		var img = new Image();
		img.src = imageURL;
			//ASEdit
		if (img.width > max_width){
			var old_width = img.width;
			img.width = max_width;
			var unrounded_height = img.height * (img.width / old_width);
			img.height = Math.round(unrounded_height);
		}
		if (img.height > max_height){
			var old_height = img.height;
			img.height = max_height;
			var unrounded_width = img.width * (img.height / old_height);
			img.width = Math.round(unrounded_width);
		}
				
		img.onload = function() { sizeImgWin(imgWin, img); };
		
	}
	else window.open(imageURL);
}
	
function sizeImgWin(win, img)
{
   	var new_w = img.width;
	var new_h = img.height;
	var old_w = win.innerWidth || win.document.body.offsetWidth;
	var old_h = win.innerHeight || win.document.body.offsetHeight;

	if (!new_w) { new_w = old_w; }
	if (!new_h) { new_h = old_h; }
	
	new_w -= old_w; new_h -= old_h;
	win.resizeBy(new_w,new_h);
	win.document.title = img.src.substring(img.src.lastIndexOf("/")+1);
	var pic = win.document.getElementById('pic');
	pic.src = img.src;
	pic.width = img.width;
	pic.height = img.height;
	pic.style.display = 'block';
	
	sw=screen.width;
	sh=screen.height;

	var leftPos=((sw-new_w)/2)-100; // Exactly centered.
	var topPos=((sh-new_h)/2)-(100+(((sh-new_h)/2)*0.1)); // Centered, then moved up 10%
	win.moveTo(leftPos, topPos);
}