var xhr = null;

function getXhr(){
  if(window.XMLHttpRequest)xhr = new XMLHttpRequest();
  else if(window.ActiveXObject) {
    try{
      xhr = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e){
      xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  else{
    alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
    xhr = false;
  }
}

function waitme() {
  if ((xhr.readyState == 1) || (xhr.readyState == 2)) {
    document.getElementById('mybody').style.cursor="wait";
  }
}

function finwait() {
  document.getElementById('mybody').style.cursor="default";
}

function refresh_div_old(id_div, url){
	getXhr()
	xhr.onreadystatechange = function() {
	  if(xhr.readyState == 4 && xhr.status == 200){
		document.getElementById(id_div).innerHTML=xhr.responseText;
		finwait();
	  }
	  else waitme();	
	}
	xhr.open("GET",url,true);
	xhr.send(null);
}

function change_month(num_content,f_id_type) {
	getXhr()
	xhr.onreadystatechange = function(){
	if(xhr.readyState == 4 && xhr.status == 200){
		document.getElementById('menu_actualite').innerHTML=xhr.responseText;
		finwait();
	}
	else waitme();
	}
	xhr.open("GET",'/menu_actu_ajax.php?num_content='+num_content+'&f_id_type='+f_id_type,true);
	xhr.send(null);
}
/*
function administration_droit_joueur_contenu(f_id_contenu) {
	getXhr()
	xhr.onreadystatechange = function(){
	if(xhr.readyState == 4 && xhr.status == 200){
		document.getElementById('div_d_droit_joueur').innerHTML=xhr.responseText;
		administration_droit_joueur_contenu_select(f_id_contenu);
		finwait();
	}
	else waitme();
	}
	xhr.open("GET",'/module/droitcontenu_joueur/administration/r_droit_joueur_ajax.php?f_id_contenu='+f_id_contenu,true);
	xhr.send(null);
}*/
/*
function administration_droit_joueur_contenu_select(f_id_contenu) {
	getXhr()
	xhr.onreadystatechange = function(){
	if(xhr.readyState == 4 && xhr.status == 200){
		document.getElementById('div_id_joueur').innerHTML=xhr.responseText;
		finwait();
	}
	else waitme();
	}
	xhr.open("GET",'/module/droitcontenu_joueur/administration/func_select_joueur_ajax.php?f_id_contenu='+f_id_contenu,true);
	xhr.send(null);
}*/
/*
function administration_droit_joueur_contenu_contenu(f_contenu) {
	getXhr()
	xhr.onreadystatechange = function(){
	if(xhr.readyState == 4 && xhr.status == 200){
		document.getElementById('div_id_contenu').innerHTML=xhr.responseText;
		finwait();
	}
	else waitme();
	}
	xhr.open("GET",'/module/droitcontenu_joueur/administration/func_select_contenu_ajax.php?f_contenu='+f_contenu,true);
	xhr.send(null);
}*/

function refresh_div(str_get, url, id_div, call_func) {
	getXhr()
	xhr.onreadystatechange = function(){
	if(xhr.readyState == 4 && xhr.status == 200){
		document.getElementById(id_div).innerHTML=xhr.responseText;
		if (call_func!="") {
			eval(call_func);
		}
		finwait();
	}
	else waitme();
	}
	xhr.open("GET",url+str_get,true);
	xhr.send(null);
}

function refresh_input(str_get, url, id_div, call_func) {
	getXhr()
	xhr.onreadystatechange = function(){
	if(xhr.readyState == 4 && xhr.status == 200){
		document.getElementById(id_div).value=xhr.responseText;
		if (call_func!="") {
			eval(call_func);
		}
		finwait();
	}
	else waitme();
	}
	xhr.open("GET",url+str_get,true);
	xhr.send(null);
}