/*********************************************************************************
Up down scroll object

Author: Tom Garrood
Created: 18-7-2000
Notes: ----

*********************************************************************************/

// Global variables
bw = new checkBrowser ();

//Default browsercheck, added to all scripts!
function checkBrowser (){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}

/*********************************************************************************
This is the object constructor function, which applies 
methods and properties to the Cross-browser layer object
*********************************************************************************/
function makeLayerObj (obj,nest){
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
  
  return this;
}

function makeUpDnScrollObj (obj,nest,control,contHeight,timerSpeed) {
  bw = new checkBrowser ();

	nest = (!nest) ? '':'document.'+nest+'.';

	// Object variables
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
  this.control=bw.dom?document.getElementById(control).style:bw.ie4?document.all[control].style:bw.ns4?eval('document.'+control):0;
	this.height=bw.ns4?this.css.document.height:this.el.offsetHeight;
	this.name=obj;
	this.scrollTimer=null;
	this.controlImages=null;
	this.contHeight=contHeight;
	this.timerSpeed=timerSpeed;
	this.controlImages=bw.ns4?eval("document."+control+".document.images"):document.images;
	
  // Object functions
	this.top=b_gettop;										
	this.scroll=b_scroll;
	this.stopScroll=b_stopScroll;

	// timer functions/variables
	this.obj = obj + "Object";
	//alert(this.obj);
  eval(this.obj + "=this");

	// Turn off both control arrows if the is not enuff content
	if (this.height<=contHeight+5) {
		eval("this.controlImages.img"+this.name+"Bottom.src = img"+this.name+"BottomOff.src");
		eval("this.controlImages.img"+this.name+"Top.src = img"+this.name+"TopOff.src");
	} else {
		eval("this.controlImages.img"+this.name+"Top.src = img"+this.name+"TopOff.src");	
	}
	
  this.css.visibility='visible';
  this.control.visibility='visible';
	return this;
}

//Getting the top for the top method
function b_gettop(){
	var gleft=(bw.ns4 || bw.ns5) ? eval(this.css.top):eval(this.css.pixelTop);
	return gleft;
}

/*********************************************************************************
The scroll function. Checks what way to scroll and checks if the
layer is not already on top or bottom.
*********************************************************************************/
function b_scroll(speed){
	clearTimeout(this.scrollTimer);
	way=speed>0?1:0;
	if ((!way && this.top() > -this.height + this.contHeight) || (this.top()<0 && way)){
		alert
		if (eval("this.controlImages.img"+this.name+"Bottom.src!=img"+this.name+"BottomOn.src"))
			eval("this.controlImages.img"+this.name+"Bottom.src=img"+this.name+"BottomOn.src");
		if (eval("this.controlImages.img"+this.name+"Top.src!=img"+this.name+"TopOn.src"))
			eval("this.controlImages.img"+this.name+"Top.src=img"+this.name+"TopOn.src");
		
			
		this.css.top=this.top()+speed;
		this.scrollTimer=setTimeout(this.obj+".scroll("+speed+")",this.timerSpeed)
	} else {
    if (way) {
      eval("this.controlImages.img"+this.name+"Top.src=img"+this.name+"TopOff.src");
		} else {
			eval("this.controlImages.img"+this.name+"Bottom.src=img"+this.name+"BottomOff.src");
		}
	}
}

//Clears the timeout so the scroll stops, this is called onmouseout.
function b_stopScroll(){
	clearTimeout(this.scrollTimer)
}
