var TCKVotingMachine = Class.create();

TCKVotingMachine.prototype= {

  initialize: function(id) {
     this.id = id;
   } 

  
}

var TCKVoting = {

  sendPostIds: function() {
 		  this.post_ids = post_ids;
  		var request = 'ap/ratings/votes';
  		var url = request;
  		new Ajax.Request(url, { 
  				method: 'post',
  				parameters: {post_ids: post_ids},
  				onSuccess: function(transport){
  			    TCKVoting.parseJSONResponse(eval(transport.responseText));
  			 	}

  		});

  },
	
  parseJSONResponse: function(post_ids) {

  			post_ids.each(function(s){
  				//console.log(s);
  				TCKVoting.showVotes(s);
  			})
  },
  			

  showVotes: function(post_id) {
    
    id = post_id[0];
    vote_count = post_id[1];
    user_votable = post_id[2];
 	  vote_div = "post-vote-" + id;
	  vote_img_div = "post-vote-img-" + id;
	  vote_count_div = "post-vote-count-" + id;
  
	  //console.log("Div: "+vote_img_div+" / Votos: "+vote_count)

	  if (user_votable == true) {
		  $(vote_img_div).show();	    
		}
 
    document.getElementById(vote_count_div).innerHTML = vote_count;
    $(vote_div).show();

	}


}
	
	
