var oScroll = null, oHolder = null, intIntervalId;
var blnRunning = false;

//This setting can be modified to alter the default speed.
var intMoveIncrement = -1

//The time increment is the frequency (in milliseconds) with
//  which the crawler is updated. It's set at 30 milliseconds 
//  because that is roughly 30 frames per second (TV quality).
//  The human eye can detect visual stuttering at anything greater
//  than 100 milliseconds.
var intTimeIncrement = 30;

//This function handles the animation of the object stored in the 
//  variable oScroll. It assumes that it is within the object oHolder.
function scroll()
{
//If scrolling has been stopped for some reason, then don't animate
if (!(blnRunning))
return;

var intHolderWidth = oHolder.style.pixelWidth;
var intLeft = oScroll.style.pixelLeft;
var intRight = intLeft + oScroll.offsetWidth;
var intDirection, blnReset = false;

//Determine if the text has gone off of the end of the display area.
//  If it has, then reset the text. This is all dependant on the direction
//  in which the text is moving.
if ((intMoveIncrement < 0) && ((-1 * intLeft) > oScroll.offsetWidth))
{
oScroll.style.left = intHolderWidth;
blnReset = true;
}
else if ((intMoveIncrement > 0) && (intLeft > intHolderWidth))
{
oScroll.style.left = -1 * oScroll.offsetWidth;
blnReset = true;
}

//If the text was not reset this cycle, then move it the specified
//  number of units.
if (!(blnReset))
oScroll.style.left = intLeft + intMoveIncrement;
}

//This function changes the magnitude only, not the direction of the scrolling.
function changeSpeed(intSpeed)
{
if (intMoveIncrement < 0)
intMoveIncrement =  (-1 * intSpeed);
else
intMoveIncrement = (1 * intSpeed);

}

//This function changes the direction of the scrolling.
function toggleDirection()
{
intMoveIncrement = -1 * intMoveIncrement;
}

//This function "pauses" the scrolling.
function toggleScroll()
{
if(blnRunning)
clearInterval(intIntervalId);
else
intIntervalId = setInterval('scroll();', intTimeIncrement);

//Toggling the boolean value is redundant because the interval 
//  is terminated/activated accordingly. However, I use it just to be sure.
blnRunning = !(blnRunning);
}

//This function must be called before any information can be scrolled.
//  Do not call toggleScroll() before this function or you will 
//  receive an error.
function initScroll(oText, oContainer)
{
//Set the object to scroll, and it's container (for width checking)
oScroll = oText;
oHolder = oContainer;

//Reset the position of the text span and start scrolling
oScroll.style.left = oHolder.style.pixelWidth;
blnRunning = false;//Set to false so that toggleScroll() will switch *to* scrolling
toggleScroll();
}