function hideAll() {
    $('.fold li').not(".fold li li").addClass('collapsed');
    $('.fold .foldable').hide();
}

function toggle() {
    $(this).parent().toggleClass('collapsed');
    if ($(this).parent('.collapsed').length > 0) {
      $(this).next('.foldable').hide();
    }
    else {
      $(this).next('.foldable').show();
    }
    
}


$(function() {
  hideAll();
  $('.fold h3').click(toggle);
});
