﻿$(function() {
    // These first three lines of code compensate for Javascript being turned on and off. 
    // It simply changes the submit input field from a type of "submit" to a type of "button".

    var paraTag = $('input#submit').parent('p');
    $(paraTag).children('input').remove();
    $(paraTag).append('<input type="button" name="submit" id="submit" value="Submit" />');

    $('#main input#submit').click(function() {
       
		$("#response").css("display", "none");
		$("#loading").css("display", "block"); 

        var name = $('input#name').val();
        var email = $('input#email').val();
		var comments = $('textarea#comments').val();
		
        $.ajax({
            type: 'post',
            url: 'contact_form/sendEmail.php',
            data: 'name=' + name + '&email=' + email + '&comments=' + comments,

            success: function(results) {
                $("#loading").css("display", "none"); 
				$("#response").css("display", "");
                $('ul#response').html(results);
				
            }
        }); // end ajax
    });
});
		