
	function menu_init(menuid,method)
	{

		if (!method) method = "mouseover";

		var menu = document.getElementById(menuid);
		menu_reset(menu);

		sublists = menu.getElementsByTagName("UL");
		var i; for (i=0;i<sublists.length;i++) {
			addClass(sublists[i].parentNode,"parent");
		}

		listitems = menu.getElementsByTagName("LI");
		var i; for (i=0;i<listitems.length;i++) {
			addEvent(listitems[i],method,menu_expand);
			addEvent(listitems[i],"mouseover",menu_hoveron);
			addEvent(listitems[i],"mouseout",menu_hoveroff);
		}

		links = menu.getElementsByTagName("A");
		var i; for (i=0;i<links.length;i++) {
			links[i].onclick = menu_linkfunc;
		}
	
		addEvent(menu,"click",menu_clickfunc);
		addEvent(document,"click",function(e) { menu_reset(menu,e); } );
	}

	function menu_reset(menu,e) {
		if (e) {
			t = findTarget(findEvent(e));
			while (t.tagName != "HTML") {
				if (t.id == menu.id) return false;
				t = t.parentNode;
			}
		}
		menu_clearpath(menu);
		submenus = menu.getElementsByTagName("UL");
		var i; for (i=0;i<submenus.length;i++) {
			submenus[i].style.display = "none";
		}
	}

	function menu_expand(e)
	{
		e = findEvent(e); t = findTarget(e);
		while (t.tagName != "LI") { t = t.parentNode; }
		menu_hidesiblings(t);
		menu_showchildren(t);
		menu_markpath(e,t);

	}

	function menu_hidesiblings(object)
	{
		var parent = object.parentNode;
		while (parent.tagName != "UL") { parent = parent.parentNode; }
		siblings = parent.childNodes;
		for(i=0;i<parent.childNodes.length;i++) {
			if (parent.childNodes[i].tagName == "LI") {
				liststohide = parent.childNodes[i].getElementsByTagName("UL");
				for (j=0;j<liststohide.length;j++)
				{
					listtohide = liststohide[j];
					listtohide.style.display = "none";
				}
			}
		}
	}
			
	function menu_showchildren(item) {
		for(i=0;i<item.childNodes.length;i++) {
			if (item.childNodes[i].tagName == "UL") {
				item.childNodes[i].style.display = "block";
			}
		}
	}
		
	function menu_clickfunc(e) {
		var t = findTarget(findEvent(e));

		while (t.tagName != "LI" && t.tagName != "HTML") { 
			if (t.tagName == "HTML") return false;
			t = t.parentNode; 
		}

		var i; for(i=0;i<t.childNodes.length;i++) {
//			if (t.childNodes[i].tagName == "UL") return false;
		}

		var i; for(i=0;i<t.childNodes.length;i++) {
			if (t.childNodes[i].tagName == "A") {
				document.location = t.childNodes[i].href;
			}
		}
	}

	function menu_linkfunc(e) {
		t = findTarget(findEvent(e));				
		while (t.tagName != "LI") { t = t.parentNode; }
		for(i=0;i<t.childNodes.length;i++) {
			if (t.childNodes[i].tagName == "UL") return false;
		}
	}
	
	function menu_markpath(event,item) {
		menu_clearpath(item);
		if (event.type != "click") item = item.parentNode;
		while (item.tagName != "BODY") {
			if (item.tagName == "LI") {
				addClass(item,"breadcrumb");
			}
			item = item.parentNode;
		}
	}

	function menu_clearpath(item) {
		while (item.tagName != "BODY"){
		if (item.tagName == "UL") { var menu = item;  }
			item = item.parentNode;
		} 
		if (menu) {
			pathitems = menu.getElementsByTagName("LI");
			var i; for (i=0;i<pathitems.length;i++) {
				if (checkClass(pathitems[i],"breadcrumb")) {
					removeClass(pathitems[i],"breadcrumb");
				}
			}
		}
	}

	function menu_hoveron(e) {
		t = findTarget(findEvent(e));
		while (t.tagName != "LI") { t = t.parentNode; }
		addClass(t,"hover");
		t.style.cursor = "pointer";
	}

	function menu_hoveroff(e) {
		t = findTarget(findEvent(e));
		while (t.tagName != "LI") { t = t.parentNode; }
		removeClass(t,"hover");
	}

