function fm_show_child(parent, child) {
  var p = document.getElementById(parent);
  var c = document.getElementById(child );
/*  var top = p.offsetHeight;
  var right = p.offsetWidth;
  for (; p; p = p.offsetParent) {
    if (p.id=="page-main") break; 
    top += p.offsetTop; 
	right += p.offsetLeft; 
  }  
  var left = right - c.offsetWidth;
  if (left < 0) left = 0;
  c.style.position = "absolute";
  c.style.top = top +'px';
  c.style.left = left +'px';*/
  c.style.visibility = "visible";
}

function fm_show() {
  var p = document.getElementById(this["fp"]);
  var c = document.getElementById(this["fc"]);
  fm_show_child(p.id, c.id);
  clearTimeout(c["ft"]);
}

function fm_hide() {
  var p = document.getElementById(this["fp"]);
  var c = document.getElementById(this["fc"]);
  c["ft"] = setTimeout("document.getElementById('" + c.id + "').style.visibility = 'hidden'", 300);
}

function fm_hide_now(menu_or_item) {
  var m = document.getElementById(menu_or_item);
  var c = document.getElementById(m["fc"]);
  c.style.visibility = "hidden";
  return true;
}

function fm_click() {
  var p = document.getElementById(this["fp"]);
  var c = document.getElementById(this["fc"]);
  if (c.style.visibility != "visible") fm_show_child(p.id, c.id) 
  else c.style.visibility = "hidden";
  return true;
}

function fm_make(parent, child) {
  var p = document.getElementById(parent);
  var c = document.getElementById(child);
  p["fp"] = p.id;
  c["fp"] = p.id;
  p["fc"] = c.id;
  c["fc"] = c.id;
  p.style.cursor = "pointer";
  p.onclick = fm_click;
  p.onmouseover = fm_show;
  p.onmouseout = fm_hide;
  c.onmouseover = fm_show;
  c.onmouseout = fm_hide;
  
  var l, i;
  l = c.getElementsByTagName('a');
  for (i in l) {
    if (l[i].onclick==null) {
	  l[i]["fp"] = p.id;
	  l[i]["fc"] = c.id;
	  l[i].onclick = fm_click;
	}
  }
  
}

