//function ToUrl(m){window.open(m);}

function goToUrl(id)
{
  
  document.location.href = $(id).options[$(id).selectedIndex].value;
}

/* 
b_ul = ul id=reservationetape1
b_li = tout les "li"
b_li_len = Nombre de "li"
b_sel = Select crée
b_ul_by_id = b_ul
ul_to_sel = ???? parentNode ??
t = Texte par défaut
b_opt = option de select
*/

var selectRef=function(){
	var b,t;
	return{
		init:function(b,t){
      
			var bul,bli,blilen,blist,blistoption,blistvalue,bsel,bulbyid,ultosel,bopt,blia,i;
			bul=document.getElementById(b);
			bli=bul.getElementsByTagName('li');
			blilen = bli.length;
			bsel = document.createElement("select");
			bulbyid = document.getElementById(b);
			ultosel = bulbyid.parentNode;
			if(t != ''){
        // Mettre le champs texte à vide
				bopt = document.createElement("option");
				bsel.appendChild(bopt);
				bopt.setAttribute("value", "");
				bopt.text = t;
			}
			for(i=0;i<blilen;i++){
        // Pour chaque Li , ajout d'une option dans le select 
				situ = bli[i];
				blia = bli[i].getElementsByTagName('a');
				blistoption = blia[0].childNodes[0].nodeValue;
				blistvalue = blia[0];
				bopt[i] = document.createElement("option");
				bsel.appendChild(bopt[i]);
        
				//bopt[i].setAttribute("value", blistvalue);
        bopt[i].value = blistvalue;
        
				bopt[i].text = blistoption;
			}
			
      
      
			bsel.setAttribute("id", b);
      
      bsel.setAttribute("onchange", "goToUrl('" + b + "');");


			ultosel.replaceChild(bsel,bulbyid);

      

		}
	}
}();
