var newWindow = null
var currentWindowHeight = 350
var currentWindowWidth = 420

function galleryWindow(imgWidth,imgHeight,imgSRC,imgTitle) { //v3.0
	if(imgWidth<400){
		var window_width = 420;
		var outerTbl_width = 402;
	}else{
    	var window_width = parseInt(imgWidth)+20;
		var outerTbl_width = parseInt(imgWidth)+2;
	}
    var window_height = parseInt(imgHeight)+50;
	var winName = "zoomImage"
    var window_top = (screen.height-window_height)/2;
    var window_left = (screen.width-window_width)/2;
	var tblborder_width = parseInt(imgWidth)+2;

	var windowContent = "<HTML><HEAD><TITLE>Epic Media</TITLE>"
	windowContent += "<script language=\"JavaScript\"> focus();</script>"
	windowContent += "<link rel=stylesheet href=\"css/epicmedia.css\" type=\"text/css\"></HEAD>"
	windowContent += "<body bgcolor=\"#DAD1C0\" leftmargin=\"0\" topmargin=\"10\" marginwidth=\"0\" marginheight=\"10\">"
	windowContent += "<table width=\"" + outerTbl_width + "\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">"
	windowContent += "<tr align=\"center\"><td colspan=\"2\">"
	windowContent += "<table width=\"" + tblborder_width + "\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
	windowContent += "<tr bgcolor=\"#000000\"><td colspan=\"3\"><img src=\"images/dot_clear.gif\" width=\"1\" height=\"1\"></td></tr>"
	windowContent += "<tr><td bgcolor=\"#000000\" width=\"1\"><img src=\"images/dot_clear.gif\" width=\"1\" height=\"1\"></td>"
	windowContent += "<td width=\"" + imgWidth + "\" align=\"center\">"
	windowContent += "<img src=\"images/" + imgSRC + "\" name=\"zoomImg\" width=\"" + imgWidth + "\" height=\"" + imgHeight + "\" alt=\"" + imgTitle + "\">"
	windowContent += "</td><td bgcolor=\"#000000\" width=\"1\"><img src=\"images/dot_clear.gif\" width=\"1\" height=\"1\"></td></tr>"
	windowContent += "<tr bgcolor=\"#000000\"><td colspan=\"3\"><img src=\"images/dot_clear.gif\" width=\"1\" height=\"1\"></td></tr></table>"
	windowContent += "</td></tr><tr><td width=\"251\"><img src=\"images/dot_clear.gif\" width=\"251\" height=\"1\"></td>"
	windowContent += "<td width=\"151\"><img src=\"images/dot_clear.gif\" width=\"151\" height=\"1\"></td></tr>"
	windowContent += "<tr align=\"center\"><td height=\"40\"><p><b>" + imgTitle + "</b></p></td>"
	windowContent += "<td height=\"40\"><p><a href=\"javascript:window.close()\">Close Window</a></p></td></tr></table>"
	windowContent += "</body></html>"

	if (!newWindow || newWindow.closed) {
		newWindow = window.open("","" + winName + "", "width=" + window_width + ",height=" + window_height + ",top=" + window_top + ",left=" + window_left + "");
		newWindow.document.write(windowContent);
		newWindow.document.close();
	} else {
		if((currentWindowWidth != window_width) || (currentWindowHeight!=window_height)){
			newWindow.close();
			newWindow = window.open("","" + winName + "", "width=" + window_width + ",height=" + window_height + ",top=" + window_top + ",left=" + window_left + "");
			newWindow.document.write(windowContent);
			newWindow.document.close();
		}else{
			newWindow.document.write(windowContent);
			newWindow.document.close();
		}
	}
	currentWindowHeight = parseInt(window_height)
	currentWindowWidth = parseInt(window_width)
}

