news = new EAST_END_NEWS();
$(document).ready(news.init);


function EAST_END_NEWS() {
	
	
	this.init = init;
	function init() {
		
		news_curIndex = 0;
		news_fadeDuration = 2;
		news_container = $('#news-items');
		news_timer = 0;
		headlines = $('.news-item').get();
		
		if ( headlines.length > 1 )
			scrollNews();
		
	} // init
	
	
	function nextHeadline() {
		var news_prevIndex = news_curIndex;
		news_curIndex = (news_curIndex + 1) % headlines.length;
		
		if ( ! news_curIndex ) {
			news_container.fadeOut(250);
			setTimeout(function() { news_container.css({'top':'0px'}).delay(500).fadeIn(); }, 500);
		}
		else
			news_container.animate({'top':'-=18px'});
		
	} // next
	
	function scrollNews() {
		if ( headlines.length ) {
			clearInterval(news_timer);
			news_timer = setInterval(nextHeadline, 5000);
		}
	} // play
	
} // EAST_END
