var Ticker = Class.create();
Ticker.prototype = {
	messages: new Array(),
	counter: 0, interval: 0,
	target: null, source: null,
	initialize: function(target, source, options){
		this.target = $(target); 
		this.source = $(source);
		this.options = Object.extend({
			updateRate: 4, 
			duration: 0.5,
			beforeStart:function(){ 
				this.counter++;
			}.bind(this) 
		}, options || {});
		
		Element.cleanWhitespace(this.source);
		$A($(this.source).childNodes).each(function(sel) {
			this.messages.push(sel.innerHTML.strip());
		}.bind(this));
		
		this.start();
	},
	appear: function(){
		this.target.update('<ul><li>' + this.messages[this.counter] + '</li></ul>');
		Element.setOpacity(this.target.firstChild, 0);
		new Effect.Appear(this.target.firstChild, this.options);
		if (this.counter == this.messages.length){ this.counter = 0;}
	},
	start: function(){
		window.setTimeout(this.appear.bind(this), 500); // for the first time! setTimeout--opera fix!
		this.interval = new PeriodicalExecuter(this.appear.bind(this), this.options.updateRate);
	},
	stop: function(){
		this.interval.stop();
	}
};