//var currentLoad = window.onload;
addEvent(window, "load", detectPopupInit);
function addEvent( obj, type, fn )
{
	if (obj.addEventListener)
		obj.addEventListener( type, fn, false );
	else if (obj.attachEvent)
	{
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}


function detectPopupInit()
{
	if(!isDetectPopupEnabled())
	{
		return;
	}
	
	var popup = window.open('/HTML/826/DCalAccess/testPopup.jsp', 'popup', 'directories=no,height=1,width=1,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,top=0,location=no');
	window.focus();
	var popupBlocked = false;
	if(popup != null)
	{
		if(typeof popup.poppedUp == undefined)
		{
			popupBlocked = true;
		}
	}
	else
	{
		popupBlocked = true;
	}
	if(popupBlocked)
	{
		informUser();
	}	
	else
	{
		popup.close();
	}

}
function informUser()
{
	var starting = document.getElementById("starting");
	if(starting != null)
	{
		var count = 0;
		while(starting.childNodes.length > 0)
		{
			starting.removeChild(starting.childNodes[0]);
		}
		var container = document.createElement("div");
		var heading = document.createElement("h3");
		var text = document.createTextNode(popupsDisabled);
		heading.appendChild(text);

		var explaination = document.createElement("p");
		var explainationText = document.createTextNode(popupExplaination);
		explaination.appendChild(explainationText);



		
		container.appendChild(heading);
		container.appendChild(explaination);

		starting.appendChild(container);
	}
	
}

function isDetectPopupEnabled()
{
	var detectPopupEnabled = document.getElementById("EnableDetectPopup") || "";
	
	if(detectPopupEnabled.value == "false")
	{
		return false;
	}
	
	return true;
}