 usernameFormMessages = new FormMessages()
 usernameReadyForValidation = false
 usernameFieldModified = false
+usernameSubmitted = false
 
 passwordFormMessages = new FormMessages()
 newPasswordReadyForValidation = false

    return # Make sure CoffeeScript does not return anything

  'blur input#username': (event, template) ->
    usernameReadyForValidation = usernameFieldModified
    username = $('#username').val()
    validateUsername username, 'username'

    return # Make sure CoffeeScript does not return anything


# Username settings
Template.settingsUsername.events =
  'submit form#set-username': (event, template) ->
    usernameSubmitted = true
    event.preventDefault()
    usernameFormMessages.resetMessages()
    username = $('#username').val()
