// JavaScript Document - fonctions cours

function delElem(parent, child) {
       var obj = document.getElementById(parent);
        var old = document.getElementById(child);
        obj.removeChild(old);
}

function creer_div_lieu_cours(monformulaire, selection) {
// recherche du noeud parent
var divParent = document.getElementById('div_lieu_cours'); 
// création du nouveau noeud
var var_div_lieu_cours_on = document.createElement('div'); 
var_div_lieu_cours_on.id='div_lieu_cours_on';

if (document.forms[monformulaire].type_domaine[0].checked == true) {

		var var_label_radio1 = document.createElement('label');
		var label1 =document.createTextNode('En Salle' );	
		var var_radio1 =document.createElement('input');
		var_radio1.setAttribute ('type', 'radio');
		var_radio1.setAttribute ('name', 'lieu_cours');
		var_radio1.setAttribute("value", 'ext.');
		if (selection == 1) {
		var_radio1.checked = true;
		}
		
		var var_label_radio2 = document.createElement('label');
		var label2 =document.createTextNode( 'A domicile' );
		var var_radio2 =document.createElement('input');
		var_radio2.setAttribute ('type', 'radio');
		var_radio2.setAttribute ('name', 'lieu_cours');
		var_radio2.setAttribute("value", 'Dom.');
		if (selection == 2) {
		var_radio2.checked = true;
		}
	
	
	divParent.appendChild(var_div_lieu_cours_on);
	
	var_div_lieu_cours_on.appendChild(var_label_radio1);
	var_label_radio1.appendChild(var_radio1);
	var_label_radio1.appendChild( label1 );
	
	var_div_lieu_cours_on.appendChild(var_label_radio2);
	var_label_radio2.appendChild(var_radio2);
	var_label_radio2.appendChild( label2 );
} else {
delElem('div_lieu_cours', 'div_lieu_cours_on');
}


}

function conf_supp_cours(texte_alerte, redirection) {
	if (confirm(texte_alerte)	== true) {
		window.location.href = redirection;
	}
	
}



	
function verifier_supp_prof_centre (centre_ou_prof, id_initiale, nom_initial) {
	if (document.forms.form1.supp_prof.checked == true && document.forms.form1.supp_centre.checked == true) {
	document.forms.form1['supp_'+centre_ou_prof].checked = false;
	alert('Vous ne pouvez pas supprimer le centre et le professeur');
	
	} else {
		if (document.forms.form1['supp_'+centre_ou_prof].checked == true) {
			document.forms.form1['deb_nom'+centre_ou_prof].value = '';
			document.forms.form1[centre_ou_prof+'_id'].value = '';
			document.getElementById('nom'+centre_ou_prof).innerHTML='';
				if (document.getElementById('liste_id_'+centre_ou_prof) ) {
					delElem('liste'+centre_ou_prof+'s', 'liste_id_'+centre_ou_prof);
				}
			} else {
			document.forms.form1[centre_ou_prof+'_id'].value = id_initiale;
			document.getElementById('nom'+centre_ou_prof).innerHTML='<strong>'+nom_initial+'</strong>';
		}
		
	}
	
	
	
}
