
$(function() {
  $('#login_form').submit(function() {
    $.ajax({
      url: $(this).attr('action'),
      type: 'POST',
      dataType: 'json',
      data: $(this).serialize(),
      success: function(data, textStatus) {
        if (data.status) {
          location.reload();
        } else {
          $('#login_form_wrap').html(data.html);
        }
      },
      beforeSend: function() {
        $('#login_form .auth-button').hide();
        $('#login_form .auth-image').show();
      },
      complete: function() {
        $('#login_form .auth-image').hide();
        $('#login_form .auth-button').show();
      }
    });
    
    return false;
  });
});

