// When the page is ready
$(document).ready(function()
{
  // Things to do on page load and, more importantly, reload
  // 1 - Hide all details
  $(".committee_position .current_details").hide();
  $(".committee_position .the_murky_past").hide();
  // END things to do on page load/reload
  
  // Things to do while the form is being used
  // 1 - Clicking on "Details" reveals or hides the details
  $(".committee_position .reveal_the_details").click(function(event)
  {
    var current_details = $(this).closest(".committee_position").find(".current_details");
    
    if (current_details.is(":hidden"))
    {
      current_details.show();
    }
    else
    {
      // Forcibly hide the murky past so that when the details
      // are reopened we are certain just the details are revealed
      // and not the murky past with them.
      current_details.find(".the_murky_past").hide();
      current_details.hide();
    }
    
    // Stop the link click from doing its normal thing
    event.preventDefault();
  });
  
  // 2 - Clicking on "<position> of the Murky Past" reveals or hides the murky past
  $(".committee_position .reveal_the_murky_past").click(function(event)
  {
    $(this).closest(".committee_position .current_details").find(".the_murky_past").toggle();
    
    // Stop the link click from doing its normal thing
    event.preventDefault();
  });
  // END things to do while the form is in use
});
