//##############################MOTEUR AJAX 1############################################
function jouer() {   
	 $.ajax({
        type: 'POST',
        url: 'gainAleatoire.php',
        data: "nom="+ $('#nom').val(),
		dataType:'xml',
        success: actualiserPage,
        error: function() {alert('Erreur serveur');}
              }); 
	 
  }
  function actualiserPage(reponse) {
	 var gain=$(reponse).find('gain').text();	
	 $('#resultat').html(gain);
								
	 var gagnant=$(reponse).find('nom').text();	
	 $('#gagnant').html(gagnant);
								
	 //affiche la zone info
	 $('#info').css("visibility", "visible");
	   
  }


$(document).ready(function() {
$('#button').click(function () {jouer();});
//gestion du bouton 
$('#button').ajaxStart(function(request, settings) { $(this).attr("disabled",true) });						$('#button').ajaxStop(function(request, settings){ $(this).attr("disabled",false) });   
//gestion du chargeur
$('#charge').ajaxStart(function(request, settings) { $(this).css("visibility", "visible") });
$('#charge').ajaxStop(function(request, settings){ $(this).css("visibility", "hidden") });
});

