String.prototype.endsWith = function(suffix) {
    return this.indexOf(suffix, this.length - suffix.length) !== -1;
};
function decorate_font(link, to_button, change_font, fontname, fontsize, color, colorb, tooltip, tooltipcolor, id, blank)
{
    if(to_button)
    {
       $('a').each(function(){
            var go = $(this).attr("href");
            var title = $(this).html();
            id = id + "_" + parseInt(Math.random()*10000);
            if((go!=undefined)&&(go.endsWith(link)))
            {
                // change to button
                if(change_font)
                {
                    $(this).replaceWith('<button id="'+id+'" style="font-family:'+fontname+';font-size:'+fontsize
                        +';background-color:'+colorb+';color:'+color+';">'+title+'</button');
                }
                else
                {
                    $(this).replaceWith('<button id="'+id+'" >'+title+'</button');
                }
                if(blank) {
                    $("#"+id).click(function(){window.open(go);return false;});
                }
                else {
                    $("#"+id).click(function(){window.location = go;return false;});
                }
                $("#"+id).bt(tooltip,{fill: tooltipcolor,    cornerRadius: 10,     strokeWidth: 0,     shadow: true,     shadowOffsetX: 3,     shadowOffsetY: 3,
                   shadowBlur: 8,     shadowColor: 'rgba(0,0,0,.9)',     shadowOverlap: false,
                   noShadowOpts: {strokeStyle: '#999', strokeWidth: 2},  positions: ['left', 'bottom',] });
            }
       });
    }
    else
    {
        $('a').each(function(){
            var go = $(this).attr("href");
            var title = $(this).html();
            if((go!=undefined)&&(go.endsWith(link)))
            {
                if(change_font)
                {
                     $(this).attr({style:'font-family:'+fontname+';font-size:'+fontsize
                        +';background-color:'+colorb+';color:'+color+';'});
                }
                if(blank)
                {
                    $(this).attr({target:'_blank'});
                }
                $(this).bt(tooltip,{fill: tooltipcolor,    cornerRadius: 10,     strokeWidth: 0,     shadow: true,     shadowOffsetX: 3,     shadowOffsetY: 3,
                   shadowBlur: 8,     shadowColor: 'rgba(0,0,0,.9)',     shadowOverlap: false,
                   noShadowOpts: {strokeStyle: '#999', strokeWidth: 2},  positions: ['left', 'bottom',] });
            }
        });
    }
}



