// +-------------------------------------------------+
// � 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net)
// +-------------------------------------------------+
// $Id: abts_modele.js,v 1.1.4.2 2025/10/10 12:39:06 dgoron Exp $

function abts_enable_node(node_id) {
	if (document.getElementById(node_id)) {
		document.getElementById(node_id).disabled = false;
	}
}

function abts_disable_node(node_id) {
	if (document.getElementById(node_id)) {
		document.getElementById(node_id).disabled = true;
	}
}

function abts_change_actif(type, obj_checked, cycle_checked) {
	if(obj_checked == true){
		abts_enable_node(type+'_increment_date');
		abts_enable_node(type+'_increment_day_of_month');
		abts_enable_node(type+'_increment_month_of_year');
		abts_enable_node(type+'_date_unite');
		abts_enable_node(type+'_increment');
		abts_enable_node(type+'_increment1');
		abts_enable_node(type+'_increment2');
		if(cycle_checked == true){
			abts_change_cycle(type, true);
		}
	}else{
		abts_disable_node(type+'_increment_date');
		abts_disable_node(type+'_increment_day_of_month');
		abts_disable_node(type+'_increment_month_of_year');
		abts_disable_node(type+'_date_unite');
		abts_disable_node(type+'_increment');
		abts_disable_node(type+'_increment1');
		abts_disable_node(type+'_increment2');
		abts_change_cycle(type, false);
	}
}

function abts_change_cycle(type, obj_checked) {
	if(obj_checked == true){
		abts_enable_node(type+'_depart');
		abts_enable_node(type+'_combien');
	} else {
		abts_disable_node(type+'_depart');
		abts_disable_node(type+'_combien');
	}
}

function gere_num(obj) {	
	var obj_id=document.getElementById(obj);	
	var vol_cycle_id=document.getElementById('vol_cycle');
	var tom_cycle_id=document.getElementById('tom_cycle');	
	if(obj== 'num_cycle'){
		abts_change_actif('num', obj_id.checked, obj_id.checked);
	}
	if(obj== 'vol_actif'){
		abts_change_actif('vol', obj_id.checked, vol_cycle_id.checked);
		if(obj_id.checked == true){
			abts_enable_node('vol_increment_numero');
			abts_enable_node('vol_cycle');
		} else {
			abts_disable_node('vol_increment_numero');
			abts_disable_node('vol_cycle');
		}
	}	
	if(obj== 'vol_cycle'){
		abts_change_cycle('vol', obj_id.checked);
	}	
	if(obj== 'tom_actif'){
		abts_change_actif('tom', obj_id.checked, tom_cycle_id.checked);
		if(obj_id.checked == true){
			abts_enable_node('tom_increment_numero');
			abts_enable_node('tom_cycle');
		} else {
			abts_disable_node('tom_increment_numero');
			abts_disable_node('tom_cycle');
		}
	}
	if(obj== 'tom_cycle'){
		abts_change_cycle('tom', obj_id.checked);
	}	
}

window.onload = function() {
	gere_num('vol_cycle');
	gere_num('tom_cycle');
	gere_num('num_cycle');
	gere_num('vol_actif');
	gere_num('tom_actif');
}