var moz		= document.getElementById&&!document.all;
var timerID = null;
var isOverMenuItem = false;
var delay = 5000;

document.onclick = HideDropdown;

function DisplayDropdown(atThisObject, dropdownID, offsetX, offsetY)
{	
	var currentDropdownID = moz ? document.getElementById(dropdownID).id : eval(dropdownID).id;
	
	if (window.theDropdown && theDropdown.id != currentDropdownID)
		theDropdownStyle.visibility = "hidden";

	theDropdown = moz ? document.getElementById(dropdownID) : eval(dropdownID);
	theDropdownStyle = theDropdown.style;

	theDropdownStyle.left = FindPosX(atThisObject) + offsetX;
	theDropdownStyle.top = FindPosY(atThisObject) + offsetY;
	theDropdownStyle.visibility = "visible";

	if (timerID != null)
		clearTimeout(timerID);
	timerID = setTimeout("TimeOut()", delay);
	  	
	return false;	
}

function HideDropdown()
{
	if (window.theDropdownStyle)
		theDropdownStyle.visibility = "hidden";
}

function TimeOut()
{
	if (!isOverMenuItem)
	{
		HideDropdown();
		timerID = null;
	}
	else
	{
		timerID = setTimeout("TimeOut()", delay);
	}
}

function MenuItemHover(rowObject, className)
{
	isOverMenuItem = (rowObject.state != "highlighted");
	
	if (rowObject.state != "highlighted")
	{
		rowObject.state			= "highlighted";
		rowObject.className		= className;
	}
	else
	{
		rowObject.className		= className;
		rowObject.state			= "none";
	}
}

function FindPosX(object)
{
	var curleft = 0;
	if (document.getElementById || document.all)
	{
		while (object.offsetParent)
		{
			curleft += object.offsetLeft;
			object = object.offsetParent;
		}
	}
	else if (document.layers)
	{
		curleft += object.x;
	}
	return curleft;
}

function FindPosY(object)
{
	var curtop = 0;
	if (document.getElementById || document.all)
	{
		while(object.offsetParent)
		{
			curtop += object.offsetTop;
			object = object.offsetParent;
		}
	}
	else if (document.layers)
	{
		curtop += object.y;
	}
	return curtop;
}

