$(document).ready(function() { 
    ajax_dispatcher = "/ajax/dispatcher.php";
    
    $("a.bookmark").click(function(e) {
        e.preventDefault();
        $this = $(this);
        id = $this.attr('id').substr(11);
        favorito = ($this.hasClass('active')) ? 0 : 1;
        
        datos = { 'id_entrada' : id, 'favorito' : favorito }
        send = { 'referer' : 'common', 'action': 'articulo_favorito', 'data' : datos }                
        $.getJSON(ajax_dispatcher, send, function(data) {
            if(data.sucess == 'ok') {
                if(favorito == 1)
                    $this.addClass("active").attr('title',"Quitar de favoritos");
                else
                    $this.removeClass("active").attr('title',"Añadir a favoritos");
            }
        });        
    });
});

