var tabBox = new Object();
tabBox.id = null;
tabBox.tabs = new Array();
tabBox.pages = new Array();
tabBox.current = 0;

document.ready(initTabBox);
function initTabBox()
{
	tabBox.id = document.getElementById('tabbox');
	if (tabBox.id == null || tabBox.id == "undefined" || tabBox.id == undefined)
		return;

	for (var i=0 ; i < 10 ; i++)
	{
		var tab = document.getElementById('tab' + i);
		var title = document.getElementById('tabtitle' + i);
		var page = document.getElementById('tabpage' + i);

		if (tab == null)
			break;

		tab.onclick = tabClick;
		tab.number = i;

		title.style.width = title.offsetWidth + "px";
		title.className = "tabtitle normal";

		tabBox.tabs.push(tab);
		tabBox.pages.push(page);
	}

	if (tabBox.tabs[0] != null)
		selectTab(0);
}

function tabClick(e)
{
	if (!e) var e = window.event

	selectTab(this.number);
}

function selectTab(number)
{
	tabBox.tabs[tabBox.current].className = "tab";
	tabBox.pages[tabBox.current].className = "tabpage";

	tabBox.tabs[number].className = "tab current";
	tabBox.pages[number].className = "tabpage current";

	tabBox.current = number;
}
