// JavaScript Document

//	Browsercheck (needed)
	function lib_bwcheck() {
		this.ver=navigator.appVersion;
		this.agent=navigator.userAgent;
		this.dom=document.getElementById?1:0;
		this.opera5=this.agent.indexOf("Opera 5")>-1;
		this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
		this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
		this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
		this.ie=this.ie4||this.ie5||this.ie6;
		this.mac=this.agent.indexOf("Mac")>-1;
		this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
		this.ns4=(document.layers && !this.dom)?1:0;
		this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5);
		return this;
	}

//	replace image
	var bw = new lib_bwcheck();
	
	function set_image(name, url) {
		var img = document.images[name];
		if(img){
		  img.src = url;
		}
	}

//	default height of the visible area
var lhi = 300;
	
//	If you want it to move faster you can set this lower, it's the timeout:
var speed = 40

//	Sets variables to keep track of what's happening
var loop, timer

//	Object constructor
function makeObj1(obj,nest) {
    nest=(!nest) ? "":'document.'+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;
	this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
	if (this.scrollHeight > lhi) {
		set_image('scrollup1', "common/uparrow1.gif");
		set_image('scrollbar1', "common/chiposcroll1.gif");
	   	set_image('scrolldown1', "common/downarrow1.gif");
  	}
	this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight
	this.up=goUp1;
	this.down=goDown1;
	this.moveIt=moveIt;
	this.x=25;
	this.y=0;
    this.obj = obj + "Object"
    eval(this.obj + "=this")
    return this
}

function makeObj2(obj,nest) {
    nest=(!nest) ? "":'document.'+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;
	this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
	if (this.scrollHeight > lhi) {
		set_image('scrollup2', "common/uparrow2.gif");
		set_image('scrollbar2', "common/chiposcroll2.gif");
		set_image('scrolldown2', "common/downarrow2.gif");
  	}
	this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight
	this.up=goUp2;
	this.down=goDown2;
	this.moveIt=moveIt;
	this.x=25;
	this.y=0;
    this.obj = obj + "Object"
    eval(this.obj + "=this")
    return this

}

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

function moveIt(x,y){
	this.x = x
	this.y = y
	this.css.left = this.x+px
	this.css.top = this.y+px
}

//	Makes the object go up
function goDown1(move){
	if (this.y>-this.scrollHeight+oCont1.clipHeight){
		this.moveIt(25,this.y-move)
			if (loop) setTimeout(this.obj+".down("+move+")",speed)
	}
}
function goDown2(move){
	if (this.y>-this.scrollHeight+oCont2.clipHeight){
		this.moveIt(25,this.y-move)
			if (loop) setTimeout(this.obj+".down("+move+")",speed)
	}
}

//	Makes the object go down
function goUp1(move){
	if (this.y<0){
		this.moveIt(25,this.y-move)
		if (loop) setTimeout(this.obj+".up("+move+")",speed)
	}
}
function goUp2(move){
	if (this.y<0){
		this.moveIt(25,this.y-move)
		if (loop) setTimeout(this.obj+".up("+move+")",speed)
	}
}

//	Calls the scrolling functions. Also checks whether the page is loaded or not.
function scroll1(speed){
	if (scrolltext1Loaded){
		loop = true;
		if (speed>0) oScroll1.down(speed)
		else oScroll1.up(speed)
	}
}
function scroll2(speed){
	if (scrolltext2Loaded){
		loop = true;
		if (speed>0) oScroll2.down(speed)
		else oScroll2.up(speed)
	}
}

//	Stops the scrolling (called on mouseout)
function noScroll(){
	loop = false
	if (timer) clearTimeout(timer)
}

//	Makes the object
var scrolltext1Loaded = false
function scrolltext1Init(target, scrollitem){ 
	oCont1 = new makeObj1(target);
	oScroll1 = new makeObj1(scrollitem,target);
	oScroll1.moveIt(25,0);
	oCont1.css.visibility = "visible";
	scrolltext1Loaded = true;
}
//	Makes the object
var scrolltext2Loaded = false
function scrolltext2Init(target, scrollitem){ 
	oCont2 = new makeObj2(target);
	oScroll2 = new makeObj2(scrollitem,target);
	oScroll2.moveIt(25,0);
	oCont2.css.visibility = "visible";
	scrolltext2Loaded = true;
}
//	Call the init on page load if the browser is ok...
//	if (bw.bw) onload = scrolltextInit
