$(document).ready( function() {
	// sidebar menu
	var $sel = $('.col-sidebar .sidebar-menu');
	
	if ( $sel.length ) {
		var $links = $sel.find('ul.l1 li.l1 a');
		var $otherMenus = $sel.find('ul.l1 li.l1 ul.l2');
		
		$otherMenus.hide();
		
		$links.each( function( index ) {
			var $thisMenu = $(this).siblings('ul.l2');
			
			if ( $thisMenu.children('li').length ) {
				$(this).addClass( 'js' );
			
				$(this).click( function() {				
					if ( !$thisMenu.is(':visible') ) {
						$thisMenu.slideDown();
						$otherMenus.not( $thisMenu ).slideUp();
					}
					
					return false;
				});
			}
		});
		
		// Showing first item or item with 'current' class if there's any
		var $currentMenu = $otherMenus.filter('.current' );
		
		if ( $currentMenu.length ) {
			$currentMenu.show();
		} else {
			$otherMenus.filter(':first').show();
		}
	}
});
