//NoFollow
function remotedMethodInvocationNF(locationProxy, nameService, parameter, tag) {
       
    if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {            
        var request = locationProxy+"?service="+nameService+"&"+parameter;
        xmlHttp.open("GET",request,true);          
        xmlHttp.onreadystatechange = function() {
            handleServerResponseNF(tag);
        }
        xmlHttp.send(null);
    } else {
        setTimeout('remotedMethodInvocationNF(locationProxy,nameService,parameter,tag)',1000);
    }
}

function process(tag,ago,pagliaio) {
    var locationProxy = "http://www.simplesoft.it/proxy/ajaxProxy.php";
    var parameter = "ago_R="+ago+"&pagliaio_R="+pagliaio;
    parameter +='&response=php';
    remotedMethodInvocationNF(locationProxy, "form_is_follow", parameter,tag);
}

function handleServerResponseNF(tag) {
    if(xmlHttp.readyState == 4) {
        if (xmlHttp.status==200) {
            var textResponse = ""+xmlHttp.responseText.replace(/\s+$|^\s+/g, "");
            var array = unserialize(textResponse);
            if(array[2]=="nofollow") document.getElementById(tag).innerHTML = "nofollow";
            else if (array[2]=="follow") document.getElementById(tag).innerHTML = "normale";
            else if (array[2]=="notfound") document.getElementById(tag).innerHTML = "non trovato";
        } else {

    }
    } else {
        if (contains(cacheRequest,tag)) return;
        else cacheRequest.push(tag);
        document.getElementById(tag).innerHTML = "<img src=\"./img/ajax/loader.gif\" alt=\"..\">";
    }
}

//AnchorText
function remotedMethodInvocationAT(locationProxy, nameService, parameter, tag) {

    if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {
        var request = locationProxy+"?service="+nameService+"&"+parameter;
        xmlHttp.open("GET",request,true);
        xmlHttp.onreadystatechange = function() {
            handleServerResponseAT(tag);
        }
        xmlHttp.send(null);
    } else {
        setTimeout('remotedMethodInvocationAT(locationProxy,nameService,parameter,tag)',1000);
    }
}

function setAnchorText(tag,ago,pagliaio) {
    var locationProxy = "http://www.simplesoft.it/proxy/ajaxProxy.php";
    var parameter = "ago_R="+ago+"&pagliaio_R="+pagliaio;
    parameter +='&response=php';
    remotedMethodInvocationAT(locationProxy, "form_get_anchor_text", parameter,tag);
}

function handleServerResponseAT(tag) {
    if(xmlHttp.readyState == 4) {
        if (xmlHttp.status==200) {
            var textResponse = ""+xmlHttp.responseText.replace(/\s+$|^\s+/g, "");           
            var array = unserialize(textResponse);
            if (array[2]==false) document.getElementById(tag).innerHTML = "non trovato";
            else document.getElementById(tag).innerHTML = ""+array[2];
        } else {

    }
    } else {
        if (contains(cacheRequest,tag)) return;
        else cacheRequest.push(tag);
        document.getElementById(tag).innerHTML = "<img src=\"./img/ajax/loader.gif\" alt=\"..\">";
    }
}


