// 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( $ ){

	

	$(".karta-slideshow li:first").attr("id","first");
	$(".karta-slideshow li:last").attr("id","last");

	$('.karta-slideshow').serialScroll({
		items:'li.ks-li',
		prev:'.buttons a.prev',
		next:'.buttons a.next',
		navigation:'.navigation li a',
		start:0, //as we are centering it, start at the 2nd
		duration:500,
		force:true,
		stop:true,
		lock:false,
		cycle:true,
		easing:'easeOutQuart', //use this easing equation for a funny effect
		jump: true, //click on the images to scroll to them
		onAfter:function( elem ){
			var currentView = $(elem).attr("id");
			
			if ( currentView == "first" ) { 
				$(".button a.prev").fadeOut("fast"); 
			} else { 
				$(".button a.prev").fadeIn("fast"); 
			}
			
			if( currentView == "last" ) { 
				$(".button a.next").fadeOut("fast"); 
			} else { 
				$(".button a.next").fadeIn("fast"); 
			}
		}
	});

});
