
schedule("navigation", menuInit); 




function menuInit()
{
	var menu = document.getElementById("navigation");
	
	if (menu.className == "")
	{
		menu.className = "js";
	}
	else
	{
		menu.className += " js";
	}

	var listItems = menu.getElementsByTagName("li");
	
	for (var i = 0; i < listItems.length; i++)
	{
		var subMenu = listItems[i].getElementsByTagName("ul");

		if (subMenu.length > 0)
		{
			var anchor = getChildrenByTagName(listItems[i], "a")[0];
			
			anchor.onclick = clickMenu;
		}
	}

	return true;
};




function clickMenu()
{
	var listItem = this.parentNode;

	if (!listItem.className.match(/(^| )open( |$)/))
	{
		if (listItem.className == "")
		{
			listItem.className = "open";
		}
		else
		{
			listItem.className += " open";
		}
	}
	else
	{
		listItem.className = listItem.className.replace(/(^| )open( |$)/, "$1");
		listItem.className = listItem.className.replace(/ $/, "");
	}
	
	return false;
};




function getChildrenByTagName(target, tagName)
{
	var children = target.childNodes;
	var matching = new Array();
	
	if (children != null)
	{
		for (var i = 0; i < children.length; i++)
		{
			if (children[i].nodeName.toLowerCase() == tagName)
			{
				matching[matching.length] = children[i];
			}
		}
	}
	
	return matching;
};