

	function getOffsets (target) 
	{
		if (typeof target.offsetLeft == 'undefined') {
			target = target.parentNode;
		}
		var pageCoords = getPageCoords(target);

		var offsets = {
			offsetX: pageCoords.x,
			offsetY: pageCoords.y
		}
		return offsets;
	}

	function getPageCoords (element) {
	  var coords = {x : 0, y : 0};
	  while (element) {
		coords.x += element.offsetLeft;
		coords.y += element.offsetTop;
		element = element.offsetParent;
	  }
	  return coords;
	}

	var timeout_hide = new Array();
	var timeout_hide_val = 1 * 100; // 1 second
	var menu_hide_selects = true;
	var last_catID = -1;

	function ShowSub(catID, selected, obj)
	{
		var last = document.getElementById("menu_sub" + last_catID);
		if (last)
		{
			if (last.style)
				last.style.visibility = "hidden";
		}

		if (last_catID != catID)
		{
			var lastcat = document.getElementById("menuitem" + last_catID + "link");
			if (lastcat)
			{
				if (lastcat.style)
				{
					lastcat.style.color = "";
					lastcat.style.backgroundColor = "";
				}
			}
		}

		ShowHideSub(catID, selected, obj.id, 1);

		// need to hide all selects
			if (menu_hide_selects)
			{
				var theSelects = document.getElementsByTagName("select");
				for (var i = 0; i < theSelects.length; i++)
				{
					theSelects[i].style.visibility = "hidden";
				}

			}
	}


	function HideSub(catID, selected, obj)
	{
		timeout_hide[catID] = setTimeout('ShowHideSub(' + catID + ', ' + selected + ', "' + obj.id + '",0)',timeout_hide_val);
		
		// need to show all selects
			if (menu_hide_selects)
			{
				var theSelects = document.getElementsByTagName("select");
				for (var i = 0; i < theSelects.length; i++)
				{
					theSelects[i].style.visibility = "visible";
				}

			}

	}

	function ShowHideSub(catID, selected, obj, on)
	{
		var theSub = document.getElementById("menu_sub" + catID);

		if (!theSub) return;
		if (!theSub.style) return;

		if (typeof(obj) == "string")
			obj = document.getElementById(obj);

		if (on)
		{
			clearTimeout(timeout_hide[catID]);
			
			var menuleft = 156;

			var ua = navigator.userAgent.toLowerCase();

//			var menutop_rel = obj.offsetTop + 37;
			var menutop_rel = document.getElementById("menu_top").offsetTop + 37;

			if (ua.match(/netscape(6)?\/[6-7]/) && ua.match(/windows/))
				menutop_rel+= 13;

			theSub.style.top = menutop_rel + "px";

			theSub.style.visibility = "visible";

			last_catID = catID;

			var parent_link = "menuitem" + theSub.id.match(/[0-9]+/) + "link";
			parent_link = document.getElementById(parent_link);
			var old_image_src = parent_link.firstChild.src.toLowerCase();
			parent_link.firstChild.src = old_image_src.replace(/^(.*)([0-9]+)_(0|1)\.gif/,"$1$2_1.gif");

			/*parent_link.style.color = "#FFF";
			parent_link.style.backgroundColor = "#245D96";*/

			//obj.className = "menu_over";
		}
		else
		{
			theSub.style.visibility = "hidden";

			var parent_link = "menuitem" + theSub.id.match(/[0-9]+/) + "link";
			parent_link = document.getElementById(parent_link);
			var old_image_src = parent_link.firstChild.src.toLowerCase();
			parent_link.firstChild.src = old_image_src.replace(/^(.*)([0-9]+)_(0|1)\.gif/,"$1$2_0.gif");

		}

	}

	function MouseOutSub(catID, selected, obj)
	{
		if (typeof(obj) == "string")
			obj = document.getElementById(obj);

		HideSub(catID, selected, obj);

		// need to show all selects
			if (menu_hide_selects)
			{
				var theSelects = document.getElementsByTagName("select");
				for (var i = 0; i < theSelects.length; i++)
				{
					theSelects[i].style.visibility = "visible";
				}
			}
	}

	function MouseOverSub(catID, selected, obj)
	{
		ShowSub(catID, selected, document.getElementById(obj));

		// need to hide all selects
			if (menu_hide_selects)
			{
				var theSelects = document.getElementsByTagName("select");
				for (var i = 0; i < theSelects.length; i++)
				{
					theSelects[i].style.visibility = "hidden";
				}

			}
	}
