function callAjax(strURL, postStr, id, last, returnFunc) {
    var xmlHttpReq = false;
    var self = this;
    var return_str = "";
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            return_str = returnFunc + '('+id+', \''+self.xmlHttpReq.responseText+'\', '+last+');';
            eval(return_str);
        }
    }
    self.xmlHttpReq.send(postStr);
}

function updaterank (id, value, last) {
    document.getElementById("rank_"+id).innerHTML = value;
    
    if (last>0) getrank(id+1, domains[id+1], last-1);
}

function getrank (id, domain, last) {
    var param = "domain="+domain;
    
    callAjax("../include/getalexa.php", param, id, last, "updaterank");
}