$(document).ready(function(){
	$('.splash #flashFeature #splashContent object, .splash #flashContent, .splash #flashFeature').css('display', 'block');
	$("#flashFeature").delay(9000).fadeOut(500);
	$("#flashContent").delay(9000).fadeOut(500);
	//$("#splashFeature").delay(8000).fadeIn(4000);
	$("#splashFeature").animate({opacity: 0, duration: 0}).delay(8500).animate({ opacity: 1, duration: 0});
		
	var $rotateBlock = $('.col-one'),
			$rotateLinks = $('.col-two a.pager');
	
	function onBefore() {
		
		var $this = $(this),
				index = parseInt($this.attr('id').split('-')[1], 10);
				
		$rotateLinks.removeClass('active').eq(index).addClass('active');
		$('#splashFeature').toggleClass('green');
	}
	
	$rotateBlock.cycle({
		fx: 'fade',
		before: onBefore,
		pause: 1,
		delay: 9000,
		timeout: 7000
	});
	
	$rotateLinks.click(function() {
		
		var $this = $(this),
				index = parseInt($this.attr('href').split('-')[1], 10);	
				
		$rotateBlock.cycle(index);
		return false;
	}).hover(function() {
		$rotateBlock.cycle('pause');
	}, function() {
		$rotateBlock.cycle('resume');
	});
	
	
	$('#today', '#starving').click(function(){
		$('#splashFeature').addClass('green');
	});

	$('#today a.pager').attr("href", "#item-0");
	$('#stories a.pager').attr("href", "#item-1");
	$('#starving a.pager').attr("href", "#item-2");
	$('#cares a.pager').attr("href", "#item-3");
});


