//AJAX
function getXMLHTTP(){
	var xhr = null;
    
	if(window.XMLHttpRequest){ // Firefox et autres
        xhr = new XMLHttpRequest();
    
	}else if(window.ActiveXObject){ // Internet Explorer
        try{
            xhr = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e){
            try{
                xhr = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e1){
                xhr = null;
            }
        }
    }else{ // XMLHttpRequest non supportÃ© par le navigateur
        alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
    }

    return xhr;
}


//ANNUAIRE FORMATION
		function change_publics(obj){
			var obj_publics = document.getElementById('bloc-publics');
			var obj_save_txt = document.getElementById('save_txt_choix-publics');
			
			var save_txt = obj_save_txt.value;
			if (obj.value == "Lycéens, Etudiants, Apprentis"){
				var save = "'CAP, BEP','BAC PRO','BTS / DUT','Licence / Licence Pro','Master','Doctorat','Titres professionnels'";
				obj_publics.innerHTML = "<div class='bloc-colonnes'><div class='titre_publics'>Formation initiale<br/></div><div class='colonne'><input type='hidden' id='save_choix-publics' name='save_choix-publics' value=\""+ save +"\" /><input type='hidden' id='save_txt_choix-publics' name='save_txt_choix-publics' value='"+ save_txt +"' /><span><input type='checkbox' name='choix-publics_1' id='choix-publics_1' value='CAP, BEP' checked='checked' />CAP, BEP<br/><input type='checkbox' name='choix-publics_2' id='choix-publics_2' value='BAC PRO' checked='checked' />BAC PRO<br/><input type='checkbox' name='choix-publics_3' id='choix-publics_3' value='BTS / DUT' checked='checked' />BTS / DUT<br/><input type='checkbox' name='choix-publics_4' id='choix-publics_4' value='Licence / Licence Pro' checked='checked' />Licence / Licence Pro<br/></span></div></div><div class='bloc-colonnes'><div class='colonne'><span><input type='checkbox' name='choix-publics_5' id='choix-publics_5' value='Master' checked='checked' />Master<br/><input type='checkbox' name='choix-publics_6' id='choix-publics_6' value='Doctorat' checked='checked' />Doctorat<br/><input type='checkbox' name='choix-publics_7' id='choix-publics_7' value='Titres professionnels' checked='checked' />Titres professionnels<br/></span></div><div class='clr'></div></div><a style='display:block; float:right;'  href=\"javascript:orangebleu('bloc-recherche4');showhide('choix-publics');showhide('bloc-publics');\"><img alt='' border='0' src='include/images/btn-valider.png'/></a><div style='display:block; float:left;padding-top:10px;color:#fff;'><a style='color:#fff;' href=\"javascript:Inverser('choix-publics');\">Inverser la sélection</a></div><div class='clr'></div>";
			}else{
				var save = "'CAP, BEP','BAC PRO','BTS / DUT','Licence','Licence Pro','Master','Doctorat','Formations courtes','Formations longues'";
				obj_publics.innerHTML = "<div class='bloc-colonnes'><div class='titre_publics'>Formation continue<br/></div><div class='colonne'><input type='hidden' id='save_choix-publics' name='save_choix-publics' value=\""+ save +"\" /><input type='hidden' id='save_txt_choix-publics' name='save_txt_choix-publics' value='"+ save_txt +"' /><span><input type='checkbox' name='choix-publics_1' id='choix-publics_1' value='CAP, BEP' checked='checked' />CAP, BEP<br/><input type='checkbox' name='choix-publics_2' id='choix-publics_2' value='BAC PRO' checked='checked' />BAC PRO<br/><input type='checkbox' name='choix-publics_3' id='choix-publics_3' value='BTS / DUT' checked='checked' />BTS / DUT<br/><input type='checkbox' name='choix-publics_4' id='choix-publics_4' value='Licence / Licence Pro' checked='checked' />Licence / Licence Pro<br/></span></div></div><div class='bloc-colonnes'><div class='colonne'><span><input type='checkbox' name='choix-publics_5' id='choix-publics_5' value='Master' checked='checked' />Master<br/><input type='checkbox' name='choix-publics_6' id='choix-publics_6' value='Formations courtes' checked='checked' />Formations courtes<br/><input type='checkbox' name='choix-publics_7' id='choix-publics_7' value='Formations longues' checked='checked' />Formations longues<br/></span></div><div class='clr'></div></div><a style='display:block; float:right;' href=\"javascript:orangebleu('bloc-recherche4');showhide('choix-publics');showhide('bloc-publics');\"><img alt='' border='0' src='include/images/btn-valider.png'/></a><div style='display:block; float:left;padding-top:10px;color:#fff;'><a style='color:#fff;' href=\"javascript:Inverser('choix-publics');\">Inverser la sélection</a></div><div class='clr'></div>";
			}
			
			var obj_resume = document.getElementById('resume_choix-publics');
			obj_resume.innerHTML = 'Tous <strong>types de formation</strong>';		
		}
		
		<!-- function SHOWHIDE affiche ou masque un calque d apres on id
		function showhide(identifiant) {
			var doc = document.getElementById(identifiant);
		
			if (doc.style.display == '') {
				doc.style.display = 'none';
			}else {
				switch (identifiant){ 
					case 'choix-geo': 
						var nb_choix = 24;
						resume_defaut = 'Toutes les <strong>régions</strong>';
						break; 
					case 'choix-secteur': 
						var nb_choix = 8;
						resume_defaut = 'Tous les <strong>secteurs</strong>';
						break;
					case 'choix-filieres': 
						var nb_choix = 11;
						resume_defaut = 'Toutes les <strong>filières</strong>';
						break;
					case 'choix-publics': 
						var nb_choix = 8;
						resume_defaut = 'Tous <strong>types de formation</strong>';
						break;
				}
				
				doc.style.display = '';
				
				var tab_region = '';
				var tab_region_2 = '';
				for(var j = 1; j < nb_choix; j++){
					var obj_check = document.getElementById(identifiant+'_'+j);
					if (obj_check.checked == true){
						tab_region = tab_region + ", " + obj_check.value;
						tab_region = tab_region.replace('\\', '');
						tab_region_2 = tab_region_2 + ",'" + obj_check.value +"'";
					}
				}
	
				var obj_resume = document.getElementById('resume_'+identifiant);
				var obj_bt = document.getElementById('bt_'+identifiant);
				var obj_save = document.getElementById('save_'+identifiant);
				var obj_save_txt = document.getElementById('save_txt_'+identifiant);
	
				if (tab_region != ''){					
					obj_resume.innerHTML = tab_region.substring(2,tab_region.length);
					obj_save_txt.value = tab_region.substring(2,tab_region.length);
					obj_bt.src = "include/images/btn-modifier.png";
					obj_save.value = tab_region_2.substring(1,tab_region_2.length);
					
				}else{
					obj_resume.innerHTML = resume_defaut;
					obj_save_txt.value = resume_defaut;
					obj_bt.src = "include/images/btn-choisir.png";
					obj_save.value = tab_region.toUpperCase();
				}
			}
		}
	
		<!--fonction orangebleu change la couleur du fond de bloc -->
		function orangebleu(identifiant) {
			var doc = document.getElementById(identifiant);
	
			if (doc.style.background == '#3ba4ee') {
				doc.style.background = '#ff8500';
			}else {
				doc.style.background = '#3ba4ee';
			}
		}
		<!--fonction titrecolor change la couleur du titre orange ou bleu  uniquement pour zone1-->
		function titrecolor(identifiant) {
			var doc = document.getElementById(identifiant);
	
			if (doc.style.color == '#3ba4ee') {
				doc.style.color = '#ff8500';
			}else{
				doc.style.color = '#3ba4ee';
			}
		}
		
		function Inverser(identifiant){
			switch (identifiant){ 
				case 'choix-geo': 
					var nb_choix = 24;
					break; 
				case 'choix-secteur': 
					var nb_choix = 8;
					break;
				case 'choix-filieres': 
					var nb_choix = 11;
					break;
				case 'choix-publics': 
					var nb_choix = 8;
					break;
			}
							
			for(var j = 1; j < nb_choix; j++){
		      var obj_check = document.getElementById(identifiant+'_'+j);
			  obj_check.checked = !obj_check.checked;
			}
		}


//AJOUT/MODIF FORMATION
		function modif_formation(){			
			var requete_ajax = getXMLHTTP();
			var id_theme = document.getElementById('id_formation');
			var theme = id_theme.options[id_theme.options.selectedIndex].value;
			var id_donnee = document.getElementById('id_donnee');
	
			requete_ajax.open('GET','/info/JSON/formation.php?id='+theme,false);
			requete_ajax.send(null);
			var data = requete_ajax.responseText;
			
			var tab_form = data.split("&_&_&");

			document.getElementById('input-27-ligne_1').value = tab_form[1];
			document.getElementById('input-27-texte_1').value = tab_form[2];
			document.getElementById('input-27-ligne_2').value = tab_form[3];
			document.getElementById('input-27-texte_3').value = tab_form[4];
			document.getElementById('input-27-ligne_4').value = tab_form[5];
			document.getElementById('input-27-ligne_5').value = tab_form[6];			
			document.getElementById('input-27-ligne_6').value = tab_form[7];
			document.getElementById('input-27-ligne_7').value = tab_form[8];
			document.getElementById('input-27-ligne_8').value = tab_form[9];
			document.getElementById('input-27-code_postal_1').value = tab_form[10];
			document.getElementById('input-27-telephone_1').value = tab_form[11];
			document.getElementById('input-27-telephone_2').value = tab_form[12];
			document.getElementById('input-27-url_1').value = tab_form[13];
			document.getElementById('input-27-ligne_9').value = tab_form[14];
			document.getElementById('input-27-email_1').value = tab_form[15];
			
			document.getElementById('input-27-select_3').value = tab_form[16];			
			document.getElementById('input-27-select_1').value = tab_form[17];
			document.getElementById('input-27-select_4').value = tab_form[18];
			
			document.getElementById('input-27-texte_2').value = tab_form[19];

			var tab_secteur = tab_form[20].split("@_@");
			for (var j = 1; j < 8; j++) {
				document.getElementById('input-27-multiple_3_'+j).checked = false;
			}
			for (var j = 0; j < tab_secteur.length-1; j++) {
				document.getElementById('input-27-'+tab_secteur[j]).checked = true;
			}
			var tab_filiere = tab_form[21].split("@_@");
			document.getElementById('input-27-multiple_2_2').checked = false;
			document.getElementById('input-27-multiple_2_3').checked = false;
			document.getElementById('input-27-multiple_2_6').checked = false;
			document.getElementById('input-27-multiple_2_7').checked = false;
			document.getElementById('input-27-multiple_2_8').checked = false;
			document.getElementById('input-27-multiple_2_9').checked = false;
			document.getElementById('input-27-multiple_2_11').checked = false;
			document.getElementById('input-27-multiple_2_12').checked = false;
			document.getElementById('input-27-multiple_2_13').checked = false;
			document.getElementById('input-27-multiple_2_14').checked = false;

			for (var j = 0; j < tab_filiere.length-1; j++) {
				document.getElementById('input-27-'+tab_filiere[j]).checked = true;
			}
			id_donnee.value= theme;		
			
			document.forms['form_cler'].action = "spip.php?page=modif_formation&id_donnee="+ theme +"#form27";			
		}
		function choix_formation(){
			var requete_ajax = getXMLHTTP();
			var id_theme = document.getElementById('id_centre');
			var theme = id_theme.options[id_theme.options.selectedIndex].value;
			var bloc_formation = document.getElementById('bloc_formation');
			
			requete_ajax.open('GET','/info/JSON/centre.php?id='+theme,false);
			requete_ajax.send(null);
			
			var data = requete_ajax.responseText;

			var tab_centres = data.split("&&&&&&");			
			var list_form ='Titre de la formation<br /><select style="width:490px;" onclick="javacript:modif_formation();" id="id_formation">';
			
			for (var j = 1; j < tab_centres.length; j++) {
				var tab_centre = tab_centres[j].split("_&_&_");
				
				list_form += '<option value="'+ tab_centre[0] +'">'+ tab_centre[1] +'</option>';
			}
			list_form +='</select>';
			bloc_formation.innerHTML= list_form;
		}
		
