// Bind document onload function
jQuery(document).ready(function () {
  // Add JS-CSS-Style class to all H5 elements.
  var int_listHeight = 0;
  jQuery(".ipd_breed_datasheet_narrow_2009_sectionText").addClass("ipd_breed_datasheet_narrow_2009_sectionTextClosed");
  jQuery(".ipd_breed_datasheet_narrow_2009_sectionText:first").each(function () {
    jQuery(this).removeClass("ipd_breed_datasheet_narrow_2009_sectionTextClosed");
    jQuery(this).parent().find("h5").addClass("ipd_breed_datasheet_narrow_2009_breedSectionsJsTitleOpend");

    int_listHeight = jQuery(this).height() + jQuery(this).parent().find("h5").height() + 30;
  });

  // Compute the new height of the list element
  jQuery("#ipd_breed_datasheet_narrow_2009_breedSections ul").height(int_listHeight + "px");

  // Add JS-CSS-Style class to all H5 elements.
  jQuery("#ipd_breed_datasheet_narrow_2009_breedSections h5").addClass("ipd_breed_datasheet_narrow_2009_breedSectionsJsTitle");

  // Add JS-CSS-Style class to all LI elements.
  jQuery("#ipd_breed_datasheet_narrow_2009_breedSections li").addClass("ipd_breed_datasheet_narrow_2009_breedSectionsJsListElement");

  // Bind onclick function to all "stripes"
  jQuery("#ipd_breed_datasheet_narrow_2009_breedSections h5").click(function () {
    // Remove "JsTitleOpend" class from all h5 elements
    jQuery("#ipd_breed_datasheet_narrow_2009_breedSections h5").removeClass("ipd_breed_datasheet_narrow_2009_breedSectionsJsTitleOpend");

    // Add "JsTitleOpend" class to the current element
    jQuery(this).addClass("ipd_breed_datasheet_narrow_2009_breedSectionsJsTitleOpend");

    // Close current tab
    jQuery(".ipd_breed_datasheet_narrow_2009_sectionText:not(.ipd_breed_datasheet_narrow_2009_sectionTextClosed)").addClass("ipd_breed_datasheet_narrow_2009_sectionTextClosed");

    // Open new tab
    jQuery(this).parent().find(".ipd_breed_datasheet_narrow_2009_sectionText").each(function() {
      jQuery(this).removeClass("ipd_breed_datasheet_narrow_2009_sectionTextClosed");

      // Compute the new height of the list element
      int_listHeight = jQuery(this).height() + jQuery(this).parent().find("h5").height() + 30;
      jQuery("#ipd_breed_datasheet_narrow_2009_breedSections ul").height(int_listHeight + "px");
    });
  });
});

