// BeeHive - Scrollbar Object, August 14, 2002// --------------------------------------------------------// (c) 2002, Peter Nederlof, http://www.xs4all.nl/~peterned// Layout vars, overwrite in htmlvar scrollerBG = "../media/scrollbg.gif";var upSRC      = "../media/scrollup.gif";// Quelle der up Rollover Grafik//var up-onSRC      = "images/scrollup-on.gif";var downSRC    = "../media/scrolldn.gif";// Quelle der down Rollover Grafik//var down-onSRC   = "images/scrolldn-on.gif";var scrollSRC  = "../media/scrollelm.gif";var scrollerHeight = 18;var leftOffset = 0;var extraSpace = 20;var scrollbarWidth = 9;var scrollArrows = true;var scrollCursor = 'hand';// End of layoutvar activeBar = null;var scrollCount = 0;var areaCount = 0;var useBar = null;var arrowActivator = "onmousedown"document.bars = [];function scrollbar(x, y, w, h, nest) {        this.x = x;        this.y = y;        this.w = w;        this.h = h;        this.eh = scrollerHeight;        this.sPos = scrollArrows? this.w:0;        this.sOff = scrollArrows? (2*this.w):0        this.currentLayer = null;        this.currentLyrId = "";        this.contentHeight = 0;        this.availHeight = 0;        this.scrolling = false;        this.speed = 0;        this.nested = nest;        this.build();}scrollProto = scrollbar.prototype;scrollProto.build = function() {        this.id = 'bar'+scrollCount;        this.cId = this.id + 'container';        with(this.container = new dynObject(this.cId, this.nested)) {            // Die neuen ScrollArrows sind 9x9px gro&szlig; und sollen unter dem Scrollbalken angeordnet werden //            // --> - 9 positioniert den kompletten scrollercontainer 9px weiter oben //                // --> + 9 verl&auml;ngert den Scroller 9px nach unten //                setProperties(this.x, this.y - 9, this.w, this.h + 9, 'visible', false, 1000);                // Scroller wird 9px weiter unten geclipt //                clipTo(0,this.w,this.h + 9,0);        }        with(this.track = new dynObject(this.cId+'track', this.cId)) {                setProperties(0,0, this.w, this.h, 'visible');                setBackground(scrollerBG);                // 0 --> 9 Scrollerhintergrund beginnt dadurch erst 9px von oben //                // --> - 26 Scrollerhintergrund bekommt 26px Abstand nach unten //        }        this.setupElement(this.track, 0, 9, this.w, this.h - 26,'dynTrackScroll()');        if(scrollArrows) {                this.upArrow = new dynObject(this.id + 'upArrow', this.cId);                this.downArrow = new dynObject(this.id + 'downArrow', this.cId);                // 0 --> (this.h - this.w) upscroller wird unter dem scrollbalken positioniert //                this.setupElement(this.upArrow, 0, (this.h - this.w), this.w, this.w, 'dynScrollBy(-1)', upSRC);                // --> + 9 downscroller wird weiter unten positioniert (unter dem upscroller)//                this.setupElement(this.downArrow, 0, (this.h - this.w + 9 ), this.w, this.w, 'dynScrollBy(1)', downSRC);        }        this.scroller  = new dynObject(this.id + 'scroller', this.cId);        this.setupElement(this.scroller, 0, this.sPos, this.w, scrollerHeight, false, scrollSRC);        this.availHeight = this.h - this.sOff - scrollerHeight;        // --> - 7 der Scrollbereich nach unten wird eingeschr&auml;nkt //        this.scroller.limitMovement(0, this.sPos, this.w, this.h - this.sPos - 7);        this.scroller.enableDragDrop('vertical');        document.bars[scrollCount] = this;        scrollCount ++;}scrollProto.setupElement = function(elm, x, y, w, h, mouseFunction, img) {        elm.setProperties(x, y, w, h, 'visible');        elm.clipTo(0,w,h,0);        elm.css.visibility = "inherit";        elm.scrollbar = this;        elm.css.cursor = scrollCursor;        elm.attachEvent('onmousedown', 'dynGetScrollbar()');        elm.attachEvent('onmouseup', 'dynStopScroll()');        if(img) {                if(is.NS4) elm.setBackground(img);                else elm.createImage(img, 0, w, h);        }        if(mouseFunction) {                elm.attachEvent(arrowActivator, 'dynGetScrollbar()');                elm.attachEvent('onmouseout', 'dynStopScroll()')                elm.attachEvent(arrowActivator, mouseFunction);        }}scrollProto.setHeight = function(h) {        this.h = h;        with(this.container) {                resizeTo(this.w, this.h);                clipTo(0, this.w, this.h, 0);        }        this.downArrow.moveTo(0,(this.h-this.w));        this.availHeight = this.h - this.sOff - scrollerHeight;        this.setLayer(this.currentLayer.id)        with(this.scroller) {                moveTo(0,this.sPos);                limitMovement(0, this.sPos, this.w, this.h - this.sPos);        }}function dynScrollBy(dir, target) {        if(useBar && useBar.needed) {                var useDy = dir * useBar.speed;                useBar.scroller.moveBy(0, useDy);                dynHandleScroll();                if(!target || Math.abs(useBar.scroller.y - target) > 7)                setTimeout('dynScrollBy('+dir+','+(target || 0)+')', 40);        }}function dynTrackScroll() {        if(useBar && useBar.needed && arrowActivator != 'onmouseover') {                var dy = activeObj.clickY - useBar.eh/2 - useBar.scroller.y                dynScrollBy((dy < 0)? -2.5:2.5, activeObj.clickY - useBar.eh/2)        }}        function dynWheelStep(dir) {                useBar = activeBar || document.bars[0];                if(useBar && useBar.needed) {                        useBar.scroller.moveBy(0, dir);                        dynHandleScroll();                }                dynStopScroll();        }function dynStopScroll() {        useBar = false;}function dynGetScrollbar() {        useBar = activeObj.scrollbar;        activeBar = useBar;}scrollProto.setLayer = function(to) {        if(!document.dyn[to]) {        new dynObject(to, null, true); }        if(this.currentLayer) {        this.currentLayer.setVisible(false); }        this.currentLayer = document.dyn[to];        this.currentLyrId = to;        with(this.currentLayer) {                moveTo(leftOffset, 0);                getDimensions();                this.speed = (this.h/h)*7;                this.pageHeight = this.availHeight/(h/this.h);        }        this.scroller.moveTo(0, this.sPos);        this.contentHeight = this.currentLayer.h - this.h + extraSpace;        this.currentLayer.setVisible(true);        this.needed = (this.contentHeight <= 0)? false:true;        this.container.setVisible(this.needed);}function dynHandleScroll() {        if(useBar && useBar.currentLayer) {                contentY = ((useBar.scroller.y - useBar.sPos)/                        useBar.availHeight) * useBar.contentHeight;                useBar.currentLayer.moveTo(leftOffset, - contentY)        }}document.attachEvent('onmousemove', 'dynHandleScroll()');document.attachEvent('onmouseup', 'dynStopScroll()');document.onkeydown = doKeyDown;if(is.IE6) { document.onmousewheel = doWheel; }function doWheel() {        var delta = event.wheelDelta;        if(delta) dynWheelStep(-delta/15);}var KU = is.NS4? 56:38;var KD = is.NS4? 50:40;var PU = is.NS4? 1000:33;var PD = is.NS4? 1000:34;function doKeyDown(e) {        useBar = activeBar || document.bars[0];        var key = is.IE? event.keyCode:e.which;        if(key == KU) dynWheelStep(-2);        if(key == KD) dynWheelStep(2);        if(key == PU) dynWheelStep(-useBar.pageHeight);        if(key == PD) dynWheelStep(useBar.pageHeight);}
