var menuids=new Array("tnav") //Enter id(s) of UL menus, separated by commas
var submenupositionX = -260; //horizontal offset list for submenu
var submenupositionY = 0; //vertical offset, same as above
var submenuwidth = 175;

var ieextraY = 0; //extra top value for IE (don't change this)
var ieextraX= 0;

function createcssmenu(){
for (var i=0; i<menuids.length; i++){
	var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
    var spanref=document.createElement("span")
		spanref.className="arrowdiv"
		spanref.innerHTML="&nbsp;&nbsp;"
		ultags[t].parentNode.getElementsByTagName("a")[0].appendChild(spanref)
		
    ultags[t].parentNode.onmouseover=function(){
	//slightly adjusted for current page layout
	//this.getElementsByTagName("ul")[0].style.left = document.getElementById("screen_width").clientWidth / 2 + (submenupositionsX[t]) +"px"; //uses whole screen width instead of parent offset
	
	//hack for IE
	//if (navigator.appName.search("Microsoft") != -1)
		//ieextra = -20;
		
	//this.getElementsByTagName("ul")[0].style.top = 182 + (submenupositionsY[t]) +ieextra+"px"; //fixed value, as top margin shouldn't be changing
	//position hack for IE
	if (navigator.appName.search("Microsoft") != -1) {
			ieextraY = -10;
			ieextraX = -38;
	}
	//position hack for FF
	if (navigator.userAgent.search("Firefox") != -1) {
		ieextraY = -12;
	}
	//position hack for IE8 (HACKETY HACK HACK)
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
	var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
	if (ieversion>=8)
		ieextraY = -22;
		ieextraX = 4;
	}
		
	this.getElementsByTagName("ul")[0].style.left = document.getElementById("screen_width").clientWidth / 2 + (submenupositionX) + ieextraX +"px"; //uses whole screen width instead of parent offset;
	this.getElementsByTagName("ul")[0].style.top = 182 + (submenupositionY) +ieextraY+"px"; //fixed value, as top margin shouldn't be changing
	this.getElementsByTagName("ul")[0].style.width = submenuwidth+"px";
	
    this.getElementsByTagName("ul")[0].style.display="inline";
    }
    ultags[t].parentNode.onmouseout=function(){
    this.getElementsByTagName("ul")[0].style.display="none";
    }
    }
  }
}


if (window.addEventListener)
window.addEventListener("load", createcssmenu, false)
else if (window.attachEvent)
window.attachEvent("onload", createcssmenu)
