

/*

bool view_track_list() -- Handler of click events on View Track Listing buttons.

object event

*/

function view_track_list( event ) {

  // Normalize the event object for cross-browser purposes
  event = ( event ? event : window.event );

  // Start from the node that was clicked
  var album_node = this;

  // Traverse up the DOM until the descendant album element is reached
  while ( ! album_node.className.match( /OMNI_album/ ) ) {

    album_node = album_node.parentNode;

  }
  // end while

  // Get a nodelist of all OL elements that are descendants of the current album node
  var lists = album_node.getElementsByTagName( 'ol' );

  var current_list;

  var track_list_class_name = 'OMNI_track_list';

  for ( var offset = 0 ; offset < lists.length ; ++offset ) {

    current_list = lists[ offset ];

    // The current list node is not a track list
    if ( ! current_list.className.match( track_list_class_name ) ) {

      continue;

    }
    // if


    // The track list is currently displayed
    if ( current_list.className.match( /inactive/ ) ) {

      current_list.className = track_list_class_name + " " + "OMNI_active";

    }
    // end if

    // The track list is currently not displayed
    else {

      current_list.className = track_list_class_name + " " + "OMNI_inactive";

    }
    // end else if

  }
  // end for


  // Prevent the link location from being followed
  if ( event && event.cancelable && event.preventDefault ) {

    event.preventDefault();

  }
  // end if


  return false;

}
// end view_track list


/*

void OMNI_loading_complete() -- Onload handler

*/

function loading_complete() {

  var view_track_list_buttons = document.getElementById( 'OMNI_discography' ).getElementsByTagName( 'div' );

  var current_button;

  for ( var offset = 0 ; offset < view_track_list_buttons.length ; ++offset ) {

    current_button = view_track_list_buttons[ offset ];

    if ( ! current_button.className.match( /view_track_list/ ) ) {

      continue;

    }
    // end if

    current_button = current_button.getElementsByTagName( 'a' )[0];

    OMNI_add_event_listener( current_button, "click", "view_track_list", false );

  }
  // end for

  return;

}
// end loading_complete

