var scrTimer = 40; // interval between calls to scroll onmouseover

function stopScroll(num) {
  if (pgLoaded && wndo[num]) {
  	clearTimeout(wndo[num].scrTmId);
  	wndo[num].scrTmId = 0;
  }
}

function loadScrLyr(num,lyr,id) {
	if (!pgLoaded) return; // avoid not loaded errors
	if (typeof wndo[num].cnt != "undefined") wndo[num].cnt.hide();
  wndo[num].scrTmId = 0;
	wndo[num].cnt = new dynObj(lyr);
  // mainly for ns6+/mozilla when scrolling horizontally
  if (id && document.getElementById) 
    wndo[num].cnt.width = document.getElementById(id).offsetWidth;
	wndo[num].cnt.show();
	wndo[num].cnt.shiftTo(0,0);	// restore top/left to 0 
	wndo[num].maxX = wndo[num].cnt.width - wndo[num].width;
	wndo[num].maxY = wndo[num].cnt.height - wndo[num].height
} 

// These functions are for onmouseover scrolling
function inchDown(num,inc) {
	if (!pgLoaded||!wndo[num]) return;
	if (wndo[num].scrTmId) clearTimeout(wndo[num].scrTmId);
	var y = parseInt(wndo[num].cnt.css.top);
	if (y>-wndo[num].maxY) { 
    if ((y-inc)>(-wndo[num].maxY)) wndo[num].cnt.shiftBy(0,-inc);
		else wndo[num].cnt.shiftBy(0,-(wndo[num].maxY-Math.abs(y)));
		wndo[num].scrTmId = setTimeout("inchDown("+num+","+inc+")",scrTimer);	
	}
}

function inchUp(num,inc) {
	if (!pgLoaded||!wndo[num]) return;
	if (wndo[num].scrTmId) clearTimeout(wndo[num].scrTmId);
	var y = parseInt(wndo[num].cnt.css.top);
	if (y<0) { 
    if ((y+inc)<=0) wndo[num].cnt.shiftBy(0,inc); 
		else wndo[num].cnt.shiftBy(0,-y);
		wndo[num].scrTmId = setTimeout("inchUp("+num+","+inc+")",scrTimer);	
  }
}

var pgLoaded = false;
var wndo = new Array();	// "window(s)" for scrollable content
function initScrLyr() {
pgLoaded=true;	
// creat scrollable content area
// arg: id of div containing scrollable div(s)
wndo[0] = new dynObj('scrollinner');	
// load scrolling content
// arg's: array number of wndo, id of scroll div
loadScrLyr(0,'scrollcontent');	

// remove layers from table for ns6+/mozilla (overflow/clip bug?)
if (navigator.userAgent.indexOf("Gecko")>-0) {
    for (var i=0; i<wndo.length; i++) {
if (wndo[i].el.parentNode.id.indexOf("scrollouter")!=-0) {
var holderId = wndo[i].el.parentNode.id;
wndo[i].holder = document.getElementById(holderId);
var scrWn = wndo[i].holder.removeChild(wndo[i].el);
document.body.appendChild(wndo[i].el);
wndo[i].css.zIndex = 500;
var y = wndo[i].holder.offsetTop;
var x = wndo[i].holder.offsetLeft;
wndo[i].shiftTo(x,y);
}
}
}
}

window.onload = initScrLyr;
if (navigator.userAgent.indexOf("Gecko")>-0) window.onresize = rePosGecko;

