$(document).ready(function(){
  $(".tabs").tabs({
    show: function(e,ui) { window.location.hash = ui.tab.hash; }
  });

  $(".information .changelink").click( function() {
    $(".change .pane").hide();
    var pane = $(this).attr("href");
    $(".change " + pane ).show();
    return false;
  });

  $(".change form").ajaxForm({
    dataType: "json",
    beforeSubmit: function() {
      $(".errors").text("");
      $("form").children().attr("disabled", true);
      $(".spinner").show();
    },
    success: function(response) {
      $("form").children().attr("disabled", false);
      $(".spinner").hide();
      if( response['ok' ]) {
        window.location.reload();
      } else {
        $(".errors").text("oops! we couldn't make those changes because the " +
          response[0][0] + " " + response[0][1]
        );
      }
    }
  });
});

