// Marca as estrelas em novas avaliações
$('.ftr-rating-change .ftr-rating-change__input').on('change', function(){
  $('.ftr-rating-change .ftr-rating-change__label').removeClass().addClass('material-icons ftr-rating-change__label ftr-active-star' + $(this).val());
});

$('#form-store-rating').validate({
  onkeyup: function(element) {
    if ($(element).valid()) {
      $(element).closest('div[class|=ftr], label[class|=ftr]').removeClass('error');
      $(element).siblings('.ftr-field__error').remove();
    }
  },
  onsubmit: true,
  showErrors: function(errorMap, errorList) {
    $.each(errorList, function() {
      $($(this)[0].element).closest('div[class^=ftr], label[class^=ftr], div[class*=ftr], label[class*=ftr]').addClass('error').find('.ftr-field__error').remove();
      $($(this)[0].element).closest('div[class^=ftr], label[class^=ftr], div[class*=ftr], label[class*=ftr]').append($('<span>').addClass('ftr-field__error').text($(this)[0].message));
    });
  }
});
