	var keepmenu = false;
  var newdiv;
  var subdiv;
  var canceltimer = null;
  var fademenu = null;
  var uberdiv;
  var hasStuff;
  var menuLoadTimeout;

  function showIt(elem)
  {
		var flashbanner = document.getElementById('fc_flashbanner');
  	if(flashbanner){
  		flashbanner.style['visibility']='hidden';
  	}
  	menuLoadTimeout = setTimeout(function () { showMenu(elem); keepMenu(); },500);
  }
  function hideIt(elem)
  {
  	clearTimeout(menuLoadTimeout);
  }
	function showMenu(elem)
	{
		document.onclick = function() { hideMenu(newdiv); }
		if(subdiv) subdiv.style.display = 'none';
		if (!newdiv)
		{
			newdiv = document.createElement('div');
			newdiv.setAttribute('id', "dropdown");
			newdiv.style.padding = "5px";
			newdiv.onmouseover = function() { keepMenu(); document.onclick = null;}
			newdiv.onmouseout = function() { hideMenu(newdiv); }

			document.body.appendChild(newdiv);
		}
		//alert(elem.innerHTML);

		newdiv.style.display = 'block';
		//newdiv.style.width = '200px';
		//newdiv.style.padding = '10px';
		//newdiv.style.height = '100px';

		newdiv.style.position = "absolute";

		var pos = getAbsolutePos(elem);
		newdiv.style.left = pos.x + "px";
		newdiv.style.top = (pos.y+18) + "px";


		newdiv.style.background = "#FFF";
		newdiv.style.border = "1px solid #000";

		var catId = elem.id.substr(8);

		var str = "";//"<div onmouseout='hideMenu(this)' onmouseover='keepMenu();' style='margin: 10px;'><div onmouseout='hideMenu(this)' onmouseover='keepMenu();'>";
		//str += "<a href='"+elem.href+"' onmouseout='noSub(this)'  onmouseover='keepMenu(); showSub(this,\"\",\"0\");'><b>Browse "+elem.innerHTML+"</b></a><br />\n";
		hasStuff = false;
		for(var parentkey in cats)
		{
			if (parentkey == catId)
			{
				for(var thiskey in cats[parentkey])
				{
					for (var catString in cats[parentkey][thiskey])
					{
						//alert(safeslashes(cats[parentkey][thiskey][catString]));
						str += "<a href='/"+catString+"' id='menuItem"+thiskey+"' onmouseout='noSub(this)' onmouseover='keepMenu(); showSub(this,\""+ safeslashes(cats[parentkey][thiskey][catString]) +"\",\""+elem.id+"\");'>"+ cats[parentkey][thiskey][catString] + "</a><br />\n";
						hasStuff = true;
					}
				}
			}
		}
		//str += "</div></div>";

		newdiv.innerHTML = str;
		if (!hasStuff)
		{
			hideMenu(elem);
		}
	}
	function safeslashes(str)
	{
		return str.replace(/\'/g, '%27');
	}
	function noSub(elem)
	{
		elem.className = '';
	}
	function showSub(elem, titletxt, parentelem)
	{

		subdiv = document.getElementById('dropdown-sub');
		if (!subdiv)
		{
			subdiv = document.createElement('div');
			subdiv.setAttribute('id', "dropdown-sub");
			subdiv.style.padding = "5px";
			subdiv.onmouseover = function() { keepMenu(); }
			subdiv.onmouseout = function() { hideMenu(newdiv); }
			document.body.appendChild(subdiv);
		}
		var catId = elem.id.substr(8);

		//alert(elem.innerHTML);

		subdiv.style.display = 'block';
		//subdiv.style.width = '230px';
		//newdiv.style.padding = '10px';
		//newdiv.style.height = '100px';

		subdiv.style.position = "absolute";

		var pos = getAbsolutePos(elem);
		var parentdiv = document.getElementById(parentelem);
		var parentpos = getAbsolutePos(parentdiv);
		var parentw = document.getElementById('dropdown').clientWidth;
		subdiv.style.left = (parentpos.x+parentw+1) + "px";
		subdiv.style.top = (pos.y-19) + "px";


		subdiv.style.background = "#FFF";
		subdiv.style.border = "1px solid #000";

		//alert(catId)

		var str = "";// "<div onmouseout='hideMenu(this)' onmouseover='keepMenu()' style='padding: 10px;'>";
		//str += "<a href='"+elem.href+"' onmouseover='keepMenu()'><b>Browse "+titletxt+"</b></a><br />\n";
		var hasStuff2 = false;
		for(var parentkey in cats)
		{
			if (parentkey == catId)
			{
				for(var thiskey in cats[parentkey])
				{
					for (var catString in cats[parentkey][thiskey])
					{
						str += "<a href='/"+catString+"' onmouseover='keepMenu()'>"+ cats[parentkey][thiskey][catString] + "</a><br />\n";
						hasStuff2 = true;
					}
				}
			}
		}
		//str += "</div>";

		subdiv.innerHTML = str;
		if (!hasStuff2) subdiv.style.display='none';
		else elem.className = 'dropdown-selected-cat';

		//alert(elem.className);
	}
	function keepMenu()
	{
		if (hasStuff)
		{

			newdiv.style.opacity = '1';
			newdiv.style.filter = 'alpha(opacity=100)';
			if (subdiv)
			{
				subdiv.style.opacity = '1';
				subdiv.style.filter = 'alpha(opacity=100)';
			}
			newdiv.style.display='block';
			clearTimeout(canceltimer);
			clearTimeout(fademenu);
		}
		else return hideMenuNow();
		//uberDiv("<b>Menu:</b> keep open");
	}
	function hideMenu(elem)
	{
		//alert("close");
		canceltimer = window.setTimeout("hideMenuNow()",1000);
		fademenu = window.setTimeout("fadeMenu(100)",100);

		//uberDiv("<b>Menu:</b> hiding");
	}
	function fadeMenu(opacity)
	{
		newdiv.style.opacity = (opacity/100);
		newdiv.style.filter = 'alpha(opacity='+opacity+')';
		if (subdiv)
		{
			subdiv.style.filter = 'alpha(opacity='+opacity+')';
			subdiv.style.opacity = (opacity/100);
		}
		opacity -= 10;
		if (opacity >= 0){
			fademenu = window.setTimeout("fadeMenu("+opacity+")",50);
		}else{
			var flashbanner = document.getElementById('fc_flashbanner');
	  	if(flashbanner){
	  		flashbanner.style['visibility']='visible';
	  	}
		}
	}
	function hideMenuNow()
	{

		newdiv.style.display='none';
		if(subdiv) subdiv.style.display='none';
		//uberDiv("<b>Menu:</b> hidden");

	}


	/* GET ABSOLUTE POSITION CODE */
	var __isIE =  navigator.appVersion.match(/MSIE/);
	var __userAgent = navigator.userAgent;
	var __isFireFox = __userAgent.match(/firefox/i);
	var __isFireFoxOld = __isFireFox && (__userAgent.match(/firefox\/2./i) || __userAgent.match(/firefox\/1./i));
	var __isFireFoxNew = __isFireFox && !__isFireFoxOld;


	function __parseBorderWidth(width) {
	    var res = 0;
	    if (typeof(width) == "string" && width != null && width != "" ) {
	        var p = width.indexOf("px");
	        if (p >= 0) {
	            res = parseInt(width.substring(0, p));
	        }
	        else {
	     		//do not know how to calculate other values (such as 0.5em or 0.1cm) correctly now
	    		//so just set the width to 1 pixel
	            res = 1;
	        }
	    }
	    return res;
	}


	//returns border width for some element
	function __getBorderWidth(element) {
		var res = new Object();
		res.left = 0; res.top = 0; res.right = 0; res.bottom = 0;
		if (window.getComputedStyle) {
			//for Firefox
			var elStyle = window.getComputedStyle(element, null);
			res.left = parseInt(elStyle.borderLeftWidth.slice(0, -2));
			res.top = parseInt(elStyle.borderTopWidth.slice(0, -2));
			res.right = parseInt(elStyle.borderRightWidth.slice(0, -2));
			res.bottom = parseInt(elStyle.borderBottomWidth.slice(0, -2));
		}
		else {
			//for other browsers
			res.left = __parseBorderWidth(element.style.borderLeftWidth);
			res.top = __parseBorderWidth(element.style.borderTopWidth);
			res.right = __parseBorderWidth(element.style.borderRightWidth);
			res.bottom = __parseBorderWidth(element.style.borderBottomWidth);
		}

		return res;
	}

	//returns absolute position of some element within document
	function getAbsolutePos(element) {
		var res = new Object();
		res.x = 0; res.y = 0;
		if (element !== null) {
			res.x = element.offsetLeft;
			res.y = element.offsetTop;

			var offsetParent = element.offsetParent;
			var parentNode = element.parentNode;
			var borderWidth = null;

			while (offsetParent != null) {
				res.x += offsetParent.offsetLeft;
				res.y += offsetParent.offsetTop;

				var parentTagName = offsetParent.tagName.toLowerCase();

				if ((__isIE && parentTagName != "table") || (__isFireFoxNew && parentTagName == "td")) {
					borderWidth = __getBorderWidth(offsetParent);
					res.x += borderWidth.left;
					res.y += borderWidth.top;
				}

				if (offsetParent != document.body && offsetParent != document.documentElement) {
					res.x -= offsetParent.scrollLeft;
					res.y -= offsetParent.scrollTop;
				}

				//next lines are necessary to support FireFox problem with offsetParent
	   			if (!__isIE) {
	    			while (offsetParent != parentNode && parentNode !== null) {
						res.x -= parentNode.scrollLeft;
						res.y -= parentNode.scrollTop;

						if (__isFireFoxOld) {
							borderWidth = kGetBorderWidth(parentNode);
							res.x += borderWidth.left;
							res.y += borderWidth.top;
						}
	    				parentNode = parentNode.parentNode;
	    			}
				}

	   			parentNode = offsetParent.parentNode;
	    		offsetParent = offsetParent.offsetParent;
			}
		}
	    return res;
	}