//With nested layers for netscape, this function hides the layer if it's visible and visa versa
function div_isVisible(div){
	var ctl = eval(admFormStr + '.ctl_' + div);
	
	if (ctl.value != 1) return false
	else return true
}

//Shows the div
function div_show(div){
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?document.layers[div]:0; 
	
	if (bw.ns4){
		var ctl = eval(admFormStr + '.ctl_' + div);
		if (obj) {
			obj.visibility='show';
		}
		if (ctl)
			ctl.value = 1;
	} else {
		//alert('show ' + div);
		var ctl = eval(admFormStr + '.ctl_' + div);
		
		if (obj) {
			obj.visibility='visible';
			obj.position='';
		}
		if (ctl)
			ctl.value = 1;
	}
}

//Hides the div
function div_hide(div){
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?document.layers[div]:0; 
		
	if (bw.ns4){
		var ctl = eval(admFormStr + '.ctl_' + div);
		if (obj) {
			obj.visibility='hidden';
		}
		if (ctl)
			ctl.value = 0;
	} else {
		var ctl = eval(admFormStr + '.ctl_' + div);
		
		if (obj) {
			obj.visibility='hidden';
			obj.position='absolute';
			obj.left = -3000;
			obj.top= -3000;
		}
		if (ctl)
			ctl.value = 0;
	}	
	
	return;
}

function check_FDyn(){
	var k,l;
	var valeur;
	
	//alert('check_FDyn');
	
	//on desactive tout
	for (k=0;k<arActions.length;k++) {
		for (l=0;l<arActions[k][2].length;l++) {
			div_hide('adm_' + arActions[k][2][l][1]);
		}
	}

	for (k=0;k<arActions.length;k++) {
		//on recupere la valeur
		var ctl = eval(admFormStr + '.' + arActions[k][1]);
		
		if (ctl) {
			if (ctl.length > 1) {
				switch (ctl.type){
					case 'select-one':
						valeur = ctl.value;
					default:
						for (l=0; l < ctl.length; l++){
						   if (ctl[l].checked){
							  valeur = ctl[l].value;
						   }
						}
				}
				
			} else {
				switch (ctl.type){
					case 'checkbox':
						valeur = ctl.checked?1:0;
						break;
					case 'radio':
					//case undefined:
						for (l=0; l < ctl.length; l++){
						   if (ctl[l].checked){
							  valeur = ctl[l].value;
						   }
						}
						break;
					default :
						valeur = ctl.value;
				}
			}
		}

		//on reactive
		if (div_isVisible('adm_' + arActions[k][0])) {
			for (l=0;l<arActions[k][2].length;l++) {
				if (arActions[k][2][l][0] == valeur) {
					div_show('adm_' + arActions[k][2][l][1]);
				}
			}
		}
	}
}

//Variables generales
var indexAct;
var arActions;

arActions = new Array();

indexAct = 0;

ADM_Event.add(window,"load",check_FDyn,false);
