/**********************************************************************************   
PageScroll 
*   Copyright (C) 2001 <a href="/dhtmlcentral/thomas_brattli.asp">Thomas Brattli</a>
*   This script was released at DHTMLCentral.com
*   Visit for more great scripts!
*   This may be used and changed freely as long as this msg is intact!
*   We will also appreciate any links you could give us.
*
*   Made by <a href="/dhtmlcentral/thomas_brattli.asp">Thomas Brattli</a> 
*********************************************************************************/

/*********************************************************************************
These are the variables you have to set:
*********************************************************************************/

//The speed of the timeout between each scroll.
timSpeed = 50

//The height of the container (change this when it scrolls to much or to little)
contHeight = 80

/*********************************************************************************
This is the object constructor function, which applies 
methods and properties to the Cross-browser layer object
*********************************************************************************/

function makeScrollObj(obj,nest,controler){
	nesttmp=(!nest) ? "":'document.'+nest+'.'		
	controlertmp=(!controler) ? "":'document.'+controler+'.'
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nesttmp+'document.'+obj):0;
	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nesttmp+'document.'+obj):0;		
	this.height=bw.ns4?this.css.document.height:this.el.offsetHeight;
	if(nest){
		this.contenerel=bw.dom?document.getElementById(nest):bw.ie4?document.all[nest]:bw.ns4?eval(nesttmp+'document.'+obj):0;
		this.contenercss=bw.dom?document.getElementById(nest).style:bw.ie4?document.all[nest].style:bw.ns4?eval('document.'+nest):0;		
		this.contenerhight=bw.ns4?this.contenercss.document.height:this.contenerel.offsetHeight;
	}
	this.top=b_gettop;
	if(controler){
		this.controlerel=bw.dom?document.getElementById(controler):bw.ie4?document.all[controler]:bw.ns4?eval(controlertmp+'document.'+obj):0;
		this.controlercss=bw.dom?document.getElementById(controler).style:bw.ie4?document.all[controler].style:bw.ns4?eval('document.'+controler):0;		
		if(this.height-this.contenerhight>0){
			this.controlercss.visibility = "visible";
		}
	}
	
	return this;
}

function initNewScroll(content,contener,controler){
	oScroll[contener] = new makeScrollObj(content,contener,controler);
	oScroll[contener].css.left = 0+px
	oScroll[contener].css.right = 0+px
	oScroll[contener].css.top = 0+px
	oScroll[contener].css.visibility = "visible"
}

// A unit of measure that will be added when setting the position of a layer.
var px = bw.ns4||window.opera?"":"px";

//Getting the top for the top method
function b_gettop(){
	var gleft=(bw.ns4 || bw.ns6)?parseInt(this.css.top):eval(this.css.pixelTop);
	return gleft;
}
//Variables
var scrollTim = 1;
//var active = 0;
/*********************************************************************************
The scroll function. Checks what way to scroll and checks if the
layer is not already on top or bottom.
*********************************************************************************/
function scroll(speed,active){
	clearTimeout(scrollTim)
	way = speed>0?1:0
	if ((!way && oScroll[active].top()>-(oScroll[active].height-oScroll[active].contenerhight)) || (oScroll[active].top()<0 && way)){
		oScroll[active].css.top = (oScroll[active].top()+speed)+px
		scrollTim = setTimeout("scroll("+speed+",'"+active+"')",timSpeed)
	}
}
//Clears the timeout so the scroll stops, this is called onmouseout.
function noScroll(){
	clearTimeout(scrollTim)
}
