//
// Common.js
//

// Author: Colin Jaggs
// Date: 17th September 2004
// Description: common JS functions for BBRail website


// create global popup window handle
var popUpWin = false;

// generic popup image function - opens a set width and height and displays the image as passed in through imagePath at the full width and height specified
function popUpImage(imagePath, width, height, windowTitle)
{
	windowTitle = windowTitle || "RWGreeff - Providing solutions for the future";
	closePopups();
	popUpWin = window.open("", "popupwin", "width=" + width + ",height=" + height + ",left=" +( (screen.width / 2) - (width / 2)) + ",top=" + ((screen.height / 2) - (height / 2)));
	popUpWin.document.open();
	popUpWin.document.write("<html><head><title>" + windowTitle + "</title></head><body bottommargin=0 topmargin=0 leftmargin=0 rightmargin=0 marginwidth=0 marginheight=0><img src='" + imagePath + "' width=" + width + ",height=" + height + "></body></html>");
	popUpWin.document.close();
}

// generic popup window function - opens a popup window with the specified parameters
function popUpWindow(url, width, height, center, scroll, status)
{
	closePopups();
	var features = "";
	if (center) features += ",left=" +( (screen.width / 2) - (width / 2)) + ",top=" + ((screen.height / 2) - (height / 2));
	if (scroll) features += ",scrollbars=" + scroll;
	if (status) features += ",status=" + status;
	popUpWin = window.open(url, "popupwin", "width=" + width + ",height=" + height + ((features) ? "," + features : ""));
}

// generic function to close any popup windows created by this page
function closePopups()
{
	if (popUpWin.open) popUpWin.close();
}
