// $Id: register.js

Drupal.register = {
  'node': function(data) {
    var node = $(this).parents('.node');
  }
};

if (Drupal.jsEnabled) {
  $(function() {
    $('a.register').click(function() {
      // Add the throbber
      var link = $(this).addClass('throbbing');

      // Perform a request to the server
      jQuery.post(this.href, { confirm: true, javascript: true }, function(data) {
        data = Drupal.parseJson(data);
        if (data) {
          // Remove the throbber
          alert(data.callback);
          link.html(data.text).removeClass('throbbing');

          // Call the callback function for altering the display of other elements
          if (data.callback && Drupal.register[data.callback]) {
            Drupal.register[data.callback].call(link[0], data);
          }
        }
      });

      // Do not execute the regular functionality when the user clicks the link
      return false;
    });
  });
}
