function update_email() {
    $('#email_from').val( $("#email").val() );
}

function update_data() {
    var Data = "First Name: " + $('#first_name').val()
               + "<br />Last Name: " + $('#last_name').val()
               + "<br />Email: " + $('#email').val()
               + "<br />Phone: " + $('#phone').val()
               + "<br />Description: " + $('#description').val();
    $('#email_message').val( Data );
}

$(document).ready(function() { 
    $('#emailer-form').ajaxForm({
        beforeSubmit: function(data, obj, opt) {
            // Start by disabling the send button.
            $('#send').attr("disabled", "disabled");
            $('#contact-status').css('display', 'block');
            //$('#contact-status').html('<img src="http://www.chicagopersonalinjurylawyer.com/dojeda/mt/mt-static/images/indicator.white.gif" width="16" height="16" style="margin: 0 auto;" />');
            var responseText='';
            
            // Do the validation.
            if ( !$('#first_name').val() ) {
                responseText += '<p>Please fill out the First Name field.</p>';
            }
            if ( !$('#last_name').val() ) {
                responseText += '<p>Please fill out the Last Name field.</p>';
            }
            if ( !$('#email').val() ) {
                responseText += '<p>Please enter a valid Email address.</p>';
            }
            if ( !$('#phone').val() ) {
                responseText += '<p>Please fill out the Phone field.</p>';
            }
//            if ( !$('#description').val() ) {
//                responseText += '<p>Please fill out the Description of Arrest field.</p>';
//            }
            
            // Enable the buttons on the form again.
            $('#send').removeAttr("disabled","");

            update_email();
            update_data();

            if (responseText) {
                $('#contact-status').html(responseText);
                return false;
            }
        },
        success: function(responseText, statusText) {
            if ( responseText.match(/Your email was successfully sent/) ) {
                // At this point, the form should have been successfully
                // sent to the recipient with the Emailer plugin.
                // So now, just send to Salesforce!
                $('#contact-form').submit();
            }
            else {
                // Still errors in the submission process--display them to the visitor.
                $('#contact-status').css('display', 'block');
                $('#contact-status').html(responseText);
            }
        }
    }); 
}); 
