var gZone, gPays;
var gPaysInitial;

function initSelectsZone() {
	if (gZone == null) gZone = document.getElementById("zone");
	if (gPays == null) gPays = document.getElementById("pays");
	if (gPays == null) return false;
	if (gPaysInitial == null) gPaysInitial = gPays.cloneNode(true);
	return true;
}

function filtreZone(pKeepSelected) {
	if (!initSelectsZone()) return;
	var fPays = gPays.value;
	var fOldIndex = 0;
	if (fPays == "") fPays = null;
	var fInstru = gZone.value;
	if (fInstru == "") fInstru = null;
	var fChilds = gPaysInitial.childNodes;
	var fNewNoms = gPaysInitial.cloneNode(false);
	for (var i=0; i < fChilds.length; i++) {
		var lNode = fChilds[i];
		if (lNode.nodeType != 1 || lNode.tagName.toLowerCase() != "option") continue;
		if (lNode.disabled == true) {
			lNode = fNewNoms.appendChild(lNode.cloneNode(true));
			lNode.selected = true;
			continue;
		}
		var lIndex = lNode.className.indexOf("zone_");
		var lInstru = lNode.className.substring(lIndex + 5);
		if ((fInstru == null || fInstru == lInstru)) {
			lNode = fNewNoms.appendChild(lNode.cloneNode(true));
			lNode.selected = false;
			if (pKeepSelected && lNode.value == fPays) fOldIndex = lNode.index;
		}		
	}
	gPays.parentNode.replaceChild(fNewNoms, gPays);
	gPays = fNewNoms;
	if (pKeepSelected) {
		gPays.selectedIndex = fOldIndex;
	} else	gPays.selectedIndex = 0;
	show(gPays);
}

function checkSubmit() {

}