       when "register"         then @submitRegister()
       when "login"            then @submitLogin()
       when "complete"         then @submitComplete()
-      
+    
     e.preventDefault()
     false
+  
+  buildErrors: (errors) ->
+    t = "<ul style='text-align: left;'>"
+    $.each errors, (index,error) ->
+      t += "<li><strong>#{error.ref_node}</strong> #{error.message}</li>" if error.type == "field"
+    t += "</ul>"
   
   submitRestore: ->
     

        @hide(logout: false)
      error: (response) =>
        resp = $.parseJSON(response.responseText)
        @.$('.input-group').tooltip(
          placement: 'top'
          trigger: 'manual'
          animation: false
          title: resp.flash.title + " " + resp.flash.message
        ).tooltip('show')
          
        switch resp.status
          # when 401
          #   # do stuff
          when 403
            @logoutUser()
          # when 500
          #   # do stuff
              
  submitComplete: ->
    submitData = {}

        @hide(logout: false)
      error: (response) =>
        resp = $.parseJSON(response.responseText)
          
        switch resp.status
          when 422
            @.$('.input-group').tooltip(
              placement: 'top'
              trigger: 'manual'
              animation: false
              html: true
              title: @buildErrors(resp.errors)

            ).tooltip('show')
          when 403
            @logoutUser()
          else
            
            
          
  submitLogin: ->
    
