var Banner = new Class({

	Implements				: Options,
	
	options					:
	{
		'speed'					: 30000
	},
	
	initialize				: function(wrapper,banner,options)
	{
		this.setOptions(options);
		this.elements			= $(banner).getElements('div');
		this.count				= this.elements.length;
		this.view				= $(wrapper).getSize();
		this.current			= 0;
		this.tween				= new Fx.Tween($(banner),{'duration' : this.options.speed});
		//Calc elements
		this.calculate();
		//Loop text
		this.run();
	},
	
	calculate				: function()
	{
		this.elements.each(function(element){
			var size = element.getSize();
			element.setStyle('width',size.x + 10);
		});
	},
	
	run						: function()
	{
		if (this.current == this.count) this.current = 0;
		this.elements.setStyle('visibility','hidden');
		var el 		= this.elements[this.current];
		el.setStyle('visibility','visible');
		var size	= el.getStyle('width');
		this.tween.set('left',this.view.x);
		this.tween.start('left','-' + size + 'px').chain(function(){
			this.current++;
			this.run();
		}.bind(this));
	}

});
