/**
 * Initializes menu, setting onclick attributes for toggle links and hiding
 * toggle parts of menu, with no active links
 */
function initMenu()
{
	anchors = elById('menu_container').getElementsByTagName('a');

	for (i = 0; i < anchors.length; i++)
		if (anchors[i].href.match(/#toggle/)) {
			anchors[i].onclick = menuToggle;
			hidden = anchors[i].href.match(/#toggle\|hide$/) ? true : false;
			anchors[i].href = 'javascript: void(0);';

			if (hidden) {
				menuItem = anchors[i].parentNode;
				subMenu = menuItem.getElementsByTagName('ul');
				
				if (subMenu[0]) {
					toggleVisibility(subMenu[0]);
				}
			}
		}
}

/**
 * Hides/shows link submenu (for onclick usage)
 */
function menuToggle()
{
	menuItem = this.parentNode;
	
	if (menuItem.getElementsByTagName('ul').length != 0)
		toggleVisibility(menuItem.getElementsByTagName('ul')[0]);
}
