function select_innerHTML(objeto,innerHTML){
/******
* select_innerHTML - corrige o bug do InnerHTML em selects no IE
* Veja o problema em: http://support.microsoft.com/default.aspx?scid=kb;en-us;276228
* Versão: 2.1 - 04/09/2007
* Autor: Micox - Náiron José C. Guimarães - micoxjcg@yahoo.com.br
* @objeto(tipo HTMLobject): o select a ser alterado
* @innerHTML(tipo string): o novo valor do innerHTML
*******/
    objeto.innerHTML = ""
    var selTemp = document.createElement("micoxselect")
    var opt;
    selTemp.id="micoxselect1"
    document.body.appendChild(selTemp)
    selTemp = document.getElementById("micoxselect1")
    selTemp.style.display="none"
    if(innerHTML.toLowerCase().indexOf("<option")<0){//se não é option eu converto
        innerHTML = "<option>" + innerHTML + "</option>"
    }
    innerHTML = innerHTML.toLowerCase().replace(/<option/g,"<span").replace(/<\/option/g,"</span")
    selTemp.innerHTML = innerHTML


    for(var i=0;i<selTemp.childNodes.length;i++){
  var spantemp = selTemp.childNodes[i];

        if(spantemp.tagName){
            opt = document.createElement("OPTION")

   if(document.all){ //IE
    objeto.add(opt)
   }else{
    objeto.appendChild(opt)
   }

   //getting attributes
   for(var j=0; j<spantemp.attributes.length ; j++){
    var attrName = spantemp.attributes[j].nodeName;
    var attrVal = spantemp.attributes[j].nodeValue;
    if(attrVal){
     try{
      opt.setAttribute(attrName,attrVal);
      opt.setAttributeNode(spantemp.attributes[j].cloneNode(true));
     }catch(e){}
    }
   }
   //getting styles
   if(spantemp.style){
    for(var y in spantemp.style){
     try{opt.style[y] = spantemp.style[y];}catch(e){}
    }
   }
   //value and text
   opt.value = spantemp.getAttribute("value")
   opt.text = spantemp.innerHTML
   //IE
   opt.selected = spantemp.getAttribute('selected');
   opt.className = spantemp.className;
  }
 }
 document.body.removeChild(selTemp)
 selTemp = null
}

    function showResponseContent(response)
    {
      select_innerHTML(document.getElementById("comunenasc"),response.response);
        /*document.getElementById("comunenasc").innerHTML=response.response;*/
    }

		function set_comune(formid,selectid,divid,comuneid) {
			objForm = document[formid];
			var select_provincia=objForm[selectid];
			var select_comune=objForm[divid];
			var selected_provincia=select_provincia.options[select_provincia.selectedIndex].value;
			if (objForm[selectid].value!="")
			{
				select_comune.disabled=false;
				document.getElementById(comuneid).style.display='block';
			}else{
				select_comune.disabled=true;
				document.getElementById(comuneid).style.display='none';
			}

    	xmlHttp = new DHTMLSuite.ajaxUtil();
		  xmlHttp.sendRequest('comuni.php','provincia='+selected_provincia,'showResponseContent');
		}

    function showResponseContent2(response)
    {
      select_innerHTML(document.getElementById("comuneres"),response.response);
        /*document.getElementById("comuneres").innerHTML=response.response;*/
      //alert(document.getElementById("comuneres").innerHTML);
    }

	function set_comune2(formid,selectid,divid,comuneid) {
			objForm = document[formid];
			var select_provincia=objForm[selectid];
			var select_comune=objForm[divid];
			var selected_provincia=select_provincia.options[select_provincia.selectedIndex].value;
			if (objForm[selectid].value!="")
			{
				select_comune.disabled=false;
				document.getElementById(comuneid).style.display='block';
			}else{
				select_comune.disabled=true;
				document.getElementById(comuneid).style.display='none';
			}

    	xmlHttp = new DHTMLSuite.ajaxUtil();
		  xmlHttp.sendRequest('comuni.php','provincia='+selected_provincia,'showResponseContent2');
		}
		
	function showResponseContent3(response){
      select_innerHTML(document.getElementById("comuneop"),response.response);
    }

	function set_comune3(formid,selectid,divid,comuneid) {
			objForm = document[formid];
			var select_provincia=objForm[selectid];
			var select_comune=objForm[divid];
			var selected_provincia=select_provincia.options[select_provincia.selectedIndex].value;
			//alert(selected_provincia);
			if (objForm[selectid].value!="")
			{
				select_comune.disabled=false;
				document.getElementById(comuneid).style.display='block';
			}else{
				select_comune.disabled=true;
				document.getElementById(comuneid).style.display='none';
			}

    	xmlHttp = new DHTMLSuite.ajaxUtil();
		  xmlHttp.sendRequest('comuni.php','provincia='+selected_provincia,'showResponseContent3');
		}

    function showResponseContent4(response)
    {
      //alert(response.response);
			document.getElementById("codbelfiore").value="";
        document.getElementById("codbelfiore").value=response.response;
      //alert(document.getElementById("codbelfiore").value);
    }


		function getBelfiore(formid,divid)
		{
			objForm = document[formid];
			
			var select_comune=objForm[divid];
			var selected_comune=select_comune.options[select_comune.selectedIndex].value;

    	xmlHttp = new DHTMLSuite.ajaxUtil();
		  xmlHttp.sendRequest('comuni.php','comune='+selected_comune,'showResponseContent4');
		}

// **** //

	function showResponseContentServ(response){
      select_innerHTML(document.getElementById("idservizio"),response.response);
    }

	function setServiziCliente(formid,cliente_select,servizioid) {
			objForm = document[formid];
			var select_idcliente=objForm[cliente_select];
			var idoperatore = document.getElementById("idoperatore").value;
			//alert(idoperatore);
			var selected_idcliente=select_idcliente.options[select_idcliente.selectedIndex].value;
			//alert(selected_idcliente);
			if (objForm[cliente_select].value!="")
			{

				document.getElementById(servizioid).style.display='block';
			}else{
				
				document.getElementById(servizioid).style.display='none';
			}

    	xmlHttp = new DHTMLSuite.ajaxUtil();
    	//alert('idcliente='+selected_idcliente+'&idoperatore='+idoperatore);
		  xmlHttp.sendRequest('servizi.php','idcliente='+selected_idcliente+'&idoperatore='+idoperatore,'showResponseContentServ');
		}

