var Ticker = new Class({
	initialize: function(element, options) {
		this.setOptions({
			"fxDuration": 500,
			"interval": 2000,
			"fxType": "opacity",
			"fxTransition": Fx.Transitions.linear
		}, options);
		this.count = 1;
		this.tickerOver = false;
		
		this.currentIndex = 0;
		this.theTicker = $(element);
		//this.theTickerScroller = $(element.getProperty("rel"));
		//this.theLIs = this.theTickerScroller.getChildren();
		this.theLIs = $(element).getChildren();
		
		if(this.theLIs.length <= 1) {
			return;
		}
		
		for(i=1;i<this.theLIs.length;i++){
			$(this.theLIs[i]).setStyle("display","none");
		}
		
		this.theTicker.addEvent("mouseover",function(){this.tickerOver = true;}.bind(this));
		this.theTicker.addEvent("mouseout",function(){this.tickerOver = false;}.bind(this));

		this.tEffect = new Fx.Style(
		$(this.theTicker), 
		this.options.fxType, 
		{
			"duration":this.options.fxDuration,
			"transition":this.options.fxTransition,
			"onComplete":function() {
				if(this.tEffect.to == 0) {
					$(this.theLIs[this.currentIndex]).setStyle("display","none");
					this.currentIndex = this.count;
					$(this.theLIs[this.count]).setStyle("display","block");
					this.tEffect.start(0,1);
					this.count++;
				}
			}.bind(this)
		});
		
		this.tick.periodical(this.options.interval, this);
	},
	
	tick: function() {
		if (!this.tickerOver) {
			if (this.count < this.theLIs.length) {
				this.tEffect.start(1,0);			
			} else {
				this.count = 0;
				this.tick();
			}
		}
	}

});

Ticker.implement(new Options);