/**
 * Css clipping based scroller
 * based on the code from http://www.quirksmode.org/js/layerscroll.html
 *
 */


/**
 * this values must match the css clip values
 */
var clipTop = 0;
var clipWidth = 110;
var clipBottom = 200;
var topper = 27; /* css top */
var lyrheight = 0; 
var time,amount,theTime;

function init(name)
{
	lyrheight = $(name).offsetHeight;
}

function scrollayer(layername,amt,tim)
{
	thelayer = $(layername);
	if (!thelayer) return;
	amount 	= amt;
	theTime = tim;
	realscroll();
}

function realscroll()
{
	clipTop 	+= amount;
	clipBottom 	+= amount;
	topper 		-= amount;
	if (clipTop < 0 || clipBottom > lyrheight)
	{
		clipTop 	-= amount;
		clipBottom 	-= amount;
		topper 		+= amount;
		return;
	}
	clipstring = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)';
	thelayer.style.clip = clipstring;
	thelayer.style.top = topper + 'px';
	time = setTimeout('realscroll()',theTime);
}

function stopScroll()
{
	if (time) clearTimeout(time);
}