﻿
function SendEmail(fromId, toId, subjectId, bodyId)
{
    var fromObj = document.getElementById(fromId);    
    var toObj = document.getElementById(toId);
    var subjectObj = document.getElementById(subjectId);
    var bodyObj = document.getElementById(bodyId);
        
    if (fromObj == null || toObj == null || subjectObj == null || bodyObj == null) return;
    
    var url = "/Ajax.aspx?type=proxy&method=sendEmail&from=" + fromObj.value + 
        "&to=" + toObj.value + "&subject=" + subjectObj.value;
    
    var re = /\r\n/g;   
    var s = bodyObj.innerHTML.replace(re, "<BR/>");
    
    var req = new Request();
    req.Post(url, SendEmail_OnSuccess, SendEmail_OnFail, "emailbody=" + encodeURIComponent(s));
}


function SendEmail_OnSuccess(data)
{
    alert(data);
    
    if (sendEmailToAdvertiser != null)
    {
        hidebox("sendEmailToAdvertiser");
    }
    if (sendEmailToFriend != null)
    {
        hidebox("sendEmailToFriend");
    }    
}

function SendEmail_OnFail(data)
{
    alert(data);
}