var hockeyTas_news = {
	initCallback: function(carousel){
		// Disable autoscrolling if the user clicks the prev or next button.
		carousel.buttonNext.bind('click', function() {
			carousel.startAuto(0);
		});
		carousel.buttonPrev.bind('click', function() {
			carousel.startAuto(0);
		});    

		// Pause autoscrolling if the user moves with the cursor over the clip
		carousel.clip.hover(function() {        
			carousel.stopAuto();
		}, function() {        
			carousel.startAuto();
		});    		

		// Enable the index to change the focused item
		$('#newsHeadlines a').bind('click', function() {
			carousel.scroll($.jcarousel.intval($(this).attr('rel')));
			return false;
		});
	},		
	itemChanged: function(carousel, item, index, state) {
		$('#newsHeadlines .selectedItem').removeClass('selectedItem');
		$('#newsHeadlines li').eq(index-1).addClass('selectedItem');			
	},
	recordOutboundLink : function (link, category, action) {
		_gat._getTracker("UA-485652-1")._trackEvent(category, action);
		setTimeout('document.location = "' + link.href + '"', 100);
	}
}

$(document).ready( function() {
	$('#newsArticles').jcarousel({
		scroll: 1, auto: 5, wrap: 'last',
		initCallback: hockeyTas_news.initCallback,
		itemFirstInCallback: hockeyTas_news.itemChanged });
		
	$('ul.fileList li.FileItem a').click( function() {
		var that = $(this);
		hockeyTas_news.recordOutboundLink(this, 'Download', that.attr('title'));
		return false;
	});
});

