// JavaScript Document
function recupXhr(){
var httpRequest = false;

if (window.XMLHttpRequest) { // Mozilla, Safari,...
	httpRequest = new XMLHttpRequest();
	if (httpRequest.overrideMimeType) {
		httpRequest.overrideMimeType('text/html');
	}
}
else if (window.ActiveXObject) { // IE
	try {
		httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e) {
		try {
			httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e) {}
	}
}

if (!httpRequest) {
	alert('Abandon : votre navigateur n\'autorise pas cette action. Merci d\'utiliser Firefox ou Internet Explorer');
	return false;
}
return httpRequest;
}

function affiche_reponse(id){
var zone = document.getElementsByName('reponse['+id+']');
var nb = zone.length;
for(var i=0;i<nb; i++){
	if(zone[i].style.display == ''){
		zone[i].style.display = 'none';
	}else{
		zone[i].style.display = '';
	}
}}

function deplie_sous_cat(id){
var sous_cat = document.getElementsByName('sous_cat['+id+']');
var nb = sous_cat.length;
for(var i=0;i<nb; i++){
	if(sous_cat[i].style.display == ''){
		sous_cat[i].style.display = 'none';
	}else{
		sous_cat[i].style.display = '';
	}
}}

function affiche_qr(id_cat,wwwroot,mc){
var xhr = recupXhr();
xhr.onreadystatechange = function() { 
	   if(xhr.readyState == 4) {
		 	var rst = xhr.responseText;
			//alert(rst);
			document.getElementById('affiche_qr').innerHTML = rst;
		}
		return xhr.readyState;
	} 
	
var data = "id_cat="+id_cat+"&mc="+mc;

xhr.open("GET", wwwroot + "/xhr_faq.php?"+data,true);
xhr.send(null);		
}

function active_all_faq(active,wwwroot){
var xhr = recupXhr();
xhr.onreadystatechange = function() { 
	   if(xhr.readyState == 4) {
		 	var rst = xhr.responseText;
			alert(rst);	
			window.location.reload();
		}
			return xhr.readyState;
	} 
	
var data = "active="+active;

xhr.open("GET", wwwroot + "/administrer/xhr_active_faq.php?"+data,true);
xhr.send(null);		

}

function supprime_cat_faq(id_cat, wwwroot){
var xhr = recupXhr();
xhr.onreadystatechange = function() { 

	   if(xhr.readyState == 4 && xhr.status == 200) {
			var rst = xhr.responseText;
			document.getElementById('succes').innerHTML = rst;
			setTimeout("window.location.reload()", 2000);
		}
		return xhr.readyState;
	} 
	
var data = "id_cat="+id_cat;
xhr.open("GET", wwwroot+"/administrer/xhr_supprime_cat_faq.php?"+data,true);
//xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xhr.send(null);	
}



