mtdropdown.spacergif = ""; mtdropdown.dingbaton = ""; mtdropdown.dingbatoff = ""; mtdropdown.dingbatsize = 14; mtdropdown.menupadding = 0; mtdropdown.itempadding = 4; mtdropdown.shadowsize = 2; mtdropdown.shadowoffset = 3; mtdropdown.shadowcolor = "#98ebff"; mtdropdown.shadowpng = ""; mtdropdown.backgroundcolor = "#00557c"; mtdropdown.backgroundpng = ""; mtdropdown.hidedelay = 200; mtdropdown.slidetime = 300; mtdropdown.reference = {topleft:1,topright:2,bottomleft:3,bottomright:4}; mtdropdown.direction = {down:1,right:2}; mtdropdown.registry = []; mtdropdown._maxz = 100; mtdropdown.issupported = function() { if (typeof mtdropdown.issupported.r == "boolean") return mtdropdown.issupported.r; var ua = navigator.useragent.tolowercase(); var an = navigator.appname; var r = false; if (ua.indexof("gecko") > -1) r = true; else if (an == "microsoft internet explorer") { if (document.getelementbyid) r = true; } mtdropdown.issupported.r = r; return r; } mtdropdown.initialize = function() { for (var i = 0, menu = null; menu = this.registry[i]; i++) { menu.initialize(); } } mtdropdown.renderall = function() { var amenuhtml = []; for (var i = 0, menu = null; menu = this.registry[i]; i++) { amenuhtml[i] = menu.tostring(); } document.write(amenuhtml.join("")); } /////////////////////////////// class mtdropdown begins ///////////// function mtdropdown(oactuator, idirection, ileft, itop, ireferencepoint, parentmenuset) { this.additem = additem; this.addmenu = addmenu; this.tostring = tostring; this.initialize = initialize; this.isopen = false; this.show = show; this.hide = hide; this.items = []; this.onactivate = new function(); this.ondeactivate = new function(); this.onmouseover = new function(); this.onqueue = new function(); this.index = mtdropdown.registry.length; mtdropdown.registry[this.index] = this; var id = "mtdropdown" + this.index; var contentheight = null; var contentwidth = null; var childmenuset = null; var animating = false; var childmenus = []; var slideaccel = -1; var elmcache = null; var ready = false; var _this = this; var a = null; var pos = idirection == mtdropdown.direction.down ? "top" : "left"; var dim = null; function additem(stext, surl) { var item = new mtdropdownitem(stext, surl, this); item._index = this.items.length; this.items[item._index] = item; } function addmenu(omenuitem) { if (!omenuitem.parentmenu == this) throw new error("cannot add a menu here"); if (childmenuset == null) childmenuset = new mtdropdownset(mtdropdown.direction.right, -5, 2, mtdropdown.reference.topright); var m = childmenuset.addmenu(omenuitem); childmenus[omenuitem._index] = m; m.onmouseover = child_mouseover; m.ondeactivate = child_deactivate; m.onqueue = child_queue; return m; } function initialize() { initcache(); initevents(); initsize(); ready = true; } function show() { if (ready) { _this.isopen = true; animating = true; setcontainerpos(); elmcache["clip"].style.visibility = "visible"; elmcache["clip"].style.zindex = mtdropdown._maxz++; slidestart(); _this.onactivate(); } } function hide() { if (ready) { _this.isopen = false; animating = true; for (var i = 0, item = null; item = elmcache.item[i]; i++) dehighlight(item); if (childmenuset) childmenuset.hide(); slidestart(); _this.ondeactivate(); } } function setcontainerpos() { var sub = oactuator.constructor == mtdropdownitem; var act = sub ? oactuator.parentmenu.elmcache["item"][oactuator._index] : oactuator; var el = act; var x = 0; var y = 0; var minx = 0; var maxx = (window.innerwidth ? window.innerwidth : document.body.clientwidth) - parseint(elmcache["clip"].style.width); var miny = 0; var maxy = (window.innerheight ? window.innerheight : document.body.clientheight) - parseint(elmcache["clip"].style.height); while (sub ? el.parentnode.classname.indexof("mtdropdownmenu") == -1 : el.offsetparent) { x += el.offsetleft; y += el.offsettop; if (el.scrollleft) x -= el.scrollleft; if (el.scrolltop) y -= el.scrolltop; el = el.offsetparent; } if (oactuator.constructor == mtdropdownitem) { x += parseint(el.parentnode.style.left); y += parseint(el.parentnode.style.top); } switch (ireferencepoint) { case mtdropdown.reference.topleft: break; case mtdropdown.reference.topright: x += act.offsetwidth; break; case mtdropdown.reference.bottomleft: y += act.offsetheight; break; case mtdropdown.reference.bottomright: x += act.offsetwidth; y += act.offsetheight; break; } x += ileft; y += itop + 0; // original: y += itop; x = math.max(math.min(x, maxx), minx); y = math.max(math.min(y, maxy), miny); elmcache["clip"].style.left = x + "px"; elmcache["clip"].style.top = y + "px"; } function slidestart() { var x0 = parseint(elmcache["content"].style[pos]); var x1 = _this.isopen ? 0 : -dim; if (a != null) a.stop(); a = new accelimation(x0, x1, mtdropdown.slidetime, slideaccel); a.onframe = slideframe; a.onend = slideend; a.start(); } function slideframe(x) { elmcache["content"].style[pos] = x + "px"; } function slideend() { if (!_this.isopen) elmcache["clip"].style.visibility = "hidden"; animating = false; } function initsize() { var ow = elmcache["items"].offsetwidth; var oh = elmcache["items"].offsetheight; var ua = navigator.useragent.tolowercase(); elmcache["clip"].style.width = ow + mtdropdown.shadowsize + 1 + "px"; elmcache["clip"].style.height = oh + mtdropdown.shadowsize + 2 + "px"; elmcache["content"].style.width = ow + mtdropdown.shadowsize + "px"; elmcache["content"].style.height = oh + mtdropdown.shadowsize + "px"; contentheight = oh + mtdropdown.shadowsize; contentwidth = ow + mtdropdown.shadowsize; dim = idirection == mtdropdown.direction.down ? contentheight : contentwidth; elmcache["content"].style[pos] = -dim - mtdropdown.shadowsize + "px"; elmcache["clip"].style.visibility = "hidden"; if (ua.indexof("mac") == -1 || ua.indexof("gecko") > -1) { elmcache["background"].style.width = ow + "px"; elmcache["background"].style.height = oh + "px"; elmcache["background"].style.backgroundcolor = mtdropdown.backgroundcolor; elmcache["shadowright"].style.left = ow + "px"; elmcache["shadowright"].style.height = oh - (mtdropdown.shadowoffset - mtdropdown.shadowsize) + "px"; elmcache["shadowright"].style.backgroundcolor = mtdropdown.shadowcolor; elmcache["shadowbottom"].style.top = oh + "px"; elmcache["shadowbottom"].style.width = ow - mtdropdown.shadowoffset + "px"; elmcache["shadowbottom"].style.backgroundcolor = mtdropdown.shadowcolor; } else { elmcache["background"].firstchild.src = mtdropdown.backgroundpng; elmcache["background"].firstchild.width = ow; elmcache["background"].firstchild.height = oh; elmcache["shadowright"].firstchild.src = mtdropdown.shadowpng; elmcache["shadowright"].style.left = ow + "px"; elmcache["shadowright"].firstchild.width = mtdropdown.shadowsize; elmcache["shadowright"].firstchild.height = oh - (mtdropdown.shadowoffset - mtdropdown.shadowsize); elmcache["shadowbottom"].firstchild.src = mtdropdown.shadowpng; elmcache["shadowbottom"].style.top = oh + "px"; elmcache["shadowbottom"].firstchild.height = mtdropdown.shadowsize; elmcache["shadowbottom"].firstchild.width = ow - mtdropdown.shadowoffset; } } function initcache() { var menu = document.getelementbyid(id); var all = menu.all ? menu.all : menu.getelementsbytagname("*"); elmcache = {}; elmcache["clip"] = menu; elmcache["item"] = []; for (var i = 0, elm = null; elm = all[i]; i++) { switch (elm.classname) { case "items": case "content": case "background": case "shadowright": case "shadowbottom": elmcache[elm.classname] = elm; break; case "item": elm._index = elmcache["item"].length; elmcache["item"][elm._index] = elm; break; } } _this.elmcache = elmcache; } function initevents() { for (var i = 0, item = null; item = elmcache.item[i]; i++) { item.onmouseover = item_mouseover; item.onmouseout = item_mouseout; item.onclick = item_click; } if (typeof oactuator.tagname != "undefined") { oactuator.onmouseover = actuator_mouseover; oactuator.onmouseout = actuator_mouseout; } elmcache["content"].onmouseover = content_mouseover; elmcache["content"].onmouseout = content_mouseout; } function highlight(orow) { orow.classname = "item hover"; if (childmenus[orow._index]) orow.lastchild.firstchild.src = mtdropdown.dingbaton; } function dehighlight(orow) { orow.classname = "item"; if (childmenus[orow._index]) orow.lastchild.firstchild.src = mtdropdown.dingbatoff; } function item_mouseover() { if (!animating) { highlight(this); if (childmenus[this._index]) childmenuset.showmenu(childmenus[this._index]); else if (childmenuset) childmenuset.hide(); } } function item_mouseout() { if (!animating) { if (childmenus[this._index]) childmenuset.hidemenu(childmenus[this._index]); else dehighlight(this); } } function item_click() { if (!animating) { if (_this.items[this._index].url) location.href = _this.items[this._index].url; } } function actuator_mouseover() { parentmenuset.showmenu(_this); } function actuator_mouseout() { parentmenuset.hidemenu(_this); } function content_mouseover() { if (!animating) { parentmenuset.showmenu(_this); _this.onmouseover(); } } function content_mouseout() { if (!animating) { parentmenuset.hidemenu(_this); } } function child_mouseover() { if (!animating) { parentmenuset.showmenu(_this); } } function child_deactivate() { for (var i = 0; i < childmenus.length; i++) { if (childmenus[i] == this) { dehighlight(elmcache["item"][i]); break; } } } function child_queue() { parentmenuset.hidemenu(_this); } function tostring() { var ahtml = []; var sclassname = "mtdropdownmenu" + (oactuator.constructor != mtdropdownitem ? " top" : ""); for (var i = 0, item = null; item = this.items[i]; i++) { ahtml[i] = item.tostring(childmenus[i]); } return '