// Image popup window function with auto-resize
function PopupImage(imageURL,imageTitle,imageWidth,imageHeight)
{
	// Default image width and height values
	imageWidth = (typeof(imageWidth)!='undefined')?imageWidth:0;
	imageHeight = (typeof(imageHeight)!='undefined')?imageHeight:0;
	
	// Set the horizontal and vertical position for the popup
	if (imageWidth==0 && imageHeight==0)
	{
		PositionX = 10;
		PositionY = 10;
	}
	else
	{
		PositionX = (screen.width - imageWidth)/2;
		PositionY = (screen.height - imageHeight)/2;
	}

	if (parseInt(navigator.appVersion.charAt(0))>=4)
	{
		var isNN=(navigator.appName=="Netscape")?1:0;
		var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
		var isOpera=(navigator.userAgent.indexOf("Opera")!=-1)?1:0;
		if (isOpera) {isIE=0;isNN=0;}
	}
	// Set the width and height values approximately 20 pixels greater than the size of the largest image to be used (needed for Netscape)
	var optNN='scrollbars=no,width=800,height=800,left='+PositionX+',top='+PositionY;
	var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
	var optOpera='scrollbars=no,width='+imageWidth+',height='+imageHeight+',left='+PositionX+',top='+PositionY;
	if (imageWidth==0 && imageHeight==0)
	{
		optOpera=optIE;
	}

	if (isNN){imgWin=window.open('about:blank','',optNN);}
	if (isIE){imgWin=window.open('about:blank','',optIE);}
	if (isOpera){imgWin=window.open('about:blank','',optOpera);}
	with (imgWin.document)
	{
		if (isOpera)
		{
			writeln('<html><head><title>'+imageTitle+'</title><style>body{margin:0px;}</style>');
		}
		else
		{
			writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
		}
		writeln('<sc'+'ript>');
		writeln('var isNN,isIE;');
		writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
		writeln('isNN=(navigator.appName=="Netscape")?1:0;');
		writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
		writeln('function reSizeToImage(){');
		writeln('if (isIE){');
		writeln('window.resizeTo(150,100);');
		writeln('width=150-(document.body.clientWidth-document.images[0].width);');
		writeln('height=100-(document.body.clientHeight-document.images[0].height);');
		writeln('window.resizeTo(width,height);}');
		writeln('if (isNN){');
		writeln('window.innerWidth=document.images["PopupImage"].width;');
		writeln('window.innerHeight=document.images["PopupImage"].height;}}');
		writeln('function doTitle(){document.title="'+imageTitle+'";}');
		writeln('</sc'+'ript>');
		writeln('</head><body bgcolor="FFFFFF" scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
		if (imageWidth==0 && imageHeight==0)
		{
			writeln('<img name="PopupImage" onclick="self.close()" src="'+imageURL+'" style="display:block" alt="'+imageTitle+'"></body></html>');
		}
		else
		{
			writeln('<img name="PopupImage" width="'+imageWidth+'" height="'+imageHeight+'" onclick="self.close()" src="'+imageURL+'" style="display:block" alt="'+imageTitle+'"></body></html>');
		}
		close();
	}
}
