// JavaScript Document

// Create the XML HTTP request object. We try to be
	// more cross-browser as possible.
	function CreateXmlHttpReq(handler) {
		var xmlhttp = null;
  		try {
    		xmlhttp = new XMLHttpRequest();
  		} catch(e) {
    		try {
    		    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    		} catch(e) {
    		    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    		}
  			}
  		xmlhttp.onreadystatechange = handler;
  		return xmlhttp;
	}
	
	//Funzione handler
	function myHandler() {
    	if (myRequest.readyState == 4 && myRequest.status == 200) {
			
			 aa=document.Form.cboCCatS_Comune.options.length;
   			for (i=0; i<aa; i++) {
				document.Form.cboCCatS_Comune.options[1] = null;
			}
			string = myRequest.responseText;
			string_spl = string.split("//");
			//for (i in string_spl) {
			i=0;
			while (i < string_spl.length) {
				//alert(string_spl[i]);
				if (string_spl != "") {
					
					u = i+1;
					//alert(u);
					
					string_opt = string_spl[i].split(",,");
					//alert(u);
					option = new Option(string_opt[1],string_opt[0]);
					document.Form.cboCCatS_Comune.options[u] = option;
				}
				i++;
			}
		set_comune();
		
   	}
	}
	
	
	function drop_comuni(id) {
	
		if (id != "") {
			myRequest = CreateXmlHttpReq(myHandler);
			myRequest.open("GET","drop.asp?id=" + id);
			myRequest.send(null);
			
		}
		else
		{
			aa=document.Form.cboCCatS_Comune.options.length;
   			for (i=0; i<aa; i++){
      			document.Form.cboCCatS_Comune.options[0] = null;
   			}
			option = new Option("Tutti","");
			document.Form.cboCCatS_Comune.options[0] = option;
		}	
	}
	
	function set_comune(){
		comune = document.getElementById("hid_param").innerHTML;
		aa=document.Form.cboCCatS_Comune.options.length;
   		for (i=0; i<aa; i++){
    		if (document.Form.cboCCatS_Comune.options[i].value == comune) {
				document.Form.cboCCatS_Comune.options.selectedIndex=i;
			}
   		}
	}
	
	function test_provincia() {
	//alert(document.Form.cboCCatS.options[document.Form.cboCCatS.selectedIndex].value);
	drop_comuni(document.Form.cboCCatS.options[document.Form.cboCCatS.selectedIndex].value);
	//set_comune();
		
	}
