// Do the final menu clearing
function close_menu_final($id)
	{
		$use_id = "#sub-menu-"+$id;
		$($use_id).slideUp("10000");
	}
$menu_open = 0;
$(document).ready(function()
	{	
		
		/*****************/
		/* HashOne Menu */
		$("a[id^='main-menu-item-']").click(function(){
					// Create the id to ref the submenu
			$sub_menu_id = $(this).attr("id").replace("main-menu-item-", "");
			$id = "sub-menu-"+$sub_menu_id;
			$new_sub_menu = "#"+$id;
			/* If we're choosing a new menu */ 
			if($menu_open !== $sub_menu_id)
				{
					if(("sub_menu").id !== $id)
						{
							// close the old menu
							$(".sub_menu").slideUp("2000").removeClass("sub_menu");
							// fade in the submenu
							$($new_sub_menu).slideDown("2000").addClass("sub_menu");				
						}
					$menu_open = $sub_menu_id;
				}
			/* If we're closing the current one*/ 
			else
				{
					$sub_menu_id = $(this).attr("id").replace("main-menu-item-", "");
					// Start the cloding process
					close_menu_final($sub_menu_id);
					$menu_open = 0;
				}
		});
	});
