// jQuery function for DCC navigation menus
// 	April 20, 2010



$(document).ready(function() {
	$('#divNewMenu ol a.hasSubs').hover(function () { // bind hover event to top-level menu item links 
		$('#divNewMenu ol a').removeClass('menuActive'); // remove any current navbar highlighting 
		$link = $(this); // name the active menu link 
		$link.addClass('menuActive'); // highlight the top navbar item 
		if ($('#divNavPanel').is(":hidden")) { // see whether the nav panel is hidden 
			$('#divNavPanel div.menuPanel').hide(); // hide any panels that might still be open 
			menuName = '#div' + $link.attr('id'); // get the name of the div that should be enabled 
			$(menuName).show(); // enable the div 
			$('#divNavPanel').show("slide", {}, 500); // display the div 
			$('.menuPanel ul a.hasSubs').click(function () { // bind click event to links with submenus 
				$sublink = $(this); // name the active submenu link 
				$('#divNavPanel div.menuPanel').hide(); // hide the menu panel that is currently open 
				submenuName = '#div' + $sublink.attr('id'); // get the name of the div that should be enabled 
				$(submenuName).show(); // display the div 
				return false; // don't navigate 
			});
			$('#divNewMenu').hover(function () { // bind hover event to entire menu once a panel is open 
				return false; // as long as the mouse is over the menu, don't do anything 
				}, function() { // but when the mouse moves away from the menu... 
					$('#divNavPanel').hide("slide", {}, 500); // close the nav panel 
					// $('#divNavPanel div.menuPanel').hide(); hide the menu panel that is currently open 
					$('#divNewMenu ol a').removeClass('menuActive'); // remove the current navbar highlighting 
					$(this).unbind();
					return false; // don't navigate 
				}
			);
		} 
		else {
			if (menuName != 'div' + $link.attr('id')) { // see whether a different menu item has been selected 
			$('#divNavPanel div.menuPanel').hide(); // hide any panels that might still be open 
			menuName = '#div' + $link.attr('id'); // get the name of the div that should be displayed 
			$(menuName).show(); // display the div 
			}
			return false; // don't navigate 
		}
	});
});

