var curPos=0, lastPos=-1;
var pausing = 0, restart = 0;
var PAUSE_DURATION = 2000; // milliseconds

function setPauseDone(){
	 pausing = 0;
}

function pause() {
	pausing = 1; /* set flag that scrollWindow() will watch */		
	window.setTimeout("setPauseDone()", PAUSE_DURATION);
}

function initialize() {
	window.setInterval("scrollWindow()", 15)
	pause(); /* delay before we start scrolling */
}

function scrollWindow() {
    if (pausing == 1 || parent.scrollOn == 0)
	   return;

	if (restart == 1) {
	    window.scroll(0, 0);    /* restart from top */
		pause();  /* delay before we start scrolling */
		restart = 0;            /* reset flag */
	} else {
		window.scrollBy(0, 1);
	}
	
	
	if (document.all)
		curPos = document.body.scrollTop;
	else
		curPos = window.pageYOffset;
		
	if (curPos == lastPos) { /* if it hasn't moved, we're at the end of the window */
		pause();
		curPos = 0;
		restart = 1;
	} else {
	    lastPos = curPos;
	}
	
}

window.onload = initialize;
