// This is a script for creating a menu with items that change color when moused over
// John Murphy 
// 6/27/06

function getElementsById(sId)
 {
    var outArray = new Array();	
	if(typeof(sId)!='string' || !sId)
	{
		return outArray;
	}
	
	if(document.evaluate)
	{
		var xpathString = "//*[@id='" + sId.toString() + "']"
		var xpathResult = document.evaluate(xpathString, document, null, 0, null);
		while ((outArray[outArray.length] = xpathResult.iterateNext())) { }
		outArray.pop();
	}
	else if(document.all)
	{
		
		for(var i=0,j=document.all[sId].length;i<j;i+=1){
		outArray[i] =  document.all[sId][i];}
		
	}
	else if(document.getElementsByTagName)
	{
	
		var aEl = document.getElementsByTagName( '*' );	
		for(var i=0,j=aEl.length;i<j;i+=1){
		
			if(aEl[i].id == sId )
			{
				outArray.push(aEl[i]);
			}
		}	
	}
	return outArray;
 }

function show_dark()
{
  var c = document.getElementById(this.id);
  idx=this.id;
  idx="menu"+(parseInt(idx.charAt(4))+1);
  var d = document.getElementById(idx);
  c.style.background="#006699";
  c.style.color="#FFFFFF";
  d.style.background="#006699";
  d.style.color="#FFFFFF";
}

function show_light()
{
  var c = document.getElementById(this.id);
  idx=this.id;
  idx="menu"+(parseInt(idx.charAt(4))+1);
  var d = document.getElementById(idx);
  c.style.background="#FFFFFF";
  c.style.color="#006699";
  d.style.background="#FFFFFF";
  d.style.color="#006699";
}

function set_menu(name)
{
  p = getElementsById(name);
  
  for (j = 0; j < p.length; j++)
  {
    var stringj=j+'';
	p[j].id=p[j].id+stringj;   // make the parent id's unique

	if (j==0 || j==2 || j==4){
		p[j].onmouseover = show_dark;
		p[j].onmouseout = show_light;
	}
    
  }
}

