// 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( $ ){
				
	var $prev = $('#prev'),//prev button
		$prev2 = $('#prev2'),//prev button
		$next = $('#next');//next button
		$next2 = $('#next2');//next button
		
	$next.show();
	$next2.hide();
		
	$('#screen').serialScroll({
							  
		target:'#sections',
		items:'li', // Selector to the items (relative to the matched elements, '#sections' in this case) Ej. items:'div.pags'
		prev:'img.prev',// Selector to the 'prev' button (absolute!, meaning it's relative to the document)
		next:'img.next',// Selector to the 'next' button (absolute too)
		axis:'xy',// The default is 'y' scroll on both ways
		step:1, //how many elements to scroll on each action
		duration:700,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
		navigation:'#cajathumbs li a', // links separados
		force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
		cycle:false,
		start: 0,
		
		onBefore:function( e, elem, $pane, $items, pos ){
			
			/* Oculto los botones cuando se llega al final o principio */
			$prev.add($next).show();
			$prev2.hide(); /* oculto el boton2 previos */
			$next.show(); /* muestro el boton2 previos */
			
			if(( pos == 0 ) && ($items.length > 1)){	
				$prev.hide();
				$prev2.show();
				$next.show();
				$next2.hide();
			}else if( pos == $items.length-1 ){
				$next.hide();
				$next2.show();
			}else if(( pos > 0 ) && ( pos != $items.length-1 )) {
				$next2.hide();
				$next.show();
			}
			
			e.preventDefault();
			if( this.blur )
				this.blur();
		},
		onAfter:function( elem ){
			//'this' is the element being scrolled ($pane) not jqueryfied
		}
	});

});