Event.addBehavior({
    ".soussection_checkbox@click" : function() {
    	var id = this.id.replace(/^soussection/, '');
	var section_id = $('section_sous_section' + id).value;
    	var div = $('checkbox_section_' + section_id);
	var checkbox_section = $('section' + section_id);
	if(div) {
		var children_checkboxes = div.select('input[type=checkbox]');
		var a_child_is_checked = children_checkboxes.any(function (elem) {return elem.checked; });
		if(a_child_is_checked) {
			checkbox_section.checked = "checked";			
		} else {
			checkbox_section.checked = "";			
		}
	}
	if(this.checked) {
		Effect.Appear($('option_gamme' + id));
	} else {
		Effect.Fade($('option_gamme' + id));
	}
    },
    "#formulaire_tarifs" : function () {
	this.hide();
    },
    "#afficher_formulaire_tarifs@click" : function() {
	Effect.Appear($('formulaire_tarifs'));
    },
    ".section_checkbox@click" : function() {
    	var id = this.id.replace(/^section/, '');
	var div = $('checkbox_section_' + id);
	if(this.checked) {
		Effect.Appear($('option_gamme' + id));
	} else {
		Effect.Fade($('option_gamme' + id));
		div.select('input[type=checkbox]').each(function (check) {
			var id_soussection = check.id.replace(/^soussection/, '');
			if(!isNaN(id_soussection)) {
				Effect.Fade($('option_gamme' + id_soussection));
			}
			check.checked = "";
		});
	}
    },
    "p.faq" : function() {
	this.hide();
    },
    "a.lien_voir_reponse@click" : function() {
    	var div = this.up('div');
	var ind = div.id.replace(/^div_para_/, '');
	var para = div.down('#para' + ind);
    	if(para.style.display == "none") {
		Effect.Appear(para);
	} else {
		Effect.Fade(para);
	}
    },
    "div#personnaliser_demande" : function() {
	this.hide();
    },
    "a.telecharger_tarifs@click" : function() {
	var p = $('personnaliser_demande');
	if(p.style.display == "none") {
		Effect.Appear(p);
	}
    }
});
