
function Ticker(container) {
	
	this.container = container;
	this.childrenHolder = document.getElementById('TICKER_CHILDREN_HOLDER');
	this.ticking = true;
	this.interval = 33.33;
	this.intervalId = null;
	this.speed = 30;
	this.left = 0;
	var _this = this;
	
	this.container.onmouseover = function(event) {
//		_this.ticking = false;
	}
	
	this.container.onmouseout = function(event) {
//		_this.ticking = true;
	}
	
	this.isSpan = function(item) {
		if(!item || item==null)
			return false;
		try {
			if(item instanceof HTMLSpanElement)
				return true;
		} catch (e) {}
		try {
			if(item.nodeType == 1 && (item.tagName == 'span' || item.tagName == 'SPAN'))
					return true;
		} catch (e) {}
		return false;
	}
	
	this.isDiv = function(item) {
		if(!item || item==null)
			return false;
		try {
			if(item instanceof HTMLDivElement)
				return true;
		} catch (e) {}
		try {
			if(item.nodeType == 1 && (item.tagName == 'div' || item.tagName == 'DIV'))
					return true;
		} catch (e) {}
		return false;
	}
	
	this.animate = function() {
		if(_this.ticking) {
			_this.left += _this.diff;
			_this.container.scrollLeft = parseInt(_this.left);
			if(true) {
				var children = _this.childrenHolder.childNodes;
				var child = null;
				for(var i=0;i<children.length;i++) {
					child = children[i];
//					alert(_this.isSpan(child) + " " + child.offsetWidth + " " + _this.isDiv(child) + " " + child.offsetWidth);
					if(_this.isSpan(child) && child.offsetWidth > 0 || _this.isDiv(child) && child.offsetWidth > 0)
						break;
				}
				if(child && child.offsetWidth && child.offsetWidth<_this.left - 4) {
//					alert('remove'+child.innerHTML);
					_this.left -= child.offsetWidth + 4;
					_this.childrenHolder.removeChild(child);
//					alert(_this.childrenHolder.innerHTML);
					_this.container.scrollLeft = parseInt(_this.left);
					if(!_this.isDiv(child)) {
						_this.childrenHolder.appendChild(child);
						_this.childrenHolder.innerHTML += " ";
					}
				}
			}
		}
		_this.intervalId = setTimeout(_this.animate, _this.interval);
	}
	
	this.startAnimation = function() {
		_this.diff = _this.speed*_this.interval/1000;
		this.intervalId = setTimeout(this.animate, this.interval);
	}
	
	this.init = function() {
		this.startAnimation();
	}
	
	if(this.container && this.container!=null)
		this.init();
	
}
