$( function( ) {
  $( '#tabs li a' ).click( function( evt ) {
    evt.preventDefault();
  } );

  $( '#tabs li a' ).mousedown( function( evt ) {
    if ( evt.which == 1 ) { // just trigger if LMB is pressed
      tuDispatcher.trigger( "tabSelected", $( this ).closest( 'li' ).attr( 'id' ) );
    }
    evt.preventDefault();
  } );

  $( '#tabs li a' ).keydown( function( event ) {
    if ( ( event.which == 13 ) || ( event.which == 32 ) ) {
      $( this ).mousedown( );
      return false;
    }
  } );

  // Select and init the tab that is marked as "selected" in the html code
  tuDispatcher.trigger( "tabSelected", $( '#tabs li.selected' ).attr( 'id' ) );
} );
