var RightMenu=Class.create();RightMenu.prototype={initialize:function(bar){this.areas=$(bar).select(".stoolRbarCollapsableArea");this.currentlyOpen=-1;for(var i=0;i<this.areas.size();i++){var isOpen=this.areas[i].attributes.getNamedItem("expanded").value;if(isOpen=="True"){this.areas[i].down("div",0).down("img").scr="images/arrowDown.gif";this.areas[i].down("div",0).down("img").attributes.getNamedItem("src").value="images/arrowDown.gif";this.currentlyOpen=i}}this.topPosition=$(bar).down("div.stoolRbarTopArea").getHeight();this.separationHeight=parseInt($(bar).attributes.getNamedItem("separationheight").value)},expand:function(area){var areaToOpen=$(area).up().up(),heightExpanded=parseInt(areaToOpen.attributes.getNamedItem("expandedheight").value),toOpenIndex=this.areas.indexOf(areaToOpen),content=areaToOpen.down("div",1);if(toOpenIndex!=this.currentlyOpen){this.hideCurrent();this.moveAreas(toOpenIndex,content,heightExpanded);this.currentlyOpen=toOpenIndex;this.showCurrent()}},hideCurrent:function(){if(this.currentlyOpen!=-1){Effect.Fade(this.areas[this.currentlyOpen].down("div",1),{duration:.5});this.areas[this.currentlyOpen].down("div",0).down("img").scr="images/arrowRight.gif";this.areas[this.currentlyOpen].down("div",0).down("img").attributes.getNamedItem("src").value="images/arrowRight.gif"}},showCurrent:function(){var div=this.areas[this.currentlyOpen];Effect.Appear(this.areas[this.currentlyOpen].down("div",1),{queue:"end",afterFinish:function(){Scroll.showScrollbar(div)},duration:.5});this.areas[this.currentlyOpen].down("div",0).down("img").scr="images/arrowDown.gif";this.areas[this.currentlyOpen].down("div",0).down("img").attributes.getNamedItem("src").value="images/arrowDown.gif"},moveAreas:function(toOpenIndex,content,heightExpanded){var p=this,h=heightExpanded;this.areas.each(function(o,i){var newY=p.topPosition+i*p.separationHeight+(i>toOpenIndex?h:0);new Effect.Move(o,{y:newY,mode:"absolute",duration:.4,delay:.4})})},restart:function(){for(var heightExpanded=0,i=0;i<this.areas.size();i++){var isOpen=this.areas[i].attributes.getNamedItem("expanded").value;if(isOpen=="True"){this.areas[i].down("div",0).down("img").scr="images/arrowDown.gif";this.areas[i].down("div",0).down("img").attributes.getNamedItem("src").value="images/arrowDown.gif";this.currentlyOpen=i;heightExpanded=parseInt(this.areas[i].attributes.getNamedItem("expandedheight").value)}}var p=this;this.areas.each(function(o,i){var newY=p.topPosition+i*p.separationHeight+(i>p.currentlyOpen?heightExpanded:0);o.style["top"]=newY+"px"})},expandOnly:function(area){var areaToOpen=$(area).up().up(),toOpenIndex=this.areas.indexOf(areaToOpen);if(this.currentlyOpen==toOpenIndex){this.hideCurrent();this.currentlyOpen=-1}else{this.currentlyOpen=toOpenIndex;this.showCurrent()}}};
