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.parts = 2;
        this.options = Object.extend({
			updateRate: 10
		});
		
		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())*this.parts + 'px',
    		duration: 4,
    		afterFinish: function(){
	    		for(i=0;i<this.parts;i++){
	    			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);
    }
});
