function sendData(params, to, oncomplete)
{
    if (typeof oncomplete == 'undefined')
    {
        oncomplete = function() {};
    }
    if (typeof window.ActiveXObject != 'undefined' ) {
        http = new ActiveXObject("Microsoft.XMLHTTP");
        http.onreadystatechange = oncomplete;
    }
    else {
        http = new XMLHttpRequest();
        http.onload = oncomplete;
    }
    http.open("POST", to, true)
    http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    http.setRequestHeader("Content-Length", params.length);
    http.setRequestHeader("Connection", "close");
    http.send(params);            
}

function sendMail(f)
{
    var mailObj =
    {
        from: f.elements.from.value,
        fromEmail: f.elements.fromEmail.value,
        comment: escape(f.elements.comment.value)
    };

    with (f.elements.submit)
    {
        style.background = "none";
        style.border = "none";
        innerHTML = "<img src='images/loading-ffffff.gif' alt='' />";
        onclick = function() {return false;};
    }

    sendData("", "/api/send-mail/" + JSON.stringify(mailObj) + "/",
             function ()
             {
                 SexyLightbox.display(
                     "#TB_inline?width=250&height=100&inlineId=mailSent"
                   + "&background=black"
                 );
             }
    );

    return false;
}
