var UA = ( "" + window.navigator.userAgent );
var MSIE = UA.indexOf("MSIE") > 0;
var MSIE6 = UA.indexOf("MSIE 6") > 0;
var Safari = UA.indexOf("Safari") > 0;

var FF3 = UA.indexOf("Firefox/3") > 0;

var Cur;
function Show(id)
{
	if(Cur)
		Cur.style.display="none";
	Cur = document.getElementById(id);
	Cur.style.display="block";
	document.getElementById("UILink").style.display="";
}


function OIFL()
{
	try
	{
		var D, O = document.getElementById("Overlay");
		if(MSIE)
			D = document.frames("OverlayF").document;	//	T.document;
		else
		{
			var T;
			T = O.childNodes[2];
			D = T.contentWindow.document;
		}

	//	alert( D.title );
		O.childNodes[1].childNodes[0].innerHTML = D.title;
	}
	catch(e)
	{
		// probably just a foreign page blocked by security
	}
}

var AE;
if( window.attachEvent )
	AE = function( name, hdlr )
	{
		this.attachEvent( "on" + name, hdlr );
	};
else
	AE = function( name, hdlr )
	{
		this.addEventListener( name, hdlr, true );
	};

function OnOLLClick()
{
	var E;
	if(MSIE)
		E = window.event.srcElement;
	else
		E = this;
	// alert( E.getAttribute("orig_href") + "\n" + E.getAttribute("title") );
	ShowOverlay(E.getAttribute("orig_href"),E.getAttribute("title"));
	return false;
}

function OPL(cid)
{
	var HasOLL;
	var As = document.getElementById(cid);
	if(As)
	{
		As = As.getElementsByTagName("A"), L = As.length;

		for( var i=0; i < L; i++ )
		{
			var A = As[i];
			if( A.className == "OverlayLink" )
			{
				A.setAttribute("orig_href",A.href);
				A.href="#";
				A.target = null;
				
				if( ! A.title )
					A.title = A.innerHTML;

				AE.call( A, "click", OnOLLClick );
				HasOLL = true;
			}
		}
	}
	if( HasOLL )
	{
		AE.call( document.getElementById("Overlay").childNodes[2], "load", OIFL );
	}
}

/*
<div id="Overlay">
	<div class="SneezeGuard">&nbsp;</div>
	<div class="TitleBar">
		<span>Title</span>
		<img src="/common/images/CloseX-grey.gif" onclick="HideOverlay()" />
	</div>
	<iframe src="about:blank"></iframe>
</div>
*/
function ShowOverlay(url,title)
{
	window.open(url, 'CESample', 'location=0,menubar=0,resizable=1,status=0,toolbar=0,width=800,height=600', true);
	return false;
}

function HideOverlay()
{
	document.getElementById("Overlay").style.display="none";
	return false;
}

////////////////////////////////////////////////////////////////////////////////

AE.call( window, "load",
	function()
	{
		OPL('text1');
	}
);
