function Menu()
	{
		this.current_menu = null;
		this.previous_menu = null;
		
		this.heights = {};
		this.widths = {};
		var menu_obj = this;
		
		$('.dhtml_submenu').each(function(i){
			menu_obj.heights[ this.id ] = $(this).height() - 19; //19 este dimensiunea barei de jos a meniului
			menu_obj.widths[ this.id ] = $(this).width();
			//alert(menu_obj.heights[ this.id ]);
		});
		
		
		$(document).click(
			function()
			{
				if(menu_obj.current_menu)
				{
					menu_obj.current_menu.hide();						
					menu_obj.current_menu = null;
				}
			}
		);
		
		$('.menu_item, .menu_item_selected').hover(
			function(){
				
				//alert($('.menu_item').index(this));
				//alert(this.id);
				var id = this.id;
				var id = 'dhtml_' + id.replace('menu_', '');
				if($('#' + id + ' .content').length == 0)
				{
					return;
				}
				
				if(menu_obj.timer)
				{
					clearTimeout(menu_obj.timer);
				}
				
				if(menu_obj.current_menu && menu_obj.current_menu[0].id == id)
				{
					return;
				}
				
				
				if(menu_obj.current_menu)
				{					
					menu_obj.current_menu.hide();
				}
				
				
				
				menu_obj.current_menu = $('#' + id);
				
				var object = $(this);
				
				$('#' + id)
					.css(
						{'top' : object.offset().top + object.height(), 'left' : object.offset().left, 'width' : menu_obj.widths[ id ]}
					)
					.show();
				$('#' + id + ' .content')
					.hide()						
					.css({'overflow' : 'hidden'})
					.height(1)
					.show()
					.animate(
						{'height' : menu_obj.heights[ id ]},
						300,
						'easeOutCubic',
						function()
						{
							
						}
					);
				
			}, 
			function(){
				/*var id = this.id;
				var id = id.replace('menu_', '');
				$('#' + id).hide();*/
				
				menu_obj.timer = setTimeout(
					function(){
						if(menu_obj.current_menu)
						{
							menu_obj.current_menu.hide();						
							menu_obj.current_menu = null;
						}
					}, 1000
				);
				
				
			}
		);
		
		$('.dhtml_submenu').hover(
			function()
			{
				clearTimeout(menu_obj.timer);
			},
			function()
			{
				menu_obj.timer = setTimeout(
					function(){
						if(menu_obj.current_menu)
						{
							menu_obj.current_menu.hide();	
							menu_obj.current_menu = null;					
						}
					}, 2000
				);
			}
		);
	}
	$(document).ready(
		function()
		{
			new Menu();	
		}
	);
	