﻿jQuery(document).ready(function() {

    //feature section
    $('#hometop_left').cycle({
        fx: 'fade',
		timeout: 10000,
		speed: 750,
        before: onBefore,
        pager: '.pagination',
        pagerAnchorBuilder: function(idx, slide) {
            idxNUM = idx + 1;
            return '<li class="inactive">' + idxNUM + '</li>';
        }
    });

    //stop the cycle if someone clicks on a selector
	$('.pagination .inactive').click(function(){
		$('#hometop_left').cycle('stop');
	});
	
	$('#content_links span').click(function(){
	    $('#content_links span').removeClass('active');
	    $(this).addClass('active');
	    
	    url = "/pages/WhatsNewHelper.aspx?newstype=" + this.id;
	    $('#whats_new_container').fadeOut("2500", function(){$('#whats_new_container').load(url).fadeIn("2500")});

	});
});

//jquery hook called by cycle plugin.  Changes css of active selector
$.fn.cycle.updateActivePagerLink = function(pager, currSlideIndex) {
    $(pager).find('li').removeClass('active')
        .filter('li:eq(' + currSlideIndex + ')').addClass('active');
};

//populate initial carousel information
function onBefore() {
	$('#hometop_inner_right').html($('.hometop_right_temp', this).html());
}
