//»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» //-------------------------------------------------------------------------- // JavaScript Browser Object Constructor for Dynamic Html. //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- function browserCheck() { var b = navigator.appName if (b=="Netscape") this.b = "ns" else if (b=="Microsoft Internet Explorer") this.b = "ie" else this.b = b this.version = navigator.appVersion this.v = parseInt(this.version) this.ns = (this.b=="ns" && this.v>=4) this.ns4 = (this.b=="ns" && this.v==4) this.ns5 = (this.b=="ns" && this.v==5) this.ie = (this.b=="ie" && this.v>=4) this.ie4 = (this.version.indexOf('MSIE 4')>0) this.ie5 = (this.version.indexOf('MSIE 5')>0) this.min = (this.ns||this.ie) } is = new browserCheck() //-------------------------------------------------------------------------- // End of JavaScript Browser Object Constructor. //«««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««« //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» //-------------------------------------------------------------------------- // JavaScript Object Constructor for Dynamic Html. // // Usage: // layerobj(id,nestref,frame) // Public: // layerobjMoveTo(x,y) // layerobjMoveBy(x,y) // layerobjShow() // layerobjHide() // layerobjSlideInit() // layerobjSlideTo(endx,endy,inc,speed,fn) // layerobjSlideBy(distx,disty,inc,speed,fn) // layerobjSlideStart(endx,endy,distx,disty,inc,speed,fn) // layerobjSlide(dx,dy,endx,endy,num,i,speed,fn) // layerobjClipInit(clipTop,clipRight,clipBottom,clipLeft) // layerobjClipTo(t,r,b,l) // layerobjClipBy(t,r,b,l) // layerobjClipValues(which) // layerobjWrite(html) // layerobjTest(id,nestref) // Internal: // Notes: //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- function layerobj(id,nestref,frame) { if (!layerobj.set && !frame) layerInit() if (is.ns) { if (is.ns) { if (!frame) { if (!nestref) var nestref = layerobj.nestRefArray[id] if (layerobj.useTest && !layerobjTest(id,nestref)) return this.css = (nestref)? eval("document."+nestref+".document."+id) : document.layers[id] } else this.css = (nestref)? eval("parent."+frame+".document."+nestref+".document."+id) : parent.frames[frame].document.layers[id] this.elm = this.event = this.css this.doc = this.css.document } if (is.ns5) { this.elm = document.getElementById(id) this.css = this.elm.style this.doc = document } this.x = this.css.left this.y = this.css.top this.w = this.css.clip.width this.h = this.css.clip.height } else if (is.ie) { this.elm = this.event = (frame)? parent.frames[frame].document.all[id] : document.all[id] this.css = (frame)? parent.frames[frame].document.all[id].style : document.all[id].style this.doc = document this.x = this.elm.offsetLeft this.y = this.elm.offsetTop this.w = (is.ie4)? this.css.pixelWidth : this.elm.offsetWidth this.h = (is.ie4)? this.css.pixelHeight : this.elm.offsetHeight } this.id = id this.obj = id + "layerobj" eval(this.obj + "=this") this.moveTo = layerobjMoveTo this.moveBy = layerobjMoveBy this.show = layerobjShow this.hide = layerobjHide this.slideInit = layerobjSlideInit this.clipInit = layerobjClipInit this.write = layerobjWrite } //-------------------------------------------------------------------------- function layerobjMoveTo(x,y) { if (x!=null) { this.x = x if (is.ns) this.css.left = this.x else this.css.pixelLeft = this.x } if (y!=null) { this.y = y if (is.ns) this.css.top = this.y else this.css.pixelTop = this.y } } function layerobjMoveBy(x,y) { this.moveTo(this.x+x,this.y+y) } function layerobjShow() { this.css.visibility = (is.ns)? "show" : "visible" } function layerobjHide() { this.css.visibility = (is.ns)? "hide" : "hidden" } //-------------------------------------------------------------------------- function layerobjSlideInit() { this.slideTo = layerobjSlideTo this.slideBy = layerobjSlideBy this.slideStart = layerobjSlideStart this.slide = layerobjSlide this.onSlide = new Function("") this.onSlideEnd = new Function("") } function layerobjSlideTo(endx,endy,inc,speed,fn) { if (endx==null) endx = this.x if (endy==null) endy = this.y var distx = endx-this.x var disty = endy-this.y this.slideStart(endx,endy,distx,disty,inc,speed,fn) } function layerobjSlideBy(distx,disty,inc,speed,fn) { var endx = this.x + distx var endy = this.y + disty this.slideStart(endx,endy,distx,disty,inc,speed,fn) } function layerobjSlideStart(endx,endy,distx,disty,inc,speed,fn) { if (this.slideActive) return if (!inc) inc = 10 if (!speed) speed = 20 var num = Math.sqrt(Math.pow(distx,2) + Math.pow(disty,2))/inc if (num==0) return var dx = distx/num var dy = disty/num if (!fn) fn = null this.slideActive = true this.slide(dx,dy,endx,endy,num,1,speed,fn) } function layerobjSlide(dx,dy,endx,endy,num,i,speed,fn) { if (!this.slideActive) return if (i++ < num) { this.moveBy(dx,dy) this.onSlide() if (this.slideActive) setTimeout(this.obj+".slide("+dx+","+dy+","+endx+","+endy+","+num+","+i+","+speed+",\""+fn+"\")",speed) else this.onSlideEnd() } else { this.slideActive = false this.moveTo(endx,endy) this.onSlide() this.onSlideEnd() eval(fn) } } //-------------------------------------------------------------------------- function layerobjClipInit(clipTop,clipRight,clipBottom,clipLeft) { this.clipTo = layerobjClipTo this.clipBy = layerobjClipBy this.clipValues = layerobjClipValues if (is.ie) { if (arguments.length==4) this.clipTo(clipTop,clipRight,clipBottom,clipLeft) else if (is.ie4) this.clipTo(0,this.css.pixelWidth,this.css.pixelHeight,0) } } function layerobjClipTo(t,r,b,l) { if (t==null) t = this.clipValues('t') if (r==null) r = this.clipValues('r') if (b==null) b = this.clipValues('b') if (l==null) l = this.clipValues('l') if (is.ns) { this.css.clip.top = t this.css.clip.right = r this.css.clip.bottom = b this.css.clip.left = l } else if (is.ie) this.css.clip = "rect("+t+"px "+r+"px "+b+"px "+l+"px)" } function layerobjClipBy(t,r,b,l) { this.clipTo(this.clipValues('t')+t,this.clipValues('r')+r,this.clipValues('b')+b,this.clipValues('l')+l) } function layerobjClipValues(which) { if (is.ie) var clipv = this.css.clip.split("rect(")[1].split(")")[0].split("px") if (which=="t") return (is.ns)? this.css.clip.top : Number(clipv[0]) if (which=="r") return (is.ns)? this.css.clip.right : Number(clipv[1]) if (which=="b") return (is.ns)? this.css.clip.bottom : Number(clipv[2]) if (which=="l") return (is.ns)? this.css.clip.left : Number(clipv[3]) } //-------------------------------------------------------------------------- function layerobjWrite(html) { if (is.ns) { this.doc.open() this.doc.write(html) this.doc.close() } else if (is.ie) { this.event.innerHTML = html } } //-------------------------------------------------------------------------- function layerobjTest(id,nestref) { var ref = new Array() if (nestref) ref = nestref.split('.document.') ref[ref.length] = id var refstr = (is.ns)? 'document.'+ref[0] : 'document.all.'+ref[0] for (var i=1; i<=ref.length; i++) { if (eval(refstr)) { if (ref.length==i) return true else refstr += (is.ns)? '.document.'+ref[i] : '.all.'+ref[i] } else { var str ='layerobj Error:' for (j in ref) { str += '\n'+ref[j] if (j==i-1) str += ' <-- this layer cannot be found' } if (layerobjTest.count++<5) alert(str) else alert("Too many layerobj errors, quitting.") return false } } return false } layerobjTest.count = 0 //-------------------------------------------------------------------------- function layerInit(nestref) { if (!layerobj.set) layerobj.set = true if (is.ns) { if (nestref) ref = eval('document.'+nestref+'.document') else {nestref = ''; ref = document;} for (var i=0; i<ref.layers.length; i++) { var divname = ref.layers[i].name layerobj.nestRefArray[divname] = nestref var index = divname.indexOf("Div") if (index > 0) { eval(divname.substr(0,index)+' = new layerobj("'+divname+'","'+nestref+'")') } if (ref.layers[i].document.layers.length > 0) { layerobj.refArray[layerobj.refArray.length] = (nestref=='')? ref.layers[i].name : nestref+'.document.'+ref.layers[i].name } } if (layerobj.refArray.i < layerobj.refArray.length) { layerInit(layerobj.refArray[layerobj.refArray.i++]) } } else if (is.ie) { for (var i=0; i<document.all.tags("DIV").length; i++) { var divname = document.all.tags("DIV")[i].id var index = divname.indexOf("Div") if (index > 0) { eval(divname.substr(0,index)+' = new layerobj("'+divname+'")') } } } return true } layerobj.nestRefArray = new Array() layerobj.refArray = new Array() layerobj.refArray.i = 0 layerobj.set = false layerobj.useTest = true //-------------------------------------------------------------------------- // returns CSS syntax for generated layers function css(id,left,top,width,height,color,vis,z,other) { if (id=="START") return '<STYLE TYPE="text/css">\n' else if (id=="END") return '</STYLE>' var str = (left!=null && top!=null)? '#'+id+' {position:absolute; left:'+left+'px; top:'+top+'px;' : '#'+id+' {position:relative;' if (arguments.length>=4 && width!=null) str += ' width:'+width+'px;' if (arguments.length>=5 && height!=null) { str += ' height:'+height+'px;' if (arguments.length<9 || other.indexOf('clip')==-1) str += ' clip:rect(0px '+width+'px '+height+'px 0px);' } if (arguments.length>=6 && color!=null) str += (is.ns)? ' layer-background-color:'+color+';' : ' background-color:'+color+';' if (arguments.length>=7 && vis!=null) str += ' visibility:'+vis+';' if (arguments.length>=8 && z!=null) str += ' z-index:'+z+';' if (arguments.length==9 && other!=null) str += ' '+other str += '}\n' return str } function writeCSS(str,showAlert) { str = css('START')+str+css('END') document.write(str) if (showAlert) alert(str) } //-------------------------------------------------------------------------- // End of JavaScript Object Constructor. //«««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««« <!--------------------------------------------------------------------------> <!-------------------------------------------------------------------------->