jQuery(function( $ ){

	/**
	 * Demo binding and preparation, no need to read this part
	 */
	//borrowed from jQuery easing plugin
	//http://gsgd.co.uk/sandbox/jquery.easing.php

	$(document).ready(function() {
	
		// Stops the click on the links
		$('div.prevnext').click(function(e){
			e.preventDefault();
			var link = e.target;
			link.blur();
		});
	
		// MAIN MENU
		// Scrolls the whole window
		$('#mainmenu a').click(function(){
			$.scrollTo( this.hash, 2000, { easing:'swing' });
			$(this.hash).find('span.message').text( this.title );
			return false;
		});
	
		// WORK GALLERY
		// Scrolls the whole window
		var $paneTargetWork = $('#workslider');
	
		$('#work-next').click(function(){
			$paneTargetWork.stop().scrollTo( '+=240', 1000, {axis:'x'} );
			return false;
		});
	
		$('#work-prev').click(function(){
			$paneTargetWork.stop().scrollTo( '-=240', 1000, {axis:'x'} );		
			return false;
		});
	
	
		// PEOPLE GALLERY
		// Scrolls the whole window
		var $paneTargetPeople = $('#peopleslider');
	
		$('#people-next').click(function(){
			$paneTargetPeople.stop().scrollTo( '+=720', 1000, {axis:'x'} );
			return false;
		});
	
		$('#people-prev').click(function(){
			$paneTargetPeople.stop().scrollTo( '-=720', 1000, {axis:'x'} );		
			return false;
		});
	
	
	
	
		
		// This one is important, many browsers don't reset scroll on refreshes
		// Reset all scrollable panes to (0,0)
		$('div#wrapper').scrollTo( 0 );
		$('div#workgallery').scrollTo( 0 );
		$('div#peoplegallery').scrollTo( 0 );
		// Reset the screen to (0,0)
		$.scrollTo( 0 );
	
	});

});
