form = document.search; 
var chcommune = form.communeCp;
 toto = form.communeCp.selectedIndex;
 var commune = chcommune.options[toto];
        while(chcommune.length!=1){
                chcommune.removeChild(chcommune.options[1]);
        }
        i= form.cantonCp.selectedIndex;
        canton = form.cantonCp.options[i].text;
        nb = form.concatCantonCommuneCp.options.length;

        for(i=0;i<nb;i++){
        	tmp = form.concatCantonCommuneCp.options[i].text;
          j = tmp.indexOf("(",1);
          jj = tmp.lastIndexOf("(",tmp.length);
          art = tmp.lastIndexOf("(Les)",tmp.length);
          indexLes = tmp.indexOf("(Les)",1);
          indexLa = tmp.indexOf("(La)",1);
          indexLe = tmp.indexOf("(Le)",1);
          l = tmp.length;
          k = tmp.lastIndexOf(")",l);

          if(j != -1){
          	if(art != -1){
          		tmpch = tmp.substring(0,art);
          		arti = tmpch.lastIndexOf("(",tmpch.length);
          		ch = tmp.substring(arti + 1,tmpch.length) + "(Les)";
          	}
          	else{
          		ch = tmp.substring(jj+1,k);
          	}
            if(j < k){
            	if(ch == canton){
            		if(art != -1)
              		st = tmp.substring(0,arti);
              	else
              		st = tmp.substring(0,jj);
                if(st != ""){
                	if(st == commune.value){
                		label = new Option(st,st,true,true);
                	}
                	else{
                		label = new Option(st,st,false,false);
                	}
                	
                  form.communeCp.options[form.communeCp.length] = label;
                }
             	}
             	if(canton == 'choix...'){
             		if(art == -1){
             			if(indexLes == -1 && indexLa == -1 && indexLe == -1)
             				st = tmp.substring(0,j);
                	if(indexLes != -1){
                		st = tmp.substring(0,indexLes + 5);
                		alert("stles:"+st);
                	}
                	if(indexLa != -1){
                		st = tmp.substring(0,indexLa + 4);
                	}
                	if(indexLe != -1){
                		st = tmp.substring(0,indexLe + 4);
                	}
                	
                }
                if(art != -1){
                	if(indexLes != -1){
                		st = tmp.substring(0,indexLes + 5);
                	}
                }
                if(st != ""){
                		ind = st.indexOf("Andelys (Les)",1);
                		if(ind != -1){
                			st = st.substring(0,ind-1);
                		}
                		if( st != ""){
                			if(st == commune.value){
                        		label = new Option(st,st,true,true);
                        	}
                        	else{
                        		label = new Option(st,st,false,false);
                        	}
                  		form.communeCp.options[form.communeCp.length] = label;
                  	}
                } 	
             }
            }
                
                	
                
                /*
                else{
                	st = tmp.substring(0,arti);
                	if(st != ""){
                		label = new Option(st,st,false,false);
                		form.communeCp.options[form.communeCp.length] = label;
                	}
                }
                */
             	}
            }
