home *** CD-ROM | disk | FTP | other *** search
- // Lemon (HK) Ltd
- // last modified on 30 July 1999
-
- __INIT = IE = NS = ver4 = zmax = 0;
- __registered_Slide = new Array();
- __registered_Grow = new Array();
- __registered_Loading = new Array();
-
- function SimpleLayer(src) {
- if (!__INIT) {
- IE = document.all ? 1 : 0;
- NS = document.layers ? 1 : 0;
- IE4 = navigator.appVersion.indexOf("MSIE 5") == -1;
- zmax = 999;
- __INIT=true;
- document.onmouseup = null;
- document.onmousedown = null;
- document.onmousemove = null;
- }
- this.obj = getObject(src);
- if (NS) {
- this.x = this.obj.left;
- this.y = this.obj.top;
- this.w = this.obj.clip.width;
- this.h = this.obj.clip.height;
- this.z = this.obj.zIndex;
- }
- if (IE) {
- this.x = this.obj.offsetLeft;
- this.y = this.obj.offsetTop;
- this.w = this.obj.offsetWidth;
- this.h = this.obj.offsetHeight;
- this.z = this.obj.style.zIndex;
- }
- this.id = this.obj.id;
- this.moveTo = SimpleLayerMoveTo;
- this.moveBy = SimpleLayerMoveBy;
- this.resize = SimpleLayerResize;
- this.clip = SimpleLayerClip;
- this.isVisible = SimpleLayerIsVisible;
- this.show = SimpleLayerShow;
- this.hide = SimpleLayerHide;
- this.bringTo = SimpleLayerBringTo;
- this.bringToFront = SimpleLayerBringToFront;
- this.bringToBack = SimpleLayerBringToBack;
- this.slideTo = SimpleLayerSlideTo;
- this.growTo = SimpleLayerGrowTo;
- this.load = SimpleLayerLoad;
- this.onMouseDown = SimpleLayerOnMouseDown;
- this.onMouseUp = SimpleLayerOnMouseUp;
- this.onMouseMove = SimpleLayerOnMouseMove;
- this.onMouseOver = SimpleLayerOnMouseOver;
- this.onMouseOut = SimpleLayerOnMouseOut;
- this.path=src;
- this.timeout=null;
- this.iframe=null;
- this.afterSlide = null;
- this.clip(0,this.w,0,this.h);
- }
- function SimpleLayerMoveTo(x,y) {
- this.x=x; this.y=y;
- if (NS) { this.obj.left = x; this.obj.top = y; }
- else { this.obj.style.pixelLeft = x; this.obj.style.pixelTop = y; }
- }
- function SimpleLayerMoveBy(x,y) {
- this.moveTo(this.x+x,this.y+y);
- }
- function SimpleLayerResize(w,h) {
- this.w=w; this.h=h;
- this.clip(0,w,0,h);
- if (NS) { this.obj.clip.width = w; this.obj.clip.height = h; }
- else { this.obj.style.pixelWidth = w; this.obj.style.pixelHeight = h; }
- }
- function SimpleLayerClip(l,r,t,b) {
- if (NS) {
- this.obj.clip.left=l;
- this.obj.clip.right=r;
- this.obj.clip.top=t;
- this.obj.clip.bottom=b;
- }
- else this.obj.style.clip = "rect("+t+"px, "+r+"px, "+b+"px, "+l+"px)";
- }
- function SimpleLayerIsVisible() {
- return NS ? this.obj.visibility == "show": this.obj.style.visibility == "visible";
- }
- function SimpleLayerShow() {
- NS ? this.obj.visibility = "show" : this.obj.style.visibility = "visible";
- }
- function SimpleLayerHide() {
- NS ? this.obj.visibility = "hide" : this.obj.style.visibility = "hidden";
- }
- function SimpleLayerBringTo(i) {
- NS ? this.obj.zIndex=i : this.obj.style.zIndex=i;
- }
- function SimpleLayerBringToFront() {
- this.bringTo(zmax++);
- }
- function SimpleLayerBringToBack() {
- this.bringTo(1);
- }
- function SimpleLayerSlideTo(dx, dy, speed, dec, owner) {
- if (__registered_Slide[this.id] == null) __registered_Slide[this.id] = this;
-
- var ddx = (dx > -speed && dx < speed) ? dx : Math.floor(dx/speed);
- var ddy = (dy > -speed && dy < speed) ? dy : Math.floor(dy/speed);
- var obj = owner ? __registered_Slide[owner] : this;
- if (!dec) dec=0.5; // 0 to 1
- obj.moveBy(ddx,-ddy);
- dx -= ddx; dy -= ddy; speed-=1-dec;
- if (dx || dy) obj.timeout = setTimeout("SimpleLayerSlideTo("+dx+","+dy+","+speed+","+dec+",'"+obj.id+"')",100);
- else {
- __registered_Slide[owner ? owner : this.id] = null;
- obj.timeout=null;
- if (obj.afterSlide!=null) obj.afterSlide();
- }
- }
- function SimpleLayerGrowTo(dw, dh, speed, dec, owner) {
- if (__registered_Grow[this.id] == null) __registered_Grow[this.id] = this;
-
- var ddw = (dw > -speed && dw < speed) ? dw : Math.floor(dw/speed);
- var ddh = (dh > -speed && dh < speed) ? dh : Math.floor(dh/speed);
- var obj = owner ? __registered_Grow[owner] : this;
- if (!dec) dec=0.5; // 0 to 1
- obj.resize(obj.w+ddw, obj.h+ddh);
- dw -= ddw; dh -= ddh; speed-=1-dec;
- if (dw || dh) obj.timeout = setTimeout("SimpleLayerGrowTo("+dw+","+dh+","+speed+","+dec+",'"+obj.id+"')",100);
- else {
- __registered_Grow[owner ? owner : this.id] = null;
- obj.timeout=null;
- // if (obj.afterSlide!=null) obj.afterSlide();
- }
- }
- function SimpleLayerLoad(url) {
- if (NS) this.obj.load(url,this.w);
- else {
- if (!this.iframe) {
- this.obj.innerHTML = '<div id=SOURCE style="visibility:hidden"><IFRAME name=IF_' + this.id + ' style="height:0px; width:0px; visibility:hidden"></IFRAME></div><div id=DATA></div>';
- this.iframe = this.obj.all("SOURCE").all("IF_" + this.id);
- }
- this.iframe.src=url;
- __registered_Loading["IF_" + this.id] = this;
- }
- }
- function SimpleLayerLoaded(name) {
- if (NS) return;
- for (var i=document.frames.length-1; i>=0; i--)
- {
- if (document.frames(i).loaded == 1) {
- var fname = document.frames(i).name;
- var t = document.frames(fname).document.body.innerHTML;
- var t_obj = __registered_Loading[fname];
- if (t_obj) t_obj.obj.all("DATA").innerHTML = t;
- __registered_Loading[fname] = null;
- }
- }
- }
- function SimpleLayerOnMouseDown(handler) {
- if (NS) {
- if (handler) this.obj.captureEvents(Event.MOUSEDOWN); else this.obj.releaseEvents(Event.MOUSEDOWN);
- }
- this.obj.onmousedown = handler;
- }
- function SimpleLayerOnMouseUp(handler) {
- if (NS) {
- if (handler) this.obj.captureEvents(Event.MOUSEUP); else this.obj.releaseEvents(Event.MOUSEUP);
- }
- this.obj.onmouseup = handler;
- }
- function SimpleLayerOnMouseMove(handler) {
- if (NS) {
- if (handler) this.obj.captureEvents(Event.MOUSEMOVE); else this.obj.releaseEvents(Event.MOUSEMOVE);
- }
- this.obj.onmousemove = handler;
- }
- function SimpleLayerOnMouseOver(handler) {
- this.obj.onmouseover = handler;
- }
- function SimpleLayerOnMouseOut(handler) {
- this.obj.onmouseout = handler;
- }
- function getObject(name) {
- var obj;
- var names = name.split(".");
- for (var i=0; i<names.length; i++) {
- if (!i) obj = NS ? "document.layers['" + names[i] + "']" : "document.all['" + names[i] + "']";
- else obj += (NS ? ".document." : ".all.") + names[i];
- }
- return eval(obj);
- }
- function getParent(name) {
- var obj=null;
- var names = name.split(".");
- for (var i=0; i<names.length-1; i++) {
- if (!i) obj = NS ? "document.layers['" + names[i] + "']" : "document.all['" + names[i] + "']";
- else obj += (NS ? ".document." : ".all.") + names[i];
- }
- if (!obj) return null;
- return eval(obj);
- }
- function findObject(obj, arr) {
- var rslt = null;
- for (var i=arr.length-1; i>=0; i--)
- if (obj == arr[i].obj) { rslt=arr[i]; break; }
- return rslt;
- }
-