// JavaScript Document


var xhr = null;
 
// Fonction de creation de l'objet XMLHttpRequest qui resservira pour chaques fonctions AJAX
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, veuillez le mettre à jour"); 
    xhr = false; 
   } 
 }







function afficheEtoile(msg)
 {
  getXhr();
  xhr.onreadystatechange = function()
   {
    if(xhr.readyState == 4 && xhr.status == 200)
     {
		
      //document.getElementById('content').innerHTML = xhr.responseText;
	  document.getElementById('etoile').innerHTML = xhr.responseText;
	  
	  //alert(xhr.responseText); 
	  
	  
     }
	 
	 
   }
  
  xhr.open("POST",'ajax/voter2.php',true);
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  xhr.send("nbEtoile="+msg);
 }


function voter(numero){
	

getXhr();
  xhr.onreadystatechange = function()
   {
    if(xhr.readyState == 4 && xhr.status == 200)
     {
		
      
	  document.getElementById('resultats').innerHTML = xhr.responseText;
	  
	  
	  
	  alert("Merci d'avoir pris le temps de participer à ce sondage");
     }
	 
	 
   }
  
  xhr.open("POST",'ajax/voter3.php',true);
  xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  xhr.send("nbEtoile="+ numero);
  




}











