// JavaScript Document
var XMLHTTP;
var destinazione;


function caricaload(dest)
{
 	document.getElementById(dest).innerHTML ="<div align='center' class='load'><img src='indicator_arrows.gif' width='51' height='19' /></div>";
}


function Richiesta(var_dest,tipo,idrif)
{
	destinazione=var_dest;
	if (idrif!='-')
	{
		//document.getElementById(destinazione).innerHTML = "";
	
					var url = "inscarr.asp?idprod=" + idrif;
					XMLHTTP = RicavaBrowser(CambioStato);
					//XMLHTTP.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
					XMLHTTP.open("GET", url, true);
					XMLHTTP.send(null);
	}
}


function RichiestaInsert(var_dest,form)
{

destinazione=var_dest;

	//document.getElementById(destinazione).innerHTML = "";
	
	var url = "funz_carello.asp";
	XMLHTTP = RicavaBrowser(CambioStato);
	XMLHTTP.open("POST", url);
	alert('prima');
	XMLHTTP.send(form);
	alert('dopo');
}

function Richiestaric(var_dest,prodotto,confezione,gusto)
{
	destinazione=var_dest;
	
	//document.getElementById(destinazione).innerHTML = "";
	
	var url = "ricerca_ajax.asp?selprodotto="+prodotto+"&selconfezione="+confezione+"&selgusto="+gusto;
	XMLHTTP = RicavaBrowser(CambioStato);
	//XMLHTTP.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	XMLHTTP.open("GET", url, true);
	//window.open(url);
	XMLHTTP.send(null);

}


function CambioStato()
{
    if (XMLHTTP.readyState == 4)
    {
        var R = document.getElementById(destinazione);
        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("Questo browser non č supportato!");
    }
}

