$(document).ready(function(){
	$('#left_pane h6').each(function(i){
		if(i!=0){
			$(this).next().hide();
			$(this).attr('class','closed');
		}
		$(this).click(function(){
			if ($(this).hasClass('opened'))
				return;

			$('#left_pane h6.opened').each(function(){
				$(this).attr('class','closed');
				$(this).next().slideUp();
			});
			
			$(this).attr('class','opened');
			$(this).next().slideDown('slow');
			
			$('#left_pane .scrollable').jScrollPane({animateTo:true, showArrows:true, scrollbarWidth:14, scrollbarOnLeft:true});

		});
	});
	
	$('.scrollable').jScrollPane({
		animateTo:true,
		showArrows:true,
		scrollbarWidth:14,
		scrollbarOnLeft:true,
		dragMinHeight:24,
		dragMaxHeight:24
	});
	
	$('#left_pane li a').click(function(event){
		var target = $('#right_pane a[name='+$(this).attr('href').replace('#','')+']');
		var cont = $('#right_pane .scrollable');
		var p = target.parent();
		var h = parseInt(p[0].offsetTop);
		cont[0].scrollTo(h);

		event.preventDefault();
	});
});

