/* This function will write windows on-the-fly and size them automatically. But.....

IMPORTANT:
Make sure to pre-load all images in the HTML file. Otherwise, the window that opens might only be the default 100 px square. That's because this script reads the dimensions automatically, and there usually isn't enough time to read the dimensions before creating and sizing the window.


Example of pre-loading images:
<script language="JavaScript" type="text/javascript">
<!--
image1 = new Image();
image1.src = "images/picture1.jpg";
image2 = new Image();
image2.src = "images/picture2.jpg";
// -->
</script>


Example of this code in a Web page:
<a href="javascript:pWindow('images/graphic.jpg')">

*/


function pWindow(gName){
// gName is the path and name of the image


// find the width and height of the image
theImage = new Image();
theImage.src = gName;
ImageWidth = theImage.width;
ImageHeight = theImage.height;

// find the width and height of the screen
screenWidth = screen.availWidth
screenHeight = screen.availHeight

// draw a window that's a little bigger than the image (see the margins in the body tag below)
windowWidth = ImageWidth + 10
windowHeight = ImageHeight + 10

// center the window on the screen
leftSide = (screenWidth - windowWidth)/2
topSide = (screenHeight - windowHeight)/2


// use these alerts in case image sizing seems odd
// alert("screenWidth =" + screenWidth + "  screenHeight =" + screenHeight)
// alert("ImageWidth =" + ImageWidth + "  ImageHeight =" + ImageHeight)
// alert("topSide =" + topSide)


gWindowOptions = "toolbar=no, directories=no, height=" + windowHeight + ", width=" + windowWidth + ", menubar=no, scrollbars=no, resizable=no, screenX=" + leftSide + ", screenY=" + topSide + ", top=" + topSide + ", left=" + leftSide

coverWindow = window.open("", "gWindow", gWindowOptions)

// add a 5 px border around the image (window is 10 px bigger than the image)
coverWindow.document.write("<html><head><title></title></head><body topmargin='5' leftmargin='5'>")

coverWindow.document.write("<img src='" + gName + "'>")
coverWindow.document.write("</body></html>")
coverWindow.document.close()
coverWindow.focus()


// coverWindow.moveTo(leftSide, topSide)
// this shouldn't be necessary -- it's here for historical reference


//end of function
}



/*
******************************************************************************************************
******************************************************************************************************
******************************************************************************************************
*/


function pdWindow(gName,theWidth,theHeight){
// gName is the path and name of the image


/* Writes windows on-the-fly but requires the width and height -- it DOESN'T size the images automatically.

pdWindow
p=popup
d=dimensions

IMPORTANT:
Make sure to pre-load all images in the HTML file. Otherwise, the window that opens might only be the default 100 px square. That's because this script reads the dimensions automatically, and there usually isn't enough time to read the dimensions before creating and sizing the window.


Example of pre-loading images:
<script language="JavaScript" type="text/javascript">
<!--
image1 = new Image();
image1.src = "images/picture1.jpg";
image2 = new Image();
image2.src = "images/picture2.jpg";
//
</script>


Example of this code in a Web page:
<a href="javascript:pdWindow('images/graphic.jpg','400','300')">

*/



// find the width and height of the image
ImageWidth = theWidth;
ImageHeight = theHeight;

// find the width and height of the screen
screenWidth = screen.availWidth
screenHeight = screen.availHeight

// draw a window that's a little bigger than the image (see the margins in the body tag below)
windowWidth = eval(theWidth) + 10
windowHeight = eval(theHeight) + 10

// center the window on the screen
leftSide = (screenWidth - windowWidth)/2
topSide = (screenHeight - windowHeight)/2


// use these alerts in case image sizing seems odd
// alert("screenWidth =" + screenWidth + "  screenHeight =" + screenHeight)
// alert("ImageWidth =" + ImageWidth + "  ImageHeight =" + ImageHeight)
// alert("topSide =" + topSide)


gWindowOptions = "toolbar=no, directories=no, height=" + theHeight + ", width=" + theWidth + ", menubar=no, scrollbars=no, resizable=no, screenX=" + leftSide + ", screenY=" + topSide + ", top=" + topSide + ", left=" + leftSide



coverWindow = window.open("", "gWindow", gWindowOptions)

// add a 5 px border around the image (window is 10 px bigger than the image)
coverWindow.document.write("<html><head><title></title></head><body topmargin='5' leftmargin='5'>")

coverWindow.document.write("<img src='" + gName + "'>")
coverWindow.document.write("</body></html>")
coverWindow.document.close()
coverWindow.focus()


// coverWindow.moveTo(leftSide, topSide)
// this shouldn't be necessary -- it's here for historical reference


//end of function
}




/*
******************************************************************************************************
******************************************************************************************************
******************************************************************************************************
*/






/* ROLLOVER FUNCTIONS */


/* Browser sensing */
/* Set up boolean variables to record the browser type */
var isNS4 = 0;
var isIE4 = 0;
var isNew = 0;
var docObj, styleObj, currObj

/* Determines the browser name and browser version */
var brow = ((navigator.appName) + (parseInt(navigator.appVersion)));

/* reassign variable depending on the browser */
if (parseInt(navigator.appVersion >= 5)) {isNew = 1}
	else if (brow == "Netscape4") 
	{isNS4 = 1;}
		else if (brow == "Microsoft Internet Explorer4") 
		{isIE4 = 1;}

				
if (isNS4||isIE4||isNew) {
	docObj = (isNS4) ? 'document' : 'document.all';
	styleObj = (isNS4) ? '' : '.style';
	}
	



// this checks which browser is viewing this page
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);
if (browserName == "Netscape" && browserVer >= 3) browserVer = "1";
else if (browserName == "Microsoft Internet Explorer" && browserVer == 4) browserVer = "1";
else browserVer = "2";


// create the image swapping function that works in any browser
function hiLite(imgDocID, imgObjName) {
	if (browserVer == 1) {
		document.images[imgDocID].src = eval(imgObjName + ".src");
	}
}


function hiLiteWidth(imgDocID, imgObjName, imgWidth, imgHeight) {
	if (browserVer == 1) {
		document.images[imgDocID].src = eval(imgObjName + ".src' width='" + imgWidth + "' height='" + imgHeight + "'");
	}
}


/*
How to use it:

<script language="Javascript" src="popups.js"></script>

<a href="menu.html" onmouseover="hiLite('ourMenuHomeButton','ourMenuHomeOver'); window.status='See what\'s on the menu'; return true" onmouseout="hiLite('ourMenuHomeButton','ourMenuHomeOut'); window.status=''; return true"><img src="images/our-menu-home.gif" name="ourMenuHomeButton" border="0"></a>
*/