var menuids=new Array("verticalmenu") //Enter id(s) of UL menus, separated by commas
var submenuoffset=-2 //Offset of submenus from main menu. Default is -2 pixels.

function createcssmenu(){
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	if (sPage == "")
	{
		sPage = "index.html"
	}
	//alert(sPage);
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.id ="arrowdiv" + t
		spanref.className="arrowdiv"
		spanref.innerHTML="&nbsp;&nbsp;"
		ultags[t].parentNode.getElementsByTagName("a")[0].appendChild(spanref)
		// hide the arrow to start with
		//document.getElementById("arrowdiv" + t).style.display="none"
		
		
    ultags[t].parentNode.onmouseover=function()
	{ // This happens when the mouse is moved over a link
  	   this.getElementsByTagName("ul")[0].style.left=this.parentNode.offsetWidth+submenuoffset+"px"
 	   this.getElementsByTagName("ul")[0].style.display="block"
	   
	   this.getElementsByTagName("span")[0].style.display="block"
	   
    } // end onmouseover

	ultags[t].parentNode.onmouseout=function()
	{ // This happens when the mouse is moved out of a link
		
		if (sPage == "index.html" || sPage == "newsandevents.html" || sPage == "programs.html" || sPage == "reportingabuse.html" || sPage == "donations.html")
		{
		  document.getElementById("resourcesSub").style.display="none"
		  document.getElementById("aboutusSub").style.display="none"
		  document.getElementById("arrowdiv0").style.display="none"
		  document.getElementById("arrowdiv1").style.display="none"
		} else
		{

		// There are submenus so make the current sticky the the other one not sticky
			if (sPage == "overview.html" || sPage == "interagencyagreement.html" || sPage == "boardofdirectors.html")
	  {
		  document.getElementById("resourcesSub").style.display="none"
		  document.getElementById("aboutusSub").style.display="block"
		  document.getElementById("arrowdiv0").style.display="block"
		  document.getElementById("arrowdiv1").style.display="none"
	  }
	  
	  	// There are submenus so make the current sticky the the other one not sticky
	  	if (sPage == "usefullinks.html" || sPage == "publications.html")
	  {
		  document.getElementById("resourcesSub").style.display="block"
		  document.getElementById("aboutusSub").style.display="none"
		  document.getElementById("arrowdiv0").style.display="none"
		  document.getElementById("arrowdiv1").style.display="block"
	  }
	  
		}
    }
    }
	  // keep the submenu on for certian pages
	  if (sPage == "index.html" || sPage == "newsandevents.html" || sPage == "programs.html" || sPage == "reportingabuse.html" || sPage == "usefullinks.html" || sPage == "donations.html")
		{
		  document.getElementById("arrowdiv0").style.display="none"
		  document.getElementById("arrowdiv1").style.display="none"
		}
	  
	  
	  if (sPage == "overview.html" || sPage == "interagencyagreement.html" || sPage == "boardofdirectors.html")
	  {
		  document.getElementById("aboutusSub").style.left="148px"
		  document.getElementById("aboutusSub").style.display="block"
		  document.getElementById("aboutUsParent").style.color="#083d6a"
		  document.getElementById("arrowdiv0").style.display="block"
		  document.getElementById("arrowdiv1").style.display="none"
	  }
	  
	  	  if (sPage == "usefullinks.html" || sPage == "publications.html")
	  {
		  document.getElementById("resourcesSub").style.left="148px"
		  document.getElementById("resourcesSub").style.display="block"
		  document.getElementById("resourcesParent").style.color="#083d6a"
		  document.getElementById("arrowdiv0").style.display="none"
		  document.getElementById("arrowdiv1").style.display="block"
	  }
	  
	  // Set the selected cover by the page name and the id of the link
		var theID = sPage.replace(/.html/,"Lnk")
		document.getElementById(theID).style.color="#083d6a"

	  
  }
}

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