var contHeight=280;
var totHeight=0;
var active=0;
var topBar=126;
var botBar=388;
var mo=0;
//************************************
var scrTimer = 30; // interval between calls to scroll onmouseover
var scrTmId=0;	// for setTimeouts
var pgLoaded;
wndo = new Array();	// "window" for scrollable content
var origWidth, origHeight;
if (ns4) {
	origWidth = window.innerWidth;
  origHeight = window.innerHeight;
}
 
function reDo() {
	if (ns4) {
	 if (window.innerWidth != origWidth || window.innerHeight != origHeight) 
	    window.location.reload();
	} else setTimeout("posToRelLyr()",200);
}
window.onresize = reDo;

function posToRelLyr() {
	var x = getPgLeft('divCont');	var y = getPgTop('divCont');
	wndo[0].shiftTo(x,y);
	wndo[0].show();
}

//function initScrLyr() {
function scrollInit() {
	pgLoaded=true;	
	// creat scrollable content area
	// arg: id of div containing scrollable div(s)
	wndo[0] = new dw_lyrObj('divCont');	
	// load scrolling content
	// arg's: array number of wndo, id of scroll div
	loadScrLyr(0,'divScroll1');
	// position and show wndo 
	posToRelLyr();
}
function scrollInit2() {
scrollInit();
}


//window.onload = initScrLyr;

// NOTE: Using offset positions to set style position 
// may not work accurately in Mac IE. 
// adapted from dhtmllib.js by Mike Hall
// from www.brainjar.com
// gets layer left relative to document
function getPgLeft(lyr) {
	var elem = (ns4)? document.layers[lyr]: (ie4)? document.all[lyr]: (ie5||ns5)? document.getElementById(lyr): null;

	var x = 0;
	if (ns4) return x = elem.pageX;	  	
  else if (ie4 || ie5) {
		while (elem.offsetParent != null) {
      x += elem.offsetLeft;
      elem = elem.offsetParent;
    }
    x += elem.offsetLeft;
		return x;
  } else if (ns5) return x = elem.offsetLeft;
	return x;
}

function getPgTop(lyr) {
	var elem = (ns4)? document.layers[lyr]: (ie4)? document.all[lyr]: (ie5||ns5)? document.getElementById(lyr): null;
	var y = 0;
	if (ns4) return y = elem.pageY;	  	
  else if (ie4 || ie5) {
		while (elem.offsetParent != null) {
      y += elem.offsetTop;
      elem = elem.offsetParent;
    }
    y += elem.offsetTop;
		return y;
	} else if (ns5) return y = elem.offsetTop;
	return y;
}

function dw_shiftTo(x,y) {
	if (ns4) { this.css.moveTo(x,y); } 
	else { this.css.left=x+"px"; this.css.top=y+"px"; }
}

function dw_shiftBy(x,y) {
	if (ns4) { this.css.moveBy(x,y); }
	else { 
		this.css.left = parseInt(this.css.left)+x+"px";
		this.css.top = parseInt(this.css.top)+y+"px";
	}
}

function dw_show() {	this.css.visibility = "visible"; }
function dw_hide() { this.css.visibility = "hidden"; }

// These functions are for onclick scrolling
function jumpDown(num,jump) {
	var y = parseInt(wndo[num].cnt.css.top);
	if (y>(-wndo[num].maxY)) { 
		if ((y-jump)>(-wndo[num].maxY)) wndo[num].cnt.shiftBy(0,-jump);
		else wndo[num].cnt.shiftBy(0,-(wndo[num].maxY-Math.abs(y)));	
  }
}

function jumpRight(num,jump) {
	var x = parseInt(wndo[num].cnt.css.left);
	if (x>(-wndo[num].maxX)) {
		if ((x-jump)>(-wndo[num].maxX)) wndo[num].cnt.shiftBy(-jump,0);
		else wndo[num].cnt.shiftBy(-(wndo[num].maxX-Math.abs(x)),0);	
  }
}

function jumpUp(num,jump) {
	var y = parseInt(wndo[num].cnt.css.top);
	if (y<0) { 
		if ((y+jump)<=0) wndo[num].cnt.shiftBy(0,jump); 
		else wndo[num].cnt.shiftBy(0,-y); 
	}
}

function jumpLeft(num,jump) {
	var x = parseInt(wndo[num].cnt.css.left);
	if (x<0) { 
		if ((x+jump)<=0) wndo[num].cnt.shiftBy(jump,0); 
		else wndo[num].cnt.shiftBy(-x,0); 
	}
}

// These functions are for onmouseover scrolling
function inchDown(num,inc) {
stopScroll()
	if (!pgLoaded) return; var y = parseInt(wndo[num].cnt.css.top);
	if (y>-wndo[num].maxY) {
		wndo[num].cnt.shiftBy(0,-inc);
		scrTmId = setTimeout("inchDown("+num+","+inc+")",scrTimer);
		moveBar(-inc);	
	}
}

function inchUp(num,inc) {
stopScroll()
	if (!pgLoaded) return; var y = parseInt(wndo[num].cnt.css.top);
	if (y<0) { 
		wndo[num].cnt.shiftBy(0,inc);
		scrTmId = setTimeout("inchUp("+num+","+inc+")",scrTimer);
		moveBar(inc);	
  }
}

function inchRight(num,inc) {
	if (!pgLoaded) return; var y = parseInt(wndo[num].cnt.css.left);	
	if (y>-wndo[num].maxX) { 
		wndo[num].cnt.shiftBy(-inc,0);
		scrTmId = setTimeout("inchRight("+num+","+inc+")",scrTimer);	
	}
}

function inchLeft(num,inc) {
	if (!pgLoaded) return; var y = parseInt(wndo[num].cnt.css.left);
	if (y<0) { 
		wndo[num].cnt.shiftBy(inc,0);
		scrTmId = setTimeout("inchLeft("+num+","+inc+")",scrTimer);	
  }
}

function stopScroll() {
	clearTimeout(scrTmId);
}
function noScroll(){
	stopScroll();
}

////////////////////////////////////////////////////////////////////
//  Constructor function used for creating scrollable content areas.
//	Used to create both wndo and content objects.
//  Argument for creating wndo objects:	id of wndo div.
//	Arguments for creating content (done in loadScrLyr function):
//	id of content div, id of html element that contains content. 
//	NOTE: Netscape 6 needs that html container and its id 
//	in order to get width for horizontal scrolling.
//	If only using vertical scrolling, that extra container
//	is not necessary.
////////////////////////////////////////////////////////////////////
function dw_lyrObj(obj,id) {
	this.el = (ns4)? getLyrRef(obj,document): (ie4)? document.all[obj]: (ie5||ns5)? document.getElementById(obj): null;
	this.css = (ns4)? this.el: (ie4||ie5||ns5)? this.el.style: null;
	this.height = (ns4)? this.el.clip.height: (ie4||ie5)? this.el.clientHeight: (ns5)? this.el.offsetHeight: 0;
	this.width = (ns4)? this.el.clip.width: (ie4||ie5)? this.el.clientWidth: (ns5)? (id)? document.getElementById(id).offsetWidth: this.el.offsetWidth: 0;
}

/////////////////////////////////////////////////////////////////////
// loadScrLyr function: loads scrollable content div(s)
//	arg's: wndo array number, id of scrollable div,
//	and id of table or other html element that contains div content. 
//	NOTE: Netscape 6 needs that html container and its id 
//	in order to get width for horizontal scrolling.
//	If only using vertical scrolling, that extra container
//	is not necessary.
/////////////////////////////////////////////////////////////////////
function loadScrLyr(num,lyr,id) {
	if (!pgLoaded) return; // avoid not loaded errors
	if (typeof wndo[num].cnt != "undefined") wndo[num].cnt.hide();
	wndo[num].cnt = new dw_lyrObj(lyr,id);
	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
} 

dw_lyrObj.prototype.shiftBy=dw_shiftBy;
dw_lyrObj.prototype.shiftTo=dw_shiftTo;
dw_lyrObj.prototype.show=dw_show; 
dw_lyrObj.prototype.hide=dw_hide;

// get reference to nested layer for ns4
// from dhtmllib.js by Mike Hall of www.brainjar.com
function getLyrRef(lyr,doc) {
	if (ns4) {
		var theLyr;
		for (var i=0; i<doc.layers.length; i++) {
	  	theLyr = doc.layers[i];
			if (theLyr.name == lyr) return theLyr;
			else if (theLyr.document.layers.length > 0) 
	    	if ((theLyr = getLyrRef(lyr,theLyr.document)) != null)
					return theLyr;
	  }
		return null;
  }
}

function scroll(speed){
	if(speed>0){
			inchUp(0,speed);
	}
	else{
		inchDown(0,-speed);
		}
		

}
function moveBar(sp){
	mo=-(botBar-topBar)*parseInt(wndo[0].cnt.css.top)/(wndo[0].cnt.height-contHeight);
	difBar=botBar-topBar;
	if (mo>difBar){
		mo=difBar;
	}
if (ie5 || ns5) { //W3C compliant
	   document.getElementById("bar").style.top = mo + topBar + "px";
	}
	else {
	   eval((ns4)?'document.bar.top=mo+topBar':'document.all.bar.style.pixelTop=mo+topBar');
	}
	//eval((ns4)?'document.bar.top=mo+topBar':'document.all.bar.style.pixelTop=mo+topBar');
//	scrTmId = setTimeout("moveBar("+sp+")",scrTimer);
}

//#################################################
//for click on the bar. 
if (!(ie4||ie5)) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var tempX = 0;
var tempY = 0;
function getMouseXY(e) {
//alert('inside mouse cap');
if (ie4||ie5) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft;
tempY = event.clientY + document.body.scrollTop;
}
else {  // grab the x-y pos.s if browser is NS
tempX = e.pageX;
tempY = e.pageY;
}  
if (tempX < 0){tempX = 0;}
if (tempY < 0){tempY = 0;}
//alert('invoding inchup');  

//document.Show.MouseX.value = tempX;
//document.Show.MouseY.value = tempY;
return true;
}
function movePage()
{
var t = -(botBar-topBar)*parseInt(wndo[0].cnt.css.top)/(wndo[0].cnt.height-contHeight+2);

var moveY = tempY-126;
if(moveY > t)
{
	noScroll();
	inchDown(0,10);
}
else if(moveY<t)
{
	noScroll();
	inchUp(0,10);
}
else
	noScroll();

return;

   
}

//####################################################
//*****************************