$(document).ready(function(){
  var started = false;
  $('#new_invitation input').focus(function() {
    if (!started) {
      Metrics.betaInvitationStarted();
      started = true;
    }
  });
  
  // If they load the invitation page with an error (ex. duplicate email or whatnot)
  if ($('#new_invitation #errorExplanation').length > 0) {
    Metrics.betaInvitationError();
  }

  if ($('#new_invitation').length > 0) {
    Metrics.betaInvitationLoaded();
  }
  
  // success message that the invitation is done
  if ($('#new_invitation_thank_you_text').length > 0) {
    Metrics.betaInvitationCompleted();
  }
  
  // login page loaded
  if ($('#new_user_session').length > 0) {
    Metrics.loginLoaded();
  }
  
  // forgot password loaded
  if ($('#forgot_password_form').length > 0) {
    Metrics.forgotPasswordLoaded();
  }
  
  // forgot password sent
  if ($('#forgot_password_sent').length > 0) {
    Metrics.forgotPasswordSuccess();
  }
  
  // Login with email success
  if ($('#login_email_success').length > 0) {
    Metrics.loginEmailSuccess();
  }

  // Login with openid success
  if ($('#login_openid_success').length > 0) {
    Metrics.loginOpenIdSuccess();
  }
});