var tab_act = 0;

function do_tab(n)
{
	if(n == tab_act) return;
	
	var t = document.getElementById('tab_' + n);
	if(t == null) return;
	
	t.style.display = 'block';
	document.getElementById('tab_' + tab_act).style.display = "none";
	
	tab_act = n;
	
	var m = document.getElementById('tab_menu');
	
	var s = "";
	var tabs;
	if(location.href.indexOf('about.html') >= 0) {
		tabs = ["People", "Mission", "Partnerships"];
	} else if(location.href.indexOf('resources.html') >= 0 || location.href.indexOf('resources_tmp.html') >= 0) {	
		tabs = ["RISE Programs", "Science Education Resources", "Duke K-12 Science Education Programs"];
	} else return;

	for(var i = 0; i < tabs.length; i++) {
		if(i == n) {
			s += tabs[i];
		} else {
			s += '<a href="javascript:do_tab(' + i + ')">' + tabs[i] + '</a>';
		}
		if(i < tabs.length - 1) {
			 s += ' | ';
		}
	}
	m.innerHTML = s;
}

function init()
{
	if(location.href.indexOf('about') >= 0 || location.href.indexOf('resources') >= 0) {
		if(location.search.length > 1) {
			tab_act = parseInt(location.search.substr(1));
			if(!isNaN(tab_act) && tab_act != 0) {
				var n = tab_act;
				tab_act = 0;
				do_tab(n);
			}
		}
	}
}


