/* x.js compiled from X 4.0 with XC 0.27b. Distributed by GNU LGPL. For copyrights, license, documentation and more visit Cross-Browser.com */ // globals, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL var xOp7Up,xOp6Dn,xIE4Up,xIE4,xIE5,xNN4,xUA=navigator.userAgent.toLowerCase(); if(window.opera){ var i=xUA.indexOf('opera'); if(i!=-1){ var v=parseInt(xUA.charAt(i+6)); xOp7Up=v>=7; xOp6Dn=v<7; } } else if(navigator.vendor!='KDE' && document.all && xUA.indexOf('msie')!=-1){ xIE4Up=parseFloat(navigator.appVersion)>=4; xIE4=xUA.indexOf('msie 4')!=-1; xIE5=xUA.indexOf('msie 5')!=-1; } else if(document.layers){xNN4=true;} xMac=xUA.indexOf('mac')!=-1; // xAddEventListener, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xAddEventListener(e,eT,eL,cap) { if(!(e=xGetElementById(e))) return; eT=eT.toLowerCase(); if((!xIE4Up && !xOp7Up) && e==window) { if(eT=='resize') { window.xPCW=xClientWidth(); window.xPCH=xClientHeight(); window.xREL=eL; xResizeEvent(); return; } if(eT=='scroll') { window.xPSL=xScrollLeft(); window.xPST=xScrollTop(); window.xSEL=eL; xScrollEvent(); return; } } var eh='e.on'+eT+'=eL'; if(e.addEventListener) e.addEventListener(eT,eL,cap); else if(e.attachEvent) e.attachEvent('on'+eT,eL); else eval(eh); } // called only from the above function xResizeEvent() { 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() { 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(); } } // xAppendChild, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xAppendChild(oParent, oChild) { if (oParent.appendChild) return oParent.appendChild(oChild); else return null; } // xBackground, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xBackground(e,c,i) { if(!(e=xGetElementById(e))) return ''; var bg=''; if(e.style) { if(xStr(c)) { if(!xOp6Dn) e.style.backgroundColor=c; else e.style.background=c; } if(xStr(i)) e.style.backgroundImage=(i!='')? 'url('+i+')' : null; if(!xOp6Dn) bg=e.style.backgroundColor; else bg=e.style.background; } return bg; } // xBar, Copyright 2003,2004,2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL // Bar-Graph Object function xBar(dir, // direction, 'ltr', 'rtl', 'ttb', or 'btt' conStyle, barStyle) // container and bar style class names { //// Public Properties this.value = 0; // current value, read-only //// Public Methods // Update current value this.update = function(v) { if (v < 0) v = 0; else if (v > this.inMax) v = this.inMax; this.con.title = this.bar.title = this.value = v; switch(this.dir) { case 'ltr': // left to right v = this.scale(v, this.w); xLeft(this.bar, v - this.w); break; case 'rtl': // right to left v = this.scale(v, this.w); xLeft(this.bar, this.w - v); break; case 'btt': // bottom to top v = this.scale(v, this.h); xTop(this.bar, this.h - v); break; case 'ttb': // top to bottom v = this.scale(v, this.h); xTop(this.bar, v - this.h); break; } }; // Change position and/or size this.paint = function(x, y, // container position w, h) // container size { if (xNum(x)) this.x = x; if (xNum(y)) this.y = y; if (xNum(w)) this.w = w; if (xNum(h)) this.h = h; xResizeTo(this.con, this.w, this.h); xMoveTo(this.con, this.x, this.y); xResizeTo(this.bar, this.w, this.h); xMoveTo(this.bar, 0, 0); }; // Change scale and/or start value this.reset = function(max, start) // non-scaled values { if (xNum(max)) this.inMax = max; if (xNum(start)) this.start = start; this.update(this.start); }; //// Private Methods this.scale = function(v, outMax) { return Math.round(xLinearScale(v, 0, this.inMax, 0, outMax)); }; //// Private Properties this.dir = dir; this.x = 0; this.y = 0; this.w = 100; this.h = 100; this.inMax = 100; this.start = 0; this.conStyle = conStyle; this.barStyle = barStyle; //// Constructor // Create container this.con = document.createElement('DIV'); this.con.className = this.conStyle; // Create bar this.bar = document.createElement('DIV'); this.bar.className = this.barStyle; // Insert in object tree this.con.appendChild(this.bar); document.body.appendChild(this.con); } // end xBar // xCapitalize, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL // Capitalize the first letter of every word in str. function xCapitalize(str) { var i, c, wd, s='', cap = true; for (i = 0; i < str.length; ++i) { c = str.charAt(i); wd = isWordDelim(c); if (wd) { cap = true; } if (cap && !wd) { c = c.toUpperCase(); cap = false; } s += c; } return s; function isWordDelim(c) { // add other word delimiters as needed // (for example '-' and other punctuation) return c == ' ' || c == '\n' || c == '\t'; } } // xCardinalPosition, Copyright 2004-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xCardinalPosition(e, cp, margin, outside) { if(!(e=xGetElementById(e))) return; if (typeof(cp)!='string'){window.status='xCardinalPosition error: cp=' + cp + ', id=' + e.id; return;} var x=xLeft(e), y=xTop(e), w=xWidth(e), h=xHeight(e); var pw,ph,p = xParent(e); if (p == document || p.nodeName.toLowerCase() == 'html') {pw = xClientWidth(); ph = xClientHeight();} else {pw=xWidth(p); ph=xHeight(p);} var sx=xScrollLeft(p), sy=xScrollTop(p); var right=sx + pw, bottom=sy + ph; var cenLeft=sx + Math.floor((pw-w)/2), cenTop=sy + Math.floor((ph-h)/2); if (!margin) margin=0; else{ if (outside) margin=-margin; sx +=margin; sy +=margin; right -=margin; bottom -=margin; } switch (cp.toLowerCase()){ case 'n': x=cenLeft; if (outside) y=sy - h; else y=sy; break; case 'ne': if (outside){x=right; y=sy - h;}else{x=right - w; y=sy;}break; case 'e': y=cenTop; if (outside) x=right; else x=right - w; break; case 'se': if (outside){x=right; y=bottom;}else{x=right - w; y=bottom - h}break; case 's': x=cenLeft; if (outside) y=sy - h; else y=bottom - h; break; case 'sw': if (outside){x=sx - w; y=bottom;}else{x=sx; y=bottom - h;}break; case 'w': y=cenTop; if (outside) x=sx - w; else x=sx; break; case 'nw': if (outside){x=sx - w; y=sy - h;}else{x=sx; y=sy;}break; case 'cen': x=cenLeft; y=cenTop; break; case 'cenh': x=cenLeft; break; case 'cenv': y=cenTop; break; } var o = new Object(); o.x = x; o.y = y; return o; } // xClientHeight, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xClientHeight() { var h=0; if(xOp6Dn) h=window.innerHeight; else if(document.compatMode == 'CSS1Compat' && !window.opera && document.documentElement && document.documentElement.clientHeight) 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; } // xClientWidth, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xClientWidth() { var w=0; if(xOp6Dn) w=window.innerWidth; else if(document.compatMode == 'CSS1Compat' && !window.opera && document.documentElement && document.documentElement.clientWidth) w=document.documentElement.clientWidth; else if(document.body && document.body.clientWidth) w=document.body.clientWidth; else if(xDef(window.innerWidth,window.innerHeight,document.height)) { w=window.innerWidth; if(document.height>window.innerHeight) w-=16; } return w; } // xClip, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xClip(e,t,r,b,l) { if(!(e=xGetElementById(e))) return; if(e.style) { if (xNum(l)) e.style.clip='rect('+t+'px '+r+'px '+b+'px '+l+'px)'; else e.style.clip='rect(0 '+parseInt(e.style.width)+'px '+parseInt(e.style.height)+'px 0)'; } } // xCollapsible, Copyright 2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xCollapsible(outerEle, bShow) // object prototype { // Constructor var container = xGetElementById(outerEle); if (!container) {return null;} var isUL = container.nodeName.toUpperCase() == 'UL'; var i, trg, aTgt = xGetElementsByTagName(isUL ? 'UL':'DIV', container); for (i = 0; i < aTgt.length; ++i) { trg = xPrevSib(aTgt[i]); if (trg && (isUL || trg.nodeName.charAt(0).toUpperCase() == 'H')) { aTgt[i].xTrgPtr = trg; aTgt[i].style.display = bShow ? 'block' : 'none'; trg.style.cursor = 'pointer'; trg.xTgtPtr = aTgt[i]; trg.onclick = trg_onClick; } } // Private function trg_onClick() { var tgt = this.xTgtPtr.style; if (tgt.display == 'none') { tgt.display = 'block'; } else { tgt.display = 'none'; } } // Public this.displayAll = function(bShow) { for (var i = 0; i < aTgt.length; ++i) { if (aTgt[i].xTrgPtr) { xDisplay(aTgt[i], bShow ? "block":"none"); } } }; // The unload listener is for IE's circular reference memory leak bug. this.onUnload = function() { if (!xIE4Up || !container || !aTgt) {return;} for (i = 0; i < aTgt.length; ++i) { trg = aTgt[i].xTrgPtr; if (trg) { if (trg.xTgtPtr) { trg.xTgtPtr.TrgPtr = null; trg.xTgtPtr = null; } trg.onclick = null; } } }; } // xColor, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xColor(e,s) { if(!(e=xGetElementById(e))) return ''; var c=''; if(e.style && xDef(e.style.color)) { if(xStr(s)) e.style.color=s; c=e.style.color; } return c; } // xCreateElement, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xCreateElement(sTag) { if (document.createElement) return document.createElement(sTag); else return null; } // xDef, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xDef() { for(var i=0; i 0) { var offset = document.cookie.indexOf(search); if (offset != -1) { offset += search.length; var end = document.cookie.indexOf(";", offset); if (end == -1) end = document.cookie.length; value = unescape(document.cookie.substring(offset, end)); } } return value; } // xGetElementById, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL 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 e=null; return e; } // xGetElementsByAttribute, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xGetElementsByAttribute(sTag, sAtt, sRE, fn) { var a, list, found = new Array(), re = new RegExp(sRE, 'i'); list = xGetElementsByTagName(sTag); for (var i = 0; i < list.length; ++i) { a = list[i].getAttribute(sAtt); if (!a) {a = list[i][sAtt];} if (typeof(a)=='string' && a.search(re) != -1) { found[found.length] = list[i]; if (fn) fn(list[i]); } } return found; } // xGetElementsByClassName, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xGetElementsByClassName(c,p,t,f) { var found = new Array(); var re = new RegExp('\\b'+c+'\\b', 'i'); var list = xGetElementsByTagName(t, p); for (var i = 0; i < list.length; ++i) { if (list[i].className && list[i].className.search(re) != -1) { found[found.length] = list[i]; if (f) f(list[i]); } } return found; } // xGetElementsByTagName, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xGetElementsByTagName(t,p) { var list = null; t = t || '*'; p = p || document; if (xIE4 || xIE5) { if (t == '*') list = p.all; else list = p.all.tags(t); } else if (p.getElementsByTagName) list = p.getElementsByTagName(t); return list || new Array(); } // xGetElePropsArray, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xGetElePropsArray(ele, eleName) { var u = 'undefined'; var i = 0, a = new Array(); nv('Element', eleName); nv('id', (xDef(ele.id) ? ele.id : u)); nv('tagName', (xDef(ele.tagName) ? ele.tagName : u)); nv('xWidth()', xWidth(ele)); nv('style.width', (xDef(ele.style) && xDef(ele.style.width) ? ele.style.width : u)); nv('offsetWidth', (xDef(ele.offsetWidth) ? ele.offsetWidth : u)); nv('scrollWidth', (xDef(ele.offsetWidth) ? ele.offsetWidth : u)); nv('clientWidth', (xDef(ele.clientWidth) ? ele.clientWidth : u)); nv('xHeight()', xHeight(ele)); nv('style.height', (xDef(ele.style) && xDef(ele.style.height) ? ele.style.height : u)); nv('offsetHeight', (xDef(ele.offsetHeight) ? ele.offsetHeight : u)); nv('scrollHeight', (xDef(ele.offsetHeight) ? ele.offsetHeight : u)); nv('clientHeight', (xDef(ele.clientHeight) ? ele.clientHeight : u)); nv('xLeft()', xLeft(ele)); nv('style.left', (xDef(ele.style) && xDef(ele.style.left) ? ele.style.left : u)); nv('offsetLeft', (xDef(ele.offsetLeft) ? ele.offsetLeft : u)); nv('style.pixelLeft', (xDef(ele.style) && xDef(ele.style.pixelLeft) ? ele.style.pixelLeft : u)); nv('xTop()', xTop(ele)); nv('style.top', (xDef(ele.style) && xDef(ele.style.top) ? ele.style.top : u)); nv('offsetTop', (xDef(ele.offsetTop) ? ele.offsetTop : u)); nv('style.pixelTop', (xDef(ele.style) && xDef(ele.style.pixelTop) ? ele.style.pixelTop : u)); nv('', ''); nv('xGetComputedStyle()', ''); nv('top'); nv('right'); nv('bottom'); nv('left'); nv('width'); nv('height'); nv('color'); nv('background-color'); nv('font-family'); nv('font-size'); nv('text-align'); nv('line-height'); nv('content'); nv('float'); nv('clear'); nv('margin'); nv('padding'); nv('padding-top'); nv('padding-right'); nv('padding-bottom'); nv('padding-left'); nv('border-top-width'); nv('border-right-width'); nv('border-bottom-width'); nv('border-left-width'); nv('position'); nv('overflow'); nv('visibility'); nv('display'); nv('z-index'); nv('clip'); nv('cursor'); return a; function nv(name, value) { a[i] = new Object(); a[i].name = name; a[i].value = typeof(value)=='undefined' ? xGetComputedStyle(ele, name) : value; ++i; } } // xGetElePropsString, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xGetElePropsString(ele, eleName, newLine) { var s = '', a = xGetElePropsArray(ele, eleName); for (var i = 0; i < a.length; ++i) { s += a[i].name + ' = ' + a[i].value + (newLine || '\n'); } return s; } // xGetURLArguments, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xGetURLArguments() { var idx = location.href.indexOf('?'); var params = new Array(); if (idx != -1) { var pairs = location.href.substring(idx+1, location.href.length).split('&'); for (var i=0; i= eX + l && x <= eX + xWidth(e) - r && y >= eY + t && y <= eY + xHeight(e) - b ); } // xHeight, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xHeight(e,h) { if(!(e=xGetElementById(e))) return 0; if (xNum(h)) { if (h<0) h = 0; else h=Math.round(h); } else h=-1; var css=xDef(e.style); if (e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') { h = xClientHeight(); } else if(css && xDef(e.offsetHeight) && xStr(e.style.height)) { if(h>=0) { var pt=0,pb=0,bt=0,bb=0; if (document.compatMode=='CSS1Compat') { var gcs = xGetComputedStyle; pt=gcs(e,'padding-top',1); if (pt !== null) { pb=gcs(e,'padding-bottom',1); bt=gcs(e,'border-top-width',1); bb=gcs(e,'border-bottom-width',1); } // Should we try this as a last resort? // At this point getComputedStyle and currentStyle do not exist. else if(xDef(e.offsetHeight,e.style.height)){ e.style.height=h+'px'; pt=e.offsetHeight-h; } } h-=(pt+pb+bt+bb); if(isNaN(h)||h<0) return; else e.style.height=h+'px'; } h=e.offsetHeight; } else if(css && xDef(e.style.pixelHeight)) { if(h>=0) e.style.pixelHeight=h; h=e.style.pixelHeight; } return h; } // xHex, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xHex(n, digits, prefix) { var p = '', n = Math.ceil(n); if (prefix) p = prefix; n = n.toString(16); for (var i=0; i < digits - n.length; ++i) { p += '0'; } return p + n; } // xHide, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xHide(e){return xVisibility(e,0);} // xImgAsyncWait, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xImgAsyncWait(fnStatus, fnInit, fnError, sErrorImg, sAbortImg, imgArray) { var i, imgs = imgArray || document.images; for (i = 0; i < imgs.length; ++i) { imgs[i].onload = imgOnLoad; imgs[i].onerror = imgOnError; imgs[i].onabort = imgOnAbort; } xIAW.fnStatus = fnStatus; xIAW.fnInit = fnInit; xIAW.fnError = fnError; xIAW.imgArray = imgArray; xIAW(); function imgOnLoad() { this.wasLoaded = true; } function imgOnError() { if (sErrorImg && !this.wasError) { this.src = sErrorImg; } this.wasError = true; } function imgOnAbort() { if (sAbortImg && !this.wasAborted) { this.src = sAbortImg; } this.wasAborted = true; } } // end xImgAsyncWait() // Don't call xIAW() directly. It is only called from xImgAsyncWait(). function xIAW() { var me = arguments.callee; if (!me) { return; // I could have used a global object instead of callee } var i, imgs = me.imgArray ? me.imgArray : document.images; var c = 0, e = 0, a = 0, n = imgs.length; for (i = 0; i < n; ++i) { if (imgs[i].wasError) { ++e; } else if (imgs[i].wasAborted) { ++a; } else if (imgs[i].complete || imgs[i].wasLoaded) { ++c; } } if (me.fnStatus) { me.fnStatus(n, c, e, a); } if (c + e + a == n) { if ((e || a) && me.fnError) { me.fnError(n, c, e, a); } else if (me.fnInit) { me.fnInit(); } } else setTimeout('xIAW()', 250); } // end xIAW() // xImgRollSetup, Copyright 2002,2003,2004,2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xImgRollSetup(p,s,x) { var ele, id; for (var i=3; i"; } // else is it a .css file? else if (f.indexOf('.css') != -1) { // CSS file h = ""; } // write the link or script element into the document if (h.length) { document.writeln(h); } } // end if (!inc) } // end outer for return true; } // end if (min dhtml support) return false; } // xInnerHtml, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xInnerHtml(e,h) { if(!(e=xGetElementById(e)) || !xStr(e.innerHTML)) return null; var s = e.innerHTML; if (xStr(h)) {e.innerHTML = h;} return s; } // xIntersection, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xIntersection(e1, e2, o) { var ix1, iy2, iw, ih, intersect = true; var e1x1 = xPageX(e1); var e1x2 = e1x1 + xWidth(e1); var e1y1 = xPageY(e1); var e1y2 = e1y1 + xHeight(e1); var e2x1 = xPageX(e2); var e2x2 = e2x1 + xWidth(e2); var e2y1 = xPageY(e2); var e2y2 = e2y1 + xHeight(e2); // horizontal if (e1x1 <= e2x1) { ix1 = e2x1; if (e1x2 < e2x1) intersect = false; else iw = Math.min(e1x2, e2x2) - e2x1; } else { ix1 = e1x1; if (e2x2 < e1x1) intersect = false; else iw = Math.min(e1x2, e2x2) - e1x1; } // vertical if (e1y2 >= e2y2) { iy2 = e2y2; if (e1y1 > e2y2) intersect = false; else ih = e2y2 - Math.max(e1y1, e2y1); } else { iy2 = e1y2; if (e2y1 > e1y2) intersect = false; else ih = e1y2 - Math.max(e1y1, e2y1); } // intersected rectangle if (intersect && typeof(o)=='object') { o.x = ix1; o.y = iy2 - ih; o.w = iw; o.h = ih; } return intersect; } // xLeft, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xLeft(e, iX) { if(!(e=xGetElementById(e))) return 0; var css=xDef(e.style); if (css && xStr(e.style.left)) { if(xNum(iX)) e.style.left=iX+'px'; else { iX=parseInt(e.style.left); if(isNaN(iX)) iX=0; } } else if(css && xDef(e.style.pixelLeft)) { if(xNum(iX)) e.style.pixelLeft=iX; else iX=e.style.pixelLeft; } return iX; } // xLinearScale, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xLinearScale(val,iL,iH,oL,oH) { var m=(oH-oL)/(iH-iL); var b=oL-(iL*m); return m*val+b; } // xLoadScript, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xLoadScript(url) { if (document.createElement && document.getElementsByTagName) { var s = document.createElement('script'); var h = document.getElementsByTagName('head'); if (s && h.length) { s.src = url; h[0].appendChild(s); } } } // xMenu1, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xMenu1(triggerId, menuId, mouseMargin, openEvent) { var isOpen = false; var trg = xGetElementById(triggerId); var mnu = xGetElementById(menuId); if (trg && mnu) { xAddEventListener(trg, openEvent, onOpen, false); } function onOpen() { if (!isOpen) { xMoveTo(mnu, xPageX(trg), xPageY(trg) + xHeight(trg)); xShow(mnu); xAddEventListener(document, 'mousemove', onMousemove, false); isOpen = true; } } function onMousemove(ev) { var e = new xEvent(ev); if (!xHasPoint(mnu, e.pageX, e.pageY, -mouseMargin) && !xHasPoint(trg, e.pageX, e.pageY, -mouseMargin)) { xHide(mnu); xRemoveEventListener(document, 'mousemove', onMousemove, false); isOpen = false; } } } // end xMenu1 // xMenu1A, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xMenu1A(triggerId, menuId, mouseMargin, slideTime, openEvent) { var isOpen = false; var trg = xGetElementById(triggerId); var mnu = xGetElementById(menuId); if (trg && mnu) { xHide(mnu); xAddEventListener(trg, openEvent, onOpen, false); } function onOpen() { if (!isOpen) { xMoveTo(mnu, xPageX(trg), xPageY(trg)); xShow(mnu); xSlideTo(mnu, xPageX(trg), xPageY(trg) + xHeight(trg), slideTime); xAddEventListener(document, 'mousemove', onMousemove, false); isOpen = true; } } function onMousemove(ev) { var e = new xEvent(ev); if (!xHasPoint(mnu, e.pageX, e.pageY, -mouseMargin) && !xHasPoint(trg, e.pageX, e.pageY, -mouseMargin)) { xRemoveEventListener(document, 'mousemove', onMousemove, false); xSlideTo(mnu, xPageX(trg), xPageY(trg), slideTime); setTimeout("xHide('" + menuId + "')", slideTime); isOpen = false; } } } // end xMenu1A // xMenu1B, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xMenu1B(openTriggerId, closeTriggerId, menuId, slideTime, bOnClick) { xMenu1B.instances[xMenu1B.instances.length] = this; var isOpen = false; var oTrg = xGetElementById(openTriggerId); var cTrg = xGetElementById(closeTriggerId); var mnu = xGetElementById(menuId); if (oTrg && cTrg && mnu) { xHide(mnu); if (bOnClick) oTrg.onclick = openOnEvent; else oTrg.onmouseover = openOnEvent; cTrg.onclick = closeOnClick; } function openOnEvent() { if (!isOpen) { for (var i = 0; i < xMenu1B.instances.length; ++i) { xMenu1B.instances[i].close(); } xMoveTo(mnu, xPageX(oTrg), xPageY(oTrg)); xShow(mnu); xSlideTo(mnu, xPageX(oTrg), xPageY(oTrg) + xHeight(oTrg), slideTime); isOpen = true; } } function closeOnClick() { if (isOpen) { xSlideTo(mnu, xPageX(oTrg), xPageY(oTrg), slideTime); setTimeout("xHide('" + menuId + "')", slideTime); isOpen = false; } } this.close = function() { closeOnClick(); } } // end xMenu1B xMenu1B.instances = new Array(); // static member of xMenu1B // xMenu5, Copyright 2004,2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xMenu5(idUL, btnClass, idAutoOpen) // object prototype { // Constructor var i, ul, btns, mnu = xGetElementById(idUL); btns = xGetElementsByClassName(btnClass, mnu, 'DIV'); for (i = 0; i < btns.length; ++i) { ul = xNextSib(btns[i], 'UL'); btns[i].xClpsTgt = ul; btns[i].onclick = btn_onClick; set_display(btns[i], 0); } if (idAutoOpen) { var e = xGetElementById(idAutoOpen); while (e && e != mnu) { if (e.xClpsTgt) set_display(e, 1); while (e && e != mnu && e.nodeName != 'LI') e = e.parentNode; e = e.parentNode; // UL while (e && !e.xClpsTgt) e = xPrevSib(e); } } // Private function btn_onClick() { var thisLi, fc, pUl; if (this.xClpsTgt.style.display == 'none') { set_display(this, 1); // get this label's parent LI var li = this.parentNode; thisLi = li; pUl = li.parentNode; // get this LI's parent UL li = xFirstChild(pUl); // get the UL's first LI child // close all labels' ULs on this level except for thisLI's label while (li) { if (li != thisLi) { fc = xFirstChild(li); if (fc && fc.xClpsTgt) { set_display(fc, 0); } } li = xNextSib(li); } } else { set_display(this, 0); } } function set_display(ele, bBlock) { if (bBlock) { ele.xClpsTgt.style.display = 'block'; ele.innerHTML = '-'; } else { ele.xClpsTgt.style.display = 'none'; ele.innerHTML = '+'; } } // Public this.onUnload = function() { for (i = 0; i < btns.length; ++i) { btns[i].xClpsTgt = null; btns[i].onclick = null; } } } // end xMenu5 prototype // xMoveTo, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xMoveTo(e,x,y) { xLeft(e,x); xTop(e,y); } // xName, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xName(e) { if (!e) return e; else if (e.id && e.id != "") return e.id; else if (e.name && e.name != "") return e.name; else if (e.nodeName && e.nodeName != "") return e.nodeName; else if (e.tagName && e.tagName != "") return e.tagName; else return e; } // xNextSib, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xNextSib(e,t) { var s = e ? e.nextSibling : null; if (t) while (s && s.nodeName != t) { s = s.nextSibling; } else while (s && s.nodeType != 1) { s = s.nextSibling; } return s; } // xNum, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xNum() { for(var i=0; i= e.slideTime) { e.moving = false; } } // xSlideTo, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL 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 if (e.slideLinear) e.B = 1/e.slideTime; else 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) _xSlideTo(e); } function _xSlideTo(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("_xSlideTo('"+e.id+"')", e.timeout); if (e.slideLinear) s = e.B * t; else 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; } } // xStopPropagation, Copyright 2004,2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xStopPropagation(evt) { if (evt && evt.stopPropagation) evt.stopPropagation(); else if (window.event) window.event.cancelBubble = true; } // xStr, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xStr(s) { for(var i=0; i= t.preset) { // timer event on t t.obj[t.mthd](t); // pass listener this xTimerObj if (t.type.charAt(0) == 'i') { t.time0 = now; } else { t.stop(); } } } } }; // Object Prototype used only by xTimerMgr function xTimerObj(type, obj, mthd, preset, data) { // Public Properties this.data = data; // Read-only Properties this.type = type; // 'interval' or 'timeout' this.obj = obj; this.mthd = mthd; // string this.preset = preset; this.reset(); } // end xTimerObj constructor // xTimerObj Methods xTimerObj.prototype.stop = function() { this.running = false; }; xTimerObj.prototype.start = function() { this.running = true; }; // continue after a stop xTimerObj.prototype.reset = function() { var d = new Date(); this.time0 = d.getTime(); this.elapsed = 0; this.running = true; }; var xTimer = new xTimerMgr(); // applications assume global name is 'xTimer' setInterval('xTimer.run()', 250); // xTooltipGroup, Copyright 2002,2003,2004,2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL document.write(""); document.write("
xTooltipElement
"); var xttTrigger = null; // current trigger element function xTooltipGroup(grpClassOrIdList, tipClass, origin, xOffset, yOffset, textList) { //// Properties this.c = tipClass; this.o = origin; this.x = xOffset; this.y = yOffset; this.t = null; // tooltip element - all groups use the same element //// Constructor Code var i, tips; if (xStr(grpClassOrIdList)) { tips = xGetElementsByClassName(grpClassOrIdList); for (i = 0; i < tips.length; ++i) { tips[i].xTooltip = this; } } else { tips = new Array(); for (i = 0; i < grpClassOrIdList.length; ++i) { tips[i] = xGetElementById(grpClassOrIdList[i]); if (!tips[i]) { alert('Element not found for id = ' + grpClassOrIdList[i]); } else { tips[i].xTooltip = this; tips[i].xTooltipText = textList[i]; } } } if (!this.t) { // only execute once this.t = xGetElementById('xTooltipElement'); xAddEventListener(document, 'mousemove', this.docOnMousemove, false); } } // end xTooltipGroup ctor //// xTooltipGroup Methods xTooltipGroup.prototype.show = function(trigEle, mx, my) { if (xttTrigger != trigEle) { // if not active or moved to an adjacent trigger this.t.className = trigEle.xTooltip.c; this.t.innerHTML = trigEle.xTooltipText ? trigEle.xTooltipText : trigEle.title; xttTrigger = trigEle; } var x, y; switch(this.o) { case 'right': x = xPageX(trigEle) + xWidth(trigEle); y = xPageY(trigEle); break; case 'top': x = xPageX(trigEle); y = xPageY(trigEle) - xHeight(trigEle); break; case 'mouse': x = mx; y = my; break; } xMoveTo(this.t, x + this.x, y + this.y); xShow(this.t); }; xTooltipGroup.prototype.hide = function() { xMoveTo(this.t, -1000, -1000); xttTrigger = null; }; xTooltipGroup.prototype.docOnMousemove = function(oEvent) { // this == document at runtime var o, e = new xEvent(oEvent); if (e.target && (o = e.target.xTooltip)) { o.show(e.target, e.pageX, e.pageY); } else if (xttTrigger) { xttTrigger.xTooltip.hide(); } }; // xTop, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xTop(e, iY) { if(!(e=xGetElementById(e))) return 0; var css=xDef(e.style); if(css && xStr(e.style.top)) { if(xNum(iY)) e.style.top=iY+'px'; else { iY=parseInt(e.style.top); if(isNaN(iY)) iY=0; } } else if(css && xDef(e.style.pixelTop)) { if(xNum(iY)) e.style.pixelTop=iY; else iY=e.style.pixelTop; } return iY; } // xTriStateImage, Copyright 2004,2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xTriStateImage(idOut, urlOver, urlDown, fnUp) // Object Prototype { var img; // Downgrade Detection if (typeof Image != 'undefined' && document.getElementById) { img = document.getElementById(idOut); if (img) { // Constructor Code var urlOut = img.src; var i = new Image(); i.src = urlOver; i = new Image(); i.src = urlDown; // Event Listeners (closure) img.onmouseover = function() { this.src = urlOver; }; img.onmouseout = function() { this.src = urlOut; }; img.onmousedown = function() { this.src = urlDown; }; img.onmouseup = function() { this.src = urlOver; if (fnUp) { fnUp(); } }; } } // Destructor Method this.onunload = function() { if (xIE4Up && img) { // Remove any circular references for IE img.onmouseover = img.onmouseout = img.onmousedown = null; img = null; } }; } var xVersion = "4.0";// xVisibility, Copyright 2003-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xVisibility(e, bShow) { if(!(e=xGetElementById(e))) return null; if(e.style && xDef(e.style.visibility)) { if (xDef(bShow)) e.style.visibility = bShow ? 'visible' : 'hidden'; return e.style.visibility; } return null; } //function xVisibility(e,s) //{ // if(!(e=xGetElementById(e))) return null; // var v = 'visible', h = 'hidden'; // if(e.style && xDef(e.style.visibility)) { // if (xDef(s)) { // // try to maintain backwards compatibility (???) // if (xStr(s)) e.style.visibility = s; // else e.style.visibility = s ? v : h; // } // return e.style.visibility; // // or... // // if (e.style.visibility.length) return e.style.visibility; // // else return xGetComputedStyle(e, 'visibility'); // } // else if (xDef(e.visibility)) { // NN4 // if (xDef(s)) { // // try to maintain backwards compatibility // if (xStr(s)) e.visibility = (s == v) ? 'show' : 'hide'; // else e.visibility = s ? v : h; // } // return (e.visibility == 'show') ? v : h; // } // return null; //} // xWalkEleTree, Copyright 2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xWalkEleTree(n,f,d,l,b) { if (typeof l == 'undefined') l = 0; if (typeof b == 'undefined') b = 0; var v = f(n,l,b,d); if (!v) return 0; if (v == 1) { for (var c = n.firstChild; c; c = c.nextSibling) { if (c.nodeType == 1) { if (!l) ++b; if (!xWalkEleTree(c,f,d,l+1,b)) return 0; } } } return 1; } // xWalkTree, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xWalkTree(n, f) { f(n); for (var c = n.firstChild; c; c = c.nextSibling) { if (c.nodeType == 1) xWalkTree(c, f); } } // original implementation: // function xWalkTree(oNode, fnVisit) // { // if (oNode) { // if (oNode.nodeType == 1) {fnVisit(oNode);} // for (var c = oNode.firstChild; c; c = c.nextSibling) { // xWalkTree(c, fnVisit); // } // } // } // xWidth, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xWidth(e,w) { if(!(e=xGetElementById(e))) return 0; if (xNum(w)) { if (w<0) w = 0; else w=Math.round(w); } else w=-1; var css=xDef(e.style); if (e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') { w = xClientWidth(); } else if(css && xDef(e.offsetWidth) && xStr(e.style.width)) { if(w>=0) { var pl=0,pr=0,bl=0,br=0; if (document.compatMode=='CSS1Compat') { var gcs = xGetComputedStyle; pl=gcs(e,'padding-left',1); if (pl !== null) { pr=gcs(e,'padding-right',1); bl=gcs(e,'border-left-width',1); br=gcs(e,'border-right-width',1); } // Should we try this as a last resort? // At this point getComputedStyle and currentStyle do not exist. else if(xDef(e.offsetWidth,e.style.width)){ e.style.width=w+'px'; pl=e.offsetWidth-w; } } w-=(pl+pr+bl+br); if(isNaN(w)||w<0) return; else e.style.width=w+'px'; } w=e.offsetWidth; } else if(css && xDef(e.style.pixelWidth)) { if(w>=0) e.style.pixelWidth=w; w=e.style.pixelWidth; } return w; } // xWinClass, Copyright 2003-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL // xWinClass Object Prototype function xWinClass(clsName, winName, w, h, x, y, loc, men, res, scr, sta, too) { var thisObj = this; var e='',c=',',xf='left=',yf='top='; this.n = name; if (document.layers) {xf='screenX='; yf='screenY=';} this.f = (w?'width='+w+c:e)+(h?'height='+h+c:e)+(x>=0?xf+x+c:e)+ (y>=0?yf+y+c:e)+'location='+loc+',menubar='+men+',resizable='+res+ ',scrollbars='+scr+',status='+sta+',toolbar='+too; this.opened = function() {return this.w && !this.w.closed;}; this.close = function() {if(this.opened()) this.w.close();}; this.focus = function() {if(this.opened()) this.w.focus();}; this.load = function(sUrl) { if (this.opened()) this.w.location.href = sUrl; else this.w = window.open(sUrl,this.n,this.f); this.focus(); return false; }; // Closures // this == element reference, thisObj == xWinClass object reference function onClick() {return thisObj.load(this.href);} // '*' works with any element, not just A xGetElementsByClassName(clsName, document, '*', bindOnClick); function bindOnClick(e) {e.onclick = onClick;} } // xWindow, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xWindow(name, w, h, x, y, loc, men, res, scr, sta, too) { var e='',c=',',xf='left=',yf='top='; this.n = name; if (document.layers) {xf='screenX='; yf='screenY=';} this.f = (w?'width='+w+c:e)+(h?'height='+h+c:e)+(x>=0?xf+x+c:e)+ (y>=0?yf+y+c:e)+'location='+loc+',menubar='+men+',resizable='+res+ ',scrollbars='+scr+',status='+sta+',toolbar='+too; this.opened = function() {return this.w && !this.w.closed;}; this.close = function() {if(this.opened()) this.w.close();}; this.focus = function() {if(this.opened()) this.w.focus();}; this.load = function(sUrl) { if (this.opened()) this.w.location.href = sUrl; else this.w = window.open(sUrl,this.n,this.f); this.focus(); return false; }; } // Previous implementation: // function xWindow(name, w, h, x, y, loc, men, res, scr, sta, too) // { // var f = ''; // if (w && h) { // if (document.layers) f = 'screenX=' + x + ',screenY=' + y; // else f = 'left=' + x + ',top=' + y; // f += ',width=' + w + ',height=' + h + ','; // } // f += ('location='+loc+',menubar='+men+',resizable='+res // +',scrollbars='+scr+',status='+sta+',toolbar='+too); // this.features = f; // this.name = name; // this.load = function(sUrl) { // if (this.wnd && !this.wnd.closed) this.wnd.location.href = sUrl; // else this.wnd = window.open(sUrl, this.name, this.features); // this.wnd.focus(); // return false; // } // } // xWinOpen, Copyright 2003-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL // A simple alternative to xWindow. var xChildWindow = null; function xWinOpen(sUrl) { var features = "left=0,top=0,width=600,height=500,location=0,menubar=0," + "resizable=1,scrollbars=1,status=0,toolbar=0"; if (xChildWindow && !xChildWindow.closed) {xChildWindow.location.href = sUrl;} else {xChildWindow = window.open(sUrl, "myWinName", features);} xChildWindow.focus(); return false; } // xWinScrollTo, Copyright 2003-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL var xWinScrollWin = null; function xWinScrollTo(win,x,y,uTime) { var e = win; if (!e.timeout) e.timeout = 25; var st = xScrollTop(e, 1); var sl = xScrollLeft(e, 1); e.xTarget = x; e.yTarget = y; e.slideTime = uTime; e.stop = false; e.yA = e.yTarget - st; e.xA = e.xTarget - sl; // A = distance e.B = Math.PI / (2 * e.slideTime); // B = period e.yD = st; e.xD = sl; // D = initial position var d = new Date(); e.C = d.getTime(); if (!e.moving) { xWinScrollWin = e; _xWinScrollTo(); } } function _xWinScrollTo() { var e = xWinScrollWin || window; 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("_xWinScrollTo()", e.timeout); s = Math.sin(e.B * t); newX = Math.round(e.xA * s + e.xD); newY = Math.round(e.yA * s + e.yD); e.scrollTo(newX, newY); e.moving = true; } else { e.scrollTo(e.xTarget, e.yTarget); xWinScrollWin = null; e.moving = false; } } // xZIndex, Copyright 2001-2005 Michael Foster (Cross-Browser.com) // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL function xZIndex(e,uZ) { if(!(e=xGetElementById(e))) return 0; if(e.style && xDef(e.style.zIndex)) { if(xNum(uZ)) e.style.zIndex=uZ; uZ=parseInt(e.style.zIndex); } return uZ; }