var time_p = new Array();
var tbl_p = new Array();
var tbl_sp = new Array();

function Change_Img(l_objet,new_img){
	l_objet.src = new_img;
}

function Donne_T(l_objet){
	if (l_objet.offsetParent) return (l_objet.offsetTop + Donne_T(l_objet.offsetParent));
	else return (l_objet.offsetTop);
} 

function Donne_L(l_objet){
	if (l_objet.offsetParent) return (l_objet.offsetLeft + Donne_L(l_objet.offsetParent));
	else return (l_objet.offsetLeft);
} 

function Donne_H(l_objet){
	return l_objet.height;
}

function Action_Sp(p,bas){
	var ul_p = window.document.getElementById("ul_p_"+p);	
	ul_p.style.clip = "rect(0,194,"+bas+",0)";
}

function Ferme_Mn(p,nb_part){
	for (i=1;i<=nb_part;i++){
		if (i!=p) Action_Sp(i,0);
	}
}

function Affich_Sp_TO(p,haut_ul){
	var bt_p = window.document.getElementById("bt_p_"+p);
	var new_img = "img/bt_"+p+"_over.gif";
	Change_Img(bt_p,new_img);
	
	ul_p = window.document.getElementById("ul_p_"+p);
	ul_p.style.top = Donne_T(bt_p) + Donne_H(bt_p);
	ul_p.style.left = Donne_L(bt_p);	

	var intervalle = 0;
	for (var haut=0;haut<=haut_ul;haut=haut+10){
		time_p[p] = window.setTimeout("Action_Sp("+p+","+haut+")",(intervalle*20));
		intervalle++;	
	}	
}

function Affich_Sp(p,haut_ul){
	var bt_p = window.document.getElementById("bt_p_"+p);
	var new_img = "img/bt_"+p+"_over.gif";
	Change_Img(bt_p,new_img);

	Action_Sp(p,haut_ul);
}

function Cach_Sp_TO(p,haut_ul){
	var intervalle = 0;
	for (var haut=haut_ul;haut>=0;haut=haut-10){
		time_p[p] = window.setTimeout("Action_Sp("+p+","+haut+")",(intervalle*20));
		intervalle++;
	}
	
	var bt_p = window.document.getElementById("bt_p_"+p);
	var new_img = "img/bt_"+p+"_out.gif";
	Change_Img(bt_p,new_img);
}

function Cach_Sp(p){ 
	Action_Sp(p,0);
	
	var bt_p = window.document.getElementById("bt_p_"+p);
	var new_img = "img/bt_"+p+"_out.gif";
	Change_Img(bt_p,new_img);
}

function Acc_Over(p){
	var acc_p = window.document.getElementById("acc_p_"+p);
	var new_img = "img/acc_"+p+"_over.gif";
	Change_Img(acc_p,new_img);
	
	ul_p = window.document.getElementById("ul_p_"+p);
	ul_p.style.display = "block";	
}

function Acc_Out(p){
	var acc_p = window.document.getElementById("acc_p_"+p);
	var new_img = "img/acc_"+p+"_out.gif";
	Change_Img(acc_p,new_img);
	
	ul_p = window.document.getElementById("ul_p_"+p);
	ul_p.style.display = "none";
}

function Cel_Over(p,sp,couleur){
	li_sp = window.document.getElementById("li_"+p+"_"+sp);
	li_sp.style.backgroundColor = couleur; 
	li_sp.style.color = "#FFFFFF";
}

function Cel_Out(p,sp,couleur){
	li_sp = window.document.getElementById("li_"+p+"_"+sp);
	li_sp.style.backgroundColor = "#EEEEEE";
	li_sp.style.color = couleur;
}

function Lien(url){
	window.location.href = url;
}

function Affich_Div(btn,num_btn,nb,couleur){
	btn.style.backgroundColor = couleur;
	btn.style.color = '#FFFFFF';
	for (i=1;i<=nb;i++){
		div = "div_" + i;
		if (i!=num_btn){
			lk = "lk_" + i;
			window.document.getElementById(lk).style.backgroundColor = "#FFFFFF";
			window.document.getElementById(lk).style.color = couleur;
			window.document.getElementById(div).style.display = "none";
		}
		else {
			window.document.getElementById(div).style.display = "block";
		}
	}
	return false;
}

var tbl_form = new Array;
var tbl_reg = new Array;

function Affich_Reg(id_form,couleur){
	if (tbl_reg.length>0) Cache_Etabl(tbl_reg);

	window.document.getElementById('reg_no').style.display = "none";		
	tbl_form[tbl_form.length] = id_form;
	for (i=0;i<tbl_form.length;i++){
		la_form = tbl_form[i];
		lkf = "lkf_" + la_form;
		reg = "reg_" + la_form;
		if (la_form!=id_form){	
			window.document.getElementById(lkf).style.color = "#000000";
			window.document.getElementById(lkf).style.backgroundColor = "#FFFFFF";
			window.document.getElementById(lkf).style.textDecoration = "underline";
			window.document.getElementById(reg).style.display = "none";
			
		}
		else {
			tbl_reg[id_form] = new Array;
			sel_reg = "sel_reg_" + id_form;
			window.document.getElementById(lkf).style.color = couleur;
			window.document.getElementById(lkf).style.backgroundColor = "#EEEEEE";
			window.document.getElementById(lkf).style.textDecoration = "none";
			window.document.getElementById(sel_reg).options[0].selected = true;			
			window.document.getElementById(reg).style.display = "block";
		}
	}
	return false;
}

function Affich_Etabl(id_form,id_reg){
	window.document.getElementById('etabl_no').style.display = "none";
	tbl_reg[id_form][tbl_reg[id_form].length] = id_reg;
	for (i=0;i<tbl_reg[id_form].length;i++){
		la_reg = tbl_reg[id_form][i];
		etabl = "etabl_"+id_form+"_"+la_reg;
		if (la_reg!=id_reg) window.document.getElementById(etabl).style.display = "none";
		else window.document.getElementById(etabl).style.display = "block";
	}
	return false;
}

function Affich_Cfa(id_reg){
	window.document.getElementById('etabl_no').style.display = "none";
	tbl_reg[tbl_reg.length] = id_reg;
	for (i=0;i<tbl_reg.length;i++){
		la_reg = tbl_reg[i];
		etabl = "etabl_"+la_reg;
		if (la_reg!=id_reg) window.document.getElementById(etabl).style.display = "none";
		else window.document.getElementById(etabl).style.display = "block";
	}
	return false;
}

function Cache_Etabl(tbl_reg){
	for (i in tbl_reg){
		for (j in tbl_reg[i]){
			etabl = "etabl_"+i+"_"+tbl_reg[i][j];
			window.document.getElementById(etabl).style.display = "none";
		}
	}
	window.document.getElementById('etabl_no').style.display = "block";
	return false;
}

function Affich_Met(id_form){
	window.document.getElementById('met_no').style.display = "none";	
	for (i=0;i<tbl_form.length;i++){
		la_form = tbl_form[i];
		met = "met_" + la_form;
		if (la_form==id_form) window.document.getElementById(met).style.display = "block";
		else window.document.getElementById(met).style.display = "none";
	}
	return false;	
}

ref_cqp = 0;
function Affich_Ref(){
	cqp = window.document.getElementById('formation');
	if (ref_cqp==0){
		cqp.style.display = "block";
		ref_cqp = 1;
	}
	else {
		cqp.style.display = "none";
		ref_cqp = 0;		
	}
	return false;
}

var tbl_dr = new Array;

function Affich_Dr(id_dr){
	tbl_dr[id_dr] = id_dr;
	for (i in tbl_dr){
		div_dr = "div_dr_" + i;
		if (i==id_dr) window.document.getElementById(div_dr).style.display = "block";	
		else window.document.getElementById(div_dr).style.display = "none";		
	}
	window.document.getElementById('carte').src = "img/carte/carte_" + id_dr + ".gif";
	return false;
}

function Cache_Dr(id_dr){
	div_dr = "div_dr_" + id_dr;	
	window.document.getElementById(div_dr).style.display = "none";		
	window.document.getElementById('carte').src = "img/carte/carte.gif";
	return false;
}

function Valid_DP3(form){
	var champs = new String;
	var cpte = 0;
	if (form.nom_etabl.value.length<3){
		cpte+= 1;
		champs+= "\n- nom de l'établissement";
	}
	if (form.code.value.length<3){
		cpte+= 1;
		champs+= "\n- code de l'établissement";
	}
	if (form.adr1.value.length<3){
		cpte+= 1;
		champs+= "\n- adresse de l'établissement";
	}
	if (form.zip.value.length<5){
		cpte+= 1;
		champs+= "\n- code postal de l'établissement";
	}
	if (form.ville.value.length<3){
		cpte+= 1;
		champs+= "\n- ville de l'établissement";
	}
	if (form.tel.value.length<8){
		cpte+= 1;
		champs+= "\n- téléphone de l'établissement";
	}
	if (form.nom_1.value.length<3){
		cpte+= 1;
		champs+= "\n- nom du 1er contact";
	}
	if (form.prenom_1.value.length<3){
		cpte+= 1;
		champs+= "\n- prénom du 1er contact";
	}
	if (form.adr_mail_1.value.length<3){
		cpte+= 1;
		champs+= "\n- adresse e-mail du 1er contact";
	}
	if (form.mat_1.value.length<3){
		cpte+= 1;
		champs+= "\n- matière du 1er contact";
	}
	
	if (cpte==0) return true;
	else if (cpte==1) alert ("Merci de renseigner le champ obligatoire :\n"+champs);
	else alert ("Merci de renseigner les champs obligatoires :\n"+champs);
	return false;
}

function Confirm_Choix(message,url){
	if (confirm(message+"\n\nConfirmez-vous ce choix ?")){
		window.location.href = url;
	}
}