function EnregVote(){
	//On regarde si au moins une réponse est choisi
	var buttons = $('sndRep').getInputs('radio', 'choix');
	var ok=0,option=0;
	buttons.each(function (n){
		if (n.checked == true) {
			ok = 1;
			option = n.value;
		}
	});
	if (ok == 1) {
		var myAjax = new Ajax.Request(
			'/FF/action.php',
			{
				method: 'post',
				parameters: 'F=EnregVote&I='+$F('idSondage')+'&R='+option,
				onComplete: VoteOk
			});
	}
	return false;
}

function VoteOk(org){
	if (org.responseText != 0) {
		var infos = eval('('+org.responseText+')');
		var total=0;
		$('sndRep').innerHTML = '';
		$('validsond').innerHTML = '';
		for(var i=0;i<infos.length;++i){
			total+=parseInt(infos[i]['NB']);
		}
		for(var i=0;i<infos.length;++i){
			$('sndRep').innerHTML += '<div class="repsond"><div>'+unescape(infos[i]['LIB']) + '</div>' +Math.round(infos[i]['NB']/total*100)+'%</div>';
		}
	}
	else {
		$('sndRep').innerHTML = 'Vous avez déjà voté pour ce sondage aujourd\'hui';
	}
}
Event.observe(window,'load',function(){
	Event.observe($('validsond'),'click',EnregVote);
});