

$(function () { 
  // assuming we have the open class set on the H2 when the HTML is delivered
  //$('#sidebar ul h2:not(.open)').hide();

  $('h5.drawer-handle').click(function () {
    // hide all the others.
    //$('h5.open').removeClass('open').next().removeClass('open');
    var header = $(this);
    var ul = header.next();

    if (header.hasClass('open')) {
        header.removeClass('open');
        var onAnimateEnd = function(foo) {
            var ul = $(this);
            ul.css("height", "auto");
            ul.removeClass("open");
        };

        ul.animate({height: "0px"}, 300, null, onAnimateEnd)
    } else {
        header.addClass('open');
        var fullHeight = ul.height();
        ul.addClass("open");
        ul.css("height", "0px");
        ul.animate({height: fullHeight + "px"}, 300);
    }
  });

  Cufon.replace('#content h2');
  Cufon.replace('#content h3');
  Cufon.replace('#content h4');
  Cufon.replace('p.large');
});