var bccsCountsHelpers={profileServerUrl:function(){if(window.location.host.match(/stage/)){var a="profile-stage"}else{var a="profile"}return"http://"+a+"."+bccsCountsHelpers.domain()},domain:function(){var b=window.location.host.split(".");var a=b[b.length-1];var c=b[b.length-2];return c+"."+a},commentCountUrl:function(){return bccsCountsHelpers.profileServerUrl()+"/comment_counts.json"},canonicalDomain:function(){if(typeof(bccs_canonical_domain)=="undefined"){return window.location.host}else{return bccs_canonical_domain}},cleanUrl:function(b){var a=b.indexOf("#");var c=b.indexOf("?");if(a!=-1){b=b.substring(0,a)}else{if(c!=-1){b=b.substring(0,c)}}return b},normalizeUrl:function(b){var a=bccsCountsHelpers.cleanUrl(b);if(bccsCountsHelpers.isFullUrl(a)){return a}else{return window.location.protocol+"//"+bccsCountsHelpers.canonicalDomain()+a}},isFullUrl:function(a){if(a.match(/http:\/\//)){return true}else{return false}}};var bccsCounts={initialize:function(){if(bccsCounts.commentableUrls().length>0){bccsCounts.getCommentCounts()}},commentableUrls:function(){var a=[];$(".bccs-comments-link").each(function(){var b=bccsCountsHelpers.normalizeUrl($(this).attr("href"));a.push(b)});return a},getCommentCounts:function(){$.ajax({url:bccsCountsHelpers.commentCountUrl(),dataType:"jsonp",data:{commentable_urls:bccsCounts.commentableUrls().join(",")},success:function(a){$(".bccs-comments-link").each(function(){var c=bccsCountsHelpers.normalizeUrl($(this).attr("href"));var b=a[c];$(this).html(b+"&nbsp;Comments")})}})}};$(document).ready(bccsCounts.initialize);