var ddlevelsmenu={enableshim:true,arrowpointers:{downarrow:["images/site/arrow-down.gif",11,7],rightarrow:["images/site/arrow-left.gif",12,12],showarrow:{toplevel:false,sublevel:false}},hideinterval:500,effects:{enableswipe:true,enablefade:true,duration:0},httpsiframesrc:"blank.htm",topmenuids:[],topitems:{},subuls:{},lastactivesubul:{},topitemsindex:-1,ulindex:-1,hidetimers:{},shimadded:false,nonFF:!/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent),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")}},getwindowsize:function(){this.docwidth=window.innerWidth?window.innerWidth-10:this.standardbody.clientWidth-10;this.docheight=window.innerHeight?window.innerHeight-15:this.standardbody.clientHeight-18},gettopitemsdimensions:function(){for(var A=0;A<this.topmenuids.length;A++){var D=this.topmenuids[A];for(var B=0;B<this.topitems[D].length;B++){var E=this.topitems[D][B];var C=document.getElementById(E.getAttribute("rel"));E._dimensions={w:E.offsetWidth,h:E.offsetHeight,submenuw:C.offsetWidth,submenuh:C.offsetHeight}}}},isContained:function(A,B){var B=window.event||B;var C=B.relatedTarget||((B.type=="mouseover")?B.fromElement:B.toElement);while(C&&C!=A){try{C=C.parentNode}catch(B){C=A}}if(C==A){return true}else{return false}},addpointer:function(D,F,A,C){var E=document.createElement("img");E.src=A[0];E.style.width=A[1]+"px";E.style.height=A[2]+"px";if(F=="rightarrowpointer"){E.style.left=D.offsetWidth-A[2]-2+"px"}E.className=F;var B=D.childNodes[D.firstChild.nodeType!=1?1:0];if(B&&B.tagName=="SPAN"){D=B}if(C=="before"){D.insertBefore(E,D.firstChild)}else{D.appendChild(E)}},css:function(B,A,C){var D=new RegExp("(^|\\s+)"+A+"($|\\s+)","ig");if(C=="check"){return D.test(B.className)}else{if(C=="remove"){B.className=B.className.replace(D,"")}else{if(C=="add"&&!D.test(B.className)){B.className+=" "+A}}}},addshimmy:function(B){var C=(!window.opera)?document.createElement("iframe"):document.createElement("div");C.className="ddiframeshim";C.setAttribute("src",location.protocol=="https:"?this.httpsiframesrc:"about:blank");C.setAttribute("frameborder","0");B.appendChild(C);try{C.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)"}catch(A){}return C},positionshim:function(G,C,A,F,E){if(G._istoplevel){var E=window.pageYOffset?window.pageYOffset:this.standardbody.scrollTop;var D=G._offsets.top-E;var B=E+this.docheight-G._offsets.top-G._dimensions.h;if(D>0){this.shimmy.topshim.style.left=F+"px";this.shimmy.topshim.style.top=E+"px";this.shimmy.topshim.style.width="99%";this.shimmy.topshim.style.height=D+"px"}if(B>0){this.shimmy.bottomshim.style.left=F+"px";this.shimmy.bottomshim.style.top=G._offsets.top+G._dimensions.h+"px";this.shimmy.bottomshim.style.width="99%";this.shimmy.bottomshim.style.height=B+"px"}}},hideshim:function(){this.shimmy.topshim.style.width=this.shimmy.bottomshim.style.width=0;this.shimmy.topshim.style.height=this.shimmy.bottomshim.style.height=0},buildmenu:function(D,F,C,E,A,B){F._master=D;F._pos=E;F._istoplevel=A;if(A){this.addEvent(F,function(G){ddlevelsmenu.hidemenu(ddlevelsmenu.subuls[this._master][parseInt(this._pos)])},"click")}this.subuls[D][E]=C;F._dimensions={w:F.offsetWidth,h:F.offsetHeight,submenuw:C.offsetWidth,submenuh:C.offsetHeight};this.getoffsetof(F);C.style.left=0;C.style.top=0;C.style.visibility="hidden";this.addEvent(F,function(J){if(!ddlevelsmenu.isContained(this,J)){var H=ddlevelsmenu.subuls[this._master][parseInt(this._pos)];if(this._istoplevel){ddlevelsmenu.css(this,"selected","add");clearTimeout(ddlevelsmenu.hidetimers[this._master][this._pos])}ddlevelsmenu.getoffsetof(F);var L=window.pageXOffset?window.pageXOffset:ddlevelsmenu.standardbody.scrollLeft;var I=window.pageYOffset?window.pageYOffset:ddlevelsmenu.standardbody.scrollTop;var N=this._offsets.left+this._dimensions.submenuw+(this._istoplevel&&B=="topbar"?0:this._dimensions.w);var G=this._offsets.top+this._dimensions.submenuh;var M=(this._istoplevel?this._offsets.left+(B=="sidebar"?this._dimensions.w:0):this._dimensions.w);if(N-L>ddlevelsmenu.docwidth){M+=-this._dimensions.submenuw+(this._istoplevel&&B=="topbar"?this._dimensions.w:-this._dimensions.w)}H.style.left=M+"px";var K=(this._istoplevel?this._offsets.top+(B=="sidebar"?0:this._dimensions.h):this.offsetTop);if(G-I>ddlevelsmenu.docheight){if(this._dimensions.submenuh<this._offsets.top+(B=="sidebar"?this._dimensions.h:0)-I){K+=-this._dimensions.submenuh+(this._istoplevel&&B=="topbar"?-this._dimensions.h:this._dimensions.h)}else{K+=-(this._offsets.top-I)+(this._istoplevel&&B=="topbar"?-this._dimensions.h:0)}}H.style.top=K+"px";if(ddlevelsmenu.enableshim&&(ddlevelsmenu.effects.enableswipe==false||ddlevelsmenu.nonFF)){ddlevelsmenu.positionshim(F,H,B,L,I)}else{H.FFscrollInfo={x:L,y:I}}ddlevelsmenu.showmenu(F,H,B)}},"mouseover");this.addEvent(F,function(H){var G=ddlevelsmenu.subuls[this._master][parseInt(this._pos)];if(this._istoplevel){if(!ddlevelsmenu.isContained(this,H)&&!ddlevelsmenu.isContained(G,H)){ddlevelsmenu.hidemenu(G)}}else{if(!this._istoplevel&&!ddlevelsmenu.isContained(this,H)){ddlevelsmenu.hidemenu(G)}}},"mouseout")},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(D,B,A){if(this.effects.enableswipe||this.effects.enablefade){if(this.effects.enableswipe){var C=(D._istoplevel&&A=="topbar")?D._dimensions.submenuh:D._dimensions.submenuw;B.style.width=B.style.height=0;B.style.overflow="hidden"}if(this.effects.enablefade){this.setopacity(B,0)}B._curanimatedegree=0;B.style.visibility="visible";clearInterval(B._animatetimer);B._starttime=new Date().getTime();B._animatetimer=setInterval(function(){ddlevelsmenu.revealmenu(D,B,C,A)},10)}else{B.style.visibility="visible"}},revealmenu:function(E,C,D,B){var A=new Date().getTime()-C._starttime;if(A<this.effects.duration){if(this.effects.enableswipe){if(C._curanimatedegree==0){C.style[E._istoplevel&&B=="topbar"?"width":"height"]="auto"}C.style[E._istoplevel&&B=="topbar"?"height":"width"]=(C._curanimatedegree*D)+"px"}if(this.effects.enablefade){this.setopacity(C,C._curanimatedegree)}}else{clearInterval(C._animatetimer);if(this.effects.enableswipe){C.style.width="auto";C.style.height="auto";C.style.overflow="visible"}if(this.effects.enablefade){this.setopacity(C,1);C.style.filter=""}if(this.enableshim&&C.FFscrollInfo){this.positionshim(E,C,B,C.FFscrollInfo.x,C.FFscrollInfo.y)}}C._curanimatedegree=(1-Math.cos((A/this.effects.duration)*Math.PI))/2},hidemenu:function(A){if(typeof A._pos!="undefined"){this.css(this.topitems[A._master][parseInt(A._pos)],"selected","remove");if(this.enableshim){this.hideshim()}}clearInterval(A._animatetimer);A.style.left=0;A.style.top="-1000px";A.style.visibility="hidden"},addEvent:function(B,C,A){if(B.addEventListener){B.addEventListener(A,C,false)}else{if(B.attachEvent){B.attachEvent("on"+A,function(){return C.call(B,window.event)})}}},init:function(B,D){this.standardbody=(document.compatMode=="CSS1Compat")?document.documentElement:document.body;this.topitemsindex=-1;this.ulindex=-1;this.topmenuids.push(B);this.topitems[B]=[];this.subuls[B]=[];this.hidetimers[B]=[];if(this.enableshim&&!this.shimadded){this.shimmy={};this.shimmy.topshim=this.addshimmy(document.body);this.shimmy.bottomshim=this.addshimmy(document.body);this.shimadded=true}var H=document.getElementById(B);var C=H.getElementsByTagName("a");this.getwindowsize();for(var F=0;F<C.length;F++){if(C[F].getAttribute("rel")){this.topitemsindex++;this.ulindex++;var J=C[F];this.topitems[B][this.topitemsindex]=J;var K=document.getElementById(J.getAttribute("rel"));document.body.appendChild(K);K.style.zIndex=2000;K._master=B;K._pos=this.topitemsindex;this.addEvent(K,function(){ddlevelsmenu.hidemenu(this)},"click");var L=(D=="sidebar")?"rightarrowpointer":"downarrowpointer";var G=(D=="sidebar")?this.arrowpointers.rightarrow:this.arrowpointers.downarrow;if(this.arrowpointers.showarrow.toplevel){this.addpointer(J,L,G,(D=="sidebar")?"before":"after")}this.buildmenu(B,J,K,this.ulindex,true,D);K.onmouseover=function(){clearTimeout(ddlevelsmenu.hidetimers[this._master][this._pos])};this.addEvent(K,function(N){if(!ddlevelsmenu.isContained(this,N)&&!ddlevelsmenu.isContained(ddlevelsmenu.topitems[this._master][parseInt(this._pos)],N)){var M=this;if(ddlevelsmenu.enableshim){ddlevelsmenu.hideshim()}ddlevelsmenu.hidetimers[this._master][this._pos]=setTimeout(function(){ddlevelsmenu.hidemenu(M)},ddlevelsmenu.hideinterval)}},"mouseout");var E=K.getElementsByTagName("ul");for(var I=0;I<E.length;I++){this.ulindex++;var A=E[I].parentNode;if(this.arrowpointers.showarrow.sublevel){this.addpointer(A.getElementsByTagName("a")[0],"rightarrowpointer",this.arrowpointers.rightarrow,"before")}this.buildmenu(B,A,E[I],this.ulindex,false,D)}}}this.addEvent(window,function(){ddlevelsmenu.getwindowsize();ddlevelsmenu.gettopitemsdimensions()},"resize")},setup:function(B,A){this.addEvent(window,function(){ddlevelsmenu.init(B,A)},"load")}}
