// 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( $ ){
	
	/**
	 * No need to have only one element in view, you can use it for slideshows or similar.
	 * In this case, clicking the images, scrolls to them.
	 * No target in this case, so the selectors are absolute.
	 */
	
	$('#slideShow').serialScroll({
                items:'li',
		prev:'#buttons a.prev',
		next:'#buttons a.next',
		offset:0, //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:true,
		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: false, //click on the images to scroll to them

                onBefore:function( e, elem, $pane, $items, pos ){
			/**
			 * 'this' is the triggered element
			 * e is the event object
			 * elem is the element we'll be scrolling to
			 * $pane is the element being scrolled
			 * $items is the items collection at this moment
			 * pos is the position of elem in the collection
			 * if it returns false, the event will be ignored
			 */
                         var stopScrolling = $items.length - pos;
                         
                         if(stopScrolling==3){
                            elem.trigger( 'stop' );
                            //elem..trigger( 'prev' );
                            //elem.trigger( 'next' );
                            //elem.trigger( 'goto', [ 3 ] );
                            //elem.trigger( 'start' );
                            //elem.trigger( 'stop' );
                            //elem.trigger( 'notify', [ 4 ] );
                         }
			 //those arguments with a $ are jqueryfied, elem isn't.
			//e.preventDefault();
			//if( this.blur )
			//	this.blur();
		}

	});

        $('#partners').cycle({
            fx:    'fade',
            speed:  2500
        });

        

});
