var ticker = new Class({
				
	Implements: [Options],
	options: {
		interval: 10000,
		container: 'newsticker'
	},
	
	initialize: function(options,container) {
		this.setOptions(options);
		this.container = $(this.options.container).getElements('div.quote');		
		this.current = 0;
		this.messages = 0;
		this.startTick();	
	},
	startTick: function() {		
		this.container.each(function(item) {
			item.setStyles({
				display: 'none',
				opacity: 0
			});
		});
		this.onTick();
	},
	onTick: function() {
		if(this.messages==0) {
			var fx = new Fx.Tween(this.current_item);
			if (this.current_item) {
				var self = this;
				fx.start('opacity', 0).chain(function() {
					this.set('display', 'none');
					this.callChain();			
				}).chain(function() {					
					self.current_item = self.container[self.current%self.container.length];
					self.current_item.setStyles({display: 'block'});
					self.current_item.tween( 'opacity', 1);
					self.current_title = self.current_item.innerHTML;
					self.current++;
					self.myTick();
				});
			} else {
				this.current_item = this.container[this.current%this.container.length];
				this.current_item.setStyles({display: 'block'});
				this.current_item.tween( 'opacity', 1);
				this.current_title = this.current_item.innerHTML;
				this.current++;
				this.myTick();
			}
		}
	},
	myTick: function() {
		setTimeout(this.onTick.bind(this),this.options.interval);		
	}
});
			
