//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 ChangeActu(id){
				var xhr = getXhr();
				xhr.onreadystatechange = function(){
					if(xhr.readyState == 4 && xhr.status == 200){
						document.getElementById('actualites').innerHTML = xhr.responseText;
					}
				}
				xhr.open("POST", "ajax/change-actu.php",true);
				xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				xhr.send("actu_id="+id);
}

//AFFICHER/CAHER BOITE id
function ClearBoxAndShowId(show_id, liste_of_box){
//alert("show id="+show_id+"   liste="+liste_of_box+"  length="+liste_of_box.length);
	var childbox = document.getElementById(show_id);
	var btn = document.getElementById('Btn'+show_id);
	for(i=0;i<liste_of_box.length;i++){
	document.getElementById(liste_of_box[i]).style.display='none';
	document.getElementById('Btn'+liste_of_box[i]).className= 'menu-pas-actif';
		}
	childbox.style.display='block';
	btn.className= 'menu-actif'; 
}

//Function change GammePro
function AddPanier(id){
				var xhr = getXhr();
				xhr.onreadystatechange = function(){
					if(xhr.readyState == 4 && xhr.status == 200){
						//document.getElementById('panierbox').innerHTML = xhr.responseText;
						window.location.reload();
					}
				}
				xhr.open("POST", "Ajax_Panier.php",true);
				xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				xhr.send("pid="+id);
}

//Function change GammePro
function SupprObjetPanier(id){
				var xhr = getXhr();
				xhr.onreadystatechange = function(){
					if(xhr.readyState == 4 && xhr.status == 200){
						if(xhr.responseText=="0"){
						window.location.replace('index.php');
						}else{
						window.location.reload();
						}
					}
				}
		xhr.open("POST", "Ajax_SupprObjetPanier.php",true);
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhr.send("pid="+id);
}

//Function change GammePro
function RazPanier(){
				var xhr = getXhr();
				xhr.onreadystatechange = function(){
					if(xhr.readyState == 4 && xhr.status == 200){
						var chaine = document.location.href;
						var reg1 = new RegExp("(reservation)","g");
						if (chaine.match(reg1)) {
							window.location.replace('/index.php');
							}else{
							window.location.reload();
						}
				}
			}
		xhr.open("POST", "Ajax_ViderPanier.php",true);
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhr.send("test");
}
