// Submit e-list form via ajax
$("#eList").submit(function() {
    var self = $(this);
    // Grab form action
    var formAction = $(self).attr("action");
    // Serialize form values to be submitted with POST
    var str = $(self).serialize();
    var serialized = str + "&action=" + formAction;
    $.ajax({
        url: "php/proxy.php",
        type: "POST",
        data: serialized,
        success: function(data) {
            // Server-side validation
            if (data.search(/invalid/i) != -1) {
                alert('Please enter a valid email address.');
            }
            else
            {
                // If successfully submitted hide the form
                $(self).hide();
                // Show confirmation, then show form, reset form.
                $("#confirmation").fadeIn("slow").delay(1500).fadeOut(function() {
                    $(self).fadeIn().each(function() {
                        this.reset();
                    });
                });
            }
        }
    });
    return false;
});

