function faire_liste_strucure(){
	var f = document.forms[1];
	var nom_strucure = f.texte_structure.value;
	if (nom_strucure=='') alert('Veuillez inscire un nom de structure');
	else{
		if(window.ActiveXObject) {// Internet Explorer
	    	var xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	  	}
		else if(window.XMLHttpRequest) {// Firefox
	    	var xhr_object = new XMLHttpRequest();
	  	}
		else  { // XMLHttpRequest non supporté par le navigateur
	    	alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
	    	return;
	  	}
	  	xhr_object.open("GET",  "/index.php?module=efigip&action=REPStructure&texte_structure="+nom_strucure, true);
			
		xhr_object.onreadystatechange = function() {
		  	if(xhr_object.readyState == 4){
		  		eval(xhr_object.responseText);
		  	}
		}
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		var data = "";
		xhr_object.send(data);	
	}
	
	//initialisation du select des adresses
	var liste_existante = document.getElementById('id_adresse');
	liste_existante.options.length = 1;
	
}


function faire_liste_adresse(){
	var f = document.forms[1];
	var liste_existante = document.getElementById('id_structure');
	var id_structure = "";
	
	for(i=0;i<liste_existante.length;i++){
		if (liste_existante[i].selected) {
			id_structure += liste_existante[i].value+",";
		}	
	}
	
	var longueur = id_structure.length;
	longueur = longueur-1;
	id_structure = id_structure.substr(0,longueur);
	
	
	if (id_structure=='') alert('Veuillez sélectionner une structure');
	else{
		if(window.ActiveXObject) {// Internet Explorer
	    	var xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	  	}
		else if(window.XMLHttpRequest) {// Firefox
	    	var xhr_object = new XMLHttpRequest();
	  	}
		else  { // XMLHttpRequest non supporté par le navigateur
	    	alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
	    	return;
	  	}
	  	xhr_object.open("GET",  "/index.php?module=efigip&action=REPAdresse&id_structure="+id_structure, true);
			
		xhr_object.onreadystatechange = function() {
		  	if(xhr_object.readyState == 4){
		  		eval(xhr_object.responseText);
		  	}
		}
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		var data = "";
		xhr_object.send(data);	
	}
}


/*************************************** Champsintervention ************************************/
function SelectChampsintervention(nom_form){	
	var f = eval('document.'+nom_form);
	champsintervention = document.getElementById("champsintervention");
	var selectChampsintervention = f.selectChampsintervention;
	var c = selectChampsintervention.checked;
	for(var i=0; i<champsintervention.length; i++){
		if (champsintervention[i].selected!=c){
			champsintervention[i].selected = c;
		}
	}
}

function SelectChampsintervention2(nom_form){	
	var f = eval('document.'+nom_form);
	champsintervention2 = document.getElementById("champsintervention2");
	var selectChampsintervention2 = f.selectChampsintervention2;
	var c = selectChampsintervention2.checked;
	for(var i=0; i<champsintervention2.length; i++){
		if (champsintervention2[i].selected!=c){
			champsintervention2[i].selected = c;
		}
	}
}

function SelectChampsintervention3(nom_form){	
	var f = eval('document.'+nom_form);
	champsintervention2 = document.getElementById("champsintervention2");
	for(var i=0; i<champsintervention2.length; i++){
		champsintervention2[i].selected = "true";
	}
}


function ajouterChampsintervention(nom_form){
	var f = eval('document.'+nom_form);
	var t1 = document.getElementById('champsintervention');
	var id_champsintervention = f.liste_champsintervention.value;
	
	tab_champsintervention_select = new Array();
    tab_champsintervention_exist = new Array(); 
    
	var j=0;
	for(i=0;i<t1.length;i++){
		if (t1[i].selected) {
			tab_champsintervention_select[j] = t1[i].value;
			j=j+1;
		}
	}
	
	for (i=0;i<tab_champsintervention_select.length;i++){
		var test='non';
		var valeur_selectionne = tab_champsintervention_select[i];
		for (j=0;j<tab_champsintervention_exist.length;j++){
			if (valeur_selectionne==tab_champsintervention_exist[j]){
				test='oui';
			}
		}
		if (test!='oui'){
			if (id_champsintervention!='') id_champsintervention += ",";
			id_champsintervention += valeur_selectionne;
		}
		test='non';
	}
	
	f.liste_champsintervention.value = id_champsintervention;

	if(window.ActiveXObject) {// Internet Explorer
    	var xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
  	}
	else if(window.XMLHttpRequest) {// Firefox
    	var xhr_object = new XMLHttpRequest();
  	}
	else  { // XMLHttpRequest non supporté par le navigateur
    	alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
    	return;
  	}
  	xhr_object.open("GET",  "/index.php?module=efigip&action=REPChampsinterventionAjout&id_champsintervention="+escape(id_champsintervention)+"&nom_form="+nom_form, true);
		
	xhr_object.onreadystatechange = function() {
	  	if(xhr_object.readyState == 4){
	  		eval(xhr_object.responseText);
	  	}
	}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var data = "";
	xhr_object.send(data);
}


function supprimerChampsintervention(nom_form){
	var f = eval('document.'+nom_form);
	var id_champsintervention='';
	tab_champsintervention_select = new Array();
    tab_champsintervention_exist = new Array(); 
	f.liste_champsintervention.value = '';
	
	var j=0;
	var liste_existante = document.getElementById('champsintervention2');
	for(i=0;i<liste_existante.length;i++){
		if (liste_existante[i].selected) {
			tab_champsintervention_select[j] = liste_existante[i].value;
		}
		tab_champsintervention_exist[i] = liste_existante[i].value;
		j=j+1;
	}
	
	for (i=0;i<tab_champsintervention_exist.length;i++){
		var test='non';
		var valeur_existante = tab_champsintervention_exist[i];
		for (j=0;j<tab_champsintervention_select.length;j++){
			if (valeur_existante==tab_champsintervention_select[j]){
				test='oui';
			}
		}
		if (test!='oui')id_champsintervention += valeur_existante+",";
		test='non';
	}
	var longueur = id_champsintervention.length;
	longueur = longueur-1;
	id_champsintervention = id_champsintervention.substr(0,longueur);
	
	/*var liste_champsintervention = f.champsintervention2;
    liste_champsintervention.length=0;
    
    var selectChampsintervention2 = f.selectChampsintervention2;
	if (selectChampsintervention2.checked) selectChampsintervention2.checked=false;
	*/
	
	f.liste_champsintervention.value = id_champsintervention;
	
	if(window.ActiveXObject) {// Internet Explorer
    	var xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
  	}
	else if(window.XMLHttpRequest) {// Firefox
    	var xhr_object = new XMLHttpRequest();
  	}
	else  { // XMLHttpRequest non supporté par le navigateur
    	alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
    	return;
  	}
  	xhr_object.open("GET",  "/index.php?module=efigip&action=REPChampsinterventionAjout&id_champsintervention="+escape(id_champsintervention)+"&nom_form="+nom_form, true);
		
	xhr_object.onreadystatechange = function() {
	  	if(xhr_object.readyState == 4){
	  		eval(xhr_object.responseText);
	  	}
	}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var data = "";
	xhr_object.send(data);
}


/*************************************** Rayonnementgeographique ************************************/
function SelectRayonnementgeographique(nom_form){	
	var f = eval('document.'+nom_form);
	rayonnementgeographique = document.getElementById("rayonnementgeographique");
	var selectRayonnementgeographique = f.selectRayonnementgeographique;
	var c = selectRayonnementgeographique.checked;
	for(var i=0; i<rayonnementgeographique.length; i++){
		if (rayonnementgeographique[i].selected!=c){
			rayonnementgeographique[i].selected = c;
		}
	}
}

function SelectRayonnementgeographique2(nom_form){	
	var f = eval('document.'+nom_form);
	rayonnementgeographique2 = document.getElementById("rayonnementgeographique2");
	var selectRayonnementgeographique2 = f.selectRayonnementgeographique2;
	var c = selectRayonnementgeographique2.checked;
	for(var i=0; i<rayonnementgeographique2.length; i++){
		if (rayonnementgeographique2[i].selected!=c){
			rayonnementgeographique2[i].selected = c;
		}
	}
}

function SelectRayonnementgeographique3(nom_form){	
	var f = eval('document.'+nom_form);
	rayonnementgeographique2 = document.getElementById("rayonnementgeographique2");
	for(var i=0; i<rayonnementgeographique2.length; i++){
		rayonnementgeographique2[i].selected = "true";
	}
}

function ajouterRayonnementgeographique(nom_form){
	var f = eval('document.'+nom_form);
	var t1 = document.getElementById('rayonnementgeographique');
	var id_rayonnementgeographique=f.liste_rayonnementgeographique.value;
	
	tab_rayonnementgeographique_select = new Array();
    tab_rayonnementgeographique_exist = new Array(); 
	
	var j=0;
	for(i=0;i<t1.length;i++){
		if (t1[i].selected) {
			tab_rayonnementgeographique_select[j] = t1[i].value;
			j=j+1;
		}
	}
	
	for (i=0;i<tab_rayonnementgeographique_select.length;i++){
		var test='non';
		var valeur_selectionne = tab_rayonnementgeographique_select[i];
		for (j=0;j<tab_rayonnementgeographique_exist.length;j++){
			if (valeur_selectionne==tab_rayonnementgeographique_exist[j]){
				test='oui';
			}
		}
		if (test!='oui'){
			if (id_rayonnementgeographique!='') id_rayonnementgeographique += ",";
			id_rayonnementgeographique += valeur_selectionne;
		}
		test='non';
	}
	
	f.liste_rayonnementgeographique.value = id_rayonnementgeographique;
	
	if(window.ActiveXObject) {// Internet Explorer
    	var xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
  	}
	else if(window.XMLHttpRequest) {// Firefox
    	var xhr_object = new XMLHttpRequest();
  	}
	else  { // XMLHttpRequest non supporté par le navigateur
    	alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
    	return;
  	}
  	xhr_object.open("GET",  "/index.php?module=efigip&action=REPRayonnementgeographiqueAjout&id_rayonnementgeographique="+escape(id_rayonnementgeographique)+"&nom_form="+nom_form, true);
		
	xhr_object.onreadystatechange = function() {
	  	if(xhr_object.readyState == 4){
	  		eval(xhr_object.responseText);
	  	}
	}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var data = "";
	xhr_object.send(data);
}


function supprimerRayonnementgeographique(nom_form){
	var f = eval('document.'+nom_form);
	var id_rayonnementgeographique='';
	tab_rayonnementgeographique_select = new Array();
    tab_rayonnementgeographique_exist = new Array(); 
	f.liste_rayonnementgeographique.value = '';
	
	var j=0;
	var liste_existante = document.getElementById('rayonnementgeographique2');
	for(i=0;i<liste_existante.length;i++){
		if (liste_existante[i].selected) {
			tab_rayonnementgeographique_select[j] = liste_existante[i].value;
		}
		tab_rayonnementgeographique_exist[i] = liste_existante[i].value;
		j=j+1;
	}
	
	for (i=0;i<tab_rayonnementgeographique_exist.length;i++){
		var test='non';
		var valeur_existante = tab_rayonnementgeographique_exist[i];
		for (j=0;j<tab_rayonnementgeographique_select.length;j++){
			if (valeur_existante==tab_rayonnementgeographique_select[j]){
				test='oui';
			}
		}
		if (test!='oui')id_rayonnementgeographique += valeur_existante+",";
		test='non';
	}
	var longueur = id_rayonnementgeographique.length;
	longueur = longueur-1;
	id_rayonnementgeographique = id_rayonnementgeographique.substr(0,longueur);
	
	/*var liste_rayonnementgeographique = f.rayonnementgeographique2;
    liste_rayonnementgeographique.length=0;
    
    var selectRayonnementgeographique2 = f.selectRayonnementgeographique2;
	if (selectRayonnementgeographique2.checked) selectRayonnementgeographique2.checked=false;
	*/	
	f.liste_rayonnementgeographique.value = id_rayonnementgeographique;

	if(window.ActiveXObject) {// Internet Explorer
    	var xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
  	}
	else if(window.XMLHttpRequest) {// Firefox
    	var xhr_object = new XMLHttpRequest();
  	}
	else  { // XMLHttpRequest non supporté par le navigateur
    	alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
    	return;
  	}
  	xhr_object.open("GET",  "/index.php?module=efigip&action=REPRayonnementgeographiqueAjout&id_rayonnementgeographique="+escape(id_rayonnementgeographique)+"&nom_form="+nom_form, true);
		
	xhr_object.onreadystatechange = function() {
	  	if(xhr_object.readyState == 4){
	  		eval(xhr_object.responseText);
	  	}
	}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var data = "";
	xhr_object.send(data);
}



/*************************************** Public ************************************/
function SelectPublic(nom_form){	
	var f = eval('document.'+nom_form);
	public = document.getElementById("public");
	var selectPublic = f.selectPublic;
	var c = selectPublic.checked;
	for(var i=0; i<public.length; i++){
		if (public[i].selected!=c){
			public[i].selected = c;
		}
	}
}

function SelectPublic2(nom_form){	
	var f = eval('document.'+nom_form);
	public2 = document.getElementById("public2");
	var selectPublic2 = f.selectPublic2;
	var c = selectPublic2.checked;
	for(var i=0; i<public2.length; i++){
		if (public2[i].selected!=c){
			public2[i].selected = c;
		}
	}
}

function SelectPublic3(nom_form){	
	var f = eval('document.'+nom_form);
	public2 = document.getElementById("public2");
	for(var i=0; i<public2.length; i++){
		public2[i].selected = "true";
	}
}

function ajouterPublic(nom_form){
	var f = eval('document.'+nom_form);
	var t1 = document.getElementById('public');
	var id_public=f.liste_public.value;
	
	tab_public_select = new Array();
    tab_public_exist = new Array(); 
	
	var j=0;
	for(i=0;i<t1.length;i++){
		if (t1[i].selected) {
			tab_public_select[j] = t1[i].value;
			j=j+1;
		}
	}
	
	for (i=0;i<tab_public_select.length;i++){
		var test='non';
		var valeur_selectionne = tab_public_select[i];
		for (j=0;j<tab_public_exist.length;j++){
			if (valeur_selectionne==tab_public_exist[j]){
				test='oui';
			}
		}
		if (test!='oui'){
			if (id_public!='') id_public += ",";
			id_public += valeur_selectionne;
		}
		test='non';
	}
	
	f.liste_public.value = id_public;
	
	if(window.ActiveXObject) {// Internet Explorer
    	var xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
  	}
	else if(window.XMLHttpRequest) {// Firefox
    	var xhr_object = new XMLHttpRequest();
  	}
	else  { // XMLHttpRequest non supporté par le navigateur
    	alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
    	return;
  	}
  	xhr_object.open("GET",  "/index.php?module=efigip&action=REPPublicAjout&id_public="+escape(id_public)+"&nom_form="+nom_form, true);
		
	xhr_object.onreadystatechange = function() {
	  	if(xhr_object.readyState == 4){
	  		eval(xhr_object.responseText);
	  	}
	}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var data = "";
	xhr_object.send(data);
}


function supprimerPublic(nom_form){
	var f = eval('document.'+nom_form);
	var id_public='';
	tab_public_select = new Array();
    tab_public_exist = new Array(); 
	f.liste_public.value = '';
	
	var j=0;
	var liste_existante = document.getElementById('public2');
	for(i=0;i<liste_existante.length;i++){
		if (liste_existante[i].selected) {
			tab_public_select[j] = liste_existante[i].value;
		}
		tab_public_exist[i] = liste_existante[i].value;
		j=j+1;
	}
	
	for (i=0;i<tab_public_exist.length;i++){
		var test='non';
		var valeur_existante = tab_public_exist[i];
		for (j=0;j<tab_public_select.length;j++){
			if (valeur_existante==tab_public_select[j]){
				test='oui';
			}
		}
		if (test!='oui')id_public += valeur_existante+",";
		test='non';
	}
	var longueur = id_public.length;
	longueur = longueur-1;
	id_public = id_public.substr(0,longueur);
	
	/*var liste_public = f.public2;
    liste_public.length=0;
    
    var selectPublic2 = f.selectPublic2;
	if (selectPublic2.checked) selectPublic2.checked=false;
	*/

	f.liste_public.value = id_public;

	if(window.ActiveXObject) {// Internet Explorer
    	var xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
  	}
	else if(window.XMLHttpRequest) {// Firefox
    	var xhr_object = new XMLHttpRequest();
  	}
	else  { // XMLHttpRequest non supporté par le navigateur
    	alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
    	return;
  	}
  	xhr_object.open("GET",  "/index.php?module=efigip&action=REPPublicAjout&id_public="+escape(id_public)+"&nom_form="+nom_form, true);
		
	xhr_object.onreadystatechange = function() {
	  	if(xhr_object.readyState == 4){
	  		eval(xhr_object.responseText);
	  	}
	}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var data = "";
	xhr_object.send(data);
}


function rep_nouvelle_recherche(nom_form){
	var f = eval('document.'+nom_form);
	f.reset();
	f.structure_txt.value="";
	SelectChampsintervention3(nom_form);
	supprimerChampsintervention(nom_form);
	SelectRayonnementgeographique3(nom_form);
	supprimerRayonnementgeographique(nom_form);
	SelectPublic3(nom_form);
	supprimerPublic(nom_form);
}

