// BeeHive - Dhtml Library, August 15, 2002 // -------------------------------------------------------- // (c) 2002, Peter Nederlof, http://www.xs4all.nl/~peterned // // -------------------------------------------------------- // patched + rewritten, Owen van Dijk TROS Internet // last edit date : 21 augustus 2002 document.dyn = new Array(); var dynLoaded = true; var is = "", topZ = 500; // Browser check // -------------------------------------------------------- function BrowserCheck() { var n = navigator; var d = document; var v = n.appVersion; var ua = n.userAgent; this.IE = (ua.indexOf('MSIE') > -1) this.NS = (n.appName.indexOf('Netscape') > -1) this.OP = (ua.indexOf('Opera') > -1) this.IE4 = (d.all && !d.getElementById)? true:false; this.IE4UP = (this.IE &&(d.all || d.getElementById))? true:false; this.IE5 = (ua.indexOf('MSIE 5.0') > -1) this.IE55 = (ua.indexOf('MSIE 5.5') > -1) this.IE6 = (ua.indexOf('MSIE 6.0') > -1) this.NS4 = (this.NS && v.indexOf("4.") > -1)? true:false; this.NS6 = (this.NS && d.getElementById)? true:false; this.DOM = (d.getElementById && d.createElement)? true:false; this.OP5 = (this.OP && ua.indexOf('5.') > -1) this.MAC = (n.platform.indexOf('Mac') > -1) } is = new BrowserCheck(); // Layer object // -------------------------------------------------------- function dynObject(id, nestIn, attach) { this.id = id; this.nested = nestIn || false; this.parent = false; this.children = []; this.attached = attach; this.create(); } dynProto = dynObject.prototype; function attachObject(id, nestIn) { return document.dyn[id] || new dynObject(id, nestIn, true); } // Basic Functions // -------------------------------- dynProto.moveTo = function(x, y) { this.x = x; this.y = y; if(this.limitedMove) { var mLim = this.limits if(x < mLim[0]) this.x = mLim[0]; if(y < mLim[1]) this.y = mLim[1]; var xl = mLim[2] - this.w; if(x > xl) this.x = xl; var yl = mLim[3] - this.h; if(y > yl) this.y = yl; } if(!this.mayNotMove) { this.css.left = this.x; this.css.top = this.y; } } dynProto.slideTo = function(x, y, time, style) { if(time < 50) { alert('Warning: slide-time too short (<50)'); return; } this.tx = x; this.ty = y; this.stepX = (this.tx - this.x)/(time/50); this.stepY = (this.ty - this.y)/(time/50); this.slideStyle = (style == "slowed")? 0.97:false; if(this.timer) clearInterval(this.timer); this.timer = setInterval('document.dyn["'+this.id+'"].slideStep()', 50); this.isSliding = true; } dynProto.slideBy = function(dx, dy, time, style) { this.slideTo(this.x+dx, this.y+dy, time, style); } dynProto.slideStep = function() { if((this.tx - this.x)/this.stepX < 1 || (this.ty - this.y)/this.stepY < 1) { clearInterval(this.timer); if(this.onSlideEnd) eval(this.onSlideEnd); this.moveTo(this.tx, this.ty); this.isSliding = false; } else this.moveBy(this.stepX, this.stepY); if(this.slideStyle) { this.stepX *= this.slideStyle; this.stepY *= this.slideStyle; } } dynProto.moveBy = function(dx, dy) { this.moveTo(this.x + dx, this.y + dy); } dynProto.write = function(content) { this.html = content; if(is.NS4) { with(this.document) {open(); write(content); close();} } else { this.innerHTML = '\n'+ this.html +'\n';} } dynProto.add = function(content) { this.html += content; this.write(this.html); } dynProto.setVisible = function(mode) { this.css.visibility = (mode)? (this.nested? 'inherit':'visible'):"hidden"; this.visible = mode; } dynProto.setZIndex = function(z) { this.css.zIndex = this.z = z; if(z > topZ) topZ = z; } dynProto.bringToFront = function() { this.setZIndex(topZ + 1); } dynProto.setBackground = function(to) { if(to.indexOf('.') != -1) { if(is.IE4UP || is.NS6) this.css.backgroundImage = "url("+to+")"; else { if(is.NS4) this.background.src = to; } } else { if(is.OP5) this.css.background = to; else if(is.IE4UP || is.NS6) this.css.backgroundColor = to; else { if(is.NS4) this.bgColor = to; } } } dynProto.resizeTo = function(w,h) { if(is.NS4 && w && h) this.resizeTo(w,h); if(w) this.setWidth(w); if(h) this.setHeight(h); } dynProto.setWidth = function(w) { this.w = w; this.r = this.x + w; if(is.OP5) this.css.pixelWidth = w; else this.resize.width = w; } dynProto.setHeight = function(h) { this.h = h; this.b = this.y + h; if(is.OP5) this.css.pixelHeight = h; else this.resize.height = h; } dynProto.clipTo = function(t,w,h,l) { this.clip = [t,w,h,l]; if(is.IE4UP || is.NS6) { this.css.clip = 'rect('+t+','+w+','+h+','+l+')'; } else if(is.NS4) { with(this) { clip.top = t; clip.width = w; clip.height = h; clip.left = l; } } } dynProto.getDimensions = function() { if(is.IE4UP || is.NS6) { this.w = (is.IE4UP)? this.clientWidth:this.offsetWidth; this.h = (is.IE4UP)? this.clientHeight:this.offsetHeight; } else if(is.NS4) { this.w = this.document.width; this.h = this.document.height; } this.x = parseInt(this.css.left); this.r = this.x + this.w; this.y = parseInt(this.css.top); this.b = this.y + this.h; } dynProto.setProperties = function(x, y, w, h, vis, bg, z) { this.moveTo(x,y); this.resizeTo(w,h); if(vis) this.setVisible((vis=="visible")?true:false); if(bg) this.setBackground(bg); if(z) this.setZIndex(z); } dynProto.limitMovement = function(x,y,w,h) { this.limits = [x,y,w,h]; this.limitedMove = true; } dynProto.createImage = function(src, name, w, h) { var imgName = (name)? (' name="'+name+'"'):''; var iDim = (w? (' width='+w+' '):'') + (h? (' height='+h+' '):''); this.write(''); if(name) { var target = (is.NS4)? this.document:document; this.image = target.images[name]; } } dynProto.setOpacity = function(to) { this.opacity = to; if(is.NS6) this.css.MozOpacity = to/100; if(is.IE4UP) this.css.filter = 'alpha(opacity='+to+')' } dynProto.setBorder = function(width, style, color) { this.css.borderWidth = width; this.css.borderStyle = style || 'solid'; this.css.borderColor = color || 'black'; } var defaultAttributes = 'position:absolute; left:0px; top:0px; visibility:hidden;'; dynProto.create = function() { if(this.nested && !this.attached) { this.parent = attachObject(this.nested) this.parent.children[this.parent.children.length] = this; this.parent.children[this.id] = this; } // Initialise new Object // -------------------------------- if(!this.attached) { if(is.IE4UP) { var source = '
'; var target = (this.nested)? getObject(this.nested):document.body; target.insertAdjacentHTML('beforeEnd',source); } else if(is.DOM) { var source = document.createElement("Div"); source.setAttribute('style', defaultAttributes); source.id = this.id; var target = (this.nested)? getObject(this.nested):document.body; target.appendChild(source); } else if(is.NS4) { if(!this.parent) document.layers[this.id] = new Layer(100); else document.layers[this.id] = new Layer(100, getObject(this.nested)); } } this.layer = getObject(this.id); if(!this.layer) { alert('WARNING \n\n Layer: '+this.id+' was NOT found');} if(is.NS4) { this.layer.id = this.id; this.layer.style = this.layer; } this.css = this.layer.style; this.resize = (is.NS4)? this.layer.document:this.css; document.dyn[document.dyn.length] = this; document.dyn[this.id] = this; if(this.attached) this.getDimensions(); } // Finding objects // -------------------------------------------------------- function getObject(id) { if(is.IE4UP) return document.all[id]; if(is.NS6) return document.getElementById(id); if(is.NS4) return findObject(id, document); } function findObject(name, doc) { if(doc.layers[name]) return doc.layers[name]; for (var i=0; i