var Ticker = new Class({
	initialize: function(element, options) {
		this.setOptions({
			"fxDuration": 500,
			"interval": 2000,
			"fxMin": 0,
			"fxMax": 0.99,
			"fxType": "opacity",
			"fxTransition": Fx.Transitions.linear,
			"mouseStop": true
		}, options);
		this.count = 1;
		this.tickerOver = false;
		
		this.currentIndex = 0;
		this.tickerElement = $(element);
		this.els = this.tickerElement.getChildren();
		
		if(this.els.length <= 1) {
			return;
		}
		this.els.each(function(el, index){
			if(index > 0){
				this.els[index].setStyle("display","none");
			}
		}.bind(this));
		
		if(this.options.mouseStop){
			this.tickerElement.addEvent("mouseover",function(){this.tickerOver = true;}.bind(this));
			this.tickerElement.addEvent("mouseout",function(){this.tickerOver = false;}.bind(this));
		}

		this.tEffect = new Fx.Style(
		this.tickerElement, 
		this.options.fxType, 
		{
			"duration":this.options.fxDuration,
			"transition":this.options.fxTransition,
			"onComplete":function() {
				if(this.tEffect.to == 0) {
					this.els[this.currentIndex].setStyle("display","none");
					this.currentIndex = this.count;
					this.els[this.count].setStyle("display","block");
					this.tEffect.start(this.options.fxMin, this.options.fxMax);
					this.count++;
				}
			}.bind(this)
		});
		
		this.tick.periodical(this.options.interval, this);
	},
	
	tick: function() {
		if (!this.tickerOver) {
			if (this.count < this.els.length) {
				this.tEffect.start(this.options.fxMax,this.options.fxMin);			
			} else {
				this.count = 0;
				this.tick();
			}
		}
	}

});

Ticker.implement(new Options);