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

var bouncingScroller;
var START_END_DELAY = 1000;


function BouncingScroller(frameDivId, scrollerDivId, scrollInterval) {
	this.theScrollingElement = MM_findObj(scrollerDivId);
	this.theFrameElement = MM_findObj(frameDivId);
	this.theScrollingElement.onmouseover = BouncingScroller_pause;
	this.theScrollingElement.onmouseout = BouncingScroller_resume;
	this.objectStyle = this.theScrollingElement.style;
	this.scrollPos = 0;
	this.frameHeight = this.theFrameElement.offsetHeight;
	this.scrollDirection = -1;
	this.scrollLimit = -this.theScrollingElement.offsetHeight+this.frameHeight;
	this.scrollInterval = scrollInterval;
	this.move = BouncingScroller_move;
	bouncingScroller = this;
	setTimeout("bouncingScroller.move()", START_END_DELAY);
}

function BouncingScroller_move() {
	this.frameHeight = this.theFrameElement.offsetHeight;
	this.scrollLimit = -this.theScrollingElement.offsetHeight+this.frameHeight;	
	if (!bouncingScroller.myPause){
		var nextScroll = this.scrollInterval;
		this.scrollPos += this.scrollDirection;
		this.objectStyle.top = this.scrollPos;
		if ((this.scrollPos < this.scrollLimit) || (this.scrollPos > 0)) {
			this.scrollDirection = -this.scrollDirection;
			nextScroll = START_END_DELAY;
		}
	}
	
	setTimeout("bouncingScroller.move()", nextScroll);
}

function BouncingScroller_pause() {
	bouncingScroller.myPause = true;
}

function BouncingScroller_resume() {
	bouncingScroller.myPause = false;
}
