var menu_open = {

	x: null,
	ul: null,

	init: function() {

		// the elements we're dealing with

		// Finds the main nav UL
		this.ul = $("menu").getElementsByTagName("ul")[0];
		Element.extend(this.ul);

		// Lists all the LI's for the main nav
		//var lis = this.ul.immediateDescendants();
		var lis = $$(".main-li");

		//Loop through the main LI's to find nested UL's. If any, hide them
		for(i=0; i < lis.length; i++) {

			var sub_uls = lis[i].getElementsByTagName("ul");

			if(sub_uls.length > 0) {
				Element.extend(sub_uls[0]);
				sub_uls[0].hide();
			}
			
	
			//
			//Notes for when we forget what we need to do here!!!
			//
			//make a note of selected menu item, then onmouseover fake the 'current-top'
			//onmouseout we need to revert back to the currently selected menu item, or do an if()
			
			//can you do globals in js?! is so we need to save the REAL current-top!			

			// Show submenus on mouse over
			lis[i].onmouseover = function() { 				

				if(this.readAttribute('id')=="current-top")				
			 		this.writeAttribute('id', 'real-current-top');
				else
			 		this.writeAttribute('id', 'current-top');				

				var sub_uls = this.getElementsByTagName("UL");
				
				if(sub_uls.length > 0)
				{
					Element.extend(sub_uls[0]);
					sub_uls[0].show();					
					//sub_uls[0].style.display = "block";
				}

			}


			// Hide submenu's on mouse out
			lis[i].onmouseout = function() {

				var sub_uls = this.getElementsByTagName("ul");

				if(sub_uls.length>0)
				{
					Element.extend(sub_uls[0]);
					sub_uls[0].hide();
					//sub_uls[0].style.display = "none";
				}

				if(this.readAttribute('id')=="real-current-top")				
			 		this.writeAttribute('id', 'current-top');
				else				
					this.writeAttribute('id', '');				

			}
		}

	}


}

menu_open.init();
	
/*
function show_quick_menu(menu){

	menu_to_show = "quick-menu-" + menu;
	$(menu_to_show).show();
	//Effect.BlindDown(menu_to_show);
}

function hide_quick_menus(menu){

		menu_to_hide = "quick-menu-" + menu;
		$(menu_to_hide).hide();

}*/

