//dynamic top navigation
initPage = function() {
	var navRoot = document.getElementById("navigation");
	var lis = navRoot.getElementsByTagName("li");
	var curItem = "";
	for (var i=0; i<lis.length; i++)
	{
		if (lis[i].parentNode.id == "navigation")
		{
			if (lis[i].className.indexOf('active') != -1) curItem = lis[i];
			lis[i].onmouseover = function()
			{
				this.className += " hover";
				if ((this.getElementsByTagName("ul").length != 0 )&&(this != curItem))
					curItem.className += " hidden-sub";
			}
			lis[i].onmouseout = function()
			{
				this.className = this.className.replace("hover", "");
				if ((this.getElementsByTagName("ul").length != 0 )&&(this != curItem))
					curItem.className = curItem.className.replace("hidden-sub", "");
			}
		}
	}
}
if (window.addEventListener)
	window.addEventListener("load", initPage, false);
else if (window.attachEvent)
	window.attachEvent("onload", initPage);

//tab switcher (shamelessly borrowed from expressionengine.com homepage, hope they don't mind :)

	var lastTabId = 1;

function tab_switch(id)
{
	document.getElementById('section' + lastTabId).style.display = 'none';
	document.getElementById('section' + id).style.display = 'block';
	lastTabId = id;
	
	var ourTabs = document.getElementById('middle-nav').getElementsByTagName("li");
	
	for(var i = 0; i < ourTabs.length; i++)
	{
		if ((i + 1) == id)
		{
			ourTabs[i].className = 'tabOn' + (i+1);
		}
		else
		{
			ourTabs[i].className = 'tab' + (i+1);
		}
	}
}

function blurAnchors(){
  if(document.getElementsByTagName){
    var a = document.getElementsByTagName("a");
    for(var i = 0; i < a.length; i++){
      a[i].onfocus = function(){this.blur()};}
  }
}
window.onload = blurAnchors;