var newWindow = null
var currentWindowHeight = 300
var currentWindowWidth = 400

function galleryWindow(imgFileName,imgName,imgDir,imgFolder,imgWidth,imgHeight,imgLatinName,imgFamily,imgDescription,imgWhereTaken) { //v3.0
	var window_width = parseInt(imgWidth)+100;
    var window_height = parseInt(imgHeight)+100;
	var winName = "zoomImage"
    var window_top = (screen.height-window_height)/2;
    var window_left = (screen.width-window_width)/2;
	var tableWidth = parseInt(imgWidth)+2;
	
	imgName = "<b>" + imgName + "</b>";
	if(imgWhereTaken != ""){
		imgName = imgName + ", " + imgWhereTaken;
	}
	if(imgLatinName != ""){
		imgLatinName = "Latin Name: " + imgLatinName;
		if(imgFamily== ""){
			imgLatinName = imgLatinName + "<br>";
		}
	}
	if(imgFamily != ""){
		imgFamily = "Family: " + imgFamily  + "<br>";
		if(imgLatinName != ""){
			imgFamily = "&nbsp;&nbsp;&nbsp;" + imgFamily;
		}
	}

	var windowContent = ""
	//Page Head
	windowContent += "<HTML><HEAD><TITLE>Close-Up Photolibrary - Image Gallery</TITLE>";
	windowContent += "<script language=\"JavaScript\"> focus();</script>";
	windowContent += "<link rel=stylesheet href=\"resources/CloseUp.css\" type=\"text/css\"></HEAD>";
	//Begin body
	windowContent += "<body bgcolor=\"#F3E6D9\" leftmargin=\"10\" topmargin=\"10\" marginwidth=\"10\" marginheight=\"10\">";
	//Begin outer table
	windowContent += "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">";
	windowContent += "<tr><td align=\"center\">";
	//Begin inner table
	windowContent += "<table width=\""+ tableWidth +"\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">";
	windowContent += "<tr bgcolor=\"#000000\"><td colspan=\"3\"><img src=\"resources/1px-clear.gif\" width=\"1\" height=\"1\"></td></tr>";
	windowContent += "<tr><td bgcolor=\"#000000\" width=\"1\"><img src=\"resources/1px-clear.gif\" width=\"1\" height=\"1\"></td>";
	windowContent += "<td align=\"center\" width=\"" + imgWidth + "\">";
	windowContent += "<img src=\"" + imgDir + "/" + imgFolder + "/" + imgFileName + ".jpg\" name=\"zoomImg\" width=\"" + imgWidth + "\" height=\"" + imgHeight + "\" alt=\"" + imgName + "\">";
	windowContent += "</td><td bgcolor=\"#000000\" width=\"1\"><img src=\"resources/1px-clear.gif\" width=\"1\" height=\"1\"></td></tr>";
	//End inner table
	windowContent += "<tr bgcolor=\"#000000\"><td colspan=\"3\"><img src=\"resources/1px-clear.gif\" width=\"1\" height=\"1\"></td></tr></table>";
	//Beginn text content
	windowContent += "</td></tr>";
	windowContent += "<tr><td align=\"center\"><p>" + imgName + "</p></td></tr>";
	windowContent += "<tr><td align=\"center\"><p class=\"NormalPrices\">" + imgLatinName +  imgFamily + imgDescription + "</p></td></tr>";
	windowContent += "<tr><td align=\"right\"><p class=\"NormalPrices\"><a href=\"javascript:window.close()\">Close Window</a></p></td></tr>";
	//End outer table
	windowContent +=  "</table>";
	//End body
	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)
}