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 '
' + '
' + '' + ahtml.join('') + '
' + '
' + '
' + '
' + '
'; } } /////////////////////////////// class mtdropdown ends ///////////// mtdropdownset.registry = []; function mtdropdownset(idirection, ileft, itop, ireferencepoint) { this.addmenu = addmenu; this.showmenu = showmenu; this.hidemenu = hidemenu; this.hide = hide; var menus = []; var _this = this; var current = null; this.index = mtdropdownset.registry.length; mtdropdownset.registry[this.index] = this; function addmenu(oactuator) { var m = new mtdropdown(oactuator, idirection, ileft, itop, ireferencepoint, this); menus[menus.length] = m; return m; } function showmenu(omenu) { if (omenu != current) { if (current != null) hide(current); current = omenu; omenu.show(); } else { cancelhide(omenu); } } function hidemenu(omenu) { if (current == omenu && omenu.isopen) { if (!omenu.hidetimer) schedulehide(omenu); } } function schedulehide(omenu) { omenu.onqueue(); omenu.hidetimer = window.settimeout("mtdropdownset.registry[" + _this.index + "].hide(mtdropdown.registry[" + omenu.index + "])", mtdropdown.hidedelay); } function cancelhide(omenu) { if (omenu.hidetimer) { window.cleartimeout(omenu.hidetimer); omenu.hidetimer = null; } } function hide(omenu) { if (!omenu && current) omenu = current; if (omenu && current == omenu && omenu.isopen) { cancelhide(omenu); current = null; omenu.hidetimer = null; omenu.hide(); } } } function mtdropdownitem(stext, surl, oparent) { this.tostring = tostring; this.text = stext; this.url = surl; this.parentmenu = oparent; function tostring(bdingbat) { var sdingbat = bdingbat ? mtdropdown.dingbatoff : mtdropdown.spacergif; var iedgepadding = mtdropdown.itempadding + mtdropdown.menupadding; var spaddingleft = "padding:" + mtdropdown.itempadding + "px; padding-left:" + iedgepadding + "px;" var spaddingright = "padding:" + mtdropdown.itempadding + "px; padding-right:" + iedgepadding + "px;" return '' + stext + ''; } } function accelimation(from, to, time, zip) { if (typeof zip == "undefined") zip = 0; if (typeof unit == "undefined") unit = "px"; this.x0 = from; this.x1 = to; this.dt = time; this.zip = -zip; this.unit = unit; this.timer = null; this.onend = new function(); this.onframe = new function(); } accelimation.prototype.start = function() { this.t0 = new date().gettime(); this.t1 = this.t0 + this.dt; var dx = this.x1 - this.x0; this.c1 = this.x0 + ((1 + this.zip) * dx / 3); this.c2 = this.x0 + ((2 + this.zip) * dx / 3); accelimation._add(this); } accelimation.prototype.stop = function() { accelimation._remove(this); } accelimation.prototype._paint = function(time) { if (time < this.t1) { var elapsed = time - this.t0; this.onframe(accelimation._getbezier(elapsed/this.dt,this.x0,this.x1,this.c1,this.c2)); } else this._end(); } accelimation.prototype._end = function() { accelimation._remove(this); this.onframe(this.x1); this.onend(); } accelimation._add = function(o) { var index = this.instances.length; this.instances[index] = o; if (this.instances.length == 1) { this.timerid = window.setinterval("accelimation._paintall()", this.targetres); } } accelimation._remove = function(o) { for (var i = 0; i < this.instances.length; i++) { if (o == this.instances[i]) { this.instances = this.instances.slice(0,i).concat( this.instances.slice(i+1) ); break; } } if (this.instances.length == 0) { window.clearinterval(this.timerid); this.timerid = null; } } accelimation._paintall = function() { var now = new date().gettime(); for (var i = 0; i < this.instances.length; i++) { this.instances[i]._paint(now); } } accelimation._b1 = function(t) { return t*t*t } accelimation._b2 = function(t) { return 3*t*t*(1-t) } accelimation._b3 = function(t) { return 3*t*(1-t)*(1-t) } accelimation._b4 = function(t) { return (1-t)*(1-t)*(1-t) } accelimation._getbezier = function(percent,startpos,endpos,control1,control2) { return endpos * this._b1(percent) + control2 * this._b2(percent) + control1 * this._b3(percent) + startpos * this._b4(percent); } accelimation.instances = []; accelimation.targetres = 10; accelimation.timerid = null;