var mooSlider = new Class({
	options: {
		'transitionOut': Fx.Transitions.Sine.easeInOut,
		'transitionOutDuration': 1000,
		'waitDuration': 1,
		'accuracy': 0,
		'direction': 'vertical'
	},
	
	initialize: function(box, elements, options){		
		(this.box = $(box)).setStyle('overflow', 'hidden');
		
		this.content = new Element('div').setStyles({
			margin: 0,
			padding: 0
		});
		
		(this.elements = $$(elements)).each(function(element, index) {
			(this.elements[index] = element.clone()).injectInside(this.content);
		}, this);
		
		this.box.empty();
		this.content.injectInside(this.box);
		
		this.setOptions(options);
		if( this.options.direction == 'horizontal' ){
			this.margin = 'margin-left';
		} else {
			this.margin = 'margin-top';
		}
		
		var fxOutOptions = { 
			onStart: Class.empty,
			onComplete: function(){
				this.fElement = this.elements.shift();
				this.elements.push(this.fElement);
				this.fElement.remove();
				this.fElement.injectInside(this.content);
				this.content.setStyle(this.margin, 0);
			}.bind(this),
			transition: this.options.transitionOut,
			duration: this.options.transitionOutDuration, 
			wait: false
		}
		this.fxOut = new Fx.Style(this.content, this.margin, fxOutOptions);
		
		if(this.elements.length > 0){
			this.slide.periodical(this.options.waitDuration, this);
		}
	},
	
	slide: function() {
		if(this.options.direction == 'horizontal'){
			this.fxOut.start((this.elements[0].getSize().size.x + this.options.accuracy)*-1);
		} else{ 
			this.fxOut.start((this.elements[0].getSize().size.y + this.options.accuracy)*-1);
		}
	}
});
mooSlider.implement(new Events, new Options);