function TopMenu() {
	
	$('#topmenu ul.navigation').css({marginLeft:-Math.floor($('#topmenu ul.navigation').width()/2)});
		
	var zIndexNumber = 10000;
	$('#topmenu ul.navigation li:has(ul)').each(function() {
		$(this).css('zIndex', zIndexNumber);
		zIndexNumber -= 10;
	});
		
	$('#topmenu ul.navigation li:has(ul)').hover(
	    
		function() {
	        	
			var $ul = $(this).find('ul:first');
	        	
	        // Первый уровень
	        if($(this).parent('ul.navigation').get(0)) {
	        		
		        var $left = 0;
		        $(this).prevAll('li').each(function(){
		        	$left += $(this).width();
		        });
				$ul.css({left:$left,top:32}).show();
		           
			// Нижележащие уровни 
	        } else {
	        		
	        	var $top = -1;
		        $(this).prevAll('li').each(function(){
		        	$top += $(this).find("a").outerHeight();
		        });
	        	$ul.css({left:$(this).parent('ul:eq(0)').width(),top:$top}).show();
	        		
	        	if($ul.offset().left>$(window).width()-$(this).width()) $ul.css({left:-50,top:$top+20});
	        		
	        }
	        
	        $(this).find('a:first:not(.active)').css({background: '#1c1919 url(/css/img/fon_menu_hover.gif) top left repeat-x' });

		},
	        
		function() { 
			$(this).find('a:first:not(.active)').css({background: 'none'});
	        $(this).find('ul:first').hide();
		}
	        
	); 
	     
}

