var anylinkcssmenu = { menusmap: {}, effects: { delayhide: 200, shadow: { enabled: true, opacity: 0.3, depth: [5, 5] }, fade: { enabled: true, duration: 500} }, dimensions: {}, getoffset: function(b, a) { return (b.offsetParent) ? b[a] + this.getoffset(b.offsetParent, a) : b[a] }, getoffsetof: function(a) { a._offsets = { left: this.getoffset(a, "offsetLeft"), top: this.getoffset(a, "offsetTop"), h: a.offsetHeight} }, getdimensions: function(a) { this.dimensions = { anchorw: a.anchorobj.offsetWidth, anchorh: a.anchorobj.offsetHeight, docwidth: (window.innerWidth || this.standardbody.clientWidth) - 20, docheight: (window.innerHeight || this.standardbody.clientHeight) - 15, docscrollx: window.pageXOffset || this.standardbody.scrollLeft, docscrolly: window.pageYOffset || this.standardbody.scrollTop }; if (!this.dimensions.dropmenuw) { this.dimensions.dropmenuw = a.dropmenu.offsetWidth; this.dimensions.dropmenuh = a.dropmenu.offsetHeight } }, isContained: function(a, b) { var b = window.event || b; var d = b.relatedTarget || ((b.type == "mouseover") ? b.fromElement : b.toElement); while (d && d != a) { try { d = d.parentNode } catch (b) { d = a } } if (d == a) { return true } else { return false } }, setopacity: function(a, b) { a.style.opacity = b; if (typeof a.style.opacity != "string") { a.style.MozOpacity = b; if (a.filters) { a.style.filter = "progid:DXImageTransform.Microsoft.alpha(opacity=" + b * 100 + ")" } } }, showmenu: function(b) { var c = anylinkcssmenu.menusmap[b]; clearTimeout(c.hidetimer); this.getoffsetof(c.anchorobj); this.getdimensions(c); var a = c.anchorobj._offsets.left + (c.orientation == "lr" ? this.dimensions.anchorw : 0); var d = c.anchorobj._offsets.top + this.dimensions.anchorh - (c.orientation == "lr" ? this.dimensions.anchorh : 0); if (a + this.dimensions.dropmenuw + this.effects.shadow.depth[0] > this.dimensions.docscrollx + this.dimensions.docwidth) { a = a - this.dimensions.dropmenuw + (c.orientation == "lr" ? -this.dimensions.anchorw : this.dimensions.anchorw) } if (d + this.dimensions.dropmenuh > this.dimensions.docscrolly + this.dimensions.docheight) { d = Math.max(d - this.dimensions.dropmenuh - (c.orientation == "lr" ? -this.dimensions.anchorh : this.dimensions.anchorh), this.dimensions.docscrolly) } if (this.effects.fade.enabled) { this.setopacity(c.dropmenu, 0); if (this.effects.shadow.enabled) { this.setopacity(c.shadow, 0) } } c.dropmenu.setcss({ left: a + "px", top: d + "px", visibility: "visible" }); if (this.effects.shadow.enabled) { c.shadow.setcss({ left: a + anylinkcssmenu.effects.shadow.depth[0] + "px", top: d + anylinkcssmenu.effects.shadow.depth[1] + "px", visibility: "visible" }) } if (this.effects.fade.enabled) { clearInterval(c.animatetimer); c.curanimatedegree = 0; c.starttime = new Date().getTime(); c.animatetimer = setInterval(function() { anylinkcssmenu.revealmenu(b) }, 20) } }, revealmenu: function(b) { var c = anylinkcssmenu.menusmap[b]; var a = new Date().getTime() - c.starttime; if (a < this.effects.fade.duration) { this.setopacity(c.dropmenu, c.curanimatedegree); if (this.effects.shadow.enabled) { this.setopacity(c.shadow, c.curanimatedegree * this.effects.shadow.opacity) } } else { clearInterval(c.animatetimer); this.setopacity(c.dropmenu, 1); c.dropmenu.style.filter = "" } c.curanimatedegree = (1 - Math.cos((a / this.effects.fade.duration) * Math.PI)) / 2 }, setcss: function(a) { for (prop in a) { this.style[prop] = a[prop] } }, hidemenu: function(a) { var b = anylinkcssmenu.menusmap[a]; clearInterval(b.animatetimer); b.dropmenu.setcss({ visibility: "hidden", left: 0, top: 0 }); b.shadow.setcss({ visibility: "hidden", left: 0, top: 0 }) }, getElementsByClass: function(a) { if (document.querySelectorAll) { return document.querySelectorAll("." + a) } else { var e = new RegExp("(^|\\s+)" + a + "($|\\s+)", "i"); var d = []; var c = document.all ? document.all : document.getElementsByTagName("*"); for (var b = 0; b < c.length; b++) { if (typeof c[b].className == "string" && c[b].className.search(e) != -1) { d[d.length] = c[b] } } return d } }, addEvent: function(a, d, b) { if (a.length > 0) { var c = a.shift(); if (c.addEventListener) { c.addEventListener(b, d, false) } else { if (c.attachEvent) { c.attachEvent("on" + b, function() { return d.call(c, window.event) }) } } this.addEvent(a, d, b) } }, setupmenu: function(b, d, f) { this.standardbody = (document.compatMode == "CSS1Compat") ? document.documentElement : document.body; var c = d.getAttribute("rel"); var a = c.replace(/\[(\w+)\]/, ""); var e = this.menusmap[b + f] = { id: b + f, anchorobj: d, dropmenu: document.getElementById(a), revealtype: (c.length != a.length && RegExp.$1 == "click") ? "click" : "mouseover", orientation: d.getAttribute("rev") == "lr" ? "lr" : "ud", shadow: document.createElement("div") }; e.anchorobj._internalID = b + f; e.anchorobj._isanchor = true; e.dropmenu._internalID = b + f; e.shadow._internalID = b + f; e.shadow.className = "anylinkshadow"; document.body.appendChild(e.dropmenu); document.body.appendChild(e.shadow); e.dropmenu.setcss = this.setcss; e.shadow.setcss = this.setcss; this.setopacity(e.shadow, this.effects.shadow.opacity); this.addEvent([e.anchorobj, e.dropmenu, e.shadow], function(g) { var h = anylinkcssmenu.menusmap[this._internalID]; if (this._isanchor && h.revealtype == "mouseover" && !anylinkcssmenu.isContained(this, g)) { anylinkcssmenu.showmenu(h.id) } else { if (typeof this._isanchor == "undefined") { clearTimeout(h.hidetimer) } } }, "mouseover"); this.addEvent([e.anchorobj, e.dropmenu, e.shadow], function(g) { if (!anylinkcssmenu.isContained(this, g)) { var h = anylinkcssmenu.menusmap[this._internalID]; h.hidetimer = setTimeout(function() { anylinkcssmenu.hidemenu(h.id) }, anylinkcssmenu.effects.delayhide) } }, "mouseout"); this.addEvent([e.anchorobj, e.dropmenu], function(g) { var h = anylinkcssmenu.menusmap[this._internalID]; if (this._isanchor && h.revealtype == "click") { if (h.dropmenu.style.visibility == "visible") { anylinkcssmenu.hidemenu(h.id) } else { anylinkcssmenu.showmenu(h.id) } if (g.preventDefault) { g.preventDefault() } return false } else { h.hidetimer = setTimeout(function() { anylinkcssmenu.hidemenu(h.id) }, anylinkcssmenu.effects.delayhide) } }, "click") }, init: function(a) { var c = this.getElementsByClass(a); for (var b = 0; b < c.length; b++) { this.setupmenu(a, c[b], b) } } };