// Contact Form Scripts

$(function() {

    $("#contactForm input,#contactForm textarea").jqBootstrapValidation({
        preventSubmit: true,
        submitError: function($form, event, errors) {
            // additional error messages or events
        },
        submitSuccess: function($form, event) {
            event.preventDefault(); // prevent default submit behaviour
            // get values from FORM
            var name = $("input#name").val();
            var email = $("input#email").val();
            var phone = $("input#phone").val();
            var message = $("textarea#message").val();
            var firstName = name; // For Success/Failure Message
            // Check for white space in name for Success/Fail message
            if (firstName.indexOf(' ') >= 0) {
                firstName = name.split(' ').slice(0, -1).join(' ');
            }
        },
        filter: function() {
            return $(this).is(":visible");
        },
    });

    $("a[data-toggle=\"tab\"]").click(function(e) {
        e.preventDefault();
        $(this).tab("show");
    });
});


/*When clicking on Full hide fail/success boxes */
$('#name').focus(function() {
    $('#success').html('');
});

@@ -870,16 +870,1710 @@
       %7D%0A
+            $.ajax(%7B%0A                url: %22././mail/contact_me.php%22,%0A                type: %22POST%22,%0A                data: %7B%0A                    name: name,%0A                    phone: phone,%0A                    email: email,%0A                    message: message%0A                %7D,%0A                cache: false,%0A                success: function() %7B%0A                    // Success message%0A                    $('#success').html(%22%3Cdiv class='alert alert-success'%3E%22);%0A                    $('#success %3E .alert-success').html(%22%3Cbutton type='button' class='close' data-dismiss='alert' aria-hidden='true'%3E&times;%22)%0A                        .append(%22%3C/button%3E%22);%0A                    $('#success %3E .alert-success')%0A                        .append(%22%3Cstrong%3EYour message has been sent. %3C/strong%3E%22);%0A                    $('#success %3E .alert-success')%0A                        .append('%3C/div%3E');%0A%0A                    //clear all fields%0A                    $('#contactForm').trigger(%22reset%22);%0A                %7D,%0A                error: function() %7B%0A                    // Fail message%0A                    $('#success').html(%22%3Cdiv class='alert alert-danger'%3E%22);%0A                    $('#success %3E .alert-danger').html(%22%3Cbutton type='button' class='close' data-dismiss='alert' aria-hidden='true'%3E&times;%22)%0A                        .append(%22%3C/button%3E%22);%0A                    $('#success %3E .alert-danger').append(%22%3Cstrong%3ESorry %22 + firstName + %22, it seems that my mail server is not responding. Please try again later!%22);%0A                    $('#success %3E .alert-danger').append('%3C/div%3E');%0A                    //clear all fields%0A                    $('#contactForm').trigger(%22reset%22);%0A                %7D,%0A            %7D);%0A
         

Revert "Remove ajax from contact"