var Wick = Wick || {};
Wick.SignUp = (function () {
  var $signUpForm = $('#sign-up-form'),
    $signUpWrap = $('#sign-up-wrapper');

  function validateEmail (argElementValue) {
    var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
    return emailPattern.test(argElementValue);
  }

  function showValidMessage () {
    if ($signUpWrap.hasClass('sign-up_invalid')) {
      $signUpWrap.removeClass('sign-up_invalid');
    }
    $signUpWrap.addClass('sign-up_valid')
  }

  $signUpForm.on('submit', function (e) {
    e.preventDefault();

    var inputValue = $('#sign-up-email').val();

    validateEmail(inputValue)
      ? showValidMessage()
      : $signUpWrap.addClass('sign-up_invalid');

    return false;
  });
})();


