headerLoop = new Class({

	Implements:				[Options,Events],
	
	options: {
		interval:			5000,
		tween:				{ duration: 500 }
								
	},
	
	initialize: function(elements,options){
		this.setOptions(options);
		this.elements = $A(elements);
		this.current = this.elements.getRandom();
		this.current.removeClass('hidden');
		this.hideCurrent.delay(this.options.interval,this);
	},
	
	hideCurrent: function(){
		var options = $merge({
				onComplete: function() {
					this.current.addClass('hidden');
					this.showNext();
				}.bind(this)
			},
			this.options.tween);
		new Fx.Tween(this.current, options).start('opacity', 1, 0);
	},
	
	showNext: function() {
		this.current = this.elements.getRandom();
		var options = $merge({
				onComplete: function() {
					this.hideCurrent.delay(this.options.interval, this);
				}.bind(this)
			},
			this.options.tween);
		this.current.setStyle('opacity', 0);
		this.current.removeClass('hidden');
		new Fx.Tween(this.current, options).start('opacity', 0, 1);
	}
	
});
