var XMLHTTP;
var qualegruppo;

function Richiesta(qualediv)
{
	Stringa = 'Nome=' + document.getElementById('Nome').value + '&Cognome=' + document.getElementById('Cognome').value +'&Azienda='+document.getElementById('Azienda').value+'&Citta='+document.getElementById('Citta').value+'&Provincia='+document.getElementById('Provincia').value+'&Cap='+document.getElementById('Cap').value+'&Telefono='+document.getElementById('Telefono').value+'&Fax='+document.getElementById('Fax').value+'&Email='+document.getElementById('Email').value+'&Richiesta='+document.getElementById('Richiesta').value;
	qualegruppo = qualediv;
	
    if (Stringa.length > 0)
    {
        var url = "ctrlpw2.asp?" + Stringa;
		
        XMLHTTP = RicavaBrowser(CambioStato);
        XMLHTTP.open("GET", url, true);
        XMLHTTP.send(null);
    }
    else
    {
        document.getElementById(qualegruppo).innerHTML = "";
    } 
}

function CambioStato()
{
    if (XMLHTTP.readyState == 4)
    {
		if (XMLHTTP.responseText == 'Password non corretta!!!!' || XMLHTTP.responseText == 'Login non corretta!!!!')
		{
			qualegruppo= qualegruppo + 'errore';
		}
        var R = document.getElementById(qualegruppo);
        R.innerHTML = XMLHTTP.responseText;
    }
}

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!");
    }
}