    $(document).ready(function(){
        $('.send').click(function(e){

            //stop the form from being submitted
            e.preventDefault();
            var error = false;
            var name = $('.name').val();
            var mail = $('.mail').val();
            var msg = $('.msg').val();
            if(name.length == 0 || name.indexOf('?') == '16'){
                var error = true;
                $('.name_error').fadeIn(500);
            }else{
                $('.name_error').fadeOut(500);
            }
            if(mail.length == 0 || mail.indexOf('@') == '-1'){
                var error = true;
                $('.mail_error').fadeIn(500);
            }else{
                $('.mail_error').fadeOut(500);
            }
            if(msg.length == 0){
                var error = true;
                $('.msg_error').fadeIn(500);
            }else{
                $('.msg_error').fadeOut(500);
            }

            //now when the validation is done we check if the error variable is false (no errors)
            if(error == false){
                $('.send').attr({'disabled' : 'true', 'value' : '...' });
                $.post("assets/send_email.php", $(".contact_form").serialize(),function(result){
                    //and after the ajax request ends we check the text returned
                    if(result == 'sent'){
                        //if the mail is sent remove the submit paragraph
                         $('.cf_submit_p').remove();
                        //and show the mail success div with fadeIn
                        $('.mail_success').fadeIn(500);
                    }else{
                        //show the mail failed div
                        $('.mail_fail').fadeIn(500);
                        //reenable the submit button by removing attribute disabled and change the text back to Send
                        $('.send').removeAttr('disabled').attr('value', 'Send');
                    }
                });
            }
        });
    });
