(function() {

  Template.userSignIn.events({
    "focus input": function(e, t) {
      return $(e.currentTarget).parent().addClass("focused");
    },
    "blur input": function(e, t) {
      return $(e.currentTarget).parent().removeClass("focused");
    }
  });

  AutoForm.hooks({
    signInForm: {
      onSubmit: function(doc) {
        var that;
        this.event.stopPropagation();
        that = this;
        Meteor.loginWithPassword(doc.email, doc.password, function(error) {
          if (error) {
            Session.set("error", "Wrong email and/or password");
          } else {
            Session.set("success", "Signed in successfully");
            Router.go(this.AccountsHelper.afterSignInPath());
          }
          return that.done();
        });
        return false;
      }
    }
  });

}).call(this);
