var NewsTicker = {
	pause : false,
	speed : 2,
	containerWidth : 516, //it used to be accessed by this.el.offsetWidth but incorrect values in FF3 were returned
	initialize : function () {
		this.el = document.getElementById('ticker');
		
		if (typeof this.el == 'undefined' || !this.el) {
			return;
		}
		
		var img = '<img src="/images/ticker_spacer.gif" width="'+ this.containerWidth+'" height="0" />';
		this.el.innerHTML = "<div>"+img+ this.el.innerHTML +img+"</div>";
		//stop scrolling while hovering over ticker
		$(this.el).hover(
			function(){ //mouse over
				NewsTicker.pause = true;
			},
			function(){ //mouse out
				NewsTicker.pause = false;
			}
		);
		this.scroll();
	},
	scroll : function () {
		
		if( !this.pause ) {
			this.el.scrollLeft += this.speed;
		}
		
		if(this.el.scrollLeft >= this.el.scrollWidth - this.containerWidth) {
			this.el.scrollLeft = 0;
		}
		
		var self = this;
		window.setTimeout( function(){
			NewsTicker.scroll.apply(self);
		}, 30);
	}
};
