
var shareButtons = function(parent_el) {
    $('.targets a', parent_el).unbind('click').click(function() {
        var $el = $(this);
        var slug = $el.attr('slug');
        var href = $el.attr('href');
        $.ajax({
            url: '/share',
            type: 'POST',
            data: { slug: slug },
            success: function(result) {
                href = href.substr(4);
                var new_url = 'http'+href.replace(/http.+?$/, result);
                $el.attr('href', new_url).unbind('click');
                document.location = new_url;
            }
        });
        return false;
    });
}

