﻿News = {
	incr:0,
	total:null,
	target: 'target',
	
	init:function(){
		try {			News.total=document.getElementsByClassName('newshome').length;
		}
		catch(e) {}
		
		if (News.total > 0)
			News.show()
		else
			$('lastnews').innerHTML='Non sono presenti news';
	},
	
	fade:function(){
		new Effect.Opacity (News.target+News.incr, {from:1.0, to:0, duration:1.0, afterFinish:function(){
			$(News.target+News.incr).style.display='none';
			News.incr++;
			News.show();
		}});
	},
	
	show:function(){
		if (News.incr < News.total){
			new Effect.Appear(News.target+News.incr, {duration:1.0, afterFinish:function(){
				if (News.total > 6)
					setTimeout("News.fade()", 5000);
			}});
		} else {
			News.incr=0;
			News.show();
		}
	}	
}






Event.observe(window, 'load', function(){
	News.init();
});

