//FUNCTION AJAX XHR enable
function getXhr(){
			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) {
			                xhr = new ActiveXObject("Microsoft.XMLHTTP");
			            }
				}
				else { // XMLHttpRequest non supporté par le navigateur 
				   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
				   xhr = false; 
				} 
    return xhr;
}

//AFFICHER ACTU (id) + (lang)
function ShowThis(niv0,niv1){
				var xhr = getXhr();
				xhr.onreadystatechange = function(){
					if(xhr.readyState == 4 && xhr.status == 200){
						document.getElementById('corps').style.display='block';
						document.getElementById('corps').innerHTML = xhr.responseText;
					}
				}
				xhr.open("POST", "ajax/afficher-choix.php",true);
				xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				xhr.send("niv0="+niv0+"&niv1="+niv1);
}

//AFFICHER/CAHER BOITE id
function ClearBoxAndShowId(show_id, liste_of_box){
	var childbox = document.getElementById(show_id);
	var cat = document.getElementById(show_id+'_cat');
	var btn = document.getElementById(show_id+'_btn');
	for(i=0;i<liste_of_box.length;i++){
	document.getElementById(liste_of_box[i]).className = 'menu-pas-actif';
	document.getElementById(liste_of_box[i]+'_cat').style.display= 'none';
	document.getElementById(liste_of_box[i]+'_btn').src= 'images/button-off.gif';
		}
	childbox.className = 'menu-actif';	
	cat.style.display= 'block'; 
	btn.src= 'images/button-on.gif'; 
}

//VERIFIER FORMULAIRE
function VerifSearch(){
	if(document.SearchForm.SearchThis.value==''){
		document.getElementById('AlertBox').innerHTML = 'Veuillez indiquer votre recherche';
		document.SearchForm.SearchThis.style.backgroundColor='#ff621e';
		document.SearchForm.SearchThis.focus();
		return false;
	}
	if(document.SearchForm.SearchThis.value=='Tapez ici votre recherche'){
		document.getElementById('AlertBox').innerHTML = 'Veuillez indiquer votre recherche';
		document.SearchForm.SearchThis.value='';
		document.SearchForm.SearchThis.style.backgroundColor='#ff621e';
		document.SearchForm.SearchThis.focus();
		return false;
	}
}

//AFFICHER BOITE
function AppelBoite(nom,coordx,coordy){
//	alert("id="+id+" coordx="+coordx+" coordy="+coordy);
	var xhr = getXhr();
	xhr.onreadystatechange = function(){
		document.getElementById('mask').style.display='block';
		document.getElementById('boite').style.top = coordy+'px';
		document.getElementById('boite').style.left = coordx+'px';
		document.getElementById('boite').innerHTML = '<div style="width:64px;height:64px;"><img src="images/loading.gif" height="24" width="24"></div>';
		if(xhr.readyState == 4 && xhr.status == 200){			
			document.getElementById('boite').innerHTML = xhr.responseText;
			}
		}
	xhr.open("POST", "Ajax/infos-zone.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("Search="+nom);
}

//FERME BOITE
function FermerBoite(){
	document.getElementById('boite').innerHTML = '';
	document.getElementById('mask').style.display='none';
}

