/*$(function() {

  var
    toc = $('#toc').show(),
    items = $('#toc > ul').hide();

  $('#toc h3')
    .click(function() {
      if (items.is(':visible')) {
        items.animate({
          height:     'hide',
          opacity:    'hide'
        }, 300, function() {
          toc.removeClass('expandedtoc');
        });
      }
      else {
        items.animate({
          height:     'show',
          opacity:    'show'
        }, 400);
        toc.addClass('expandedtoc');
      }
    });

});*/
function toggle_content(elem, callback) {
  var e = $(elem);
  return e.next().toggle('slow', callback);
}
function scroll_to_content(selectah) {
  $('body').animate({scrollTop: $(selectah)[0].offsetTop}, 1000);
}
$(window).load(function() {
  var menus = $('.dropdown h3');
  menus.click(
    function (e) {
      toggle_content(e.currentTarget);
    }
  );
  toggle_content(menus, function() {
    // While we're here, let's re-scroll to the fragment id, or content if mobile
    if (location.hash ) {
      scroll_to_content(location.hash);
    } else {
      if (document.documentElement.clientWidth <= 480) {
        scroll_to_content('.content h1');
      } else {
      }
    }
  });
});
