var props;
var leftPosition;
var topPosition;
var smallWindow = null;

function closeWin(){
	if (smallWindow != null){
		if(!smallWindow.closed)
			smallWindow.close();
	}
}

function openWin(imageName,imageWidth,imageHeight,pageName) {

	closeWin();

	leftPosition = (screen.width) ? ((screen.width-imageWidth)/2) : 10;
	topPosition = (screen.height) ? ((screen.height-imageHeight)/2) : 10;
	props = "width=" + imageWidth + ",height=" + imageHeight + ",top=" + topPosition + ",left=" + leftPosition;

	smallWindow = window.open("",pageName,props);
	smallWindow.document.writeln('<html>');
	smallWindow.document.writeln('<head>');
	smallWindow.document.writeln('<title>Click image to close</title>');
	smallWindow.document.writeln('</head>');
	smallWindow.document.writeln('<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginheight="0" marginwidth="0">');
	smallWindow.document.writeln('<a href="javascript:self.close();"><img src="images/' + imageName + '" width="' + imageWidth + '" height="' + imageHeight + '" alt="Click image to close" border="0" /></a>');
	smallWindow.document.writeln('</body>');
	smallWindow.document.writeln('</html>');
	smallWindow.document.close();
	smallWindow.focus();
}