var myAccordion

window.addEvent('domready', function(){

  // smooth scrolling
  var mySmoothScroll = new SmoothScroll({
    links: '.smoothAnchors',
    wheelStops: false
  });
  
  
  // check m2 exists	
  if ($('m2')){
    // the load
    $$('#m2 .main').addEvent('click', function(){return false;});
    $$('#m2 .sub').setStyles({
      'height': '0',
      'overflow': 'hidden',
      'display': 'block'
    });
  
    // left menu accordion
    myAccordion = new Accordion($$('#m2 .main'), $$('#m2 .sub'), {
      display: null,
      alwaysHide: false,
      opacity: false,
      onActive: function(toggler, element){
        toggler.addClass('m2active');
        element.setStyle('padding-bottom', '10px');
      },
      onBackground: function(toggler, element){
        toggler.removeClass('m2active');
        element.setStyle('padding-bottom', '0');
      }
    });
  } // end m2 check
  
  
  // now the calendar dropdowns!
  if ($('calendar')) {
    var calendarList = $('calendar');
    calendarList.getElements('li').each(function(el){
      
      // check it's not featured
      if (el.hasClass('featured') == false){
      
        // the load
        var h4child = el.getElement('div');
        h4child.slide('hide');
  
        // the click
        el.getElement('h4').addEvent('click', function(){
          var slideFx = new Fx.Slide(h4child, {transition: Fx.Transitions.Circ.easeInOut});
          slideFx.toggle();
        });
      }
      
    });
  } // end calendar check
  
}); // end domload