Ext.ux.Banner = (function(){

return{
	
		currentNews : '',
		interval	: 5000,
		
		prepareNews : function(){
			var tabNews = Ext.select('.CMS_BLOG_teaser').elements;
	
			Ext.each(tabNews, function(item, index){
				item.id = 'CMS_BLOG_teaser-'+index;
				Ext.get(item.id).addClass('menu_news-'+index);
			});
			
			$('#CMS_BLOG_teaser-0').fadeIn(3000);
			this.currentNews = 0;
			this.launchAnim();
		},
		
		doFade : function(){
			$('#CMS_BLOG_teaser-'+this.currentNews).fadeOut(3000);
			this.currentNews = parseInt(this.currentNews) + 1;
			
			if(!Ext.get('CMS_BLOG_teaser-'+this.currentNews)){
				this.currentNews = 0;
			}
		
			$('#CMS_BLOG_teaser-'+this.currentNews).fadeIn(3000);
			this.launchAnim();
		},
		
		launchAnim : function(){
			setTimeout("Ext.ux.Banner.doFade()", this.interval);
		},

		init: function(){
			this.prepareNews();
		}
	};
	
})();

Ext.onReady(Ext.ux.Banner.init, Ext.ux.Banner);

