jQuery(function( $ ){
	/**
	 * Most jQuery.localScroll's settings, actually belong to jQuery.ScrollTo, check it's demo for an example of each option.
	 * @see http://demos.flesler.com/jquery/scrollTo/
	 * You can use EVERY single setting of jQuery.ScrollTo, in the settings hash you send to jQuery.LocalScroll.
	 */
	
	/**
	 * 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
	 */
	 
	 $.easing.elasout = function(x, t, b, c, d) {
			var s=1.70158;var p=0;var a=c;
			if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
			if (a < Math.abs(c)) { a=c; var s=p/4; }
			else var s = p/(2*Math.PI) * Math.asin (c/a);
			return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
		};

	$('#content2').attr({scrollTop:50,scrollLeft:50});
	$('#content3').attr({scrollTop:50,scrollLeft:50});
	
	$('#service-list').click(function(e){
		e.preventDefault();
		var link = e.target;
		link.blur();
	});
	$('#portfolio-list').click(function(e){
		e.preventDefault();
		var link = e.target;
		link.blur();
	});

	
	$.scrollTo.defaults.axis = 'xy'; 			
	//this one is important, many browsers don't reset scroll on refreshes
	$('div#content2').scrollTo( 0 );//reset all scrollable panes to (0,0)
	$('div#content3').scrollTo( 0 );
	$.scrollTo( 0 );//reset the screen to (0,0)
	
	//TOC, shows how to scroll the whole window
	$('div.nav a').click(function(){//$.scrollTo works EXACTLY the same way, but scrolls the whole screen
		$.scrollTo( this.hash, 1800, {offset: {top:-88, left:0} } );
		//$(this.hash).find('span.message').text( this.title );
		return false;
	});
	
	//TOC, shows how to scroll the whole window
	$('div.bottom-left a').click(function(){//$.scrollTo works EXACTLY the same way, but scrolls the whole screen
		$.scrollTo( this.hash, 1800, {offset: {top:-88, left:0} } );
		//$(this.hash).find('span.message').text( this.title );
		return false;
	});

	var $paneTarget = $('#content2');
	
	$('#link-service-web').click(function(){
		var $target = $paneTarget.find('#service-web');
		$paneTarget.stop().scrollTo( $target , 800 );
	});
	
	$('#link-service-photo').click(function(){
		var $target = $paneTarget.find('#service-photo');
		$paneTarget.stop().scrollTo( $target , 800 );
	});
	
	$('#link-service-video').click(function(){
		var $target = $paneTarget.find('#service-video');
		$paneTarget.stop().scrollTo( $target , 800 );
	});
	
	$('#link-service-prod').click(function(){
		var $target = $paneTarget.find('#service-production');
		$paneTarget.stop().scrollTo( $target , 800 );
	});
	
	$('#link-service-print').click(function(){
		var $target = $paneTarget.find('#service-print');
		$paneTarget.stop().scrollTo( $target , 800 );
	});

	var $paneTarget2 = $('#content3');
	
	$('#link-portfolio-web').click(function(){
		var $target = $paneTarget2.find('#portfolio-web');
		$paneTarget2.stop().scrollTo( $target , 800 );
	});
	
	$('#link-portfolio-photo').click(function(){
		var $target = $paneTarget2.find('#portfolio-photo');
		$paneTarget2.stop().scrollTo( $target , 800 );
	});
	
	$('#link-portfolio-video').click(function(){
		var $target = $paneTarget2.find('#portfolio-video');
		$paneTarget2.stop().scrollTo( $target , 800 );
	});
	
});

/*
	$('#service-list a').click(function(){//$.scrollTo works EXACTLY the same way, but scrolls the whole screen
		$.scrollTo( this.hash, 1800, {offset: {top:-35, left:0} } );
		//$(this.hash).find('span.message').text( this.title );
		return false;
	});
// Scroll initially if there's a hash (#something) in the url 
	$.localScroll.hash({
		target: '#content2', //could be a selector or a jQuery object too.
		axis:'xy',//the default is 'y'
		queue:true,
		duration:1500
	});
	
	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.
	 
	$('#service-list').localScroll({
		target: '#content2', //could be a selector or a jQuery object too.
		axis:'xy', //the default is 'y'
		queue:true,
		duration:1000,
		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');
		}
	});
	
*/