/*global jQuery */
(function($) {

    $.fn.urlBookmarkRewriter = function(params) {

        params = $.extend({ }, params);

        return this.each(function() {
            var $_this = $(this);
            var bookmark = $(".bookmark", $_this);
            var links = $("a:not(.favorite)", $_this);
            var bid = bookmark.attr("href");

            if (bid) {
                links.click(function () {
                    var hrf = window.location.href.split("#")[0];
                    window.location.href = hrf + bid;
                });
            }
        });
    };

})(jQuery);