//<![CDATA[

/*
 * init_tabs_links() and select_tab() are for the tabs on the homepage
 * 
 */
function init_tabs_links() {
	var list = document.getElementById("searchnav");
	var tabs = list.getElementsByTagName("li");
	for (var i=0; i < tabs.length; i++) {
		var links = tabs[i].getElementsByTagName("a");
		links[0].onclick = function() {
			select_tab(this.parentNode);
			return false;
		}
	}
	return true;
}

function select_tab(tab) {
	// Check if the selected tab is currently active
	if (tab.className.match("on")) {	// if so, do nothing
		return true;
	} else {							// if not, switch classes		
		// change the currently active tab to inactive
		var list = document.getElementById("searchnav");
		var tabs = list.getElementsByTagName("li");
		for (var i=0; i < tabs.length; i++) {
			if (tabs[i].className.match("on")) tabs[i].className = "off";
		}
		// change the selected tab to active
		tab.className = "on";
		// swap the form
		var search = document.getElementById("search");
		var forms = search.getElementsByTagName("form");
		for (i=0; i < forms.length; i++) {
			if (forms[i].className.match("on")) forms[i].className = "off";
			if (forms[i].id == tab.id) forms[i].className = "on";
		}
		return true;
	}
	
	// Just in case, return
	return true;
}

addLoadEvent(init_tabs_links);

//]]>