// <script>

// Copyright (C) 2005 Ilya S. Lyubinskiy. All rights reserved.
// Technical support: http://www.php-development.ru/
//
// YOU MAY NOT
// (1) Remove or modify this copyright notice.
// (2) Distribute this code, any part or any modified version of it.
//     Instead, you can link to the homepage of this code:
//     http://www.php-development.ru/javascripts/menu.php.
//
// YOU MAY
// (1) Use this code on your website.
// (2) Use this code as a part of another product provided that
//     its main use is not creating javascript menus.
//
// NO WARRANTY
// This code is provided "as is" without warranty of any kind, either
// expressed or implied, including, but not limited to, the implied warranties
// of merchantability and fitness for a particular purpose. You expressly
// acknowledge and agree that use of this code is at your own risk.

// If you find my script useful, you can support my site in the following ways:
// 1. Vote for the script at HotScripts.com (you can do it on my site)
// 2. Link to the homepage of this script or to the homepage of my site:
//    http://www.php-development.ru/javascripts/menu.php
//    http://www.php-development.ru/
//    You will get 50% commission on all orders made by your referrals.
//    More information can be found here:
//    http://www.php-development.ru/affiliates.php


// ----- DropDown Control ------------------------------------------------------

// ----- Show Aux -----

function at_show_aux(parent, child)
{
  var pMenu = document.getElementById(parent);
  var cMenu = document.getElementById(child);

  pMenu.className = "active";

  var top  = (cMenu["at_position"] == "y") ? pMenu.offsetHeight+0 : 0;
  var left = (cMenu["at_position"] == "x") ? pMenu.offsetWidth -1 : 0;

  for (; pMenu; pMenu = pMenu.offsetParent)
  {
    if (pMenu.style.position != 'absolute')
    {
      left += pMenu.offsetLeft;
      top  += pMenu.offsetTop;
    }
  }

  cMenu.style.position   = "absolute";
  cMenu.style.top        = top +'px';
  cMenu.style.left       = left+'px';
  cMenu.style.visibility = "visible";
}

// ----- Hide Aux -----

function at_hide_aux(parent, child)
{
  document.getElementById(parent).className = "parent";
  document.getElementById(child).style.visibility = "hidden";
}

// ----- Show -----

function at_show_p()
{
  cMenu = document.getElementById(this["at_child" ]);
  at_show_aux(this.id, cMenu.id);
  clearTimeout(cMenu["at_timeout"]);
}

function at_show_c()
{
  pMenu = document.getElementById(this["at_parent"]);
  at_show_aux(pMenu.id, this.id);
  clearTimeout(this["at_timeout"]);
}

// ----- Hide -----

function at_hide_p()
{
  cMenu = document.getElementById(this["at_child" ]);
  cMenu["at_timeout"] = setTimeout("at_hide_aux('"+this.id+"', '"+cMenu.id+"')", 100);
}

function at_hide_c()
{
  pMenu = document.getElementById(this["at_parent"]);
  this["at_timeout"] = setTimeout("at_hide_aux('"+pMenu.id+"', '"+this.id+"')", 100);
}

// ----- Attach -----

function at_attach(parent, child, position)
{
  pMenu = document.getElementById(parent);
  cMenu = document.getElementById(child);

  pMenu["at_child"]    = cMenu.id;
  cMenu["at_parent"]   = pMenu.id;
  cMenu["at_position"] = position;

  pMenu.onmouseover = at_show_p;
  pMenu.onmouseout  = at_hide_p;
  cMenu.onmouseover = at_show_c;
  cMenu.onmouseout  = at_hide_c;
}

// ----- DropDown Menu ---------------------------------------------------------

// ----- Build Aux -----

/*function dhtmlmenu_build_prot_aux(parent, child, position, links)
{
  document.getElementById(parent).className = "parent";

  document.write('<div class="vert_menu" id="'+parent+'_child">');

  nMenu = 0;
  lMenu = 1;
  for (var i in child)
  {
    if (i == '-')
    {
      document.getElementById(parent).href = child[i];
      continue;
    }

    if (typeof child[i] == "object")
    {
      document.write('<a class="parent" href="' + links[i] + '" id="'+parent+'_'+nMenu+'">'+i+'</a>');
      dhtmlmenu_build_prot_aux(parent+'_'+nMenu, child[i], "x");
      lMenu++;
    }
    else document.write('<a id="'+parent+'_'+nMenu+'" href="'+child[i]+'">'+i+'</a>');
    nMenu++;
  }

  document.write('</div>');

  at_attach(parent, parent+"_child", position);
}*/
function dhtmlmenu_build_prot_aux(parent, child, position, links)
{
  document.getElementById(parent).className = "parent";

  document.write('<div class="vert_menu" id="'+parent+'_child">');

  nMenu = 0;
  lMenu = 1;
  for (var i in child)
  {
if( child.hasOwnProperty(i) ) { //THIS IS NEW
    if (i == '-')
    {
      document.getElementById(parent).href = child[i];
      continue;
    }

    if (typeof child[i] == "object")
    {
      document.write('<a class="parent" href="' + links[i] + '" id="'+parent+'_'+nMenu+'">'+i+'</a>');
      dhtmlmenu_build_prot_aux(parent+'_'+nMenu, child[i], "x");
      lMenu++;
    }
    else document.write('<a id="'+parent+'_'+nMenu+'" href="'+child[i]+'">'+i+'</a>');
    nMenu++;
  }
} //THIS IS NEW

  document.write('</div>');

  at_attach(parent, parent+"_child", position);
} 
// ----- Build -----

function dhtmlmenu_build_prot(menu, links)
{
  for (var i in menu) dhtmlmenu_build_prot_aux(i, menu[i], "y", links);
}
