
$(document).ready(function(){
  
  $('.rating').one('click', function() {
    var now = new Date().getTime();
    /*
    if ($.cookie('rate') > now - (3600 * 24)) {
      alert("vous ne pouvez voter qu'une fois par jour");
      return false;
    }
    */
    
    $.post(document.location.url, {
      post_rate: 1,
      rating: 1,
      post_id: $(this).parents('.post').attr('id').split('post-')[1],
    }, function (content) {
      $.cookie('rate', now, {expires: 1});
      alert('merci de votre participation !');
      //alert(content);
      return true;
    }, 'text');
    
    $(this).html( $(this).attr('result_rate') || 'à voté !');
    
    return false;
  });
  
  /*
	$('.rating').rating({
    maxvalue:5,
    increment:.5,
	  callback: function(rating) {
	    $.post(document.location.url, {
	      post_rate: 1,
	      rating: rating,
	      post_id: $(this).parents('.post').attr('id').split('post-')[1],
      }, function (content) {
        alert(content);
      }, 'text');
      alert($(this).parents('.post').attr('id').split('post-')[1]);
      return false;
	  }
	});
	*/
});