hTicker = {
	tickerId : 'hTicker',
	tickerFontFamily : 'tahoma',
	tickerFontSize : '11px',
	tickerFontWeight : 'normal',
	tickerFontStyle : 'normal',
	tickerScrollTimeout : 30,
	tickerScrollTimeoutOver : 100,

	_tickerInfoId : 'hTickerInfo',
	_tickerTextId : 'hTickerText',
	_tickerContent : '',
	_tickerWidth : 0,
	_tickerHeight : 0,
	_tickerContainerWidth : 0,
	_tickerScrollTimeoutCurrent : 0,
	_tickerTimeout : null,

	// get element
	_ge : function (el) {
		return document.getElementById(el);
	},

	// get element style
	_gs : function (el) {
		return document.getElementById(el).style;
	},

	// get ticker content
	_setTickerContent : function () {
		var contentHtml = String(this._ge(this._tickerTextId).innerHTML);
		contentHtml = '<nobr>'+ contentHtml + '</nobr>';
		contentHtml = contentHtml.replace(/\n/g, '');
		contentHtml = contentHtml.replace(/\r/g, '');
		this._tickerContent = contentHtml;
	},

	// get ticker text size
	_setTickerSize : function () {
		this._gs(this._tickerTextId).fontFamily = this.tickerFontFamily;
		this._gs(this._tickerTextId).fontSize = this.tickerFontSize;
		this._gs(this._tickerTextId).fontWeight = this.tickerFontWeight;
		this._gs(this._tickerTextId).fontStyle = this.tickerFontStyle;
		this._gs(this._tickerTextId).position = 'absolute';
		this._gs(this._tickerTextId).left = '-9000px';
		this._gs(this._tickerTextId).top = '-1000px';
		this._gs(this._tickerTextId).display = '';
		this._tickerWidth = this._ge(this._tickerTextId).offsetWidth;
		this._tickerHeight = this._ge(this._tickerTextId).offsetHeight;
	},

	// get ticker container size
	_setTickerContainerSize : function () {
		this._ge(this.tickerId).style.height = this._tickerHeight+"px";
		this._tickerContainerWidth = this._ge(this.tickerId).offsetWidth;
	},

	// prepare ticker text element which will be moving
	_prepareTickerTextElement : function () {
		var tickerTextElement = document.createElement('div');
		tickerTextElement.id = this._tickerInfoId;
		tickerTextElement.style.cursor = 'default';
		tickerTextElement.style.position = 'absolute';
		tickerTextElement.style.fontFamily = this.tickerFontFamily;
		tickerTextElement.style.fontSize = this.tickerFontSize;
		tickerTextElement.style.fontWeight = this.tickerFontWeight;
		tickerTextElement.style.fontStyle = this.tickerFontStyle;
		tickerTextElement.style.left = '0px';
		tickerTextElement.style.top = '0px';
		tickerTextElement.style.display = 'none';

		tickerTextElement.innerHTML = this._tickerContent;
		return tickerTextElement;
	},

	// prepare ticker container element
	_prepareTickerElement : function (textElement) {
		this._gs(this.tickerId).position = 'relative';
		this._gs(this.tickerId).overflow = 'hidden';
		this._gs(this.tickerId).height = this._tickerHeight + 'px';
		this._ge(this.tickerId).innerHTML = '';
		this._ge(this.tickerId).appendChild(textElement);

		var newTicker=document.createElement('div');
		newTicker.style.width = this._tickerContainerWidth + 'px';
		newTicker.style.overflow = 'hidden';

		var oldTickerClone = this._ge(this.tickerId).cloneNode(true);
		oldTickerClone.removeAttribute('id');

		newTicker.appendChild(oldTickerClone);
		this._ge(this.tickerId).parentNode.replaceChild(newTicker, this._ge(this.tickerId));
		newTicker.id = this.tickerId;
		
		newTicker.onmouseover=function () { hTicker.tickerOver() };
		newTicker.onmouseout=function () { hTicker.tickerOut() };
	},

	// prepare ticker elements for scrolling
	_prepareTicker : function () {
		this._setTickerContent();
		this._setTickerSize();
		this._setTickerContainerSize();
		var textElement = this._prepareTickerTextElement();
		this._prepareTickerElement(textElement);

		this._gs(this._tickerInfoId).left = this._tickerContainerWidth+'px';
		this._gs(this._tickerInfoId).top = '0px';
		this._gs(this._tickerInfoId).display = '';
	},

	scrollTicker : function () {
		if (parseInt(this._gs(this._tickerInfoId).left) > this._tickerWidth*(-1)) {
			this._gs(this._tickerInfoId).left = (parseInt(this._gs(this._tickerInfoId).left) - 1)+'px';
		} else {
			this._gs(this._tickerInfoId).left = this._tickerContainerWidth+'px'
		}
		this._tickerTimeout = setTimeout('hTicker.scrollTicker()', this._tickerScrollTimeoutCurrent)
	},

	tickerOver : function () {
		this._tickerScrollTimeoutCurrent = this.tickerScrollTimeoutOver;
	},

	tickerOut : function () {
		this._tickerScrollTimeoutCurrent = this.tickerScrollTimeout;
	},

	init : function () {
		this._prepareTicker();
		this._tickerScrollTimeoutCurrent = this.tickerScrollTimeout;
		this._tickerTimeout = setTimeout('hTicker.scrollTicker()', this._tickerScrollTimeoutCurrent);
	}
}

window.onload=function () {
	hTicker.init()
}