// JavaScript Document

  var ricerca_pro;
  var ricerca_pro2;
      
function cerca() 
{

//ok
//alert(document.form1.categoria.selectedIndex)

    var valorecampo = document.form1.categoria.options[document.form1.categoria.selectedIndex].value;
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        ricerca_pro = new XMLHttpRequest();
        ricerca_pro.onreadystatechange = ricevi;
        ricerca_pro.open("GET", "/cercaprodotto.asp?categoria_prodotto="+valorecampo,true);
        ricerca_pro.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        ricerca_pro = new ActiveXObject("Microsoft.XMLHTTP");
        if (ricerca_pro) {
            ricerca_pro.onreadystatechange = ricevi;
            ricerca_pro.open("GET", "/cercaprodotto.asp?categoria_prodotto="+valorecampo,true);
            ricerca_pro.send();
        }
    }
}

     
function ricevi()
{
	var strRes;       
	var arrValori;      
	var arrValoriProdotto;     
	
	if (ricerca_pro.readyState == 4)
	{	    
		strRes=ricerca_pro.responseText;
		arrValori=strRes.split("|");
		document.form1.sottocategoria.options.length=0;		    
		if ((arrValori.length == 1) && (arrValori[0] == ""))
		{
			document.form1.sottocategoria.disabled=true;
		}
		else
		{
			document.form1.sottocategoria.disabled=false;	  
		}
		for(i=0;i<arrValori.length;i++)
		{
			document.form1.sottocategoria.options[document.form1.sottocategoria.options.length]= new Option(arrValori[i].split("|")); 
		}

		//ora azzero il select prodotti
		arrValoriProdotto="";
		document.form1.prodotto.options.length=0;		    
		document.form1.prodotto.disabled=true;


		for(i=0;i<arrValoriProdotto.length;i++)
		{
			document.form1.prodotto.options[document.form1.prodotto.options.length]= new Option(arrValoriProdotto[i].split("|")); 
		}

		cerca2()
	}
}


function cerca2() 
{

//ok
//alert(document.form1.sottocategoria.selectedIndex)

   // var valorecampo = document.form1.sottocategoria.options[document.form1.sottocategoria.selectedIndex].value;
	var valorecampo = document.form1.sottocategoria.value;
//alert(document.form1.sottocategoria.options[document.form1.sottocategoria.selectedIndex].value)
alert(valorecampo) 


    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        ricerca_pro2 = new XMLHttpRequest();
        ricerca_pro2.onreadystatechange = ricevi2;
        ricerca_pro2.open("GET", "/cercaprodotto.asp?sottocategoria_prodotto="+valorecampo,true);
        ricerca_pro2.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        ricerca_pro2 = new ActiveXObject("Microsoft.XMLHTTP");
        if (ricerca_pro2) {
            ricerca_pro2.onreadystatechange = ricevi2;
            ricerca_pro2.open("GET", "/cercaprodotto.asp?sottocategoria_prodotto="+valorecampo,true);
            ricerca_pro2.send();
        }
    }
}

     
function ricevi2()
{   
	var strRes;       
	var arrValori;      
	if (ricerca_pro2.readyState == 4)
	{
		strRes=ricerca_pro2.responseText;
		arrValori=strRes.split("|");
		alert(arrValori);
		document.form1.prodotto.options.length=0;		    
		if ((arrValori.length == 1) ) //&& (arrValori[0] == "")
		{
			document.form1.prodotto.disabled=true;
		}
		else
		{
			document.form1.prodotto.disabled=false;	  
		}
		for(i=0;i<arrValori.length;i++)
		{
			document.form1.prodotto.options[document.form1.prodotto.options.length]= new Option(arrValori[i].split("|")); 
		}
	}
}

