function sendVariables(nazev,hodnota)
{
    this.name = nazev;
    this.value = hodnota;
}

function VytvorDotaz(sendVar)
{
    if(sendVar.length < 1)
        return "";
    
    var dotaz = new Array();
    for(var i = 0; i < sendVar.length; i++)
    {
        if(sendVar[i].name && sendVar[i].value)
            dotaz.push(sendVar[i].name + "=" + encodeURIComponent(sendVar[i].value));
    }
    var dotstr = dotaz.join("&");

    return dotstr;
}

function SendAjax(url, sendVar, type, fce)
{
    //sendVar == sendVariables()

    if(window.ActiveXObject)
        httpReq = new ActiveXObject("Microsoft.XMLHTTP");
    else
        httpReq = new XMLHttpRequest();

    httpReq.onreadystatechange = function ()
    {
        if(httpReq.readyState == 4)
        {
            if(httpReq.status == 200)
            {
                fce(httpReq.responseText);
                //return httpReq.responseText;
            }
            else
            {
                alert("Chyba dynamickeho nacitani " + httpReq.status + ": " + httpReq.statusText);
                //return "";
                //fce("");
            }
        }
        return "";
    };

    if(type=="GET")
    {
        httpReq.open(type, url + "?" + VytvorDotaz(sendVar), true);
        httpReq.send(null);
    }
    else
    {
        httpReq.open(type, url, true);
        httpReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
        httpReq.send(VytvorDotaz(sendVar));
    }
}
