var jsscrollId = 0;
function jsscrollStart(elem)
{
	spacer = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	elem.innerHTML = elem.innerHTML + spacer + elem.innerHTML + spacer; // Double the text to enable scrollwrap
	elem.jsscroll_initClientWidth = elem.clientWidth;
	elem.jsscroll_initClientHeight = elem.clientHeight;

	elem.style.height = "auto";
	elem.style.width = "9999px"; // Very very long
	elem.jsscroll_autoHeight = elem.clientHeight; // Getting the natural height when text on one line
	
	for (var width = elem.jsscroll_initClientWidth; width < 9999; width++)
	{
		elem.style.width = width + "px";
		if (elem.clientHeight == elem.jsscroll_autoHeight)
			break;
	}
	elem.style.clip = "rect(0px " + elem.jsscroll_initClientWidth + "px " + elem.clientHeight + "px 0px)";
	elem.jsscroll_offset = 0;
	if (!elem.id)
		elem.id = "jsscrollUniqueId" + jsscrollId;
	
	if (!condor_getStyle(elem, "position").match("absolute"))
	{
		elem.style.position = "relative";
		elem.style.left = "0px";
	}	
	elem.jsscroll_initLeft = parseInt(condor_getStyle(elem, "left").replace(/px/i, ""));
	elem.parentNode.style.overflow = "hidden";
	jsscrollNextFrame(elem.id);
}

function jsscrollNextFrame(elem_id)
{
	elem = document.getElementById(elem_id);
	if (!elem)
		return;
	elem.jsscroll_offset -= 2;
	if (elem.jsscroll_offset + elem.clientWidth < elem.clientWidth / 2) // If scrolled halfway... reset (remeber we doubled the text)
		elem.jsscroll_offset = 0;
	elem.style.left = elem.jsscroll_initLeft + elem.jsscroll_offset + "px";
	elem.style.clip = "rect(0px " + (elem.jsscroll_initClientWidth - elem.jsscroll_offset) + "px " + elem.clientHeight + "px " + (-elem.jsscroll_offset) + "px)";
	setTimeout("jsscrollNextFrame('" + elem.id + "');", 100);
}
