function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  p.className = "active";

  var top  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : -1;

  for (; p; p = p.offsetParent)
  {
    if (p.style.position != 'absolute')
    {
			left += p.offsetLeft;
      top  += p.offsetTop;
    }
  }

  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left +'px';
  c.style.display = "block";
}

function at_hide_aux(parent, child)
{
  document.getElementById(parent).className = "parent";
  document.getElementById(child).style.display = "none";
}

function at_show_p()
{
  c = document.getElementById(this["at_child" ]);
  at_show_aux(this.id, c.id);
  clearTimeout(c["at_timeout"]);
}

function at_show_c()
{
  p = document.getElementById(this["at_parent"]);
  at_show_aux(p.id, this.id);
  clearTimeout(this["at_timeout"]);
}

function at_hide_p()
{
  c = document.getElementById(this["at_child" ]);
  c["at_timeout"] = setTimeout("at_hide_aux('"+this.id+"', '"+c.id+"')", 100);
}

function at_hide_c()
{
  p = document.getElementById(this["at_parent"]);
  this["at_timeout"] = setTimeout("at_hide_aux('"+p.id+"', '"+this.id+"')", 100);
}

function at_attach(parent, child, position)
{
  p = document.getElementById(parent);
  c = document.getElementById(child);

  p["at_child"]    = c.id;
  c["at_parent"]   = p.id;
  c["at_position"] = position;

  p.onmouseover = at_show_p;
  p.onmouseout  = at_hide_p;
  c.onmouseover = at_show_c;
  c.onmouseout  = at_hide_c;
}

function dhtmlmenu_build_aux(parent, child, position)
{
  document.getElementById(parent).className = "parent";
	document.write('<div class="vert_menu" id="'+parent+'_child"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td class="vertmenucell" style="background-image: url(/pic/backgrounds/vert_left.png); background-repeat: repeat-y; width: 6px;"><br /></td><td style="background-color: #ffffff; padding: 5px 10px 10px 10px; white-space: nowrap;">');
  n = 0;
  for (var i in child)
  {
    if (i == '-')
    {
      document.getElementById(parent).href = child[i];
      continue;
    }

    if (typeof child[i] == "object")
    {
      document.write('<a class="parent" id="'+parent+'_'+n+'">'+i+'</a>');
      dhtmlmenuu_build_aux(parent+'_'+n, child[i], "x");
    }

    if (typeof child[i] != "object")
    {    
    	if (child[i] != '')
    	{ document.write('<a id="'+parent+'_'+n+'" href="'+child[i]+'">'+i+'</a>'); }
    	else document.write('<a id="'+parent+'_'+n+'" style="cursor: default;">'+i+'</a>');
    }
    n++;
  }

  document.write('</td><td class="vertmenucell" style="background-image: url(/pic/backgrounds/vert_right.png); background-repeat: repeat-y; width: 6px;"><br /></td></tr><tr><td colspan="3"><table cellspacing="0" cellpadding="0" border="0" style="width: 100%;"><tbody><tr><td class="vertmenucell" style="background-image: url(/pic/backgrounds/vert_bottom_left.png); background-repeat: no-repeat; height: 9px; font-size: 1px; line-height: 9px; width: 50px;">&nbsp;</td><td class="vertmenucell" style="background-image: url(/pic/backgrounds/vert_bottom.png); background-repeat: repeat-x; height: 9px; font-size: 1px; line-height: 9px;">&nbsp;</td><td class="vertmenucell" style="background-image: url(/pic/backgrounds/vert_bottom_right.png); background-repeat: no-repeat; height: 9px; font-size: 1px; line-height: 9px; width: 50px;">&nbsp;</td></tr></tbody></table></td></tr></tbody></table></div>');

  at_attach(parent, parent+"_child", position);
}

function dhtmlmenuu_build_aux(parent, child, position)
{
  document.getElementById(parent).className = "parent";
	document.write('<div class="vert_menuu" id="'+parent+'_child"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td colspan="3"><table cellspacing="0" cellpadding="0" border="0" style="width: 100%;"><tbody><tr><td class="vertmenucell" style="background-image: url(/pic/backgrounds/vert_top_left.png); background-repeat: no-repeat; height: 6px; font-size: 1px; line-height: 6px; width: 50px;">&nbsp;</td><td class="vertmenucell" style="background-image: url(/pic/backgrounds/vert_top.png); background-repeat: repeat-x; height: 6px; font-size: 1px; line-height: 6px;">&nbsp;</td><td class="vertmenucell" style="background-image: url(/pic/backgrounds/vert_top_right.png); background-repeat: no-repeat; height: 6px; font-size: 1px; line-height: 6px; width: 50px;">&nbsp;</td></tr></tbody></table></td></tr><tr><td class="vertmenucell" style="background-image: url(/pic/backgrounds/vert_left.png); background-repeat: repeat-y; width: 6px;"><img src="/css/blank.gif" width="6"></td><td style="background-color: #ffffff; padding: 5px 10px 5px 20px;">');
  m = 1000;
  for (var i in child)
  {
    if (i == '-')
    {
      document.getElementById(parent).href = child[i];
      continue;
    }

    if (typeof child[i] == "object")
    {
      document.write('<a class="parent" id="'+parent+'_'+m+'">'+i+'</a>');
      dhtmlmenuu_build_aux(parent+'_'+m, child[i], "x");
    }

    if (typeof child[i] != "object")
    {    
    	if (child[i] != '')
    	{ document.write('<a id="'+parent+'_'+m+'" href="'+child[i]+'">'+i+'</a>'); }
    	else document.write('<a id="'+parent+'_'+m+'" style="cursor: default;">'+i+'</a>');
    }
    m++;
  }

  document.write('</td><td class="vertmenucell" style="background-image: url(/pic/backgrounds/vert_right.png); background-repeat: repeat-y; width: 6px;"><img src="/css/blank.gif" width="6"></td></tr><tr><td colspan="3"><table cellspacing="0" cellpadding="0" border="0" style="width: 100%;"><tbody><tr><td class="vertmenucell" style="background-image: url(/pic/backgrounds/vert_bottom_left.png); background-repeat: no-repeat; height: 9px; font-size: 1px; line-height: 9px; width: 50px;">&nbsp;</td><td class="vertmenucell" style="background-image: url(/pic/backgrounds/vert_bottom.png); background-repeat: repeat-x; height: 9px; font-size: 1px; line-height: 9px;">&nbsp;</td><td class="vertmenucell" style="background-image: url(/pic/backgrounds/vert_bottom_right.png); background-repeat: no-repeat; height: 9px; font-size: 1px; line-height: 9px; width: 50px;">&nbsp;</td></tr></tbody></table></td></tr></tbody></table></div>');

  at_attach(parent, parent+"_child", position);
}

function dhtmlmenu_build(menu)
{
  for (var i in menu) dhtmlmenu_build_aux(i, menu[i], "y");
}

