//ImageWindow.js - pops up image in new browser window
//(c) 2000, 2002  Paul Hopwood
//
//Email:  paul@hopwood.org.uk
//
//modified for Red Shed (http://www.redshed.org.uk)
//permission granted for use by Red Shed as long as this header remains intact.  

//usage:
//     ImageWindow(filename, width, height, background , focustime)
//		where:
//				filename	=	name of image to load
//				width		=	width of image in pixels
//				height		=	height of image in pixels
//				background	=	background colour
//				focustime	=	time in seconds before window comes to front if 
//								sent behind other windows
//									1 - 900 time in seconds (1 sec - 15 minutes)
//									0		keep in foreground
//									-1		close window if focus is lost
//									>900	allow window to stay behind indefinately

//	function ImageWindow(filename, width, height, bgcolour, focustime) {

	function ImageWindow(filename, width, height) {

		bgcolour 	= '#ffffff' ;
		focustime	= -1	;

	    if (document.all)
	        var xMax = screen.width, yMax = screen.height;
	    else
    	    if (document.layers)
        	    var xMax = window.outerWidth, yMax = window.outerHeight;
	        else
    	        var xMax = 640, yMax=480;

	    var xOffset = (xMax - height)/2, yOffset = (yMax - width)/2;

		imgWindow = window.open('', 'ImageWindow', 'scrollbars=no,resizable=no,menubar=no,toolbar=no,status=no,left='+xOffset+',top='+yOffset+',width='+width+',height='+height );
        imgWindow.document.open();
        imgWindow.document.write('<html><head>');
        imgWindow.document.write('<title>Red Shed - Photo - [Click to Close]</title>');
        imgWindow.document.write('</head><body bgcolor="'+bgcolour+'" onLoad="window.focus()"');

		if (focustime > 900) {
			imgWindow.document.write('>');
			}			
		else if (focustime == -1) {
			imgWindow.document.write(' onBlur="window.close()">');
			}	
		else if (focustime == 0) {
			imgWindow.document.write(' onBlur="window.focus()">');
			}
		else {
			imgWindow.document.write(' onBlur="window.setTimeout(');
			imgWindow.document.write("'");
			imgWindow.document.write('window.focus()');
			imgWindow.document.write("'");
			imgWindow.document.write(','+focustime * 1000 + ')">');
			}			
	
		imgWindow.document.write('<div id="Picture" style="position:absolute; left:0px; top:0px;">');
		imgWindow.document.write('<table height="100%" width="100%" border="0" cellspacing="0" cellpadding="0" valign="top">');
		imgWindow.document.write('<tr valign="top" bgcolor="#cc0000" width="100%">');
		imgWindow.document.write('<td align="left"><img src="images/banner_title.gif" width="115" height="30" alt="" border="0"></td>');
		imgWindow.document.write('<td>&nbsp;</td>');
		imgWindow.document.write('<td align="right"><img src="images/banner_logo.gif" width="39" height="30" alt="" border="0"></td>');
		imgWindow.document.write('</tr><tr><td colspan="3">');
		imgWindow.document.write('<a href="#" onClick="window.close()">');
        imgWindow.document.write('<img src="images/photos/'+filename+'.jpg" width="'+width+'" height="'+height+'" border="0" alt="Close Window"></a>');
        imgWindow.document.write("</td></tr></table></div></body></html>");
        imgWindow.document.close();
	}