// JavaScript Document

var ricerca_pro;

function cerca_tipologia() 
{
var valorecampo = document.form1.area_interesse.options[document.form1.area_interesse.selectedIndex].value;
// per l'oggetto nativo XMLHttpRequest
	if (window.XMLHttpRequest) {
		ricerca_pro = new XMLHttpRequest();
		ricerca_pro.onreadystatechange = ricevi;

		valorecampo="cercatipo.php?tp="+valorecampo;
		//alert(valorecampo);

		ricerca_pro.open("GET", valorecampo , true);
		ricerca_pro.send(null);
		// per IE 
		} else if (window.ActiveXObject) {
			ricerca_pro = new ActiveXObject("Microsoft.XMLHTTP");
			if (ricerca_pro) {
			ricerca_pro.onreadystatechange = ricevi;
			
			valorecampo="cercatipo.php?tp="+valorecampo;
			//alert(valorecampo);
			ricerca_pro.open("GET", valorecampo , true);
			ricerca_pro.send();
		}
	}
}

function ricevi() { 
var strRes; 
var arrValori; 
	if (ricerca_pro.readyState == 4) { 
		strRes=ricerca_pro.responseText;
		arrValori=strRes.split("|");
		document.form1.tipologia.options.length=0; 
			for(i=0;i<arrValori.length;i++)
			{
				text = arrValori[i].split("|");
				text = text.toString();  
				
				var str1=text;
				var str2=text;
				
				pos = str1.indexOf("#");
				text = str1.substring(pos,-str1.length);
				
				
				pos = str2.indexOf("#");
				val = str2.substring(pos+1,str2.length);

				
				document.form1.tipologia.options[document.form1.tipologia.options.length]= new Option(text,val);
				//document.form1.tipologia.options[document.form1.tipologia.options.length]= new Option(arrValori[i].split("|"),'1');  
			}
	}else{
	//	alert("Problemi con la ricerca!\r\nState:"+ ricerca_pro.readyState + " Status:" + ricerca_pro.status + " "+ ricerca_pro.statusText+"\r\n");
		
	}
}

