$(document).ready(function() {
	lastPager = $('#pager1');
	$('#pager1').click(function(e){
		animatePager($(this), 0); 
		$('#cycle').cycle(0); 
	});
	$('#pager2').click(function(e){ 
		animatePager($(this), 101); 
		$('#cycle').cycle(1); 
	});
	$('#pager3').click(function(e){ 
		animatePager($(this), 202); 
		$('#cycle').cycle(2); 
	});
	function animatePager(pager, height)
	{
		if(!pager.hasClass('active'))
		{
			$('#pager_active').css({'margin-top':height+'px'});
			pager.addClass('active');
			lastPager.removeClass('active');
			lastPager = pager;
		}
	}
	function onAfter(curr, next, opts) {
		var index = opts.currSlide;
		if(index == 0) { animatePager($('#pager1'), 0); }
		if(index == 1) { animatePager($('#pager2'), 101); }
		if(index == 2) { animatePager($('#pager3'), 202); }
	}
	$('#cycle').cycle({ 
		fx:      'scrollDown', 
		speed: 1000,
		fastOnEvent: 250,		
		timeout: 10000,
		pause: true,
		after: onAfter,
		cleartype: false
	});
});