
$(function(){var conf={url:'/_backend/sondaggi.php'}
var voto=0;$('#votaSondaggio').submit(function(){voto=$("#votaSondaggio :radio[name='voto']").fieldValue()[0];if(voto){$(this).ajaxSubmit({url:conf.url+'?funct=vota',dataType:'json',type:'get',clearForm:false,success:function(r){if(r['result']){var tot=parseInt($('#totale').text())+1;var qnt_voto=parseInt($('#voti-'+voto).text())+1;$('#totale').text(tot);$('#voti-'+voto).text(qnt_voto);$('#sondaggi tbody tr').each(function(){var perc=Math.round((parseInt($('td[id^=voti-]',this).text())/tot)*100);$('.percentuale',this).text(perc+' %');$('span.barra',this).width((perc<5?3:perc)+'%');});$('#sondaggi form').children().insertBefore('#sondaggi form').end().remove();$('#sondaggi table td.radio').empty();$('#voto span').hide();$('#voto .sondaggio-msg-ok').show();$('#sondaggi div.didascalia').fadeOut('slow',function(){$(this).text('Grazie per aver votato questo sondaggio. Questi sono i risultati aggiornati.').hide().fadeIn('slow');});}
else{voto=0;$('#voto span').hide();$('#voto a').show();$('#votaSondaggio :input').removeAttr('disabled');}}});$('#votaSondaggio :input').attr('disabled','disabled');$('#voto a').hide();$('#voto .sondaggio-msg-submit').show();}
else{alert('Seleziona un\'opzione del sondaggio per votare');}
return false;});$('#voto').html('<a href="#">Vota</a>').children().click(function(){$('#votaSondaggio').submit();return false;}).css('text-decoration','none');$('#voto').append('<span class="sondaggio-msg-submit">Sto registrando il voto</span>').append('<span class="sondaggio-msg-ok">Grazie per aver votato</span>').append('<span class="sondaggio-msg-error">Hai gi&agrave; votato</span>');$('#voto span').hide();});
