var mooScroller = new Class({
	Implements: Options,
	options: {
		auto:false,
		prev:false,
		next:false,
		list:false,
		listselector:'a',
		fx_delay: 600,
		wait: 3800
	},
	initialize: function(el,options){
		this.setOptions(options);
		
		this.container = $(el) || false;
		if(!this.container){ return alert('No se encontró el contenedor con el id '+this.container); }
		
		this.bt_prev = $(this.options.prev) || false;
		this.bt_next = $(this.options.next) || false;
		this.list = $(this.options.list) || false;
		
		if(this.bt_prev) this.bt_prev.addEvent('click',function(){ this.previous(); }.bindWithEvent(this));
		if(this.bt_next) this.bt_next.addEvent('click',function(){ this.next(); }.bindWithEvent(this));
		
		this.panes = this.container.getChildren('div');
		this.total_panes = this.panes.length;
		if(this.list){
			this.listoptions = this.list.getElements(this.options.listselector);
			this.total_options = this.listoptions.length;
			
			if(this.total_panes != this.total_options) { return alert('Numero de paneles ('+this.total_panes+') y Enlaces de la lista ('+this.total_options+') no coinciden ');  }
			
			this.listoptions.each(function(opt,idx){
				opt.addEvent('click',function(){
					this.showPane(idx);
				}.bindWithEvent(this));
			}.bind(this));
		}
		 
		this.current_idx = 0;
		this.fx = new Fx.Tween(this.container,{ property:'opacity', duration:this.options.fx_delay, transition:Fx.Transitions.Quart.easeInOut, link:'chain'});

		this.setCurrent(this.current_idx);
		if(this.options.auto)
			this.next.periodical(this.options.wait,this);

	},
	setCurrent:function(idx){
		this.panes.setStyle('display','none');
		this.current_idx = idx;
		this.panes[idx].setStyle('display','block');
	},
	showPane:function(idx){
		this.fx.start(0).chain(function(){
			this.setCurrent(idx);
			this.fx.start(1);
		}.bind(this));
	},
	previous:function(){ this.showPane(this.current_idx <= 0 ? this.total_panes-1 : --this.current_idx); },
	next:function(){ this.showPane(this.current_idx >= this.total_panes-1 ? 0 : ++this.current_idx); }
	
});