Ticker = new Class({
	rotators: [],
	tops: [],
	counter: 0,
	element_height: null,
	paused: false,
	
	initialize: function(container, element_height)
	{
		this.element_height = element_height;		
		
		window.addEvent('load', function() {
			this.tops[0] = 0;			
			this.tops[1] = $(container).getFirst().getStyle('height').toInt();
			this.rotators.include($(container).getFirst());
			this.rotators.include(new Element('div', {
				styles: {
					position: 'absolute',					
					top: this.tops[1] 
				}
			}).inject($(container)));
			
			this.rotate.periodical(30, this);
			
			$(container).addEvents({
				mouseover: function() { this.paused = true; }.bind(this),
				mouseout: function() { this.paused = false; }.bind(this)
			});			 
		}.bind(this));	
	},		
	
	rotate: function()
	{
		if(this.paused) return;
		
		this.counter++;											
		
		if(this.rotators[0].getChildren().length == 0)
		{
			var rot = this.rotators[0];		
			this.rotators[0] = this.rotators[1];
			this.rotators[1] = rot;
			this.tops[0] = this.tops[1];			
			this.tops[1] = this.rotators[0].getStyle('height').toInt();						  
		}											
		else
		{
			if(this.counter > this.element_height)
			{
				this.counter = 0;
				this.rotators[0].getFirst().inject(this.rotators[1]);
				this.tops[0] += this.element_height;			
			}
			
			this.rotators[0].style.top = this.tops[0]-- + 'px';
			this.rotators[1].style.top = this.tops[1]-- + 'px';
		}
	}
});
