/**
 * Runs the given callback function when the window and
 * Google's JS API loads.  Also loads jquery.
 */
function runOnLoad(aCallback) {
  $(document).ready(aCallback);
}

/**
 * Sets up sections that can be toggled.
 * The IDs parameter should have element IDs.
 * The element with the ID, when clicked, will toggle the hidden/displayed
 * state of any div elements in the class of that ID.
 * Also, when the element with that ID is hovered it will get added to the
 * 'hover' class.
 */
function setupToggles(aIDs) {
  for (var i = 0; i < aIDs.length; i++) {
    // on hover add the class "hover" to the clickable element
    $('#' + aIDs[i]).hover(
      function() {
        $(this).addClass("hover");
      },
      function() {
        $(this).removeClass("hover");
      }
    );
    // when the element is clicked, slowly toggle the display state of any divs
    // with the class of that ID
    $('#' + aIDs[i]).click(function() {
      $("div." + this.id).slideToggle('slow');
    });
  }
}

function updateTable(aID) {
  var table = document.getElementById(aID);
  for (var i = 0; i < table.rows.length; i++) {
    for (var j = 0; j < table.rows[i].cells.length; j++) {
      $(table.rows[i].cells[j]).addClass("content");
    }
  }
}

function uncollapseURLID() {
  if (window.location.hash) {
    var elem = $('div.' + (window.location.hash).substring(1));
    if (elem) {
      $(elem).slideToggle('slow');
    }
  }
}

