var clipTop,clipWidth,clipBottom,topper,lyrheight;
var time,amount,theTime,theHeight,thelayer,topper;

function scrollinit(){
	var h = loop();
	if(h) setTimeout('scrollayer("scrollbox",5,20);',2000);
}

function loop(){
	clipTop = 0;
	clipWidth = 690;
	clipBottom = 95;
	lyrheight = 0;
	topper = 0;
	var x = document.getElementById('scrollbox');
	lyrheight = x.offsetHeight;
	x.style.clip = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)';
	x.style.top = topper + 'px';
	return lyrheight;
}

function scrollayer(layername,amt,tim){
	thelayer = document.getElementById(layername);
	if (!thelayer) return;
	amount = amt;
	theTime = tim;
	realscroll(); //thelayer
}

function realscroll(){
	clipTop += amount;
	clipBottom += amount;
	topper -= amount;
	if (clipTop < 0 || clipBottom > lyrheight){
		clipTop -= amount;
		clipBottom -= amount;
		loop();
//		time = setTimeout('realscroll()',theTime*100);
		realscroll();
		return;
	}
	clipstring = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)';
	thelayer.style.clip = clipstring;
	thelayer.style.top = topper + 'px';
	if(clipTop%95 == 0)
		time = setTimeout('realscroll()',theTime*300);
	else
		time = setTimeout('realscroll()',theTime);
}

function stopscroll(){
	if (time){
		clearTimeout(time);
		time = null;
	}
}
function runscroll(){
	if (time == null)
		time = setTimeout('scrollayer("scrollbox",5,20)',theTime);
}

window.onload = scrollinit;
