/*
 * Bastien Veysseyre pour Nexxpix
 * http://www.nexxpix.fr/
 * Version Beta 0.2

 Modifié par JFD :
 - t peut être vide sans planter
 - option selected selon la page courante
 - setAttribute remplacé pour IE qui ne marche pas avec les événements ni avec l'attribut "class"
 */

var selectRef=function() {
	var b, t, v;
	return {
		init:function(b, t, v) {
			if (v===undefined) {v="_blank";}
			var bul, bli, blilen, blistoption, blistvalue, bsel, bulbyid, ultosel, bopt, situ, 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 != "") {
				bopt= document.createElement("option");
				bsel.appendChild(bopt);
				bopt.setAttribute("value", "");
				bopt.text= t;
			} else bopt= document.createElement("option");
			for (i=0; i<blilen; i++) {
				situ= bli[i];
				blia= situ.getElementsByTagName("a");
				blistvalue= blia[0];
				blistoption= blistvalue.childNodes[0].nodeValue;
				bopt[i]= document.createElement("option");
				bsel.appendChild(bopt[i]);
				bopt[i].setAttribute("value", blistvalue.href);
                if (blistvalue==document.URL) {
					bopt[i].setAttribute("selected", "selected");
                }
				bopt[i].text= blistoption;
			}
			bsel.setAttribute("onchange", "if(this.value != \'\'){window.open(this.value,\'"+v+"\')};");
            bsel.onchange= function(){window.open(this.value,v)}; // pour IE, qui ne sait pas faire un setAttribute avec les événements
			bsel.setAttribute("id", b);
			ultosel.replaceChild(bsel,bulbyid);
		}
	}
}();
