/**
* scrolllayer.js
* 
* @version $Id: scrolllayer.js,v 1.3 2005/11/11 13:16:04 rzu Exp $
* @version $Revision: 1.3 $
* @author rzu <rzu@gurus-net.de>
* @since 2005
* @copyright copyright (c) 2005 gurus - zurawski zurawski poppl rohland gbr
*/

/**
* Revision History
* --------------------------------------------------------------------------
* $Log: scrolllayer.js,v $
* Revision 1.3  2005/11/11 13:16:04  rzu
* mbh - Objectfehler im JS gefixt
*
* Revision 1.2  2005/11/11 09:50:36  rzu
* mbh - Reihenfolge bei den news eingebaut, Scroller für Newsliste
*
* Revision 1.1  2005/08/31 15:04:04  rzu
* mbh - Inhalte eingepflegt, Adminbereich für Mitarbeiter und News
*
*
*
*/ 

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;
alert(this.scrollHeight);
	} 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);
//        this.line=new makeObj(whitelinelayer);

        if (this.bound.clipHeight< this.cont.scrollHeight) {
                this.down.css.visibility='visible';
//                this.line.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 scrollInit1() {
	sl1=new createScrollLayer('divCont','divText','divUp','divDown',5,50,'sl1');
}

function scrollInit2() {
	sl1=new createScrollLayer('divCont','divText','divUp','divDown',5,50,'sl1');
	sl2=new createScrollLayer('divCont2','divText2','divUp2','divDown2',5,50,'sl2');
}

bw=new checkBrowser();



