
YAHOO.namespace("gl");YAHOO.gl.AccordionMenu=function(settings,theListID){this.theList;this.theLIs;this.theSettings=settings;this.numOpened=0;this.animDuration=.4;if(settings.animDuration&&parseFloat(settings.animDuration)){this.animDuration=parseFloat(settings.animDuration);}
this.easing=YAHOO.util.Easing.easeNone;if(settings.easing){this.easing=settings.easing;}
this.selectedClasses=null;if(settings.selectedClasses){this.selectedClasses=settings.selectedClasses.split(",");}
this.disabledClasses=null;if(settings.disabledClasses){this.disabledClasses=settings.disabledClasses.split(",");}
this.selectFunc=settings.selectFunc;this.unselectFunc=settings.unselectFunc;var self=this;this.buildWidget=function(){if(typeof this.theSettings.sectionCollapsedSize=='undefined'){this.theSettings.sectionCollapsedSize=1.25;}
if(typeof this.theSettings.sectionSizeUnit=='undefined'){this.theSettings.sectionSizeUnit='em';}
if(typeof this.theSettings.multiSelect=='undefined'){this.theSettings.multiSelect=false;}
if(typeof this.theSettings.allowCollapse=='undefined'){this.theSettings.allowCollapse=true;}
if(theListID!=null){this.theList=document.getElementById(theListID);this.theLIs=this.theList.getElementsByTagName("li");}
for(var i=0;i<this.theLIs.length;i++){YAHOO.util.Event.addListener(this.theLIs[i],"click",this.toggleSection,self);}};this.toggleSection=function(e,obj){var theLI=this;var theTarget=YAHOO.util.Event.getTarget(e,1);if(!YAHOO.util.Dom.hasClass(theTarget,"accordionTitleDiv")||self.isDisabled(theLI)){return;}
if(obj.theSettings.multiSelect!=false){if(parseFloat(theLI.style.height,10)!=obj.theSettings.sectionCollapsedSize){if(obj.theSettings.allowCollapse||obj.numOpened>1){self.collapseSection(theLI);}}else{self.expandSection(theLI);}}else{if(parseFloat(theLI.style.height,10)!=obj.theSettings.sectionCollapsedSize){if(obj.theSettings.allowCollapse||obj.numOpened>1){self.collapseSection(theLI);}
return;}
for(var i=0;i<self.theLIs.length;i++){if(parseFloat(self.theLIs[i].style.height,10)!=obj.theSettings.sectionCollapsedSize){self.collapseSection(self.theLIs[i]);}}
self.expandSection(theLI);}};this.isSelected=function(el){if(this.selectedClasses){for(var i=0;i<this.selectedClasses.length;i++){if(YAHOO.util.Dom.hasClass(el,this.selectedClasses[i])){return true;}}}
return false;};this.isDisabled=function(el){if(this.disabledClasses){for(var i=0;i<this.selectedClasses.length;i++){if(YAHOO.util.Dom.hasClass(el,this.disabledClasses[i])){return true;}}}
return false;};this.expandSection=function(theSelection){var contentEl=YAHOO.util.Dom.getChildrenBy(theSelection,function(el){return YAHOO.util.Dom.hasClass(el,"content");});var titleEl=YAHOO.util.Dom.getChildrenBy(theSelection,function(el){return YAHOO.util.Dom.hasClass(el,"title");})
if(contentEl&&contentEl.length>0){var contentRgn=YAHOO.util.Dom.getRegion(contentEl[0]);var titleRgn=YAHOO.util.Dom.getRegion(titleEl[0]);var titleHeight=titleRgn.bottom-titleRgn.top;var newHeight=titleHeight+(contentRgn.bottom-contentRgn.top);var exAnim=new YAHOO.util.Anim(theSelection,{height:{from:titleHeight,to:newHeight,unit:this.theSettings.sectionSizeUnit}},this.animDuration,this.easing);exAnim.animate();this.numOpened++;}
if(this.selectFunc){this.selectFunc(theSelection);}};this.collapseSection=function(theSelection){var contentEl=YAHOO.util.Dom.getChildrenBy(theSelection,function(el){return YAHOO.util.Dom.hasClass(el,"content");});var titleEl=YAHOO.util.Dom.getChildrenBy(theSelection,function(el){return YAHOO.util.Dom.hasClass(el,"title");})
if(contentEl&&contentEl.length>0){var contentRgn=YAHOO.util.Dom.getRegion(contentEl[0]);var titleRgn=YAHOO.util.Dom.getRegion(titleEl[0]);var titleHeight=titleRgn.bottom-titleRgn.top;var fullHeight=titleHeight+(contentRgn.bottom-contentRgn.top);var exAnim=new YAHOO.util.Anim(theSelection,{height:{from:fullHeight,to:titleHeight,unit:this.theSettings.sectionSizeUnit}},this.animDuration,this.easing);exAnim.animate();this.numOpened--;}
if(this.unselectFunc){this.unselectFunc(theSelection);}};self.buildWidget();};
