var indexFader = new Class({
	initialize: function(ID,divclass,duration){
		cclass=this;
		cclass.dur = duration;
		window.addEvent('domready', function() {
			this.elms = $$('#'+ID+' div.'+divclass);
			this.Many = elms.length-1;
			this.loopforever=1;
			this.CurrentTop = -1;
			if(this.Many>0) cclass.fixloop();
		});
	},
	fixloop:function(){
		var cclass=this;
		setTimeout('cclass.startloop();',cclass.dur);	
	},
	startloop: function(){
		var currentclass= this;
		if(CurrentTop<0) CurrentTop = Many;
		var FadeOver = CurrentTop-1;
		if(FadeOver<0) FadeOver= Many;
		elms[CurrentTop].setStyles({'z-index':'999'});
		elms[FadeOver].setStyles({'z-index':'998'});	
		var fadeOut = new Fx.Morph(elms[CurrentTop],{duration: 1000,onComplete: function () {
        	elms[CurrentTop].setStyle('z-index','1');
			new Fx.Morph(elms[CurrentTop],{duration: 1}).start({opacity : 1}) ; 
			CurrentTop=CurrentTop-1;
			currentclass.fixloop();
        }
        });
		fadeOut.start({opacity : 0}); 
	}
});


var d= new indexFader('inDex','r',6000);
