function sel_display(sel){

  selName = sel.name;
  selValue = sel.options[sel.selectedIndex].value;
  el = document.getElementsByTagName('div');
  totEl = el.length;
  assoc = 'stato';
  shops_display();
  if(selName=='stato') assoc = 'regione';
  if(assoc=='stato') reg1 = new RegExp('^regione([0-9]+)$');
  reg0 = new RegExp('^'+assoc+'([0-9]+)$');
  for(i=0; i<totEl; i++){
    if(elId=el[i].id){
      if(reg1 && reg1.test(elId)){
        el[i].style.display = "none";
      }
      if(reg0.test(elId)){
        matches = reg0.exec(elId);
        if(matches[1]==selValue){
          el[i].style.display = "inline";
        }
        else{
          el[i].style.display = "none";
           if(el[i].hasChildNodes()){
              nL = el[i].childNodes;
              for(j=0; j<nL.length; j++){
                if(nL[j].tagName=="SELECT") nL[j].selectedIndex = false;
              }
           }
        }
      }
    }
  }

  if(assoc=='regione') shops_display(sel);

}

function shops_display(stato, regione){

  if(stato){
    pref = "shopsst";
    sel = stato;
  }else if(regione){
    pref= "shopsrg";
    sel = regione;
  }else{
    pref = false;
    sel = "shops";
  }

  el = document.getElementsByTagName('div');
  totEl = el.length;

  if(pref){
    selValue = sel.options[sel.selectedIndex].value;
    reg = new RegExp('^'+pref+'([0-9]+)$');
    for(i=0; i<totEl; i++){
      if((elId=el[i].id) && reg.test(elId)){
        matches = reg.exec(elId);
        if(matches[1]==selValue) el[i].style.display = "inline";
        else el[i].style.display = "none";
      }
    }
  }else{
    reg = new RegExp('^'+sel+'(st|rg)[0-9]+$');
    for(i=0; i<totEl; i++){
      if((elId=el[i].id) && reg.test(elId) && el[i].style.display=="inline")
        el[i].style.display = "none";
    }
  }

}