function popup(p_sUrl, p_sTitle)
{
	var iWidth = 500;
	var iHeight = 300;
	var iTop = (screen.height - iWidth) / 2;
	var iLeft = (screen.width - iHeight) / 2;
	
	var sOptions = "toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no";
	
	window.open(p_sUrl, p_sTitle, "top=" + iTop + ", left=" + iLeft + ", width=" + iWidth + ", height=" + iHeight + "," + sOptions)
}

function addLoadEvent(func)
{
	var oldonload = window.onload;
	
	if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else 
	{
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}

function checkPopup()
{
	if(testParent())
	{
		window.opener.location.href = window.location.href;
		window.close();
	}
}

function testParent() {
	if (window.opener != null && !window.opener.closed)
	return true;
	else
	return false;
}
addLoadEvent(checkPopup);

