function vote(id, vote) {

         var url = 'ajax/vote.php';
         var ajax = new sack();

         ajax.requestFile = url;
         
         ajax.setVar( 'id', id );
         ajax.setVar( 'vote', vote );
         
         ajax.onCompletion = function(){ vote_finished(ajax, id, vote); };
         ajax.runAJAX();
}

function vote_finished( ajax, id, vote ) {

         var response = ajax.response;
         
         if ( response.length ) {
            
            if (vote == 'up' && response != 'error') document.getElementById('vote_up_count').innerHTML = response;
            if (vote == 'down' && response != 'error') document.getElementById('vote_down_count').innerHTML = response;
            
            if (response == 'error') alert("Tuto odpověď jste již hodnotili.");
            
         }
}
