// ImageViewer.php
function ViewImage(sPicURL)
{
	var width = 200;
	var height = 200;
	var top = 0;
	var left = 0;
	window.open('image_viewer.php?' + sPicURL, 'ImageViewer', 'height=' + height + ',width=' + width + ',top=' + top + ', left=' + left + ',toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,modal=yes');
}

// ImageViewer.php
var temp=self.location.href.split("?");
var picUrl = (temp.length>1)?temp[1]:"";
var NS = (navigator.appName=="Netscape")?true:false;
var iWidth = 0;
var iHeight = 0;

function fitPic()
{
	maxWidth = window.screen.width;
	maxHeight = window.screen.height;
	imageWidth = document.images[0].width;
	imageHeight = document.images[0].height;

	//check windowSize and imageSize
	if (imageWidth > maxWidth || imageHeight > maxHeight)
	{
		xchange = (maxWidth-20) / imageWidth;
		ychange = (maxHeight-85) / imageHeight;
		change = (xchange < ychange)?xchange:ychange;
		newWidth = (imageWidth * change);
		newHeight = (imageHeight * change);

		iWidth = (browser=='msie')?document.body.clientWidth:window.innerWidth;
		iHeight = (browser=='msie')?document.body.clientHeight:window.innerHeight;
		iWidth = newWidth - iWidth;
		iHeight = newHeight - iHeight;
		document.images[0].width = newWidth;
		document.images[0].height = newHeight;
	}
	else
	{
		iWidth = (browser=='msie')?document.body.clientWidth:window.innerWidth;
		iHeight = (browser=='msie')?document.body.clientHeight:window.innerHeight;
		iWidth = imageWidth - iWidth;
		iHeight = imageHeight - iHeight;
	}

	if (browser=='msie')
	{
		window.moveTo(0,0);
	}

	//alert('maxwidth: ' + maxWidth + '\n maxHeight: ' + maxHeight + '\n imageHeight: ' + imageHeight + '\n imageWidth: ' + imageWidth + '\n newHeight: ' + newHeight + '\n newWidth: ' + newWidth + '\n iHeight: ' + iHeight + '\n iWidth: ' + iWidth);
	window.resizeBy(iWidth, iHeight);
	self.focus();
}