mailist_url = "/mailing-list/"
mailist_cue = "#mailist_cue"
mailist_msg = "#mailist_msg"

ok_png = "<img src='/media/misc/ok.png'>" 
warn_png = "<img src='/media/misc/warn.png'>"

function ml_send( action )
{
    var email = jQuery("#ml_email").val()
    var req = new Request()
    req.url = mailist_url + "async_post/"
    req.params['email'] = escape(email).replace('+','%2B')
    req.params['action'] = action
    req.onDone = function()
    {   
        if( req.response == "ok" ) $(mailist_cue).html(ok_png)
        else  $(mailist_cue).html(warn_png)
        $(mailist_msg).html(req.response)  
        
    }
    req.onFail = function()
    {       
        $("#errors").html(req.response)
        $(mailist_cue).html(warn_png)
        $(mailist_msg).html('لم نتمكن من إرسال الطلب')
    }      
    $(mailist_msg).html('جاري الاتصال')
    $(mailist_cue).html(none_gif) //pre-load .. 
    $(mailist_cue).html(wait_gif)
    req.sendPost()
}

