function Ticker(target, speed) {
	var ref = this;
	this.target = target;
	this.target.mouseover(function() { ref.pause = true; });
	this.target.mouseout(function() { ref.pause = false; });
	this.startingX = parseInt(this.target.css("left"));
	if (typeof(speed) != "undefined") {
		this.speed = parseInt(speed);
	}
}
Ticker.prototype = {
	pause: false,
	target: null,
	startingX: 0,
	speed: 2,
	move: function() {
		if (!this.pause) {
			var left = parseInt(this.target.css("left"));
			if (left < -this.target.width()) {
				left = this.startingX;
			} else {
				left -= this.speed;
			}
			this.target.css("left", left + "px");
		}
	},
	start: function() {
		setInterval(delegate(this, this.move), 30);
	}
}

function delegate( that, thatMethod )
{
  return function() { return thatMethod.call(that); }
}

$(document).ready(function() {
	$("div.ticker").each(function() {
		var body = $(this).find("div.ticker-body");
		var clone = body.clone();
		$(this).append(clone);
		
		var firstTicker = new Ticker(body);
		firstTicker.start();
		
		var secondTicker = new Ticker(clone);
		setTimeout(function() { secondTicker.start(); }, 10000);
	});	
});
