var popups = new Array();

function show(divId, iframeId) {
	var div = document.getElementById(divId);
	var iframe = document.getElementById(iframeId); 
	if (div != null && iframe != null) {
		iframe.style.height = div.offsetHeight;
		iframe.style.width = div.offsetWidth;
		div.style.visibility = "visible";
		iframe.style.visibility = "visible";
	}
}

function hide(divId, iframeId) {
	var div = document.getElementById(divId);
	var iframe = document.getElementById(iframeId);
	if (div != null && iframe != null) {
		div.style.visibility = "hidden";
		iframe.style.visibility = "hidden";
	}
}

/**
 * This function will show a popup given the parameters sent in.
 * If the centered parameter is true the left and top parameters are ignored.
 * url			- String - the url of the popup.
 * name			- String - the name of the popup.
 * width		- numeric - the width of the window.
 * height		- numeric - the height of the window.
 * scrollable	- boolean - whether the window is scrollable or not.
 * resizable	- boolean - whether the window is resizable or not.
 * toolbar		- boolean - whether the window has the toolbar or not.
 * centered		- boolean - whether the window is centered relative to the parent window.
 * left			- numeric - left position of the window.
 * top			- numeric - top position of the window.
 * reload		- boolean - optional parameter, if true the popups location will be reloaded 
 * 							each time this method is called to show the window.
 * returns the handle for the popup.
 */
function showPopup(url, name, width, height, scrollable, resizable, toolbar, centered, left, top, reload) {
	// see if the window is just in the background first
	if (null != popups[name] && !popups[name].closed) {
		if (window.focus) {
			// if the browser can set focus
			popups[name].focus();
			if (reload) {
				popups[name].location = url;
			}
			return popups[name];
		} else {
			// if the browser can't set focus then just destroy it and recreate it
			popups[name].close();
		}
	}
	// create the parameter string
	var paramString = "";
	paramString = paramString + "width=" + width + ","; // add the width
	paramString = paramString + "height=" + height + ","; // add the height
	paramString = paramString + "scrollbars=" + (scrollable == true ? "yes" : "no") + ","; 
	paramString = paramString + "resizable=" + (resizable == true ? "yes" : "no") + ",";
	paramString = paramString + "toolbar=" + (toolbar == true ? "yes" : "no") + ",";
	if (centered) {
		paramString = paramString + "left=" + (screen.width - width) / 2 + ",top=" + (screen.height - height) / 2 + ",";
	} else {
		paramString = paramString + "left=" + left + ",";
		paramString = paramString + "top=" + top + ",";
	}
	// show the window
	var handle = window.open(url, name, paramString);
	// for browsers that dont know opener
	if (!handle.opener) handle.opener = self;
	// save the handle
	popups[name] = handle;
	// set the focus
	popups[name].focus();
	// return the handle
	return handle;
}