// Pages using these functions will also need the Utils.js library

var loopingScroller;
var START_DELAY = 1000;

function LoopingScroller(frameDivId, scrollerDivId, scrollInterval) {
	this.theScrollingElement = MM_findObj(scrollerDivId);
	this.theFrameElement = MM_findObj(frameDivId);
	this.theScrollingElement.onmouseover = LoopingScroller_pause;
	this.theScrollingElement.onmouseout = LoopingScroller_resume;
	this.objectStyle = this.theScrollingElement.style;
	this.scrollPos = 0;
	this.scrollingLayerHeight = this.theScrollingElement.offsetHeight;
	this.frameHeight = this.theFrameElement.offsetHeight;
	this.scrollInterval = scrollInterval;
	this.move = LoopingScroller_move;
	loopingScroller = this;
	setTimeout("loopingScroller.move()", START_DELAY);
}

function LoopingScroller_move() {
	this.frameHeight = this.theFrameElement.offsetHeight;
	this.scrollingLayerHeight = this.theScrollingElement.offsetHeight;
	if (!loopingScroller.myPause){
		var nextScroll = this.scrollInterval;
		this.scrollPos -= 1;
		this.objectStyle.top = this.scrollPos;
		if (this.scrollPos < -this.scrollingLayerHeight) {
			this.scrollPos = this.frameHeight;
		}
	}
	setTimeout("loopingScroller.move()", nextScroll);
}

function LoopingScroller_pause() {
	loopingScroller.myPause = true;
}

function LoopingScroller_resume() {
	loopingScroller.myPause = false;
}

