
// Shows child in proper place and changes paernt's background

function menu_onmouseon()
{
  var p = document.getElementById(this["menu_parent"]);
  var c = document.getElementById(this["menu_child" ]);

  this["menu_focus"] = 1;

  p.style.background = "#ACC7D9 url(images/arrow_gray.gif) right no-repeat";
  p.style.color = "#3B7AA5";

  var top  = p.offsetHeight;
  var left = 0;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }

  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// Hides child and restores original parent's background

function menu_do_hide(pid, cid)
{
  var p = document.getElementById(pid);
  var c = document.getElementById(cid);

  if (p["menu_focus"]==0 && c["menu_focus"]==0)
  {
  	p.style.background = "#ACC7D9 url(images/arrow_r.gif) right no-repeat";
  	p.style.color = "#000000";
	c.style.visibility = "hidden";
  }	
}

// Schedules call to menu_do_hide() after some timeout

function menu_onmouseout()
{
  this["menu_focus"] = 0;

  setTimeout("menu_do_hide('" + this["menu_parent"] + "','" + this["menu_child"] + "')", 135);
}


// Creates the menu

function menu_create(parent, child, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  p["menu_parent"] = p.id;
  c["menu_parent"] = p.id;
  p["menu_child"] = c.id;
  c["menu_child"] = c.id;
  p["menu_focus"] = 0;
  c["menu_focus"] = 0;

  c.style.position   = "absolute";
  c.style.visibility = "hidden";

  if (cursor != undefined) p.style.cursor = cursor;

  p.onmouseover = menu_onmouseon;
  p.onmouseout  = menu_onmouseout;
  c.onmouseover = menu_onmouseon;
  c.onmouseout  = menu_onmouseout;

  menu_do_hide(parent, child);
}

