function findMenus(tagName,onClass,offClass,shutOff)
{
  //alert('DynMenu Initializing for ' + tagName);
  var menus  = getElementsByClassName(document, tagName, "dynMenu");
  
  for (var i=0; i<menus.length; i++)
  { 
    
    var popups = getElementsByClassName(menus[i], "*", "trigger");
    for (var n=0; n<popups.length; n++)
    {
      if ( (menus[i].getAttribute("dyntype") == "click") || (menus[i].getAttribute("dyntype") == "hover") ) {
        popups[n].onclick = highlight;
        popups[n].onfocus = highlight;
        if (menus[i].getAttribute("dyntype") == "hover") {
          popups[n].onmouseover = highlight;
		  //popups[n].onmouseout = hide;
          //popups[n].onunfocus = hide;
        }
      }
      else if (menus[i].getAttribute("dyntype") == "check")
      {
        popups[n].onclick = highlight;
        popups[n].onfocus = highlight;
      }
      //if (n == 0) document.getElementById(popups[n].getAttribute("show")).className = "hoverTargetOn";
      //else document.getElementById(popups[n].getAttribute("show")).className = "hoverTargetOff";
    }
  }
}

function getElementsByClassName(oElm, strTagName, strClassName)
{
  //alert('Retrieving "' + strTagName + '" Elements');
  var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
  var arrReturnElements = new Array();
  var oRegExp = new RegExp(strClassName,"i");
  var oElement;
  
  //alert(arrElements.length + " Found");
  
  for(var i=0; i<arrElements.length; i++)
  {
    oElement = arrElements[i];
    if(oRegExp.test(oElement.className))
	{
      arrReturnElements.push(oElement);
	}
  }
  //alert(arrReturnElements.length + ' Have Class=' + strClassName);
  return (arrReturnElements)
}

function getParent(obj)
{
  var parent = obj.parentNode;
  return parent;
}

function highlight(event) {
  var menu = getParent(this);
  while (menu.className != "dynMenu")
  {
    menu = getParent(menu);
  }
  
  this.className = "triggerOn";
  document.getElementById(this.getAttribute("show")).className = "targetOn";
  
  popups = getElementsByClassName(menu, "*", "trigger");
  for (var i=0; i<popups.length; i++)
  {
	if (this != popups[i])
	{
	  popups[i].className = "triggerOff";
	  document.getElementById(popups[i].getAttribute("show")).className = "targetOff";
	}
	
  }
  this.hideFocus=true;
  //return false;
}

function hide (event) {
  document.getElementById(this.getAttribute("show")).className = "targetOff";
  this.className = "triggerOff";
  this.hideFocus=true;
  return false;
}
/*
window.onload=function(){
 findMenus();
}
*/