Element.extend({getMarginLeft:function(){return this.getStyle("marginLeft").toInt()},getMarginRight:function(){return this.getStyle("marginRight").toInt()},getMarginTop:function(){return this.getStyle("marginTop").toInt()},getMarginBottom:function(){return this.getStyle("marginBottom").toInt()},getMarginH:function(){return this.getMarginLeft()+this.getMarginRight()},getMarginV:function(){return this.getMarginTop()+this.getMarginBottom()},getOuterLeft:function(A){return this.getStyle("borderLeftWidth").toInt()+this.getStyle("paddingLeft").toInt()+(A?this.getMarginLeft():0)},getOuterRight:function(A){return this.getStyle("borderRightWidth").toInt()+this.getStyle("paddingRight").toInt()+(A?this.getMarginRight():0)},getOuterTop:function(A){return this.getStyle("borderTopWidth").toInt()+this.getStyle("paddingTop").toInt()+(A?this.getMarginTop():0)},getOuterBottom:function(A){return this.getStyle("borderBottomWidth").toInt()+this.getStyle("paddingBottom").toInt()+(A?this.getMarginBottom():0)},getOuterH:function(A){return this.getOuterLeft(A)+this.getOuterRight(A)},getOuterV:function(A){return this.getOuterTop(A)+this.getOuterBottom(A)},getWidth:function(A){return A?this.scrollWidth:this.offsetWidth},getHeight:function(A){return A?this.scrollHeight:this.offsetHeight},getOuterWidth:function(A){return this.getWidth(A)+this.getMarginH()},getOuterHeight:function(A){return this.getHeight(A)+this.getMarginV()},getInnerWidth:function(A){return this.getWidth(A)-this.getOuterH()},getInnerHeight:function(A){return this.getHeight(A)-this.getOuterV()},setWidth:function(B,A){this.setInnerWidth(parseInt(B)-(window.ie?0:this.getOuterH(A)))},setHeight:function(B,A){this.setInnerHeight(parseInt(B)-(window.ie?0:this.getOuterV(A)))},setOuterWidth:function(A){this.setWidth(A,true)},setOuterHeight:function(A){this.setHeight(A,true)},setInnerWidth:function(A){this.setStyle("width",parseInt(A)-(window.ie?this.getOuterH():0)+"px")},setInnerHeight:function(A){this.setStyle("height",parseInt(A)-(window.ie?this.getOuterV():0)+"px")}});window.moopopupmenu={lastmenu:0,menus:[],items:{},lastzindex:0,lastitemid:0,substack:[],elements:[],amenushown:false,onBodyDown:function(A){if(!window.moopopupmenu.amenushown){return true}A=new Event(A);if(!A.target.ismenu){window.moopopupmenu.hideAllMenus()}},onClick2:function(A){this.toggle(A)},reg:function(A,B){this.elements.push(A);A.onclick=this.onClick2.bind(B)},hideAllMenus:function(){for(var A=0;A<this.menus.length;++A){if(this.menus[A].isVisible){this.menus[A].hide()}}this.amenushown=false},onMouseEnter:function(A){window.moopopupmenu.setClassNameOver(this);if(this.parentMenu.shownSub&&this.parentMenu.shownSub.parentItem!==this){this.parentMenu.shownSub.hide()}if(this.subMenu){this.subMenu.show()}},setClassName:function(A){if(A.className!=A.classNameNormal){A.className=A.classNameNormal}if(A.arrow){A.arrow.className="moopopupitem_arrow"}},setClassNameOver:function(A){if(A.classNameOver){A.className=A.classNameOver}if(A.arrow){A.arrow.className="moopopupitem_arrow_over"}},onMouseLeave:function(A){if(!this.subMenu){window.moopopupmenu.setClassName(this)}},onClick:function(e){if(this.stuff.istitle||this.stuff.text=="-"||(this.subMenu&&!this.stuff.command)){return }window.moopopupmenu.hideAllMenus();if(this.stuff.command){eval(this.stuff.command)}else{if($defined(this.stuff.call)){this.stuff.call(this)}}}};function mooPopupMenu(my_parent,items){window.moopopupmenu.menus[window.moopopupmenu.lastmenu]={menuObj:null,menuObjInner:null,items:{},parentItem:my_parent,isVisible:false,a:function(s){return this.addItem(s?{path:s.p,text:s.t,command:s.c,istitle:s.is,icon:s.i,call:s.call}:undefined)},addItem:function(stuff){if(!stuff){return }var menuObj=this.menuObjInner;var rest=null;var itemname=null;if(!stuff.path||stuff.path.length==0){stuff.path="/unnamed"+(++window.moopopupmenu.lastitemid)}if(stuff.path&&stuff.path.length>1){var i=stuff.path.lastIndexOf("/");if(i<=0||my_parent!=undefined){itemname=stuff.path}else{rest=stuff.path.substr(0,i);var item=window.moopopupmenu.items[rest];if(!item){return }if(!item.subMenu){item.subMenu=mooPopupMenu(item);var arrow=document.createElement("div");arrow.className="moopopupitem_arrow";item.arrow=arrow;item.insertBefore(arrow,item.firstChild)}item.subMenu.addItem(stuff);return }}var item=window.ie?new Element("div"):document.createElement("div");item.stuff=stuff;item.ismenu=true;if(stuff.istitle){item.classNameNormal="moopopupitem_title"}else{if(stuff.text=="-"){item.classNameNormal="moopopupitem_separator"}else{if(stuff.indent){item.classNameNormal="moopopupitem indent"}else{item.classNameNormal="moopopupitem"}item.classNameOver="moopopupitem_over"}}window.moopopupmenu.setClassName(item);item.onmouseover=window.moopopupmenu.onMouseEnter;item.onmouseout=window.moopopupmenu.onMouseLeave;item.onclick=window.moopopupmenu.onClick;if(stuff.text!="-"){var img=document.createElement("span");img.className="moopopupitem_icon";img.id=stuff.text.replace(/\W/g,"");if(stuff.icon&&stuff.icon.length){if(stuff.icon.charAt(0)=="<"){img.innerHTML=stuff.icon}else{var img2=document.createElement("img");img2.src=stuff.icon;img.appendChild(img2)}}item.appendChild(img);if(stuff.text){item.appendChild(document.createTextNode(stuff.text))}}else{var hr=document.createElement("div");hr.className="moopopupitem_hr";item.appendChild(hr)}item.parentMenu=menuObj;menuObj.appendChild(item);window.moopopupmenu.items[itemname]=item},show:function(event){var overlapx=4;if(this.isVisible){return }this.menuObj.setStyles({left:0,top:0});this.menuObj.setStyle("visibility","hidden");this.menuObj.setStyle("display","inline");if(window.moopopupmenu.lastzindex==0){window.moopopupmenu.lastzindex=this.menuObj.getStyle("zIndex")}var x,y;var w=this.menuObj.getWidth();var h=this.menuObj.getHeight();var sl=window.getScrollLeft(),st=window.getScrollTop();if(!this.parentItem){event=new Event(event);try{var scrolls=[];if($defined($("scroller"))){scrolls[scrolls.length]=$("scroller")}if($defined($("dataContent"))){var dc=$("dataContent").getElement("div.collection");if($defined(dc)){scrolls[scrolls.length]=dc}}if($defined($("page_2"))){scrolls[scrolls.length]=$("page_2")}if($defined($("search_results"))){scrolls[scrolls.length]=$("search_results")}y=$(event.target).getTop(scrolls)+30}catch(e){y=$(event.target).getTop()+30}if(isNaN(y)){y=$(event.target).getTop()+30}x=event.target.getLeft()+10;window.moopopupmenu.hideAllMenus();if(x+w>window.getWidth()){if(x<w){x=sl}else{x=event.page.x-w}}else{}if(y+h>window.getHeight()){if(y<h){x=st}else{y=event.page.y-h}}else{}}else{this.parentItem.parentMenu.shownSub=this;var p=this.parentItem.parentMenu.getPosition();var p2=this.parentItem.getPosition();var w2=this.parentItem.parentMenu.getWidth();var h2=this.parentItem.getHeight();x=(p.x+w2-overlapx)-sl;y=p2.y-st;if(x+w>window.getWidth()){if(p.x-w+overlapx<sl){x=sl}else{x=p.x-w+overlapx}}else{x=p.x+w2-overlapx}if(y+h>window.getHeight()){if(p2.y+h2-h<st){y=st}else{y=p2.y+h2-h}}else{y=p2.y}}this.menuObj.setStyles({left:x,top:y});window.moopopupmenu.lastzindex=parseInt(window.moopopupmenu.lastzindex)+10;this.menuObj.setStyle("zIndex",window.moopopupmenu.lastzindex);this.menuObj.setStyle("visibility","visible");this.isVisible=true;window.moopopupmenu.amenushown=true;if(event){event.stop()}},hide:function(){if(!this.isVisible){return }window.moopopupmenu.lastzindex=this.menuObj.getStyle("zIndex");this.menuObj.setStyle("display","none");if(this.parentItem){window.moopopupmenu.setClassName(this.parentItem.parentMenu.shownSub.parentItem);this.parentItem.parentMenu.shownSub=undefined}var items=this.menuObjInner.getChildren();for(var key in items){if(items[key].subMenu){items[key].subMenu.hide()}}this.isVisible=false},toggle:function(event){if(this.isVisible){this.hide()}else{this.show(new Event(event))}}};var ret;if(window.moopopupmenu.lastmenu==0){(window.ie?$(document.body):document.body).addEvent("click",window.moopopupmenu.onBodyDown)}with(window.moopopupmenu.menus[window.moopopupmenu.lastmenu]){menuObj=null;menuObj=window.ie?new Element("div"):document.createElement("div");menuObjInner=window.ie?new Element("div"):document.createElement("div");menuObj.className="moopopupmenu";menuObjInner.className="inner";menuObj.ismenu=true;menuObj.appendChild(menuObjInner);document.body.appendChild(menuObj);ret=window.moopopupmenu.menus[window.moopopupmenu.lastmenu];++window.moopopupmenu.lastmenu}if(items){var end=items.length-1;for(var c=0;c<end;c++){ret.a(items[c])}}return ret}