function ddmenu()
{
  var i;
  var j;
  var node;
  var child;
  var parent;

  var ul = document.getElementById("menubar");
  
  var ul_li = new Array();

  for (i = 0; i < ul.childNodes.length; i++)
  {
  	child = ul.childNodes[i];
		if (child.nodeName == 'LI')
		{
			ul_li[ul_li.length] = child;
			child.style.display = 'inline';
			child.style.listStyle = 'none';
			child.style.position = 'static';
		}
  }
  var ul_li_ul = new Array();

  for (i = 0; i < ul_li.length; i++){
	node = ul_li[i];
	for (j = 0; j < node.childNodes.length; j++)
	{
		child = node.childNodes[j];
		if (child.nodeName == 'UL')
		{
			ul_li_ul[ul_li_ul.length] = child;
			child.style.position = 'absolute';
			child.style.left = '-13em';
        	child.style.visibility = 'hidden';

			// attach hover to parent li
			parent = child.parentNode;
			parent.onmouseover = openMenu;
			parent.onmouseout = closeMenu;
		}
	}
  }
}


function openMenu(e){

  var i;
  var child;

// stop the pure css hover effect
//this.style.paddingBottom = '0';

  for (i = 0; i < this.childNodes.length; i++)
  {
	child = this.childNodes[i];
	if (child.nodeName == 'UL')
	{
		child.style.position = 'absolute';
		child.style.left = this.offsetLeft+'px';
		child.style.top = this.offsetTop+this.offsetHeight+'px';
		child.style.visibility = 'visible';
	}
  }
  return false;
};
function closeMenu(e){
  var relatedTarget = null;
  var i;
  var child;
  if (e)
  {
  	relatedTarget = e.relatedTarget;
            // work around Gecko Linux only bug where related target is null
            // when clicking on menu links or when right clicking and moving
            // into a context menu.
	if (navigator.product == 'Gecko' && navigator.platform.indexOf('Linux') != -1 && !relatedTarget)
	{
		relatedTarget = e.originalTarget;
	}
  }
  else if (window.event)
  {
  	relatedTarget = window.event.toElement;
  }
  if (contains(this,relatedTarget))return false;
  for (i = 0; i < this.childNodes.length; i++)
  {
	child = this.childNodes[i];
	if (child.nodeName == 'UL')
	{
		child.style.visibility = 'hidden';
	}
  }
  return false;
};
function contains(outer,inner)
{
  while (inner.parentNode && inner != outer)
  {
    inner = inner.parentNode;
  }
  if (inner == outer)
  {
    return true;
  }
  return false;
}