jQuery(function( $ ){
	
	/**
	 * Restart the scroll position to ( 0, 0 ) (Firefox doesn't reset it)
	 * could use $(target).scrollTo( 0, {axis:'xy'));
	 * but this needs to be quick(synchronous), to reset before $.localScroll.hash() begins
	 */
	$().attr({scrollTop:0,scrollLeft:0});
	
	// Scroll initially if there's a hash (#something) in the url 
	$.localScroll.hash({
		axis:'x',//the default is 'y'
		duration:1000,
		offset:-20
	});
	
	var $last = $([]);//save the last link
	
	/**
	 * NOTE: I use $.localScroll instead of $('#navigation').localScroll() so I
	 * also affect the >> and << links. I want every link in the page to scroll.
	 */
	$.localScroll({
		axis:'x', //the default is 'y'
		duration:1000,
		offset:-20,
		hash:true,
		onBefore:function( e, anchor, $target ){//'this' is the clicked link
			$last.removeClass('scrolling');
			$last = $(this).addClass('scrolling');
			if( this.blur )
				this.blur();//remove the awful outline
		},
		onAfter:function( anchor ){
			$last.removeClass('scrolling');
		}
	});
});


$(function ($)
{
	('#biographie').jScrollPane({});
	
	$('#concerts').jScrollPane({});
	$('#musiciens').jScrollPane({});
	$('#livredor').jScrollPane({});
	$('#presse').jScrollPane({});
	$('#partenaires').jScrollPane({});


// set up the links internes
				$('a.scrollInterneTo').bind(
					'click',
					function()
					{
						$this = $(this);
						var destinationSelector = $(this).attr('rel');
						$('.scrollTexte', document).each(
							function()
							{
								this.scrollTo(destinationSelector);
							}
						);
						return false;
					}
				);


});
