var mooAnimClass = {};
mooAnimClass = new Class({
	options: {interval:5000,anim:'onSimple',open:0},
	initialize: function(el,options) {
		this.setOptions(options);
		this.open = this.options.open;
		this.contents = new Element('div').injectInside(el);
		this.ul = $E('ul', el);
		this.ul.setStyles({display:'none'});
		this[this.options.anim]();	
			
	},
	anima: function(){
		var liFirst = this.ul.getFirst();
		var liLast = this.ul.getLast();
		this.contents.innerHTML= liFirst.innerHTML;
		liFirst.injectAfter(liLast);	
	},
	onSimple: function(){
		//var liFirst = this.ul.getFirst();
		//alert(liFirst.innerHTML);
		//this.contents.innerHTML="<h3>Mente &amp; Cervello 31 Agosto 2007</h3><h4><a href=\"/rassegna/index/get/last\">Giocattoli per scoprire l\'autismo<br/>Anche il modo di afferrare un sonaglio o lanciare una palla pu indicare se il bambino soffre del disturbo</a></h4>";
		//this.contents.innerHTML='<h3>Mente &amp; Cervello 31 Agosto 2007</h3><h4><a>Giocattoli per scoprire lautismo<br/>Anche il modo di afferrare un sonaglio o lanciare una palla pu indicare se il bambino soffre del disturbo</a></h4>';
		this.contents.innerHTML='<a>Mente &amp; Cervello 31 Agosto 2007</a>';
		//this.contents.innerHTML=liFirst.innerHTML;
		
		//this.anima();
		//this.onSimple.delay(this.options.interval, this);
	},
	onSlide: function(){
		if(!this.slide)
			this.slide = new Fx.Slide(this.contents, {onComplete: this.onSlide.bind(this), duration: 500, wait: false});
		if (this.open){
			this.slide.slideOut.delay(this.options.interval, this.slide);
		}else{
			this.anima();
			this.slide.slideIn();
		}
		this.open = (this.open) ? 0 : 1;
	},
    onFade: function(){
		if(!this.fade)
			this.fade = new Fx.Style(this.contents, 'opacity',{onComplete: this.onFade.bind(this), duration: 500});
		if (this.open){
			this.fade.start.delay(this.options.interval,this.fade,0);
		}else{
			this.anima();
			this.fade.start(1);
		}
		this.open = (this.open) ? 0 : 1;
    }
});
mooAnimClass.implement(new Options);

function mooAnim(parent){
	var arEl = $ES('.mooAnim',(parent || document));
	$each(arEl, function(el){
		var options = {};
		if (el.title) options = $merge(options, Json.evaluate(el.title));
		el.setProperty('title', '');
		new mooAnimClass(el,options);
	},this);
}
mooTag.extend([mooAnim]);
