var DefaultWidth  = 800;
var DefaultHeight = 600;
var IsAutoClose = false;

function popImage(e, imageURL, imageTitle) {
	var imgWin = window.open('about:blank', '', 'location=0,toolbar=0,resizable=0,scrollbars=0, width=' + DefaultWidth + ', height=' + DefaultHeight);

	var isNN = (navigator.appName == "Netscape");

	var txt = 
		'<html><head><title>Loading...</title><style>' +
		'body { margin:0px; }' +
		'.button { background-color: ccc; border-color: gray; border-width: 1px; border-style: solid; cursor: pointer; font-size: 10px; }' +
		'</style>' +
		'<scr' + 'ipt>' +
		'function resizeToImage() {' +
		'	var width = ' + (isNN ? 'window.innerWidth' : 'document.body.clientWidth') + ';\n' +
     	'	var height = ' + (isNN ? 'window.innerHeight' : 'document.body.clientHeight') + ';\n' +
     	'	var img = document.getElementById("MainImg");\n' +
     	'	if(!window._SaveImgWidth) {\n' +
     	'		window._SaveImgWidth = img.width;\n' +
     	'		window._SaveImgHeight = img.height;\n' +
     	'	}' +
		'	img.style.width = window._SaveImgWidth;\n' +
		'	img.style.height = window._SaveImgHeight;\n' +
     	'	width = img.width - width;\n' +
     	'	height = img.height - height + 30;\n' +
		'	window.resizeBy(width, height);\n' +
		'	document.title = "' + imageTitle + '";\n' +
	    '	self.focus();\n' +
		'}' +
		'</scr'+'ipt>' +
		'</head><body scroll="no" onload="resizeToImage();"' + (IsAutoClose ? 'onblur="self.close()"' : '') + '>' +
		'<div align=center><img id="MainImg" src="' + imageURL + '" style="display:block"></div>' +
		'<div align=center style="margin-top:10px;"><input type="button" class="button" value="[x] Close" onclick="window.close()"></div>' +
		'</body></html>';

	imgWin.document.writeln(txt);
	imgWin.document.close();		

	if(!e) {
		e = window.event;
	}

	if(e.preventDefault) {
		e.preventDefault();
	}
	else {
		e.returnValue = false;
	}

	return false;
}

