// Easing equation, borrowed from jQuery easing plugin
// http://gsgd.co.uk/sandbox/jquery/easing/
jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};


jQuery(function( $ ){
	

	/**----------------SERIAL-SCROLL----------------*/
	
	/**
	 * The plugin binds 6 events to the container to allow external manipulation.
	 * prev, next, goto, start, stop and notify
	 * You use them like this: $(your_container).trigger('next'), $(your_container).trigger('goto', [5]) (0-based index).
	 * If for some odd reason, the element already has any of these events bound, trigger it with the namespace.
	 */		
	 
	 
	$('#slideshow').serialScroll({
		items:'li',
		prev:'#screen a.prev',
		next:'#screen a.next',
		offset:-250, //when scrolling to photo, stop 230 before reaching it (from the left)
		start:0, //as we are centering it, start at the 2nd
		duration:1200,
		force:false,
		stop:true,
		lock:false,
		cycle:false, //don't pull back once you reach the end
		easing:'easeOutQuart', //use this easing equation for a funny effect
		jump: true, //click on the images to scroll to them
		
		onBefore:function( e, elem, $pane, $items, pos ){
			$('#screen a.prev,#screen a.next').show();
				if( pos == 0 )
					$('#screen a.prev').hide();
				else if( pos == $items.length-1 )
					$('#screen a.next').hide();
		},
		onAfter:function( elem ){
			//'this' is the element being scrolled ($pane) not jqueryfied
		}
	});	
	
	var $prev = $('#content a.prev'),//prev button
		$next = $('#content a.next');//next button
		
	
			 
	$('#sections').serialScroll({
		items:'li', // Selector to the items ( relative to the matched elements, '#sections' in this case )
		prev:'#content a.prev',// Selector to the 'prev' button (absolute!, meaning it's relative to the document)
		next:'#content a.next',// Selector to the 'next' button (absolute too)
		axis:'x',// The default is 'y' scroll on both ways
		start:0, //as we are centering it, start at the 2nd
		duration:800,
		force:true,
		stop:true,
		step:1,
		lock:false,
		cycle:true, //don't pull back once you reach the end
		constant:false
		
		//queue:false,// We scroll on both axes, scroll both at the same time.
		//event:'click',// On which event to react (click is the default, you probably won't need to specify it)
		//stop:false,// Each click will stop any previous animations of the target. (false by default)
		//lock:true, // Ignore events if already animating (true by default)		
		//start: 0, // On which element (index) to begin ( 0 is the default, redundant in this case )		
		//cycle:true,// Cycle endlessly ( constant velocity, true is the default )
		//step:1, // How many items to scroll each time ( 1 is the default, no need to specify )
		//jump:false, // If true, items become clickable (or w/e 'event' is, and when activated, the pane scrolls to them)
		//lazy:false,// (default) if true, the plugin looks for the items on each event(allows AJAX or JS content, or reordering)
		//interval:1000, // It's the number of milliseconds to automatically go to the next
		//constant:true, // constant speed

/*		onBefore:function( e, elem, $pane, $items, pos ){
			$prev.add($next).show();
			if( pos >= 6 )
				$prev.hide();
			else if( pos == $items.length-1 )
				$next.hide();
		},
				onAfter:function( elem ){
				}
*/


		
	});

	
	
});


