var HMenu = Class.create(); HMenu.prototype = { initialize: function(menuElem, menuOptions){ this.d = menuElem; this.initOptions(menuOptions); this.init();}, mOnOver: function(){ this.mFlag = true;}, menuOnOut: function(){ this.mFlag = false; setTimeout(this.mEndOut.bind(this), this.timeForEnd);}, menuOnOver: function(){ this.mFlag = true; if (this.stmt == 2){ this.stmt = 0; new Effect.BlindDown(this.divOver, {duration: this.timeForDown, afterFinish: (function(){this.stmt = 1;}).bind(this)});} else if (this.stmt == 3){ this.stmt = 0; this.func = this.menuOnOver;}}, mBlindDown: function(){ new Effect.BlindDown(this.divOver, {duration: this.timeForDown, afterFinish: (function(){this.stmt = 1;}).bind(this)});}, mEndOut: function(){ if (!this.mFlag){ if (this.stmt == 1){ this.stmt = 3; this.effect = new Effect.BlindUp(this.divOver, {duration: this.timeForUp, afterFinish: (function(){this.stmt = 2; this.func(); this.func=empty;}).bind(this)});} else setTimeout(this.mEndOut.bind(this), 500);}}, initOptions: function(menuOptions){ this.timeForDown = 0.3; this.timeForUp = 1.0; this.timeForEnd = 500; this.itemTag = 'a'; if (menuOptions != undefined){ if (menuOptions.timeForBlind != undefined){ this.timeForDown = menuOptions.timeForBlind; this.timeForUp = menuOptions.timeForBlind;} if (menuOptions.timeForDown != undefined) this.timeForDown = menuOptions.timeForDown; if (menuOptions.timeForUp != undefined) this.timeForUp = menuOptions.timeForUp; if (menuOptions.timeForEnd != undefined) this.timeForEnd = menuOptions.timeForEnd; if (menuOptions.itemTag != undefined) this.itemTag = menuOptions.itemTag;}}, init: function(){ this.d.onmouseover = this.mOnOver.bindAsEventListener(this); this.d.onmouseout = this.menuOnOut.bindAsEventListener(this); this.divOver = this.d.getElementsByTagName('div')[0]; var d1 = this.d.offsetWidth; var d2 = this.divOver.style.width; d2 = d2.replace('px', ''); var pos = Position.positionedOffset(this.d); this.divOver.style.left = pos[0] + Math.round((d1-d2)/2) + 'px'; this.divOver.style.position = 'absolute'; this.divOver.style.zIndex = '100'; this.stmt = 2; this.mFlag = false; this.func = empty; links = $A(this.d.getElementsByTagName(this.itemTag)); links.each((function(el){ el.onmouseover = this.mOnOver.bindAsEventListener(this);}).bind(this)); links[0].onmouseover = this.menuOnOver.bindAsEventListener(this);}}; var detectHMenu = function(tag){ if (tag.getAttribute && tag.getAttribute("rel")){ var rel = tag.getAttribute("rel"); var i = rel.indexOf('hmenu'); if (i != -1){ group = rel.substring(i+5, rel.length-1); this.Add(group, tag); new HMenu(tag);}} }; var hmenuCollection = new TagCollection("hmenuCollection1"); hmenuCollection.SetDetector(detectHMenu); TagDetect.Add(hmenuCollection);