   
   toggleRestore: ->
     @state = 'restore'
-    @clearLastState()
+    @refreshGfx()
     @.$('form').addClass('auth-form-restore')
-    @refreshGfx()
     false
 
   toggleRegister: ->
     @state = 'register'
-    @clearLastState()
+    @refreshGfx()
     @.$('form').addClass('auth-form-register')
-    @refreshGfx()
     false
 
   toggleLogin: ->
     @state = 'login'
-    @clearLastState()
+    @refreshGfx()
     @.$('form').addClass('auth-form-login')
-    @refreshGfx()
     false
   
   clearLastState: ->

  
  triggerAction: (e) ->
    action = @.$(e.target).data('auth-dialog-state')
    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: (args) ->
    args = {} unless args
    @state = args.state || "login"
    
    @render()
    @toggleStateFromAction(@state)
    @bindEvents()
    
    
  render: ->
    $(@el).html(@template())
    this
  
  bindEvents: ->
    @.$('.modal').modal()
  
  refreshGfx: ->
    @clearLastState()
    if @state == '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 @state == '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')
