function TabSet(id,forcetabid) {
	this.id = id;
	this.current = null;

	if(document.getElementById) {
		var activeCk = 'Programs'; // used to keep tab state on back button
		if(location.href.indexOf("tab=") >= 0) activeCk = "urldefined";
		else if(forcetabid) activeCk = forcetabid;
		var tabset = document.getElementById(id);
		var tabs =  tabset.getElementsByTagName("h3");
		var tabheads = document.createElement("div");
		tabheads.className = "tabGrp";
		for(var i = tabs.length-1; i >= 0 ; i--) {
			var tab = document.createElement("div");
			tab.tabset = this;
			tab.panel = tabs[i].parentNode;
			tab.className = "tab-head";
			tabs[i].style.display = "none";
			var txt = tabs[i].firstChild.nodeValue;
			tab.appendChild(document.createTextNode(txt));
			tabheads.insertBefore(tab,tabheads.firstChild);
			tab.onclick = onClickTab;

			if((location.href.indexOf("tab="+i) >= 0) || (activeCk == null && i == 0) || (activeCk != null && activeCk == txt)) {
				tab.className += " selected";
				this.current = tab;
			} else { 
				tab.panel.style.display = "none";
			}
			tab.innerHTML = '<span class="sub_menu">' + tab.innerHTML + '</span>';
			if(i != tabs.length-1) tab.innerHTML += " ";
		}
		tabset.insertBefore(tabheads,tabset.firstChild);
	}

	function onClickTab() {
		if(this.className.indexOf("selected") < 0) {
			var current = this.tabset.current;
			if(current != null) {
				current.panel.style.display = "none";
				current.className = current.className.replace(" selected","");
			}
			this.panel.style.display = "block";
			this.className += " selected";
			this.tabset.current = this;
			document.cookie = "tabset-" + this.tabset.id + "=" + this.firstChild.nodeValue;
		}
	}

}