window.addEvent('domready', function() {
  var dirty = 0;
  var totalHeight = 0;
  //create our Accordion instance
  var scrollBox1 = new MooScroll({selector:'#accordion', disabledOpacity:1});
  
  // Add <a> to accordion headers
  jQuery("h3.toggler span").each(function() {
    jQuery(this).html("<a href='#'>" + jQuery(this).text() + "</a>");
  });
  
  // Fire MooTools onClick event when new <a> is keyDown(<enter>)
  jQuery("h3.toggler span a").keydown(function(e) {
/*    if (e.keyCode == 13) {
      $( jQuery(this).parent().parent()[0] ).fireEvent("click");
      return false;
    } */
  }).click(function() { 
    $( jQuery(this).parent().parent()[0] ).fireEvent("click");
    return false; 
  });
  
  // Fire MooTools onClick event when invisible link become focused
  jQuery(".subnav a").focus(function() {
    if ( jQuery(this).parent().parent().parent().height() == 0 ) {
      $( jQuery(this).parent().parent().parent().prev()[0] ).fireEvent("click");
    }
  });
  
  var myAccordion = new Accordion($('accordion'), 'h3.toggler', 'div.subnav', {
    opacity: false,
    display: -1,
    onActive: function(toggler, element){
      toggler.addClass('active');
      if (dirty) {
        (function() { 
          scrollBox1.refresh();
          scrollBox1.setSlider(toggler.getPosition($('accordion')).y - 15);
        }).delay(500);
      } else {
        dirty = 1;
      }
    },
    onBackground: function(toggler, element){
      toggler.removeClass('active');
    }
  });
  (function() { scrollBox1.refresh(); }).delay(500);
  
  var status = {
    'true': 'close',
    'false': 'open'
  };
  
  var myVerticalSlide = new Fx.Slide('glossary-of-terms').hide();
  
  $('glossary-of-terms-link').addEvent('click', function(e){
    e.stop();
    myVerticalSlide.toggle();
  });
  
});


// COURSE LISTING

jQuery(document).ready(function() {

// -- collapse accrediting groups

  jQuery("#accrediting-body div.accrediting-body ul").hide();
  jQuery("#accrediting-body h4").click(function() {
    jQuery(this).next("ul").slideToggle("fast");
    jQuery(this).toggleClass("expanded");
    return false;
  });
  
// -- collapse accrediting groups

  jQuery("#catalogListing h4").click(function() {
    jQuery(this).next("ul").slideToggle("fast");
    jQuery(this).toggleClass("expanded");
    return false;
  });

});

