var Ticker = Class.create({
    initialize: function(tempHolder, tempTarget, tempSource, tempClass) {

    	this.interval = 0;	
        this.target = $(tempTarget);
		this.source = $(tempSource);
		this.className = tempClass;
    	this.titles = $$('.'+this.className+' li');
        this.options = Object.extend({
			updateRate: 3
		});
		
		width = 0;
		this.titles.each(function(el){
			width+= el.getWidth();
		});
		
    	if(width > $(tempHolder).getWidth()){
			this.start();
    	}
    },
    start: function() {
    	this.effect();
		this.interval = new PeriodicalExecuter(function() {
	    	this.effect();
		}.bind(this), this.options.updateRate);
    },
    effect: function() {
    	
    	var options = Object.extend({
    		style: 'left: -' + this.titles[0].getWidth() + 'px',
    		duration: 2,
    		afterFinish: function(){
    			var li = new Element("li");
    			li.innerHTML = this.titles[0].innerHTML;
    			$(this.source).insert(li);

				$(this.target).setStyle('left: 0px');
				$(this.titles[0]).remove();
				
    			this.titles = $$('.'+this.className+' li');
				
	    	}.bind(this)
    	});
    	new Effect.Morph(this.target,options);
    }
});