var contentItemWidth = 75;
var inactiveWidth = 30;
var expertiseTimer = null;
var scrolltextTimer = null;
var scrollertext;
var expertisetext;
var scroller;

function initScroller()
{
	scroller = document.getElementById("scroller");
	if (!scroller) return;
	scrollertext	= document.getElementById("scrollertext");
	expertisetext	= document.getElementById("expertisetext");

	imliveGreeting = scrollertext.innerHTML;
	scroller.onmousemove	= ScrollDiv;

	scrollerWidth		= scroller.offsetWidth;
	activeWidth		= scrollerWidth - 2 * inactiveWidth;
	contentItems		= scroller.childNodes.length - 1;
	contentWidth		= contentItems * contentItemWidth;
	contentScrollQuotient	= ( contentWidth - scrollerWidth ) / activeWidth;

	scrollerOffset = findPos (scroller);

}

function findPos(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
		}
	}
	return curleft;
}

function ScrollDiv(event)
{
	var e = event || window.event;
	var PointerPosition = e.clientX - scrollerOffset;
	popupPosX = e.clientX;
	popupPosY = e.clientY;

	if ( PointerPosition < inactiveWidth )
	{
		PointerPosition = inactiveWidth;
	};
	if ( PointerPosition > scrollerWidth - inactiveWidth )
	{
		PointerPosition = scrollerWidth - inactiveWidth;
	};

	PointerPosition -= inactiveWidth;
	scroller.scrollLeft = PointerPosition * contentScrollQuotient;
}

function dTitle(nick,url,expertise) {

	if (expertiseTimer != null) {
		clearTimeout(expertiseTimer);
		clearTimeout(scrolltextTimer);
		expertiseTimer = null;
	}
	scrollertext.innerHTML = 'Talk to <a href="' + url + '" target="_blank">' + nick + '</a> right now!';
	expertisetext.innerHTML = expertise;
	expertisetext.style.visibility='visible';
	expertisetext.style.left=popupPosX + 5 + "px";
//	expertisetext.style.top=popupPosX + 15 + "px";
}

function dTitleOut() {
	expertiseTimer = setTimeout("expertisetext.style.visibility='hidden';",250);
	scrolltextTimer = setTimeout("scrollertext.innerHTML = imliveGreeting;",4000);
}

