			$(document).ready(function () {
				var style = 'easeOutElastic';
				var offsetWidth =11;
		
				//Retrieve the selected item position and width
				var default_left = Math.round($('#menu_text li.selected').offset().left - $('#menu_text').offset().left);
				var default_width = $('#menu_text li.selected').width()+offsetWidth;
		
				//Set the floating bar position and width
				$('#box').css({left: default_left});
				$('#box .head').css({width: default_width});
		
				//if mouseover the menu item
				$('#menu_text li').hover(function () {
					var htmlCopy = $(this).children("div").html();
					//czy wyswietlana taka tersc nie jest juz wyswietlana
					if (htmlCopy != $('#box .next_menu').html()) {
						if (htmlCopy != null){
							$('#box .next_menu').html(htmlCopy);
							$('#box .next_menu').show('slow');
						}else{
							$('#box .next_menu').slideUp();
							$('#box .next_menu').html("");
						}
					}
					
					//Get the position and width of the menu item
					left = Math.round($(this).offset().left - $('#menu_text').offset().left);
					width = $(this).width()+offsetWidth; 
		
					//Set the floating bar position, width and transition
					$('#box').stop(false, true).animate({left: left},{duration:1000, easing: style});	//było 1000
					$('#box .head').stop(false, true).animate({width:width},{duration:1000, easing: style});
					
					
				//if user click on the menu
				}).click(function () {
					
					//reset the selected item
					$('#menu_text li').removeClass('selected');
					
					//select the current item
					$(this).addClass('selected');
			
				});
				
				//If the mouse leave the menu, reset the floating bar to the selected item
				$('#menu_text').mouseleave(function () {
					$('#box .next_menu').slideUp();
					$('#box .next_menu').html("");
					
					//Retrieve the selected item position and width
					default_left = Math.round($('#menu_text li.selected').offset().left - $('#menu_text').offset().left);
					default_width = $('#menu_text li.selected').width()+offsetWidth;
					
					//Set the floating bar position, width and transition
					$('#box').stop(false, true).animate({left: default_left},{duration:1500, easing: style});	
					$('#box .head').stop(false, true).animate({width:default_width},{duration:1500, easing: style});		
					
				});
		
			});
