// JavaScript Document
var XMLHTTP;
var dest;

function richiesta(sezione,pagina,valore)
{
	if (sezione == 'offerta') {
        dest = "corpo";
		var url = pagina;
		
		/*CAMBIO COLORE AL LINK DEL MENU CLICCATO*/
		var i=1;
		for (i=1;i<=7;i++)
		{
			if (i == valore) {
				document.getElementById('sub'+i).style.color = "#99042f";
			} else {
				document.getElementById('sub'+i).style.color = "#53534d";
			}
		}
        XMLHTTP = RicavaBrowser(CambioStato);
        XMLHTTP.open("GET", url, true);
        XMLHTTP.send(null);
	} else if (sezione == 'mktg') {
        dest = "corpo";
		var url = pagina;
		
		/*CAMBIO COLORE AL LINK DEL MENU CLICCATO*/
		var i=1;
		for (i=1;i<=4;i++)
		{
			if (i == valore) {
				document.getElementById('sub'+i).style.color = "#99042f";
			} else {
				document.getElementById('sub'+i).style.color = "#53534d";
			}
		}
        XMLHTTP = RicavaBrowser(CambioStato);
        XMLHTTP.open("GET", url, true);
        XMLHTTP.send(null);
	} else if (sezione != 'offerta') {
		dest = "corpo";
		var url = pagina;
		XMLHTTP = RicavaBrowser(CambioStato);
        XMLHTTP.open("GET", url, true);
        XMLHTTP.send(null);
    }else
    {
        document.getElementById("corpo").innerHTML = "";
    }
}

function richiestaFocus(layer,pagina)
{
	if (layer != '') {
		dest = layer;
		var url = pagina;
		XMLHTTP = RicavaBrowser(CambioStato);
        XMLHTTP.open("GET", url, true);
        XMLHTTP.send(null);
    }else
    {
        //document.getElementById(layer).innerHTML = "";
    }
}


function CambioStato()
{
    //if (XMLHTTP.readyState == 4 && XMLHTTP.status == 200)
	if (XMLHTTP.readyState == 4 )
    {
        var R = document.getElementById(dest);
        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!");
    }
}

