
function Richiesta(codice)
{

    if (codice.length > 0)
    {
	
		var url = "/include/ajax.asp?codice=" + codice;
        XMLHTTP = RicavaBrowser(CambioStato);
        XMLHTTP.open("GET", url, true);
        XMLHTTP.send(null);
		
    }

}
function Richiesta2(codice)
{

    if (codice.length > 0)
    {
	
		var url = "/include/ajax2.asp?codice=" + codice;
		
        XMLHTTP = RicavaBrowser(CambioStato);
		
        XMLHTTP.open("GET", url, true);
        XMLHTTP.send(null);
	
    }

}
function CambioStato()
{
    if (XMLHTTP.readyState == 4)
    {
		
        if (XMLHTTP.responseText =="OK")
		{

			document.getElementById("area_riservata").style.display = "none";
			document.getElementById("sidebar_newsletter").style.display = "none";	
			document.getElementById("errore_email").style.display = "none";
			
			document.getElementById("login_ok").style.display = "block";
		}
		else
		{

	 		location.href = "/it/registrazione.asp"

			document.getElementById("area_riservata").style.display = "block";
			document.getElementById("sidebar_newsletter").style.display = "block";
			document.getElementById("errore_email").style.display = "block";
			document.getElementById("login_ok").style.display = "none";
		}
			
    }
}

function RicavaBrowser(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!");
    }
}
