// JavaScript Document
function TabGroup(id, linkElement, hx)
{
//private
	var _tabscontainer = null, 
		_tabs = null, 
		_active = null, 
		_hx = hx;
	
	function getPageId(href)
	{
		return href.substr(href.indexOf("#") + 1);
	}
	
	function initTab(a, group, index)
	{
		a.group = group;
		a.index = index;
		a.page = document.getElementById(getPageId(a.href));
		a.onclick = function ()
		{
			this.group.activatePage(this.index);
			this.blur();
			return false;
		};
	}
	
	function hidePage(tab)
	{
		tab.page.style.display = "none";
		tab.className = "";
	}
	
	function showPage(tab)
	{
		tab.page.style.display = "";
		tab.className = "Current";
	}
	
	function hideHeadings(tab)
	{
		var hs = tab.page.getElementsByTagName(_hx);
		
		for (var i = 0; i < hs.length; i++)
		{
			var h = hs[i];
			
			h.style.display = "none";
		}
	}
	
	function showHeadings(tab)
	{
		var hs = tab.page.getElementsByTagName(_hx);
		
		for (var i = 0; i < hs.length; i++)
		{
			var h = hs[i];
			
			h.style.display = "";
		}
	}

//public
	this.activatePage = function (index)
	{
		var tab = _tabs[index];
		
		if (_active) { hidePage(_active); }
		showPage(tab);
		_active = tab;
	}

//construction
	_tabscontainer = document.getElementById(id);
	_tabs = _tabscontainer.getElementsByTagName(linkElement);
	
	for (var i = 0; i < _tabs.length; i++)
	{
		var tab = _tabs[i];
		
		initTab(tab, this, i);
		if (_hx) { hideHeadings(tab); }
		hidePage(tab);
	}
}