// x.js // X v3.14.1, Cross-Browser DHTML Library from Cross-Browser.com // Copyright (c) 2002,2003 Michael Foster (mike@cross-browser.com) // This library is distributed under the terms of the LGPL (gnu.org) // Variables: var xVersion='3.14.1',xOp7=false,xOp5or6=false,xIE4Up=false,xNN4=false,xUA=navigator.userAgent.toLowerCase(); if(window.opera){ xOp7=(xUA.indexOf('opera 7')!=-1 || xUA.indexOf('opera/7')!=-1); if (!xOp7) xOp5or6=(xUA.indexOf('opera 5')!=-1 || xUA.indexOf('opera/5')!=-1 || xUA.indexOf('opera 6')!=-1 || xUA.indexOf('opera/6')!=-1); } else if(document.layers) {xNN4=true;} else {xIE4Up=document.all && xUA.indexOf('msie')!=-1 && parseInt(navigator.appVersion)>=4;} // Object: function xGetElementById(e) { if(typeof(e)!='string') return e; if(document.getElementById) e=document.getElementById(e); else if(document.all) e=document.all[e]; else if(document.layers) e=xLayer(e); else e=null; return e; } function xParent(e,bNode){ if (!(e=xGetElementById(e))) return null; var p=null; if (!bNode && xDef(e.offsetParent)) p=e.offsetParent; else if (xDef(e.parentNode)) p=e.parentNode; else if (xDef(e.parentElement)) p=e.parentElement; else if (xDef(e.parentLayer)){if (e.parentLayer!=window) p=e.parentLayer;} return p; } function xDef() { for(var i=0; iwindow.innerHeight) w-=16; } return w; } function xClientHeight() { var h=0; if(xOp5or6) h=window.innerHeight; else if(!window.opera && document.documentElement && document.documentElement.clientHeight) // v3.12 h=document.documentElement.clientHeight; else if(document.body && document.body.clientHeight) h=document.body.clientHeight; else if(xDef(window.innerWidth,window.innerHeight,document.width)) { h=window.innerHeight; if(document.width>window.innerWidth) h-=16; } return h; } // Animation: function xSlideTo(e,x,y,uTime) { if (!(e=xGetElementById(e))) return; if (!e.timeout) e.timeout = 25; e.xTarget = x; e.yTarget = y; e.slideTime = uTime; e.stop = false; e.yA = e.yTarget - xTop(e); e.xA = e.xTarget - xLeft(e); // A = distance e.B = Math.PI / (2 * e.slideTime); // B = period e.yD = xTop(e); e.xD = xLeft(e); // D = initial position var d = new Date(); e.C = d.getTime(); if (!e.moving) xSlide(e); } function xSlide(e) { if (!(e=xGetElementById(e))) return; var now, s, t, newY, newX; now = new Date(); t = now.getTime() - e.C; if (e.stop) { e.moving = false; } else if (t < e.slideTime) { setTimeout("xSlide('"+e.id+"')", e.timeout); s = Math.sin(e.B * t); newX = Math.round(e.xA * s + e.xD); newY = Math.round(e.yA * s + e.yD); xMoveTo(e, newX, newY); e.moving = true; } else { xMoveTo(e, e.xTarget, e.yTarget); e.moving = false; } } // Event: function xAddEventListener(e,eventType,eventListener,useCapture) { if(!(e=xGetElementById(e))) return; eventType=eventType.toLowerCase(); if((!xIE4Up && !xOp7) && e==window) { if(eventType=='resize') { window.xPCW=xClientWidth(); window.xPCH=xClientHeight(); window.xREL=eventListener; xResizeEvent(); return; } if(eventType=='scroll') { window.xPSL=xScrollLeft(); window.xPST=xScrollTop(); window.xSEL=eventListener; xScrollEvent(); return; } } var eh='e.on'+eventType+'=eventListener'; if(e.addEventListener) e.addEventListener(eventType,eventListener,useCapture); else if(e.attachEvent) e.attachEvent('on'+eventType,eventListener); else if(e.captureEvents) { if(useCapture||(eventType.indexOf('mousemove')!=-1)) { e.captureEvents(eval('Event.'+eventType.toUpperCase())); } eval(eh); } else eval(eh); } function xRemoveEventListener(e,eventType,eventListener,useCapture) { if(!(e=xGetElementById(e))) return; eventType=eventType.toLowerCase(); if((!xIE4Up && !xOp7) && e==window) { if(eventType=='resize') { window.xREL=null; return; } if(eventType=='scroll') { window.xSEL=null; return; } } var eh='e.on'+eventType+'=null'; if(e.removeEventListener) e.removeEventListener(eventType,eventListener,useCapture); else if(e.detachEvent) e.detachEvent('on'+eventType,eventListener); else if(e.releaseEvents) { if(useCapture||(eventType.indexOf('mousemove')!=-1)) { e.releaseEvents(eval('Event.'+eventType.toUpperCase())); } eval(eh); } else eval(eh); } function xEvent(evt) { // cross-browser event object prototype this.type = ''; this.target = null; this.pageX = 0; this.pageY = 0; this.offsetX = 0; this.offsetY = 0; this.keyCode = 0; var e = evt ? evt : window.event; if(!e) return; if(e.type) this.type = e.type; if(e.target) this.target = e.target; else if(e.srcElement) this.target = e.srcElement; else if(xNN4) this.target = xLayerFromPoint(e.pageX, e.pageY); if(xOp5or6) { this.pageX = e.clientX; this.pageY = e.clientY; } else if(xDef(e.pageX,e.pageY)) { this.pageX = e.pageX; this.pageY = e.pageY; } // v3.14 else if(xDef(e.clientX,e.clientY)) { this.pageX = e.clientX + xScrollLeft(); this.pageY = e.clientY + xScrollTop(); } if(xDef(e.offsetX,e.offsetY)) { this.offsetX = e.offsetX; this.offsetY = e.offsetY; } else if(xDef(e.layerX,e.layerY)) { this.offsetX = e.layerX; this.offsetY = e.layerY; } else { this.offsetX = this.pageX - xPageX(this.target); this.offsetY = this.pageY - xPageY(this.target); } if (e.keyCode) { this.keyCode = e.keyCode; } // for moz/fb, if keyCode==0 use which else if (xDef(e.which)) { this.keyCode = e.which; } } function xResizeEvent() { // window resize event simulation if (window.xREL) setTimeout('xResizeEvent()', 250); var cw = xClientWidth(), ch = xClientHeight(); if (window.xPCW != cw || window.xPCH != ch) { window.xPCW = cw; window.xPCH = ch; if (window.xREL) window.xREL(); } } function xScrollEvent() { // window scroll event simulation if (window.xSEL) setTimeout('xScrollEvent()', 250); var sl = xScrollLeft(), st = xScrollTop(); if (window.xPSL != sl || window.xPST != st) { window.xPSL = sl; window.xPST = st; if (window.xSEL) window.xSEL(); } } // end x.js