// active lets us keep track of which menu if any is currently being displayed
var active;

// toggles a dropdown between being visible / invisible
function dropdowntoggle(t)
{
	// if there's an active drop down we hide itcingu
	if(active != null)
	{
		for(var i=0; i<active.childNodes.length; i++)
			if(active.childNodes[i].nodeName == "UL")
				active.childNodes[i].style.display = "none";
	}

	// if the user didn't just click the active one (hiding it)
	if(active != t)
	{
		// set the active dropdown
		active = t;

		// set each UL in the dropdown to be "block"
		for(var i=0; i<active.childNodes.length; i++)
			if(active.childNodes[i].nodeName == "UL")
				active.childNodes[i].style.display = "block";

		// bring it to the top
		active.style.zIndex = "999";
	}
	else
		active = null;
}

// used to untoggle when a dropdown link is clicked
function dropdownuntogglefromlink(t)
{
	// when a link is clicked in the drop down you can call this function to hide it, eg:
	// <a href="page.html" onclick="untogglefromlink(this);">whatever</a>.
	dropdowntoggle(t.parentNode.parentNode.parentNode);
}

