﻿function SendFormattedEmail(subject, from, form_type, area_id, success_message, error_message, optional_function_callback)
{
    var HTMLBody = '';
    HTMLBody += '<html><head><!-- PageID 1310 - published by Open Text Web Solutions 10.1 - 10.1.2.287 - 31735 --><title></title></head><body><table width="100%"><tbody>';

    HTMLBody += '<tr><td><strong>Company: </strong>' + $("#name1").val();
    HTMLBody += '</td>';

    HTMLBody += '<td><strong>ZIP Code: </strong>' + $("#Text2").val();
    HTMLBody += '</td></tr>';

    HTMLBody += '<tr><td><strong>First Name: </strong>' + $("#name").val();
    HTMLBody += '</td>';

    HTMLBody += '<td><strong>Address: </strong>' + $("#email0").val();
    HTMLBody += '</td></tr>';

    HTMLBody += '<tr><td><strong>Last Name: </strong>' + $("#name0").val();
    HTMLBody += '</td>';

    HTMLBody += '<td><strong>Address 2: </strong>' + $("#email1").val();
    HTMLBody += '</td></tr>';

    HTMLBody += '<tr><td><strong>Phone Number: </strong>' + $("#Text4").val();
    HTMLBody += '</td>';

    HTMLBody += '<td><strong>City: </strong>' + $("#email2").val();
    HTMLBody += '</td></tr>';

    HTMLBody += '<tr><td><strong>Email: </strong>' + $("#Text3").val();
    HTMLBody += '</td>';

    HTMLBody += '<td><strong>State: </strong>' + $("#subject0").val();
    HTMLBody += '</td></tr>';

    HTMLBody += '<tr><td><strong>Contact Preference: </strong>' + $("#subject3").val();
    HTMLBody += '</td>';

    HTMLBody += '<td><strong>Primary Provider: </strong>' + $("#email3").val();
    HTMLBody += '</td></tr>';

    HTMLBody += '<tr><td><strong>Company Type: </strong>' + $("#subject1").val();
    HTMLBody += '</td>';

    HTMLBody += '<td><strong>Number of Seats: </strong>' + $("#email4").val();
    HTMLBody += '</td></tr>';

    HTMLBody += '<tr><td><strong>Contact Title: </strong>' + $("#subject2").val();
    HTMLBody += '</td>';

    HTMLBody += '<td><strong>Number of Employees: </strong>' + $("#email5").val();
    HTMLBody += '</td></tr>';

    HTMLBody += '<tr><td><strong>Projected Open Date: </strong>' + $("#subject7").val();
    HTMLBody += '</td>';

    HTMLBody += '<td><strong>Weekly Purchases: </strong>' + $("#subject4").val();
    HTMLBody += '</td></tr>';

    HTMLBody += '<tr><td>';
    HTMLBody += '</td>';

    HTMLBody += '<td><strong>Annual Sales: </strong>' + $("#subject5").val();
    HTMLBody += '</td></tr>';

    HTMLBody += '</tr></tbody></table></p>';
    HTMLBody += '<p><strong>Comments: </strong>' + $("#Textarea1").val();

    HTMLBody += '</body></html>';

    var subject = '';
    subject += 'Become a Customer, ZIP Code: ' + $("#Text2").val();


    $.post("/asp/email.asp",
            {
            subject: subject,
            from: from,
            form_type: form_type,
            body: HTMLBody,
            success_message: success_message,
            error_message: error_message
        },
        function(data){
            alert(data);
            if (typeof optional_function_callback != "undefined")
            {
            optional_function_callback();
            }
        });
}
