/*
	Author: Bruno Amaral (protech.ws4.org)
	Date: February 2008
*/

// Popup
var win;
function openCenteredWindow(url, height, width, name, parms)
{
	var w = 0;
	var h = 0;
	
	if (screen.width) w = screen.width;
	else w = document.body.clientWidth;
	
	if (screen.height) h = screen.height;
	else h = document.body.clientheight;
	
	var left = Math.floor( (w - width) / 2);
	var top = Math.floor( (h - height) / 2);
	
	var winParms = "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width;
	if (parms) { winParms += "," + parms; }
	win = window.open(url, name, winParms);
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function closeLastPopup()
{
	if (win) win.close();
}


// QueryString
function getQueryString()
{
	var querystring = new Array;
	
	// parse current url into an array with the keys/values
	var q = String (document.location).split('?')[1];
	if (!q) return false;
	q = q.split ('&');
	
	for (var i = 0 ; i < q.length; i++)
	{
		// for each key/value, split them at the '='
		// and add them to the qerystring array
		var o = q[i].split('=');
		querystring[o[0]] = o[1];
	}
	return querystring;
}