var W3CDOM = (document.createElement && document.getElementsByTagName);

var mouseOvers = new Array();
var mouseOuts = new Array();

function init()
{
	if (!W3CDOM) return;
	var nav = document.getElementById('mouseovers');
	var imgs = nav.getElementsByTagName('img');
	for (var i=0;i<imgs.length;i++)
	{
		imgs[i].onmouseover = mouseGoesOver;
		imgs[i].onmouseout = mouseGoesOut;
		var suffix = imgs[i].src.substring(imgs[i].src.lastIndexOf('.'));
		mouseOuts[i] = new Image();
		mouseOuts[i].src = imgs[i].src;
		mouseOvers[i] = new Image();
		mouseOvers[i].src = imgs[i].src.substring(0,imgs[i].src.lastIndexOf('.')) + "_f2" + suffix;
		imgs[i].number = i;
	}
}

function mouseGoesOver()
{
	this.src = mouseOvers[this.number].src;
}

function mouseGoesOut()
{
	this.src = mouseOuts[this.number].src;
}

function MM_preloadImages()
{ //v3.0
	var d=document;
	if(d.images)
	{
		if(!d.MM_p) d.MM_p=new Array();
   		var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
   		
   		for(i=0; i<a.length; i++)
   			if (a[i].indexOf("#")!=0)
   			{
   				d.MM_p[j]=new Image;
   				d.MM_p[j++].src=a[i];
   			}
   	}
} // MM_preloadImages()

function newWindow(picTitle, picture, width, height)
{	
	// Open new window large enough to accomadate picture
	// Get screen width and height
	screenWidth=screen.width;
	screenHeight=screen.height;
	
	// Adjust width and height to allow borders
	width+=40;
	height+=85;
	
	// Check for small screen
	if(screenWidth>width)
		screenL=(screenWidth-width)/2;
	else
		screenL=0;		
	if(screenHeight>height)
		screenT=(screenHeight-height)/2;
	else
		screenT=0;
	if(screenT>20)
		screenT-=20;
	
	// Generate new window name to allow for multiple windows to be open
	winName = new Date().getSeconds().toString();
	newwin = window.open("",winName,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+width+',height='+height);

	// Write HTML to window - include picture title and image
 	with (newwin.document)
 	{
    	write()
		close()
		write("<HTML>")
		write("<title>" + picTitle + "</title>")
		write("<body>")
		write("<form><table width='100%'><tr><td width='100%' align='center'>")
		write("<img src='" + picture + "'></td></tr>");
		write("<tr><td align='center'><b>" + picTitle +"</b></td></tr>");
    	write("<tr><td width='100%' align='center'><input type='button' value='Close This Window' onclick='window.close()'>")
		write("</td></tr></table></form>")
		write("</body>")
		write("</HTML>")
  	} // with
	newwin.moveTo(screenL,screenT);
} // newWindow