var $j = jQuery.noConflict();
$j(document).ready(function() {
							
		//z-index stacking bug fix
		var zIndexNumber = 1000;
		$j('li').each(function() {
			$j(this).css('z-index', zIndexNumber);
			zIndexNumber -= 1;
		});
							
		$j('.menu > li').bind('mouseover', openFlyOut);
		$j('.menu > li').bind('mouseout', closeFlyOut);
		
		
		
		function openFlyOut() {
			//get the id and set the height
			var numberOfItems = $j(this).find('ul.subNav > li').size();
			var heightOfEachItem = 40;  //height in pixels, must be the same as the height plus top and bottom padding of li element in css!
			
			var totalHeightOfFlyOut = numberOfItems * heightOfEachItem;
			
						
			$j(this).find('ul.subNav').css('visibility', 'visible');
			$j(this).find('ul.subNav').css('z-index', '99');
			$j(this).find('ul.subNav').stop().animate({height:totalHeightOfFlyOut},'fast');
		};
		
		function closeFlyOut() {
			$j(this).find('ul.subNav').stop().animate({height:0},'fast', function() {
				 $j(this).css('visibility', 'hidden');
				 $j(this).css('z-index', '11');
			 });	
		}; 
		
		
});
