/**
 * We use the initCallback callback
 * to assign functionality to the controls
 */
function mycarousel_initCallback(carousel) {
	jQuery('#mycarousel-next').bind('click', function() {
		carousel.next();
		return false;
	});
	jQuery('#mycarousel-prev').bind('click', function() {
		carousel.prev();
		return false;
	});
};

function onAfter() { 
	var i = $('#homelinknav a.activeSlide').text()-1;
	if (i==0)
	  {i=1}
	else if (i==1)
	  {i=2}
	else if (i==2)
	  {i=0}
	$('#homepagelinks ul a').eq(i).addClass('active');
}

function onBefore() { 
	$('#homepagelinks ul a').removeClass('active');
}

// Ride the carousel...
jQuery(document).ready(function() {
	$('.site-intro')
	.before('<div id="homelinknav">')
	.cycle({
		fx:'fade',
		random:false, 
		speed:1000,
		timeout: 6000,
		pause:1,
		pager:'#homelinknav',
		after:onAfter,
		before:onBefore,
		startingSlide:0,
		prev:'#site-intro-prev',
		next:'#site-intro-next'
	});
	//nasty hack that had to be put in because the first in the cycle returns an id of -1 which is a) wrong and b) means I can't highlight the right tab MH
	//$('.site-intro').cycle('next');
});
