// ==============================================================================
//  tab.js
//  tab id naming convention: 			tab_[tabname]
// 		   example: <li id="tab_abc">
// 	tab id content naming convention:	[tabname]
// 		   example: <div id="abc">
//  tab hightlight style: class="on"
// 		   example: <li id="tab_abc" class="on">
// ==============================================================================

function Tab(arrTabNames, defaultIndex){
	this.arrTabNames = arrTabNames;
	this.defaultIndex = defaultIndex;	
}
function initTab(oTab){
	var arrTabNames = oTab.arrTabNames;
	tabName = arrTabNames[oTab.defaultIndex];	
	hideOtherTabContent(oTab,tabName);
	show(tabName);
}
function tabon(tabName,oTab){
	hideOtherTabContent(oTab,tabName);
	show(tabName);	
}
function hideOtherTabContent(oTab,not_tabName){ 
	var arrTabNames = oTab.arrTabNames;
	for (i = 0; i <arrTabNames.length; i++){
		var tabName = arrTabNames[i];
		if (tabName != not_tabName){
			hide(tabName); 
		}
	}
}
function show(eleName) {	
	var oTabItem = document.getElementById("tab_"+eleName);
	oTabItem.className="on";
	
	var obj = document.getElementById(eleName);
	obj.style.display = "inline";
}

function hide(eleName) {
	obj = document.getElementById(eleName);
	obj.style.display = "none";
	
	var oTabItem = document.getElementById("tab_"+eleName);
	oTabItem.className="";
}

//eof