
//code executes on DOM-ready
jQuery(function() {
    var matcher = /menu\d+/;
    //attach hover functionality for each link in the Nav:
    jQuery('#Nav > li > a').hover(
	    function() {
	        var parent = this,
	          match = this.className.match(matcher);
	        if(match) {
	            jQuery('div#' + match[0]).each(
	                function() {
	                    var offset = jQuery(parent).offset(),
	                    	augmentedThis = jQuery(this),
	                    	topPos = Math.round(offset.top) + parent.offsetHeight;
	                    augmentedThis.css({position: 'absolute', top: topPos, left: Math.round(offset.left)});
	                    augmentedThis.fadeIn('fast');   
	                   
	                });
	        }
	       
	    },
	    function() {
	        var parent = this,
	          match = this.className.match(matcher);
	        if(match) {
	            jQuery('div#' + match[0]).each(
	                function() {
	                		jQuery(this).css({display: 'none'});
	                        
	                });
	        }   
	    });
	//once the menus are displayed by mousing over the Nav links, we need to manage
	//an extra level of hovering:
    jQuery('.menuContainer').each(
    	function() {
    		jQuery(this).hover(
    			function() {
    				jQuery(this).css({display: 'block'});	
    			},
    			function() {
    				jQuery(this).fadeOut('fast');
    			}
    		);	
    	});
});



