// This function assumes that content for each tab corresponds to a direct child
// node of the specified content container
//
// And that each tab corresponds to a direct child node of the specified
// tab container
//
// Target tab ID is passed in, as opposed to the target tab itself in other implementations,
// to facilitate a generated Bazaar Voice script
function OnTabClicked(tabContentContainerID, targetTabContentID, targetTabID, otherTabIDsArray)
{
	var tabContentContainer = document.getElementById(tabContentContainerID);
	
	if(tabContentContainer)
	{
		var targetTabContent = document.getElementById(targetTabContentID);
		
		for(var i = 0; i < tabContentContainer.childNodes.length; i++)
		{
			// This filters the childNodes to legitimate html controls
			if(tabContentContainer.childNodes[i].tagName && tabContentContainer.childNodes[i].tagName.length > 0)
			{
				if(targetTabContent && targetTabContent == tabContentContainer.childNodes[i])
				{
					tabContentContainer.childNodes[i].style.visibility = "visible";
					tabContentContainer.childNodes[i].style.display = "";
				}
				else
				{
					tabContentContainer.childNodes[i].style.visibility = "hidden";
					tabContentContainer.childNodes[i].style.display = "none";
				}
			}
		}
	}
	
	var targetTab = document.getElementById(targetTabID);
	
	if(targetTab && targetTab.className.indexOf("Selected") < 0)
	{
		targetTab.className = targetTab.className + "Selected";
	}
	
	for(var j = 0; j < otherTabIDsArray.length; j++)
	{
		var otherTab = document.getElementById(otherTabIDsArray[j]);
		
		if(otherTab)
		{
			otherTab.className = otherTab.className.replace("Selected", "");
		}
	}
}