var Defilement = new Class({
	Implements: [ Options, Chain, Events ],

	defaultOptions: function(){
		return {
			direction: 'left',
			transition: 1000,
			pause: 5000,
			posMin: 10,
			posMax: 200,
		};
	},

	initialize: function(el, options){
		this.defilement = $(el);

		if ($defined(this.defilement))
		{
			this.setOptions(this.defaultOptions(), options);

			this.setup();
			
			this.myTimerDefilement = this.play.periodical(this.options.pause + this.options.transition, this);
		}
	},

	setup: function() {
		this.fx = new Fx.Morph(this.bandeau,{duration:this.options.transition,onComplete:function() {
			if (this.options.direction.toLowerCase() == "left")
				this.options.direction.toLowerCase() = "right";
			else
				this.options.direction.toLowerCase() = "left";
			
		}.bind(this)});

		this.play();
	},
	
	play: function() {
		if (this.options.direction.toLowerCase() == 'left') {
			this.fx.start({
				left: this.options.posMin
			});
		} else if (this.options.direction.toLowerCase() == 'right') {
			this.fx.start({
				left: this.options.posMax
			});
		}
	}
});
