﻿/** <html><head></head><body></body></html> **/ 
function SendEmail(subject, from, form_type, area_id, success_message, error_message, optional_function_callback)
{
    var HTMLBody = '';
    HTMLBody += '<html><body>';
    $('#' + area_id + ' :input[type="text"]').each(function(){
        HTMLBody += '<strong>' + $(this).attr('name') + ':</strong>';
        HTMLBody += '<p>';
        HTMLBody += $(this).val();
        HTMLBody += '</p>';
    });
    $('#' + area_id + ' select').each(function(){
        HTMLBody += '<strong>' + $(this).attr('name') + ':</strong>';
        HTMLBody += '<p>';
        HTMLBody += $(this).find('option:selected').text();
        HTMLBody += '</p>';
    });
    $('#' + area_id + ' :input[type="checkbox"]').each(function(){
        HTMLBody += '<strong>' + $(this).attr('name') + ':</strong>';
        HTMLBody += '<p>';
        HTMLBody += $(this).val();
        HTMLBody += '</p>';
    });
    $('#' + area_id + ' textarea').each(function(){
        HTMLBody += '<strong>' + $(this).attr('name') + ':</strong>';
        HTMLBody += '<p>';
        HTMLBody += $(this).val();
        HTMLBody += '</p>';
    });
    HTMLBody += '</body></html>';
        
    $.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 found success
            if(data.indexOf(success_message) != -1)
            {

                if (typeof optional_function_callback != "undefined")
                {
                    optional_function_callback();
                }
            }
    });
}
 

var FuncObjRedirect = function()
{
    window.location = "/home.html";
}
