/* Popup Image Functions
 *
 * Copyright (c) 2002 2Advanced Studios
 * Version 1.1
 */

var windowName = "";
var windowTitle = "";
var img = new Image();
var imagePath = "";

// Start loading the image, save the parameters
function popupImage(winName, winTitle, imgPath)
{
	img = new Image();
	img.src = imgPath;
	imagePath = imgPath;
	windowName = winName;
	windowTitle = winTitle;
	if(document.images && !(navigator.appName.indexOf("Microsoft") != -1 && navigator.appVersion.indexOf("Mac") != -1)) {
		checkLoad();
	} else {
		showWindow();
	}
}

// Is the image loaded yet?
function checkLoad()
{
	if(img.complete)
	{
		showPopup();
	} else {
		timerID = window.setTimeout('checkLoad()',100);
	}
}

// Show the popup
function showPopup()
{
	var winl = (screen.width - img.width) / 2;
	var wint = (screen.height - img.height) / 2;
	popupWin = window.open("", windowName, 'height=' + img.height + ',width=' + img.width + ',top=' + wint + ',left=' + winl);
	popupWin.document.open();
	popupWin.document.writeln("<html><head><title>"+windowTitle+"</title><style>body{margin: 0; padding: 0;}</style></head><body background="+imagePath+"><img src="+imagePath+" /></body>");
	popupWin.document.close();
}

// Show resizable window with scrollbars & centered image
function showWindow()
{
	var winl = (screen.width - img.width) / 2;
	var wint = (screen.height - img.height) / 2;
	imageWin = window.open("", windowName, 'height=800,width=600,scrollbars,resizable' + ',top=' + wint + ',left=' + winl);
	imageWin.document.open();
	imageWin.document.writeln("<html><head><title>"+windowTitle+"</title></head><body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'><img src="+imagePath+"></body>");
	imageWin.document.close();
}
