


function tabCls(jsId, tableid) {
	this.jsId = jsId;
	this.activeTab = null;
	this.activeTabId = null;
	this.tabsTableId = tableid;
	this.tabsTableObj = document.getElementById(tableid);
	this.tabs = new Object();
	this.tabsIndex = new Object();
	this.tabs["items"] = 0;
	
	this.tabsTableRow0C0 = this.tabsTableObj.rows[0].cells[0];
	this.tabsTableRow2C0 = this.tabsTableObj.rows[2].cells[0];
	this.tabsTableRow2C1 = this.tabsTableObj.rows[2].cells[1];
	this.tabsTableRow2C2 = this.tabsTableObj.rows[2].cells[2];
	this.tabsTableRow0C0.style.backgroundPosition = (this.tabsTableObj.clientWidth - 600) + "px 0px";
	this.tabsTableRow2C0.style.backgroundPosition = "0px " + (this.tabsTableRow2C0.clientHeight - 1000) + "px";
	this.tabsTableRow2C1.style.backgroundPosition = this.tabsTableRow2C0.style.backgroundPosition;
	this.tabsTableRow2C2.style.backgroundPosition = this.tabsTableRow2C0.style.backgroundPosition;
	var winLoc = window.location.href.toString();
	var winLocLen = 1 * winLoc.length;
	//this.isIE = /MSIE/gim.test(navigator.userAgent);
	
	this.addTab = function(tabid, contentid) {
		//alert("add start");
		this.tabs[tabid] = {
			"tabid" : tabid,
			"tabObj" : document.getElementById(tabid),
			"contentid" : contentid,
			"contentObj" : document.getElementById(contentid)
		};
		this.tabsIndex[this.tabs.items] = tabid;
		var tabs = this.tabs;
		var tab = tabs[tabid];
		var tabObj = tab.tabObj;
		var jsCls = eval(this.jsId);
		tab.tabObj.onmouseover = function() {
			//tab.tabObj.style.fontWeight = "bold";
			//tab.tabObj.style.fontStyle = "italic";
			tab.tabObj.childNodes[0].style.textDecoration = "underline";
		}
		tab.tabObj.onmouseout = function() {
			//tab.tabObj.style.fontWeight = "";
			//tab.tabObj.style.fontStyle = "";
			tab.tabObj.childNodes[0].style.textDecoration = "none";
		}
		tab.tabObj.onclick = function() {
			if (jsCls.activeTab != null) {
				if (jsCls.activeTab == jsCls.tabs[jsCls.tabsIndex[0]].tabObj)
					jsCls.activeTab.style.backgroundPosition = "0px -62px";
				else
					jsCls.activeTab.style.backgroundPosition = "0px 0px";
				jsCls.activeTab.childNodes[0].style.backgroundPosition = (jsCls.activeTab.clientWidth - 10) + "px 0px";
				jsCls.activeTab.childNodes[0].style.color = "#1B3765";
				jsCls.tabs[jsCls.activeTabId].contentObj.style.display = "none";
			}
			if (tabObj == jsCls.tabs[jsCls.tabsIndex[0]].tabObj)
				tabObj.style.backgroundPosition = "0px -93px";
			else
				tabObj.style.backgroundPosition = "0px -31px";
			tabObj.childNodes[0].style.backgroundPosition = (tab.tabObj.clientWidth - 10) + "px -31px";
			tabObj.childNodes[0].style.color = "#ffffff";
			tab.contentObj.style.display = "block";
			tab.contentObj.style.top = 0;
			jsCls.activeTab = tabObj;
			jsCls.activeTabId = tabid;
			// Set window.location !!
			//alert(/MSIE/gim.test(navigator.userAgent));
			/*
			if (/MSIE/gim.test(navigator.userAgent)) {
				//window.location.hash = tabid;
			}
			else {
				var newWinLoc = window.location.toString();
				if (newWinLoc.indexOf("#") > -1)
					newWinLoc = newWinLoc.substr(0, newWinLoc.indexOf("#")) + "#" + tabid;
				else
					newWinLoc += "#" + tabid;
				window.location.replace(newWinLoc);
			}
			*/
			return true;
		}
		this.tabs.items++;
		if (this.tabs.items > 1) {
			tab.tabObj.style.backgroundPosition = "0px 0px";
			tab.tabObj.childNodes[0].style.backgroundPosition = (tab.tabObj.clientWidth - 10) + "px 0px";
			tab.tabObj.childNodes[0].style.color = "#1B3765";
			tab.contentObj.style.display = "none";
			if (winLoc.substr(winLocLen - (tabid.length + 1), tabid.length + 1) == "#" + tabid) {
				tab.tabObj.onclick();
			}
		}
		else {
			tab.tabObj.style.backgroundPosition = "0px -93px";
			tab.tabObj.childNodes[0].style.backgroundPosition = (tab.tabObj.clientWidth - 10) + "px -31px";
			tab.tabObj.childNodes[0].style.color = "#ffffff";
			tab.contentObj.style.display = "block";
			tab.contentObj.style.top = "0px";
			//tab.contentObj.style.posTop = 0;
			jsCls.activeTab = tab.tabObj;
			jsCls.activeTabId = tabid;
		}
		//alert("add end");
		return this.tabs[tabid];
	}
}


