var newsManager = {
		
	currentItem : 0,
	
	itemsNumber : 0,
	
	changeDelay : 3000,
	
	collection : {},
	
	changeNewsItem : function ()
	{
		var itemIndexToShow;
		if(this.currentItem == this.itemsNumber)
			itemIndexToShow = 1;
		else
			itemIndexToShow = this.currentItem + 1;
		
		var jqIndex = this.currentItem - 1;
		if(jqIndex >= 0){
			this.collection.eq(jqIndex).fadeOut('normal', function(){
				jqIndex = itemIndexToShow - 1;
				newsManager.showItem(jqIndex);
				newsManager.currentItem = itemIndexToShow;
			});
		}
		else{
			jqIndex = itemIndexToShow - 1;
			newsManager.showItem(jqIndex);
			newsManager.currentItem = itemIndexToShow;
		}	
		
	},
	
	showItem : function (index)
	{
		this.collection.eq(index).show('slide',  {direction: 'right'});
	},
	
	setup : function (delay)
	{
		
		this.collection = $('.newsFlashContainer').find('p.newsFlashText');
		this.itemsNumber = this.collection.length;
		this.currentItem = 1;
		this.changeDelay = delay;
		this.collection.eq(this.currentItem - 1).show();
		setInterval('newsManager.changeNewsItem()', this.changeDelay);
	}
}
$(function(){
	
	//delay in milliseconds
	newsManager.setup(5000);

});
