

// get all the pager links from #pager
var titles = new Array();

// Runs on document load
// creates the cycle and cleans up some linking issues
function createCycle(){
	titles = $('#pager a');
	$('#pager').empty();
	$('#slides').cycle({
		fx: 'fade',
		speed: 1000,
		timeout: 5000,
		pager: '#pager',
		pagerEvent: 'mouseover',
		pagerAnchorBuilder: genPagerLinks,
		pause: true,
		pauseOnPagerHover: true,
		fastOnEvent: true
	});
	// Re-grab all the pager links
	t2 = $('#pager a');
	// Loop through the pagers and tell them to REALLY follow the links on click
	for(x=0;x<t2.length;x++){
		$(t2[x]).click(function(){
			var href = $(this).attr('href');
			location.href = href;
		});
	}
}

// Called by pagerAnchorBuilder
// merely return the next pager item from our array, which automagically adds the mouseover event
function genPagerLinks(i, e){
  return titles[i];
}

// put our createCycle function to work
$(document).ready(createCycle);