   
   triggerAction: (e) ->
     action = @.$(e.target).data('auth-dialog-state')
+    @toggleStateFromAction(action)
+    
+  toggleStateFromAction: (action) ->
     switch action
       when "restore" then @toggleRestore()
       when "register" then @toggleRegister()

    'click a.auth-dialog-help-one' : 'triggerAction'
    'click a.auth-dialog-help-two' : 'triggerAction'

  initialize: ->
    @render()
    @refreshGfx()
    @bindEvents()
    
  render: ->
    $(@el).html(@template())
    @.$('form').addClass('auth-form-login')
    this
  
  bindEvents: ->
    @.$('.modal').modal()
  
  refreshGfx: ->
    if @.$("form").hasClass('auth-form-restore')
      @.$("button.auth-submit").text("Restore")
      @.$("a.auth-dialog-help-one").text("Register an account").data('auth-dialog-state','register')
      @.$("a.auth-dialog-help-two").text("Use an existing account").data('auth-dialog-state','login')
      
    else if @.$("form").hasClass('auth-form-register')
      @.$("button.auth-submit").text("Continue")
      @.$("a.auth-dialog-help-one").text("Forgot password?").data('auth-dialog-state','restore')
      @.$("a.auth-dialog-help-two").text("Use an existing account").data('auth-dialog-state','login')

  
  toggleRestore: ->
    @state = 'restore'
    @refreshGfx()
    @.$('form').addClass('auth-form-restore')
    false

  toggleRegister: ->
    @state = 'register'
    @refreshGfx()
    @.$('form').addClass('auth-form-register')
    false

  toggleLogin: ->
    @state = 'login'
    @refreshGfx()
    @.$('form').addClass('auth-form-login')
    false
  
  clearLastState: ->
