// JavaScript Document

function ajoutJeuFavoris(id_jeu)
{ 
    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 == "") {
					 xhr2.open( "POST", "/_ajax_refresh_cadre_favoris.php", true); 
					 xhr2.send(null); 
				 } else {
	                 alert (xhr.responseText); 
				 }
			  } else {
                 alert ("Erreur : " + xhr.status); 
			  }
         }
    }; 
	
    xhr2.onreadystatechange  = function()
    {    if(xhr2.readyState  == 4)
         {    if(xhr2.status  == 200) {
         				 alert ("Le jeu a bien été ajouté aux favoris"); 
                 document.getElementById("Cadre_favoris").innerHTML = xhr2.responseText;
			  } else {
                 alert ("Erreur : " + xhr2.status); 
			  }
         }
    }; 
	
	
	xhr.open( "POST", "/_ajax_ajout_jeu_favoris.php?id="+id_jeu, true); 
	xhr.send(null); 
} 
