$(document).ready(function() {
	
    if(!(ZD.browser.msie && (ZD.browser.version<7))){ // exclude use of the js on ie6, ie8.
	// Via stylesheet, all menus except page-load-current-one are hidden.
	// determine page-load-visible section
	var currentlyMousingOver = 0;
	// Give all the base menu entries except the active one a hover over and hover out function.
	$('#zd-nav li.level-0').not('.zd-nav-active').hover(function(){
		// Hover over
		// On mouseover of a menu section, the default dropdown.
		$('.zd-nav-active ul').slideUp('fast');
		// Display the navigation of the specifically hovered base menu entry.	
		$(this).find('ul').slideDown('fast');
		currentlyMousingOver=1;
	}, function(){
		// Hover out
		// After mouseover, go back to displaying the page-load-visible section.
		$(this).find('ul').slideUp('fast');
		currentlyMousingOver=0;
		// Check whether to reinstate the default menu, after a delay.
		showDefaultWhenNoActivity();
	});

	function showDefaultWhenNoActivity(){
                setTimeout(function() { 
                // re-display default page-load-visible section
                if(!currentlyMousingOver){
                    $('.zd-nav-active ul').slideDown('fast');
                }
                }, 300);
	}
    }
});

