function initDisplayEffects(element) { //list of target elements var list = (element != null) ? $$("#"+element+" .cCollapsible") : $$('.cCollapsible'); //list elements to be clicked on var headings = (element != null) ? $$("#"+element+" .cToggler") : $$('.cToggler'); //array to store all of the collapsibles var collapsibles = new Array(); headings.each( function(heading, i) { //for each element create a slide effect var collapsible = new Fx.Slide(list[i], { duration: 300, transition: Fx.Transitions.linear }); //and store it in the array collapsibles[i] = collapsible; //add event listener heading.removeEvent('click'); heading.addEvent('click', function(e){ collapsible.toggle(); //return false; }); //collapse all of the list items collapsible.hide(); }); } window.addEvent('load', function() { new SmoothScroll(); mooWindow = $(window); initDisplayEffects(); });