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_img(img, url, id_div, prop) {
	prop2=prop.replace('[','"');
	prop=prop2.replace(']','"');
	imgbig=img.replace('small','big');
	document.getElementById(id_div).innerHTML='<img src="'+url+img+'" alt="'+img+'" '+prop+' onclick="create_all(\'center\',\'/modules/fiche_plat/consultation/d_photos_popup.php?path='+url+'&amp;img='+imgbig+'\',\'207px\',\'162px\',getElementWidth(\'center\')-2+\'px\',getElementHeight(\'center\')-2+\'px\')"  />';
}

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

