//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);
}

//GESTION DES COOKIES js
function EcrireCookie(nom, valeur){
	var argv=EcrireCookie.arguments;
	var argc=EcrireCookie.arguments.length;
	var expires=(argc > 2) ? argv[2] : null;
	var path=(argc > 3) ? argv[3] : null;
	var domain=(argc > 4) ? argv[4] : null;
	var secure=(argc > 5) ? argv[5] : false;
	document.cookie=nom+"="+escape(valeur)+
	((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
	((path==null) ? "" : ("; path="+path))+
	((domain==null) ? "" : ("; domain="+domain))+
	((secure==true) ? "; secure" : "");
}
function getCookieVal(offset){
	var endstr=document.cookie.indexOf (";", offset);
	if (endstr==-1) endstr=document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
function LireCookie(nom){
	var arg=nom+"=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while (i<clen){
		var j=i+alen;
		if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
		i=document.cookie.indexOf(" ",i)+1;
		if (i==0) break;
		}
	return null;
}
function EffaceCookie(nom){
date=new Date;
date.setFullYear(date.getFullYear()-1);
EcrireCookie(nom,null,date);
}


//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;
	}
}

