var step = 1;

function objWidth( obj )
{
	if( obj.offsetWidth )
		return obj.offsetWidth;
	if( obj.style )
		obj = obj.style;
        if( obj.pixelWidth )
                return obj.pixelWidth;
	if( obj.clip )
		return obj.clip.width;
	return 0;
}

function objHeight( obj )
{
	if( obj.offsetHeight )
		return obj.offsetHeight;
	if( obj.style )
		obj = obj.style;
        if( obj.pixelHeight )
                return obj.pixelHeight;
	if( obj.clip )
		return obj.clip.height;
	return 0;
}

function scrF( o, scrollerID, i, sH, eH )
{
	// Fix for IE problem
	// ( and Chrome and Safari )

	var text1 = document.getElementById( scrollerID + "in1" );
	eH = objHeight( text1 );
	
	if( o.paused )
		return;
	if( i.style )
		i = i.style;
	var x = parseInt( i.top ) - step;
	if( x < 2 - eH )
		//x = sH;
		x = 0;

/* DEBUGGING
	var scrollerDebug = document.getElementById( "scrollerDebug" );
	var heightTest = document.getElementById( "specialsin1" );
	var heightOf = objHeight( heightTest );
	scrollerDebug.innerHTML = "<div><br \/>x = " + x + "<br \/>eh = " + eH + "<br \/>sH = " + sH + "<br \/>height: " + heightOf + "<\/div>";
*/
	i.top = x + 'px';

}

	// BugFix: Scroller contents are not scrolling all the way to the end before wrapping around to the beginning
	// Solution: Modified the creation of the content <div> to no longer explicitly set the length of the div, allowing the true length to be set by the contents.

	// Feature: Scroller contents obviously restarting from top. Want scrolling to continue
	// Solution: Add a second copy of the contents into the <div> and reset the position to the top at the pixel perfect moment.
	
function startScroll( sID, txt )
{
	var scr = document.getElementById( sID );
	var sW = objWidth( scr ) - 6;
	var sH = objHeight( scr ) + 10;

	var text1 = '<div id="' + sID + 'in1">' + txt + '<br \/><br \/><br\/><\/div>';
	var text2 = '<div id="' + sID + 'in2">' + txt + '<\/div>';

	// Embed the content divs
	scr.innerHTML = "<div id='" + sID + "scrollerContent' style='position:absolute; left:3px; width:" + sW + "'>" + text1 + text2 + "<\/div>";
	
	var sTxt1 = document.getElementById( sID + 'in1' );
	var sTxt1Height = objHeight( sTxt1 );

	var scrollerContent = document.getElementById( sID + "scrollerContent" );
	scrollerContent.style.top = sH + 'px';
	
/* DEBUGGING
	var initDebug = document.getElementById( "initDebug" );
	initDebug.innerHTML = "<div>sTxt1Height: <br \/>" + sTxt1Height + "<\/div>";
*/	
	
	setInterval( function() { scrF(scr, sID, scrollerContent.style, sH, sTxt1Height); }, 25 ); 
}

