function VoterOui( id_jeu )
{	
	var url = 'notation.php';
	var NotePlus = 'jeu=' + id_jeu +'&note_plus_vote=1';
	new Ajax.Request( url, { method: 'get',
							async: false,
							parameters: NotePlus,
							onLoading: function () { $('PaveNotation').innerHTML = '<br /><br /><img src="css/images/loading.gif">';},
							onSuccess: function (rep) { NotationOK(rep.responseText); },
							onFailure: function () { alert( msg_erreur ); } } );
}

function VoterNon( id_jeu )
{	
	var url = 'notation.php';
	var NotePlus = 'jeu=' + id_jeu +'&note_plus_vote=0';
	new Ajax.Request( url, { method: 'get',
							async: false,
							parameters: NotePlus,
							onLoading: function () { $('PaveNotation').innerHTML = '<br /><br /><img src="css/images/loading.gif">';},
							onSuccess: function (rep) { NotationOK(rep.responseText); },
							onFailure: function () { alert( msg_erreur ); } } );
}

function NotationOK(rep)
{
	// Récupération des données
	json = rep.evalJSON(true);
	
	var html ='<table><tr><td style="text-align:left;"><small>'+like_yes+'</small></td><td style="text-align:right;"><small>'+like_no+'</small></td></tr><tr><td style="color: #000; background-image:url(css/images/vote_oui_bg.gif); height:12px; width:'+json.npluscent+'%;"><b>'+json.npluscent+'%</b></td><td style="color: #000; background-image:url(css/images/vote_non_bg.gif); height:12px; width:'+json.nmoinscent+'%;" ><b>'+json.nmoinscent+'%</b></td></tr><tr><td colspan="2">'+nbre_notes1+'<b>'+json.nb_notes+'</b>'+nbre_notes2+'</td></tr><tr><td colspan="2"><div class="PasNote">'+merci_vote+'</div></td></tr></table>';
		
	// Sauvegarde cookie
	if (document.cookie.match(/notation=/))
	{
		splits = document.cookie.split(';');
		for(i = 0; i < splits.length; i++)
		{
			if(splits[i].match(/notation=/)){favstring = splits[i].replace('notation=', '');}
		}
		var favstring = favstring+'#'+json.game_id+'#.';
		document.cookie = "notation="+favstring+"; expires=01/01/2028 00:00:00; path=/;";
	}
	else
	{
		var favstring = '#'+json.game_id +'#.';
		document.cookie = "notation="+favstring+"; expires=01/01/2028 00:00:00; path=/;";
	}
		
	$('PaveNotation').innerHTML = html;
}

function fav(gameid)
{
	if (document.cookie.match(/favoris=/))
	{
		splits = document.cookie.split(';');
		for(i = 0; i < splits.length; i++)
		{
			if(splits[i].match(/favoris=/)){favstring = splits[i].replace('favoris=', '');}
		}
		if (favstring.indexOf('#'+gameid+'#')!=-1)
		{
			var favstring = favstring.replace('#'+gameid+'#.', '');
			if(favstring == " "){document.cookie = "favoris="+favstring+"; expires=01/01/2007 00:00:00; path=/;";}
			else{document.cookie = "favoris="+favstring+"; expires=01/01/2028 00:00:00; path=/;";}
			var state = 'unadded';
		}
		else
		{
			var favstring = favstring+'#'+gameid+'#.';
			document.cookie = "favoris="+favstring+"; expires=01/01/2028 00:00:00; path=/;";
			var state = 'added';
		}
	}
	else
	{
		var favstring = '#'+gameid +'#.';
		document.cookie = "favoris="+favstring+"; expires=01/01/2028 00:00:00; path=/;";
		var state = 'added';
	}
	if(state === 'added'){alert(fav_add_msg);}
	else{alert(fav_ret_msg);}
}


