/* Share buttons */
$(function() {

post_loc = post_loc.replace(/\#([A-Za-z0-9-]+)/, '');

// if (enable_fb == 'on') {
//     $.ajax({
//         type: 'GET',
//         url: "http://api.facebook.com/restserver.php?method=links.getStats&format=json&urls=" + post_loc,
//         dataType: 'jsonp',
//         success: function(json) {
//             $.each(json,
//             function(i, items) {
//                 var count = items["share_count"];
//              $('#facebook-share .count').html('<span class="count">(' + count + ')</span>');
//             });
//         }
//     });
// }

if (enable_twitter == 'on') {
    $.ajax({
        type: 'GET',
        dataType: "jsonp",
        url: "http://api.tweetmeme.com/url_info.jsonc?url=" + post_loc,
        success: function(json) {
            var status = json["status"];
            if (status == "failure") {
				$('#tweetmeme-share .count').html('<span class="count">(0)</span>');
            } else {
                var json = json["story"];
                var count = json["url_count"];
				$('#tweetmeme-share .count').html('<span class="count">(' + count + ')</span>');
            }
        }
    });
}

if (enable_digg == 'on') {
    $.ajax({
        type: 'GET',
        dataType: 'jsonp',
        url: "http://services.digg.com/1.0/endpoint?method=story.getAll&type=javascript&link=" + post_loc,
        success: function(json) {
            var count = json["count"];
            if (count == 0 | count == undefined) {
				$('#digg-share .count').html('<span class="count">(0)</span>');
            } else {
                var diggs = json["stories"][0]["diggs"];
				$('#digg-share .count').html('<span class="count">(' + diggs + ')</span>');
            }
        }
    });
}

});
