var oQuickLinx = null;
var oTimeout   = null;
var oButton    = null;

function popUpQuicklinks ()
{
	// 0. check
	if ((oQuickLinx == null) &&
		!_initLinx())
		return false;

	// 1. get height
	var iOffY = oQuickLinx.scrollHeight;
	
	// 2. get XY of reference...
	oButton = document.getElementById("quickLinxAnchor"); // cheatmode: on
 	var aRef = _getXY(oButton);
	oQuickLinx.style.top  = (aRef.y - iOffY + 10)+"px";
	oQuickLinx.style.left = (aRef.x + 8) + "px";
	
	// 3. show it
	oQuickLinx.style.visibility = "visible";
	oButton.className = oButton.className + " open";
	
	// 4. deal with closing
	oQuickLinx.onmouseout = function()
	{
		oTimeout = setTimeout("dismissQuicklinks();", 500);
		oQuickLinx.onmouseover = function()
		{
			clearTimeout(oTimeout);
		}
	}
	document.onmousedown = function(ev)
	{ 
		// if we're clicking on a link, make sure we trigger it, otherwise it just gets swallowed…
		var oEl = (document.all) ? window.event.srcElement : ev.target;
		if (oEl.nodeName.toLowerCase() == "a")
		{
			if (oEl.onclick != null)
				return oEl.onclick();
			elseif (oEl.getAttribute("href") != "")
				return false;
		}
		
		dismissQuicklinks();
	}

	return true;
}

function dismissQuicklinks()
{
	clearTimeout(oTimeout);
	oQuickLinx.onmouseout = null;
	document.onmousedown = null;
	oQuickLinx.style.visibility = "hidden";
	oButton.className = oButton.className.replace(" open", "");
	return true;
}

function _initLinx()
{
	if ((oQuickLinx = document.getElementById('quickLinxList')) == null)
		return false;
	oQuickLinx.style.visibility = "hidden";
	oQuickLinx.style.display = "block";
	return true;
}
function _getXY (oEl)
{
	var aLoc = new Array();
	aLoc.x = 0;
	aLoc.y = 0;
	while (oEl != null)
	{
		aLoc.x += oEl.offsetLeft;
		aLoc.y += oEl.offsetTop;
		oEl = oEl.offsetParent;
	}
	return aLoc;
}