var scrollT;
function scrollOvr() {
	this.className += " on";
}
function scrollStop() {
	clearTimeout(scrollT);
	this.className = this.className.replace(/\bon\b/,"");
}
var scrollingDiv;
function scrollUp() {
	if(!scrollingDiv)
		scrollingDiv = this.bodyDiv;
	var top = parseInt(scrollingDiv.style.top) + 10;
	if(top >= 0) {
		scrollingDiv.style.top = 0;
	} else {
		scrollT = setTimeout("scrollUp()",100);
		scrollingDiv.style.top = top + "px";
	}
}
function scrollDown() {
	if(!scrollingDiv)
		scrollingDiv = this.bodyDiv;
	var top = parseInt(scrollingDiv.style.top);
	if(top + scrollingDiv.offsetHeight <= scrollingDiv.ClientHeight + 10)
		top = scrollingDiv.ClientHeight - scrollingDiv.offsetHeight + 10;
	else 
		scrollT = setTimeout("scrollDown()",100);
	scrollingDiv.style.top = top - 10 + "px";
}
function scrollInit() {
	var divs = document.getElementsByTagName("DIV");
	var div;
	for(var i=0; i < divs.length; i++) {
		div = divs[i];
		if(div.className && div.className.search(/\bscroll\b/) != -1) {
			var divs2 = div.getElementsByTagName("DIV");
			for(var j=0; j < divs2.length; j++) {
				if(divs2[j].className.search(/\bcontent\b/) != -1) {
					break;
				}
			} 
			if(divs2[j].offsetHeight > div.clientHeight - divs2[j].offsetTop) {
				divs2[j].style.position = "relative";
				divs2[j].style.top = "0";
				divs2[j].ClientHeight = div.clientHeight - divs2[j].offsetTop;
				var divPt = getXY(divs2[j]);
				var upArrow = document.createElement('DIV');
				upArrow.className = "up";
				upArrow.innerHTML = '<img src="img/spacer.gif" class="up" alt="scroll up">';
				div.appendChild(upArrow);
				var upArrowPt = getXY(upArrow);
				upArrow.style.top = (divPt.y - upArrowPt.y + 3) + "px";
				upArrow.style.left = (divPt.x + div.offsetWidth - upArrowPt.x - 20) + "px";
				upArrow.bodyDiv = divs2[j];
				upArrow.onmouseover = scrollOvr;
				upArrow.onmousedown = scrollUp;				
				upArrow.onmouseup = scrollStop;
				upArrow.onmouseout = scrollStop;
	
				var downArrow = document.createElement('DIV');
				downArrow.className = "down";
				downArrow.innerHTML = '<img src="img/spacer.gif" class="down" alt="scroll down">';
				div.appendChild(downArrow);
				var downArrowPt = getXY(downArrow);
				downArrow.style.top = (divPt.y + divs2[j].ClientHeight - downArrowPt.y - downArrow.offsetHeight - 3) + "px";
				downArrow.style.left = (divPt.x + div.offsetWidth - downArrowPt.x - 20) + "px";
				downArrow.bodyDiv = divs2[j];
				downArrow.onmouseover = scrollOvr;
				downArrow.onmousedown = scrollDown;
				downArrow.onmouseup = scrollStop;
				downArrow.onmouseout = scrollStop;
				
				delete divPt;
				delete downArrowPt;
				delete upArrowPt;
			}			
		}
	}
}