// JavaScript Document
  var ricerca_pro;   
  var stringa;
  var ricerca_prodx;
  var nomediv;
    function PreparaDati(){
  stringa = "";
  var form = document.forms[0];
  var numeroElementi = form.elements.length;
 
  for(var i = 0; i < numeroElementi; i++){
	  if (form.elements[i].type=="checkbox"){
		 if(form.elements[i].checked==true){
	   if(i < numeroElementi-1){
      stringa += form.elements[i].name+"="+encodeURIComponent(form.elements[i].value)+"&";
    }else{
      stringa += form.elements[i].name+"="+encodeURIComponent(form.elements[i].value);
    } 
		 } //chiude checked
	  } // chiude type
	      if (form.elements[i].type!="checkbox"){
    if(i < numeroElementi-1){
      stringa += form.elements[i].name+"="+encodeURIComponent(form.elements[i].value)+"&";
    }else{
      stringa += form.elements[i].name+"="+encodeURIComponent(form.elements[i].value);
    } 
  } // chiude type
  
  } 
  
}








	
	
function vaiarg(url,idcanale,idargomento,divnome) 
{  

 	  document.getElementById("divsubarg").innerHTML = "";
if (idcanale!=""){
nomediv=divnome
PreparaDati();
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        ricerca_pro = new XMLHttpRequest();
        ricerca_pro.onreadystatechange = ricevi;
        ricerca_pro.open("GET", ""+url+"?idcanale="+idcanale+"&idargomento="+idargomento,true);
		ricerca_pro.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8")
        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", ""+url+"?rand="+(Math.random())+"&idcanale="+idcanale+"&idargomento="+idargomento,true);
          		ricerca_pro.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8")

		    ricerca_pro.send();
        }
    }
	
}
}	
	
	
function vairicerca(url,tabella,campo1,campo2,campo3,divnome) 
{  

 	//  document.getElementById("divsubarg").innerHTML = "";

nomediv=divnome
PreparaDati();
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        ricerca_pro = new XMLHttpRequest();
        ricerca_pro.onreadystatechange = riceviric;
        ricerca_pro.open("POST", ""+url+"?tabella="+tabella+"&campo1="+campo1+"&campo2="+campo2+"&campo3="+campo3,true);
		ricerca_pro.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8")
        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 = riceviric;
            ricerca_pro.open("POST", ""+url+"?rand="+(Math.random()),true);
          		ricerca_pro.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8")

		    ricerca_pro.send();
        }
    }
}	






	  function riceviric() {   

    var strRes; 
	strRes=nomediv;
	
    var arrValori;      

	  if (ricerca_pro.readyState == 4) {	    
			  document.getElementById(strRes).innerHTML = unescape(ricerca_pro.responseText);
    } else {
      var results = "caricamento dati in corso";
      document.getElementById(strRes).innerHTML = results; 
    }
	}





	  function ricevi() {   

    var strRes; 
	strRes=nomediv;
	
    var arrValori;      

	  if (ricerca_pro.readyState == 4) {	    
			  document.getElementById(strRes).innerHTML = unescape(ricerca_pro.responseText);
    } else {
      var results = "caricamento dati in corso";
      document.getElementById(strRes).innerHTML = results; 
    }
	}
	
	
	
	
    function chiudidiv(nomediv)
	{var nomediv;
		 nomediv=nomediv;
		  document.getElementById(nomediv).style.backgroundColor="";
 document.getElementById(nomediv).style.border="0px";
		 
  	  document.getElementById(nomediv).innerHTML = "";
	}
  
  

