var url;
var what;

function getprov3(regione)
{
	url = "sendrprov.php";
	what = "provincie3(req.responseText)";
	
	InviaDati("location="+regione);
}
 
function provincie3(regione)
{ 
  var linguaggioBox = document.getElementById("provincia3");
  linguaggioBox.options.length = 0;

	linguaggioBox.options[linguaggioBox.options.length] = 
        new Option("Tutte le provincie", 0);
x=0;
  if(regione != "")
  { 
    var arrLinguaggi = regione.split(",");
    for(i = 0; i < arrLinguaggi.length; i++)
    {
		x++;
      if(arrLinguaggi[i] != "" && arrLinguaggi[i] != "undefined")
      {
        linguaggioBox.options[linguaggioBox.options.length] = 
        new Option(arrLinguaggi[i], arrLinguaggi[i]);
      }
    }
	linguaggioBox.selectedIndex = 1;
  }
	
	if(x > 0)
	{
		getcom3(linguaggioBox.options[1].value);
	}
	else
	{
		getcom3(linguaggioBox.options[0].value);
	}

}

function getcom3(Categoria)
{
  url = "sendrcom.php";
  what = "SetComuni3(req.responseText)";
  InviaDati("provincia="+Categoria);
}
 
function SetComuni3(Linguaggi)
{

  var linguaggioBox = document.getElementById("comune3");
  linguaggioBox.options.length = 0;

	linguaggioBox.options[linguaggioBox.options.length] = 
        new Option("Tutti i comuni", 0);

  if(Linguaggi != "")
  {

    var arrLinguaggi = Linguaggi.split(",");
    for(i = 0; i < arrLinguaggi.length; i++)
    {
      if(arrLinguaggi[i] != "")
      {
		parola = arrLinguaggi[i];
		
		correggi = new String(parola);

		correggi = correggi.replace("&egrave;","è");
		correggi = correggi.replace("&agrave;","à");
		correggi = correggi.replace("&ograve;","ò");
		correggi = correggi.replace("&ugrave;","ù");
		correggi = correggi.replace("&igrave;","ì");
			
		
        linguaggioBox.options[linguaggioBox.options.length] = 
        new Option(correggi , correggi );
      }
    }
		linguaggioBox.selectedIndex = 1;
  }
}
