/// This function is called by Bazaarvoice to display the reviews tab. The tab control is referenced with
/// hard-coded strings here so Bazaarvoice does not need to make changes if our ID changes for any reason.
function ShowReviews(){
  SelectTab('ProductInfoTabs_tabs', 'ProductInfoTabs_ReviewTab');
 }
 
function SelectTab(tabControlID, tabID){
  $(function() {$('#' + tabControlID + ' > ul').tabs('select', '#' + tabID);});
 }
 
 function createWriteReviewLink(){
	var srcLink = document.getElementById('BVSubmissionURL');
	var destLink = document.getElementById('WriteFirstReviewLink');
	if (srcLink && destLink){
		destLink.href = srcLink.href;
	}
 }
 
 // Display the number of reviews for the product next to the Product Reviews tab (as part of the tab name)
 function ShowReviewCount(reviewCount){
	var tabHeader = $("a#ProductInfoTabs_ReviewTab_link span");
	var tabHeaderText = $(tabHeader).html();
	// Check for a custom attribute.  If it's set, that means we've already appended the number of reviews to this tab name.
	// Otherwise it's possible for the number of reviews to continue to be appended with any interaction with the Bazaarvoice
	// content in the div.  For example, changing the Sort value creates another request to Bazaarvoice, causing this
	// function to be called again.
	if ($(tabHeader).attr("reviewCountDisplayed") != "true"){
		$(tabHeader).html(tabHeaderText + "(" + reviewCount + ")");
		$(tabHeader).attr("reviewCountDisplayed","true");
	}
 }