// JavaScript Document
window.onload = initAll;


//get elements by class name (cl)
document.getElementsByClassName = function(cl) {
	var retnode = [];
	var myclass = new RegExp('\\b'+cl+'\\b');
	var elem = this.getElementsByTagName('*');
	for (var i = 0; i < elem.length; i++) {
		var classes = elem[i].className;
		if (myclass.test(classes)) retnode.push(elem[i]);
		}
	return retnode;
} 	

function initAll() {
	setActiveTab();
}

//set the links to current page with id active
function setActiveTab() {
	var navTabs = document.getElementsByClassName("nav");
	for (i = 0; i < navTabs.length; i++) {
		
		if (navTabs[i].href == location.href) {
			navTabs[i].id = "active";
		}
		
	}
	
	var topTabs = document.getElementsByClassName("top_nav");
	for (i = 0; i < topTabs.length; i++) {
		var current_location = location.href.split("/");
		var tab_location = topTabs[i].href.split("/");
		if (current_location[3] == tab_location[3]) {
			topTabs[i].id = "active";
		}
	}
}