/*
	function masqueCarteSecteur() {
		//document.getElementById('coup_coeur').style.display='block';
		document.getElementById('type').style.display='inline';
		//document.getElementById('secteur').style.display='inline';
		obj_ville=document.getElementById('ville')
		if (obj_ville){
			obj_ville.style.display='inline';
		}
		document.getElementById('carte_secteur').style.display='none';
	}

	function ActualiseCarteSecteur(strSecteurSelect) {
		for (var i=0;i<tabsecteurs.length;i++) {
			objSecteur=document.getElementById('s_'+tabsecteurs[i]);
			objSecteur.className='secteur_non_select';
			if (strSecteurSelect.length > 0) {
				if (strSecteurSelect.indexOf(',')>=0) {
					var tabSecteursSelect = strSecteurSelect.split(',');
				}
				else {
					var tabSecteursSelect = new Array();
					tabSecteursSelect[0] = strSecteurSelect;
				}
				for (var j=0;j<tabSecteursSelect.length;j++) {
					if (tabsecteurs[i]==tabSecteursSelect[j]) {
						objSecteur.className='secteur_select';
					}
				}
			}
		}
	}
*/
		/*****************
		* FONCTION VILLE *
		*****************/
/*
	function addVille(idVille)
	{
		objSelectVille  = window.opener.document.getElementById('select_ville');
		if (objSelectVille.value.length > 0) {
			tabSelectVille = objSelectVille.value.split(',');
		}
		else {
			tabSelectVille = new Array();
		}
		blnAdd=true;
		for (var i=0;i<tabSelectVille.length;i++) {
			if (tabSelectVille[i]==idVille) {
				blnAdd=false;
			}
		}
		if (blnAdd) {
			tabSelectVille.push(idVille);
		}
		objSelectVille.value=tabSelectVille.join(',');
	}

	function remVille(idVille)
	{
		objSelectVille  = window.opener.document.getElementById('select_ville');
		tabSelectVille = objSelectVille.value.split(',');
		tabNouveau = new Array();
		for (var i=0;i<tabSelectVille.length;i++) {
			if (tabSelectVille[i]!=idVille) {
				tabNouveau.push(tabSelectVille[i]);
			}
		}
		objSelectVille.value=tabNouveau.join(',');
	}

	function affCarteVille(idSecteur) {
		objCarteVille=document.getElementById('carte_ville_'+idSecteur);
		objCarteVille.style.left="10px";
		objCarteVille.style.top="10px";

		if (window.opener.document.getElementById('select_ville').value.length > 0) {
			selectCarteVilleTout(window.opener.document.getElementById('select_ville').value,true);
		}
		objCarteVille.style.display='block';
		document.getElementById('carte_secteur_message').style.display='block';
	}

	function masqueCarteVille(idSecteur) {
		ListeSelectionCarte('../');
		
		document.getElementById('carte_ville_'+idSecteur).style.display='none';
	}

	function ChangeSelectVille(objVille) {
		if (objVille.className=='ville_non_select') {
			objVille.className='ville_select';
			addVille(objVille.id.substring(2));
		}
		else {
			objVille.className='ville_non_select';
			remVille(objVille.id.substring(2));
		}
	}

		// blnSelect si true alors sélect sinon déselect
	function selectCarteVilleTout(idVilles,blnSelect) {
		tabIdVilles = new Array();
		tabIdVilles = idVilles.split(',');
		for (var i=0;i<tabIdVilles.length;i++) {
			objVille=document.getElementById('v_'+tabIdVilles[i]);
			if (blnSelect) {
				objVille.className='ville_select';
				addVille(objVille.id.substring(2));
			} else {
				objVille.className='ville_non_select';
				remVille(objVille.id.substring(2));
			}

		}
	}
*/
	function ListeSelectionCarte(strChemin) {
		if (window.opener) {
			//alert(window.name);
			tab_id_selection=window.opener.document.getElementById('select_ville').value;
		} else {
			tab_id_selection=document.getElementById('select_ville').value;
		}
			/* Création de l'objet : */
		var xmlhttp = getHTTPObject();
		/* Préparation d'une requête asynchrone de type GET : */
		xmlhttp.open("GET", strChemin+"get_libelle_ville.php?id_villes="+tab_id_selection, true);
		/* Effectue la requête : */
		xmlhttp.onreadystatechange = function() {
			if(xmlhttp.readyState == 4) {
				tab_result=xmlhttp.responseText.split("|");
				if (window.name=='carte') {
					//window.opener.document.getElementById('select_secteur').value=tab_result[0];
					window.opener.document.getElementById('libelle_villes').innerHTML=tab_result[1];
					window.close();
				} else {
					//document.getElementById('select_secteur').value=tab_result[0];
					document.getElementById('libelle_villes').innerHTML=tab_result[1];
				}
				//tab_result=xmlhttp.responseText.split("|");
				//tab_result=xmlhttp.responseText;
				//if (window.name=='planrecherche') {
					//window.opener.document.getElementById('libelle_villes').innerHTML=tab_result;
					//window.close();
				//} else {
				//	document.getElementById('libelle_villes').innerHTML=tab_result;
				//	window.close();
				//}
			}
		}
		xmlhttp.send(null);
	}

	function getElBy(tag,attr,val) {
		var dbRes = [];
		var dbEl = document.body.getElementsByTagName(tag);
		for (var e = 0; e < dbEl.length; e++) {
			if (attr == 'class') {
				if (dbEl[e].className == val) {
			    	dbRes.push(dbEl[e]);
				}
			}
			else {
				if (dbEl[e].getAttribute(attr) == val) {
			    	dbRes.push(dbEl[e]);
				}
			}
		}
		return dbRes;
	}
/*
	function deselectionCarteVilleTous () {
		var tabObj = getElBy('span','class','ville_select');
		//alert(tabObj.length);
		for (var i=0;i<tabObj.length;i++) {
			tabObj[i].className='ville_non_select';
		}
	}
*/