var XMLHTTP;
preloadText = "<img src='loading.gif'> Attendere caricamento pagina in corso...";
function RichiestaAJAX_autore(stringa)
{
		if (stringa.length > 0)
    {
        var url = "menu/aggiungipreferito.asp?id_user=" + stringa.toUpperCase();
        XMLHTTP = QualeBrowser(GestioneStato_autore);
        XMLHTTP.open("GET", url, true);
        XMLHTTP.send(null);

}
    else
    {
        document.getElementById("preferiti_testo").innerHTML = "";
    } 
}

function RichiestaAJAX_autore_network(stringa,idnum)
{	numero=idnum

    if (stringa.length > 0)
    {
		var url = "menu/aggiungipreferitiN.asp?id_user=" + stringa.toUpperCase();
        XMLHTTP = QualeBrowser(GestioneStato_autore_network);
        XMLHTTP.open("GET", url, true);
        XMLHTTP.send(null);
    }
    else
    {
        document.getElementById('preferiti_testo'+idnum).innerHTML = "";
    } 

}
 
function RichiestaAJAX_valutaMail(stringa)
{
    if (stringa.length > 0)
    {
        var url = "menu/richiesteAjax.asp?cosa=valutamail&id_statoctamail=" + stringa.toUpperCase();
        XMLHTTP = QualeBrowser(GestioneStato_ValutaMail);
        XMLHTTP.open("GET", url, true);
        XMLHTTP.send(null);
    }
    else
    {
        document.getElementById("id_statoctamail").innerHTML = "";
    } 
}

function RichiestaAJAX(stringa)
{
    if (stringa.length > 0)
    {
        var url = "menu/cercanelglossario.asp?nome=" + stringa.toUpperCase();
        XMLHTTP = QualeBrowser(GestioneStato);
        XMLHTTP.open("GET", url, true);
        XMLHTTP.send(null);
    }
    else
    {
        document.getElementById("terminiglossario").innerHTML = "";
    } 
}


function RichiestaAJAX2(stringa)
{
    if (stringa.length > 0)
    {
        var url = "menu/bookmark.asp?nome=" + stringa.toUpperCase();
        XMLHTTP = QualeBrowser(GestioneStato);
        XMLHTTP.open("GET", url, true);
        XMLHTTP.send(null);
    }
    else
    {
        document.getElementById("terminiglossario").innerHTML = "";
    } 
}

function GestioneStato()
{
    if (XMLHTTP.readyState == 4)
    {
        var R = document.getElementById("terminiglossario");
        R.innerHTML = XMLHTTP.responseText;
    }
	else
	document.getElementById("terminiglossario").innerHTML = preloadText;
}

function GestioneStato_autore()
{
    if (XMLHTTP.readyState == 4)
    {
        var R = document.getElementById("preferiti_testo");
        R.innerHTML = XMLHTTP.responseText;
    }
	else
	document.getElementById("preferiti_testo").innerHTML = preloadText;
}

function GestioneStato_autore_network()
{	
    if (XMLHTTP.readyState == 4)
    {
        var R = document.getElementById('preferiti_testo'+numero);
        R.innerHTML = XMLHTTP.responseText;
    }
	else
	document.getElementById('preferiti_testo'+numero).innerHTML = preloadText;
}

function GestioneStato_ValutaMail()
{
    if (XMLHTTP.readyState == 4)
    {
        var R = document.getElementById("ValutaMail");
        R.innerHTML = XMLHTTP.responseText;
    }
	else
	document.getElementById("ValutaMail").innerHTML = preloadText;
}


function QualeBrowser(QualeBrowser)
{
    if (navigator.userAgent.indexOf("MSIE") != (-1))
    {
        var Classe = "Msxml2.XMLHTTP";
        if (navigator.appVersion.indexOf("MSIE 5.5") != (-1));
        {
            Classe = "Microsoft.XMLHTTP";
        } 
        try
        {
            OggettoXMLHTTP = new ActiveXObject(Classe);
            OggettoXMLHTTP.onreadystatechange = QualeBrowser;
            return OggettoXMLHTTP;
        }
        catch(e)
        {
            alert("Errore: l'ActiveX non verrą eseguito!");
        }
    }
    else if (navigator.userAgent.indexOf("Mozilla") != (-1))
    {
        OggettoXMLHTTP = new XMLHttpRequest();
        OggettoXMLHTTP.onload = QualeBrowser;
        OggettoXMLHTTP.onerror = QualeBrowser;
        return OggettoXMLHTTP;
    }
    else
    {
        alert("L'esempio non funziona con altri browser!");
    }
}
