//this javascript is necessary because ie6 ignores ":hover" for all elements but anchors. ie 7 fixes this, but no one uses ie7 yet

function init_hovers(){

	if (!document.getElementById) return false; //make sure the browser is up-to-date
	if(!document.getElementById("topmenu")) return false; //don't throw an error if the nav is missing on the page
	
	var nav_list = document.getElementById("topmenu");
		
	var ul_list = nav_list.getElementsByTagName("ul");
	var li_list = nav_list.getElementsByTagName("li");
	
	for (var i=0; i<ul_list.length; i++){
		ul_list[i].onmouseover = function() {
			setClass(this);
		}
		ul_list[i].onmouseout = function() {
			unsetClass(this);
		}
	}
	
	for (var i=0; i<li_list.length; i++){
		li_list[i].onmouseover = function() {
			setClass(this);
		}
		li_list[i].onmouseout = function() {
			unsetClass(this);
		}
	}
}

function add_clicks(){
	//this function makes the full menu area clickable, not just the link..doesn't work yet
	var nav_list = document.getElementById("topmenu");

	var li_list = nav_list.getElementsByTagName("li");
	
	for (var i=0; i<li_list.length; i++){
		var links = li_list[i].getElementsByTagName("a");
		var target = links[0].getAttribute("href");
		li_list[i].onclick = function(){
			//window.location = target;
			//return true;
			this.setAttribute("bob",target);
		}
	}
}
	
	

function setClass(thisclass){
	thisclass.setAttribute("class","hover");
	thisclass.setAttribute("className","hover");
}

function unsetClass(thisclass){
	thisclass.setAttribute("class","norm");
	thisclass.setAttribute("className","norm");
}

//following code adds function to the onload
function addLoadEvent(func){
	var oldonload = window.onload;
	if(typeof window.onload != 'function'){
		window.onload = func;
	}else{
		window.onload = function(){
			oldonload();
			func();
		}
	}
}

addLoadEvent(init_hovers);

