$(document).ready(function() {

    $('.entry').each(function() {  
        var id = $(this).attr('id');
        var entry_id = id.replace(/^entry-/,'');
        var permalink = $(this).find("a.entry-link").attr('href');
        if (!permalink) return;
        var sUrl = 'http://graph.facebook.com/'+permalink;
        $.ajax({
            type: 'get',
            url: sUrl,
            dataType: 'jsonp',
            context: $("#fb-likes-"+entry_id),
            success: function(data) {
                var count = '0';
                if (data.shares) count = data.shares.toString();
                $(this).html(count);
                $(this).mouseover(function(){
                    $(this).html('Like');
                    $(this).next().addClass("active");
                    var entry_id = $(this).attr('id').replace(/^fb-likes-/,'');
                    $("#fblikebutton-"+entry_id).show();
                });
            }                
        });
    });

});
