function gereCouche(nom) {
	nbpas  = document.SIG.length;
	action = "";
	if (nom=='update') {
		action = "zoom0";
	}
	else {
 		for (i=0 ; i<nbpas ; i++) {
			if (document.SIG.elements[i].name==nom) {
				if (document.SIG.elements[i].value=="on") {
					// CheckBox "on"
					document.SIG.elements[i].value="off";
					action = "retire";
		  		}
				else if (document.SIG.elements[i].value=="off") {
					// CheckBox "off"
					document.SIG.elements[i].value="on";
					action = "ajout";
				}
			}
		}
	}
	document.TOOL.action.value = action;
	document.TOOL.couche.value = nom;
	document.TOOL.submit();
//	alert(action+", "+nom);
}

function selCouche(nom) {
  document.SIG.action.value = "select";
  document.SIG.couche.value = nom;
  document.SIG.submit();
}

function gereTool(i) {
	document.TOOL.outil.value = i;
	if      (1==i) document.TOOL.action.value = 'zoom+';
	else if (2==i) document.TOOL.action.value = 'zoom-';
	else if (3==i) document.TOOL.action.value = 'pan';
	else if (4==i) document.TOOL.action.value = 'zoom0';
	else if (5==i) document.TOOL.action.value = 'info';
	if (1==i) document.TOOL.plus.src = 'images/outils/zoomin_f3.gif';
	else      document.TOOL.plus.src = 'images/outils/zoomin.gif';
	if (2==i) document.TOOL.moin.src = 'images/outils/zoomout_f3.gif';
	else      document.TOOL.moin.src = 'images/outils/zoomout.gif';
	if (3==i) document.TOOL.pan.src = 'images/outils/pan_f3.gif';
	else      document.TOOL.pan.src = 'images/outils/pan.gif';
	if (5==i) document.TOOL.info.src = 'images/outils/info_f3.gif';
	else      document.TOOL.info.src = 'images/outils/info.gif';
	document.SIG.outil.value = document.TOOL.outil.value;
	if (4==i) document.TOOL.submit();
}

function checkMapAvailability(){
	var legend = document.getElementsByTagName("fieldset")[0];
	var entries= legend.getElementsByTagName("tr");

	var displayed = 0;
	for (var i=0; i<entries.length; i++){
		var checkBox = entries[i].getElementsByTagName("input")[0];
		if (checkBox == null) 
			continue;
		var isHidden = entries[i].getElementsByTagName("i").length>0;
		if (checkBox.checked && !isHidden) 
			displayed++;
	}
	if (displayed==0){
		document.getElementById("parent").style.background='url("/images/no_data.png")';
		//document.getElementById("parent").style.backgroundRepeat ="no-repeat";
	}
}
