$(function() {
  $('#submit').click(function(event) {
    event.preventDefault();

    var no_err = true;
    var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;

    var form = $("#contact_us");
    var input_name = $("#contact_us #name");
    var input_email = $("#contact_us #email");
    var input_body = $("#contact_us #body");

    if(input_name.val().length > 0){
      input_name.css({"border":"1px solid #c5c5c5"});
    }else{
      no_err = false;
      input_name.css({"border":"1px solid #f00"});
    }
    if(input_email.val().length > 0 && filter.test(input_email.val())){
      input_email.css({"border":"1px solid #c5c5c5"});
    }else{
      no_err = false;
      input_email.css({"border":"1px solid #f00"});
    }

    if(input_body.val().length > 0){
      input_body.css({"border":"1px solid #c5c5c5"});
    }else{
      no_err = false;
      input_body.css({"border":"1px solid #f00"});
    }
    if(no_err == true){
      form.submit();
    }
  });
});
