var prezzi=new Array(
   new Array('Qualsiasi','Qualsiasi',
             'Prezzo<50000','fino a 50.000',
             'Prezzo>=50000 AND Prezzo<100000','da 50.000 a 100.000',
             'Prezzo>=100000 AND Prezzo<150000','da 100.000 a 150.000',
             'Prezzo>=150000 AND Prezzo<200000','da 150.000 a 200.000',
             'Prezzo>=200000','oltre i 200.000'
            ),
   new Array('Qualsiasi','Qualsiasi',
             'Prezzo<500','fino a 500',
             'Prezzo>=500 AND Prezzo<1000','da 500 a 1000',
             'Prezzo>=1000 AND Prezzo<1500','da 1000 a 1500',
             'Prezzo>=1500 AND Prezzo<3000','da 1500 a 3000',
             'Prezzo>=3000','3000'
            )
 );

function cambiaprezzi(){
   for(n=0;n<prezzi[document.modulo.Contratto.selectedIndex].length/2;n++)
     document.modulo.Prezzo.options[n]=new Option(prezzi[document.modulo.Contratto.selectedIndex][n*2+1],prezzi[document.modulo.Contratto.selectedIndex][n*2]);
   document.modulo.Prezzo.selectedIndex=0;
}

function settaprovincia(defval){
   for(n=0;n<zone.length;n++)
     document.modulo.Provincia.options[n]=new Option(zone[n][0]);
   document.modulo.Provincia.selectedIndex=0;

   if(defval!=null)
     for(n=0;n<document.modulo.Provincia.options.length;n++)
      if(document.modulo.Provincia.options[n].text==defval)
	document.modulo.Provincia.selectedIndex=n;
}

function settalocalita(defval){
   for(n=1;n<zone[document.modulo.Provincia.selectedIndex].length;n+=2)
     document.modulo.Localita.options[(n-1)/2]=new Option(zone[document.modulo.Provincia.selectedIndex][n]);
   for(n=document.modulo.Localita.options.length-1;n>=(zone[document.modulo.Provincia.selectedIndex].length-1)/2;n--)
     document.modulo.Localita.options[n]=null;
   document.modulo.Localita.selectedIndex=0;

   if(defval!=null)
     for(n=0;n<document.modulo.Localita.options.length;n++)
      if(document.modulo.Localita.options[n].text==defval)
	document.modulo.Localita.selectedIndex=n;

   settaarea(null);
}

function settaarea(defval){
   for(n=0;n<zone[document.modulo.Provincia.selectedIndex][2+document.modulo.Localita.selectedIndex*2].length;n++)
     document.modulo.Area.options[n]=new Option(zone[document.modulo.Provincia.selectedIndex][2+document.modulo.Localita.selectedIndex*2][n]);
   for(n=document.modulo.Area.options.length-1;n>=zone[document.modulo.Provincia.selectedIndex][2+document.modulo.Localita.selectedIndex*2].length;n--)
     document.modulo.Area.options[n]=null;
   document.modulo.Area.selectedIndex=0;

   if(defval!=null)
     for(n=0;n<document.modulo.Area.options.length;n++)
      if(document.modulo.Area.options[n].text==defval)
	document.modulo.Area.selectedIndex=n;
}

function usaDatiUtente(modulo, valore){
   if (valore){
     modulo.Nome.value='';
     modulo.Cognome.value='';
     modulo.Contatto.value='';
   }
   else{
     modulo.Nome.value='';
     modulo.Cognome.value='';
     modulo.Contatto.value='';
   }
}
