var RecaptchaOptions = {
    theme: 'clean'
};

$(document).ready(function() {

    function ValidateForm() {
        var errors = '';
        
        if ($("#name").val() == '') {
            errors += '\n* You need to enter your name.';
        }
        if ($("#email").val() == '') {
            errors += '\n* You need to enter your email address.';
        }
        
        if ($("#reason").val() == '') {
            errors += '\n* You need to enter a reason for contact.';
        }
        
        if ($("#message").val() == '') {
            errors += '\n* You need to enter a message.';
        }
        
        if ($("#recaptcha_response_field").val() == '') {
            errors += '\n* You need to enter the two words you see at the bottom of the form.';
        }
        
        if (errors != '') {
            return errors;
        } else {
            return false;
        }
        
    }
    
    $("#submitBtn").click(function() {
        /*
         var errors = ValidateForm();
         if (errors) {
         alert(errors);
         return false;
         }
         */
        var fields = $("#contactForm :input").serializeArray();
        $("#submitBtn").attr('disabled', true);
        $("#submitBtn").attr('value', ' Please wait ... ');
        
        $.getJSON("contact-me-process.php", fields, function(data) {
            if (data['error'] == false) {
                $("#submitBtn").attr('value', ' Thank you! ');
                alert(data['response']);
            } else {
                var message = 'The server could not send your message\n\n';
                alert(message + data['response']);
                $("#submitBtn").removeAttr('disabled');
                $("#submitBtn").attr('value', ' Try sending the email again ');
            }
        });
        
    });
});
