/* Handle the showing and hidding of showtimes lists */

if (Drupal.jsEnabled) {
  $(document).ready(function(){

	// Hides all showtimes list on the page
    $(".showtimes_list").hide();
    // Iterate through all elements having the toggle_button class
    $(".toggle_button").click(function() {
	  // Gets show ID
	  var className = $(this).attr('className');
	  // Strips non-numeric characters
	  var show_id = className.replace(/[^0-9]+/, '');
	  // Concatenates strings, gets ID of showtimes hidden table
	  var showtimes_element_id = '#showtimes_list_' + show_id;
      if ( $(showtimes_element_id).is('.hidden') ) {
        $(showtimes_element_id).slideDown("slow").removeClass("hidden").addClass("shown");
        $(this).text('hide all dates');

      } else

      if ( $(showtimes_element_id).is('.shown') ) {
        $(showtimes_element_id).slideUp("slow").removeClass("shown").addClass("hidden");
				$(this).text('show all dates');
      }
      return false;
  	});
  	 
  });
}
