(function($) {
  // Setup AJAX activity notification.
  $(document).ajaxStart($.fancybox.showActivity);
  $(document).ajaxStop($.fancybox.hideActivity);
    
  // Enable ajax multipart forms.
  $("form.remote-multipart").ajaxUpload();
  
  // Enable fancybox.
  $(document).ready(function() {
    $("a.fancybox").live("click", function() {
      $.fancybox.showActivity();
      $.get(this.href, $.fancybox);
      return false;
    });

    $(".fancybox-close").live("click", function() {
      $.fancybox.close();
      return false;
    });

    // Setup help bubbles.
    $('img.helpButton').live('click', function() {
      Help.toggleHelp(this);
      return false;
    });

    // Setup showing/hiding boxes
    $("a[data-show-for]").click(function() {
      $("#" + $(this).attr("data-show-for")).fadeIn();
      return false;
    })
    
    $("a[data-hide-for]").click(function() {
      $("#" + $(this).attr("data-hide-for")).fadeOut();
      return false;
    })
  });
})(jQuery);

