(function($){

	$(document).ready(function(){
	
		// Cache object containing all navigation titles
		var $items = $('.left_submenu').find('ul');
	
		// Hide contents of every currently non-active menu title
		$items.each(function(){
		
			var $that = $(this);
			$that.parent().hide().parent().height(20);
		});
		
		// Expose the menu which contains the item currently being showed
		$('.left-menu-title-active').parent().next().show().parent().height('100%');
		
		// Bind click event to all navigation item titles
		$items.parent().prev().bind('click', function(e){
		
			var $that = $(this);
			
			// If item on which has been clicked is currently active, no action
			// is necessary
			if($that.hasClass('left-menu-title-active')) return;
			
			// Go through all titles and hide their content
			// If any title has class 'left-menu-title-active' (and one should have it), remove the class
			$items.parent().prev().each(function(){
				
				var $this = $(this),
					$span = $this.find('span');
				
				if($span.hasClass('left-menu-title-active')){ 
					
					$span.removeClass('left-menu-title-active').
					addClass('left-menu-title');
				}
				
				$this.next().hide().parent().height(20);
			});
			
			$that.find('span').addClass('left-menu-title-active');
			$that.next().show().parent().height('100%');
		});
	});
	
})(jQuery);
