<div id="menubar">
  <script>
    var menubar = $( '#menubar' );
    
    var fRedirect = function( url ) {
      return function() {
        window.location.href = url;
      }
    };
    
    var fCreateLink = function( text, fAction ) {
      var link = $( '<div>' ).text( text );
      link.click( fAction );
      menubar.append(link);
    };

    fCreateLink( 'invoke event',
      fRedirect( 'forge?page=forge_event' )
    );
    fCreateLink( 'forge event poller',
      fRedirect( 'forge?page=forge_event_poller' )
    );
    fCreateLink( 'forge action invoker',
      fRedirect( 'forge?page=forge_action_invoker' )
    );
    fCreateLink( 'forge rule',
      fRedirect( 'forge?page=forge_rule' )
    );
    fCreateLink( 'admin', fRedirect( 'admin' ) );

    fCreateLink( 'logout',  function() {
      $.post( '/logout' ).done( fRedirect( document.URL ) );
    });
  </script>
</div>
