
$(document).ready(function(){

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

	$('#imagescroller_content').serialScroll({
		items:'div.imagescroller_section',
		//start: 1,
		navigation: $nav,
		prev: 'a.prev',
		next: 'a.next',
		duration: 600,
		force: true,
		stop: true,
		lock: false,
		cycle: true, //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,el,$p,$i,pos){
			$nav.removeClass("active");
			$nav.eq(pos).addClass("active");
		}
		
	});
	
	$('#imagescroller_buttons a').click(function () { 
		$('#imagescroller_buttons a').removeClass("active");
		$(this).addClass("active");
	});
	
	$('a[class^=scrollto]').click(function () { 
		var scrollno = parseInt($(this).attr('class').replace('scrollto','')) - 1;
		$('#imagescroller_content').trigger( 'goto', [ scrollno ] );
	});
	
});

