// to use openWindow, for example:
// <a href="javascript:openWindow('images/Museum/gallery-entry-hall.jpg', 'Entry Hall', 'image');">
//

function openWindow (page, title, winName) {
    // page is the relative location of the image to be displayed.
    // title is the name of the window that is displayed in title bar.
    // winName cannot contain spaces -- it is used to provide a unique name to the window
    //      and will determine whether the window is reused if the next request has the same winName.
    // if winName is null then use title.

	widthIncr = 145; heightIncr = 165;

	// The following html will be written to the new window after opening.

	var html = "<html><head> <title> " + title + " </title> "
	        + "<script language=\"javascript\">"

			+ "function resizeWindow() { "
			+ "window.resizeTo(document.image.width+" + widthIncr + ", document.image.height+" + heightIncr + "); "
			+ "} \n"+ "</script> "

			+ "<link href=\"templates.css\" rel=\"stylesheet\" type=\"text/css\"></head> "
			+ "<body  onload=\"javascript:resizeWindow();\" onblur=\"self.close();\"> "
			+ "<table id=\"outer\" align=\"center\"><tr align=\"center\" valign=\"middle\"><td align=\"center\" valign=\"middle\">"
			+ "<div align=\"center\">"
			+ "<h3>" + title + "</h3>"
			+ "<img border=2 name=\"image\" alt=\"" + title +"\" src=\"" + page +"\"> "
			+ "</div></table>"
			+ "<script language=\"JavaScript\" type=\"text/javascript\">"
			+ "resizeWindowById('outer');"
			+ "</script>"
			+ "</body></html>";


	// if winName is null - remove any spaces from title to create window name (no spaces allowed)
	if (winName == null) {
		winName = "";
		string = '' + title;
		splitstring = string.split(" ");
		for (i = 0; i < splitstring.length; i++) winName += splitstring[i];
	}

	// if winName is the same as another displayed photo the original window is re-used

	// open a new window with initially no content
    	var newWindow = window.open("", winName, "scrollbars=no,resizable=yes,width=100,height=100");
    	newWindow.document.open();

	// write the html created above to the window document and close document, set focus
	newWindow.document.write(html);
	newWindow.document.close();
	newWindow.focus();
}



function playVideo (target, title, width, height) {
	if (width == null || width == 0) width = 400;
	if (height == null || height == 0) height = 300;
	// the following html will be written to the new window
	var html = ""
        + "<!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN\"\n"
        + "\"http:\/\/www.w3.org/TR/html4/loose.dtd\">\n"
        + "<html><head>\n"
        + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n" 
        + "<title> " + title + " </title>\n"
		+ "<link href=\"cwf.css\" rel=\"stylesheet\" type=\"text/css\">\n"
		+ "</head>\n"
		+ "<body class=\"body\">\n"
		+ "<div align=\"center\"><br><br>\n"

        /*
		+ "<embed src=\"" + target + "\" width=\"400\" height=\"300\"></embed>"
		*/

		+ "<object width=\"" + width + "\" height=\"" + height + "\" "
		+ "classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" "
		+ "codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\"> "
		+ "<param name=\"src\" value=\"" + target + "\"> "
		+ "<param name=\"autoplay\" value=\"true\"> "
		+ "<param name=\"controller\" value=\"true\"> "
		+ "<embed src=\"" + target + "\" width=\"" + width + "\" height=\"" + height + "\" "
		+ "autoplay=\"true\" controller=\"true\" "
		+ "pluginspage=\"http://www.apple.com/quicktime/download/\"> "
		+ "</embed> "
		+ "</object> "

		+ "\n<br><br>"
		+ "<p class=\"normalText\"><strong> " + title +  " </strong></p><br><br> "
		+ "<p class=\"normalText\"><a href=\"javascript: self.close ()\">Close Window</a></p> "
		+ "</div>"
		+ "\n</body></html>";

    /* hold testing pieces
    */

		//+ "<embed src=\"" + target + "\" style=\"border: medium solid #0000CC; width: 400; height: 300\"></embed>"
		//+ "<object codetype=\"video/quicktime\" data=\"" + target + "\"  width=\"400\" height=\"300\"></object>"
	// alert ("html is \n" + html);
	// remove any spaces from title to create window name (no spaces allowed)
	// if winMane is the same as another displayed photo the original window is re-created
	var winName = "video"; // Use "video" for winName so same window will be used (do not compound multiple videos)
	//string = '' + title;
	//splitstring = string.split(" ");
	//for (i = 0; i < splitstring.length; i++) winName += splitstring[i];
	// open a new window with no content
	var winOptions = "scrollbars=no,resizable=yes,width=" + (width+50) + ",height=" + (height+200);
	var newWindow = window.open("", winName, winOptions);
	newWindow.document.open();
	// write the html created above to the window and close
	newWindow.document.write(html);
	newWindow.document.close();
	newWindow.focus();
}

/*
// the following code is takem from both W3C and Apple websites
// to allow for automatic download of the ActiveX and QuickTime plugins
// necessary to play QuickTime videos
// see: http://developer.apple.com/quicktime/compatibility.html

<object width="400" height="300"
classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
codebase="http://www.apple.com/qtactivex/qtplugin.cab">
<param name="src" value="videos/AcordShowpark2004.mov">
<param name="autoplay" value="true">
<param name="controller" value="true">
<embed src="videos/AcordShowpark2004.mov" width="400" height="300"
autoplay="true" controller="true"
pluginspage="http://www.apple.com/quicktime/download/">
</embed>
</object>
*/


function closeWindow () {
	self.close();
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
