;(function($){
	
	$.fn.drop_down = function() 
	{
		// Method for showing the drop down
		function show() 
		{
			var $this = $(this);
			
			$this.children('a').addClass('selected');
			$this.children('ul').fadeIn();
			clearTimeout($this.data('timeout'));
			
			// Hide other opened drop-downs
			var $siblings = $this.siblings('li');
			$siblings.children('ul').hide();
			$siblings.children('a:not(.keep-selected)').removeClass('selected');
		}
		
		// Method for hiding the drop down
		// Basically only sets a timeout function
		function hide()
		{
			var $this = $(this);
			
			$this.data('timeout', setTimeout(function() {
				$this.children('a:not(.keep-selected)').removeClass('selected');
				$this.children('ul').fadeOut('fast');
			}, 500));
		}
		
		return this.each(function() 
		{
			var $this = $(this);
			var timeout = false;
			
			// Preserve initially selected item
			if ($this.children('a').hasClass('selected')) {
				$this.children('a').addClass('keep-selected');
			}
			
			$this.hover(show, hide);
		});
	};
	
})(jQuery);
