// JavaScript Document

function envoi_commentaire()
{ 
    var xhr; 
    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) 
    {   try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
        catch (e2) 
        { try {  xhr = new XMLHttpRequest();     }
          catch (e3) {  xhr = false;   }
        }
	}
    var xhr2; 
    try {  xhr2 = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) 
    {   try {   xhr2 = new ActiveXObject('Microsoft.XMLHTTP');    }
        catch (e2) 
        { try {  xhr2 = new XMLHttpRequest();     }
          catch (e3) {  xhr2 = false;   }
        }
     }	 
	 
 
    xhr.onreadystatechange  = function()
    {    if(xhr.readyState  == 4)
         {    if(xhr.status  == 200) {
				 if (xhr.responseText == "") {
					 var id_jeu=document.form_commentaire.id_jeu.value;
					 xhr2.open( "POST", "/_ajax_refresh_cadre_commentaires.php?id="+id_jeu, true); 
					 xhr2.send(null); 
				 } else {
	                 alert (xhr.responseText); 
				 }
			  } else {
                 alert ("Erreur : " + xhr.status); 
			  }
         }
    }; 
	
    xhr2.onreadystatechange  = function()
    {    if(xhr2.readyState  == 4)
         {    if(xhr2.status  == 200) {
                 document.getElementById("Cadre_commentaires").innerHTML  = xhr2.responseText;
			  } else {
                 alert ("Erreur : " + xhr2.status); 
			  }
         }
    }; 
	
	
	
	var id_jeu=document.form_commentaire.id_jeu.value;
	var commentaire=document.form_commentaire.commentaire.value;
	xhr.open( "POST", "/_ajax_envoi_commentaire.php?id="+id_jeu+"&commentaire="+commentaire, true); 
	xhr.send(null); 
} 
