$(document).ready(function(){
  var vote = function (data) {
  
    var result = Gallerix.parseJson(data);
    
    if (result['success']) {
      Gallerix.setStatus(result['result'], 2000);
    
    }
    else {
      Gallerix.setError(result['result'], 2000);
    }

    $('#gvote-gallerix-widget-votes').html(result['votes']);        
    Gallerix.clearCache(Gallerix.pid); 
  }

  $('#gallerix-gvote-link-up').click(function() {
    $.get(this.href + Gallerix.pid + "/1", null, vote);
    
    return false;
  });

  $('#gallerix-gvote-link-down').click(function() {
    $.get(this.href + Gallerix.pid + "/0", null, vote);
    return false;
  });    
 
});