// JavaScript Document
var XmlHttpObj;

//---------------------------------------------------------------------------------------------------------------------------------------------------------------//
function CreateXmlHttpObj()	{	XmlHttpObj = new XMLHttpRequest(); }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------//
function catListOnChange() 
{
	var catList = document.getElementById("catList");
    var selectedCat = catList.options[catList.selectedIndex].value;

	var requestUrl;
    requestUrl = "php/xml_data_provider_ricerche.php" + "?filter=" + encodeURIComponent(selectedCat);
	CreateXmlHttpObj();
	
	if(XmlHttpObj)
	{
		XmlHttpObj.onreadystatechange = StateChangeHandler;
		XmlHttpObj.open("GET", requestUrl,  true);
		XmlHttpObj.send(null);		
	}

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------//
function StateChangeHandler()
{
	if(XmlHttpObj.readyState == 4)
	{
		if(XmlHttpObj.status == 200)
		{			
			alert('ciao');
			//PopulateTestList(XmlHttpObj.responseXML.documentElement);
		}
		else
		{
			alert("problem retrieving data from the server, status code: "  + XmlHttpObj.status);
		}
	}
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------//
function PopulateTestList(countryNode)
{
    var testList = document.getElementById("testList");
	
	for (var count = testList.options.length-1; count >-1; count--)
	{
		testList.options[count] = null;
	}
	
	var countryNodes = countryNode.getElementsByTagName('testata');
	var idValue;
	var textValue; 
	var optionItem;
	
	for (var count = 0; count < countryNodes.length; count++)
	{
		textValue = GetInnerText(countryNodes[count]);
		idValue = countryNodes[count].getAttribute("id");
		optionItem = new Option( textValue, idValue,  false, false);
		testList.options[testList.length] = optionItem;
	}
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------//
function GetInnerText (node)
{
	 return (node.textContent) ;
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------//
