// News ticker rotation scripts
$(document).ready(function() {

	var headlines = '';
	var counter = 0;
	
	$.getJSON('/newsTicker.php', function(links){ 

		var numItems = links.length-1;	
		var idx = 0;
		
		$('#news_ticker').html( links[idx] );
		
		var timer = setInterval( 
			function() { 
				if ( numItems > 1 ) {
				
					if ( idx++ >= numItems ) 
						idx = 0;
						
					$('#news_ticker').fadeOut();
						var startTime = new Date().getTime(); // get the current time
						while (new Date().getTime() < startTime + 350); // hog cpu
					$('#news_ticker').html( links[idx] );
					$('#news_ticker').fadeIn();
				}
			}, 5000
		);
		
	});
	
});

