var imageWindow = null;
var isEventAttached = false;

function showImageWindow(path, imageWidth, imageHeight)
{
	if(!isEventAttached)
	{
		isEventAttached = true;
		document.body.onunload = onunload;
	}
	
	var windowWidth = imageWidth + 20;
	var windowHeight = imageHeight + 25;
	
	if(imageWindow != null)
		imageWindow.close();
	
	imageWindow = window.open(path, 'imageWindow', 'width=' + windowWidth.toString() + ',height=' + windowHeight.toString() + ';scrollbars=no,status=no,resizable=no');
}

function onunload()
{
	if(imageWindow != null)
		imageWindow.close();
}