var tabCount = 4; // how many tabs
	var selTab = 1; // default to first tab
	var tabPlay = false; // autoplay
	var tabSecs = 3; // seconds per tab in autoplay

	function InitTabs() {
		document.getElementById("tcontent1").style.display = "block";
		document.getElementById("ttab1").className = "selected";
		for (loop=2;loop<=tabCount;loop++) {
			document.getElementById("tcontent"+loop).style.display = "none";
			document.getElementById("ttab"+loop).className = "";
		}		
		AutoOn();
	}

	function ShowTab(x) {
		document.getElementById("tcontent"+x).style.display = "block";
		document.getElementById("ttab"+x).className = "selected";
		if (x!=selTab) {
			document.getElementById("tcontent"+selTab).style.display = "none";
			document.getElementById("ttab"+selTab).className = "";
			selTab = x;
		}
	}
	
	function TabClick(x) {
		AutoOff();
		ShowTab(x);
	}
			
	function NextTab() {
		AutoOff();
		if (selTab+1<=tabCount) {
			ShowTab(selTab+1);
		} else {
			ShowTab(1);
		}
	}

	function PrevTab() {
		AutoOff();
		if (selTab-1>0) {
			ShowTab(selTab-1);
		} else {
			ShowTab(tabCount);
		}
	}
	
	function AutoTab() {
		if (selTab+1<=tabCount) {
			ShowTab(selTab+1);
		} else {
			ShowTab(1);
		}
	}
	
	function AutoToggle() {
		if (tabPlay) {
			AutoOff();
		} else {
			AutoOn();
		}
	}
	
	function AutoOff() {
		if (tabPlay) {
			clearInterval(tabInt);
			tabPlay = false;
			// change to play icon?
		}
	}

	function AutoOn() {
		if (!tabPlay) {
			tabInt = setInterval(AutoTab, tabSecs*1000);
			tabPlay = true;
			// change to pause icon?
		}
	}	