#Const Version		"2013-01-29"
#Const ScriptName	"TabsClient.Script.txt"

/* ------------------------------------- */
/** Return the version number of the script
 *
 *	@return		The version number of the script
 */
Text GetScriptVersion() {
	return Version;
}

/* ------------------------------------- */
/** Return the name of the script
 *
 *	@return		The name of the script
 */
Text GetScriptName() {
	return ScriptName;
}

/**
 * Called By the client UI.
 * Update a Manialink page, showing the frame of [Page] with Id [FrameTabId]
 * iff the tab [TabKey] is selected.
 * @param UI		 	UI of the player (variable "UI" in client manialink).
 * @param Page 			Manialink page containing the tab page (assumably variable "Page" in client manialink).
 * @param TabKey 		The key associated to this tab, as defined in CreateTabPaneLayer.
 * @param FrameTabId	Id of the frame containing the tab page.
 */
Void UpdateFrameTab(CUIConfig UI, CMlPage Page, Text TabKey, Text FrameTabId)
{
	declare netread Boolean _TabsLib_UseTabs for UI;
	if (! _TabsLib_UseTabs) return;
	
	declare Boolean _TabsLib_ScoresLayerIsVisible 	for UI;
	declare Boolean _TabsLib_AltLayerIsVisible 		for UI;
	declare Text 	_TabsLib_CurrentTab 			for UI;
	declare netread Text _TabsLib_ScoresTableTab 	for UI;
	
	declare Boolean ShowCurrentTab = _TabsLib_AltLayerIsVisible && (_TabsLib_CurrentTab == TabKey);
	
	if(TabKey == _TabsLib_ScoresTableTab) 
	{
		// log("_TabsLib_ScoresTableTab: "^_TabsLib_ScoresTableTab);
		ShowCurrentTab = _TabsLib_ScoresLayerIsVisible || 
			(_TabsLib_AltLayerIsVisible && (_TabsLib_CurrentTab == _TabsLib_ScoresTableTab));
	}

	declare MainFrame <=> (Page.GetFirstChild(FrameTabId) as CMlFrame);
	if(MainFrame == Null) return;
	
	if(ShowCurrentTab) {
		MainFrame.Show();
	}
	else {
		MainFrame.Hide();
	}
}


