
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;
}

function makeObj(obj,nest) {
        this.el=0;
        this.css=0;
		
        if (bw.dom) {
                this.el=document.getElementById(obj);
                this.css=document.getElementById(obj).style;
                this.scrollHeight=this.el.offsetHeight;
                this.clipHeight=this.el.offsetHeight;
        } else if (bw.ie4) {
                this.el=document.all[obj];
                this.css=document.all[obj].style;
                this.scrollHeight=this.el.offsetHeight;
                this.clipHeight=this.el.offsetHeight;
	} else if (bw.ns4) {
	        if (!nest) {
			nest='';
		} else {
			nest='document.'+nest+'.';
		}
                this.el=eval(nest+'document.'+obj);
                this.css=eval(nest+'document.'+obj);
                this.scrollHeight=this.css.document.height;
                this.clipHeight=this.css.clip.height;
	}
        return this;
}

function createScrollLayer(boundinglayer,contentlayer,btnuplayer,btndownlayer,scrollspeed,timeout,id) {
        this.id=id;
        this.bound=new makeObj(boundinglayer);
        this.cont=new makeObj(contentlayer,boundinglayer);

        this.up=new makeObj(btnuplayer);
        this.down=new makeObj(btndownlayer);

        if (this.bound.clipHeight< this.cont.scrollHeight) {
                this.down.css.visibility='visible';
        }

	this.cont.css.top=0;
        this.cont.css.left=0;

	this.cont.css.visibility='visible';
//        this.cont.css.display='block';
        this.bound.css.visibility='visible';
        this.loaded=true;
        this.speed=scrollspeed;

        this.timeout=timeout;
        this.ypos=0;

        this.scroll=scroll;
        return this;
}

function scroll(direction) {
	if(this.loaded) {
                if(direction>0) {
	                this.loop=true;
	                if ( this.ypos>(-this.cont.scrollHeight+this.bound.clipHeight)) {
                                this.cont.css.top=(this.ypos=this.ypos-this.speed);
	                        if (this.loop) this.timer=setTimeout(this.id+'.scroll(1)',this.timeout);
	                        this.up.css.visibility='visible';
	                } else {
	                        this.down.css.visibility='hidden';
	                }
                } if (direction<0) {
	                this.loop=true;
		        if (this.ypos<0) {
                                this.cont.css.top=(this.ypos=this.ypos+this.speed);
	                        if (this.loop) this.timer=setTimeout(this.id+'.scroll(-1)',this.timeout);
				this.down.css.visibility='visible';
		        } else {
				this.up.css.visibility='hidden';
		        }
		} else if (direction==0) {
                        this.loop=false;
                        if (this.timer) clearTimeout(this.timer);
                }
        }
}


function scrollInit() {
	sl1=new createScrollLayer('divCont','Spalte B','divUp_b','divDown_b',7,50,'sl1');
	sl2=new createScrollLayer('divCont2','Spalte A','divUp_a','divDown_a',7,50,'sl2');
}

bw=new checkBrowser();


