var col=document.getElementById("topmenu").getElementsByTagName("a")

/* Находим объект и присваиваем ему ID */
var obj;
for (var i in col) if (/\/produktion/.test(col[i].href))
{
  obj = col[i].parentNode;
  obj.id = 'product';
}


if (obj)
{
  obj.getElementsByTagName('a')[0].onclick = function () {InitMenu(); return false;}
  obj.onmouseover = InitMenu;
  obj.onmouseout = HideMenu;
}
else
{
  alert('Object not found!');
}

function InitMenu()
{
  var obj = document.getElementById('product');
  var nwOffset = Coordinates.northwestOffset(obj, true);
  var seOffset = Coordinates.southeastOffset(obj, true);

  ShowMenu (nwOffset.x, seOffset.y, seOffset.x-nwOffset.x)

//  alert(nwOffset.x+','+seOffset.y+','+(seOffset.x-nwOffset.x))

}

function ShowMenu (top, left, width)
{

  eTable = document.getElementById('_product_menu');
  if (!eTable) 
  {
    eTable    = document.createElement( 'table' );
    eTable.id = '_product_menu';
    eTable.style.position = 'absolute';
    eTable.className = 'prod';
    eTable.setAttribute('cellSpacing', 1);
    
    var eTBody    = document.createElement( 'tbody' );  // в IE без этого не работает!


    for(i=0; i<list.length-1; i++)
    {
      var eBodyRow  = document.createElement( 'tr' );
      eBodyRow.onmouseover = function () {this.style.backgroundColor = '#000000'; if(hiding) clearTimeout(hiding)}
      eBodyRow.onmouseout = function () {this.style.backgroundColor = '#7f7f7f'; HideMenu();}
      eBodyRow.onclick = function () {var href = this.getElementsByTagName("a")[0].href; window.location.href = href;}
      var eBodyCell = document.createElement( 'td' );
      eBodyCell.width = width-60;

      var eAnchor = document.createElement( 'a' );
      eAnchor.setAttribute('href', list[i][1]);
      eAnchor.innerHTML = list[i][0];

//      var eText = document.createTextNode(list[i][0]); // заменяет & на &amp;
//      eAnchor.appendChild(eText);

  
      eBodyCell.appendChild( eAnchor );
      eBodyRow.appendChild( eBodyCell );
      eTBody.appendChild( eBodyRow );
    }
    
    eTable.appendChild( eTBody );

    document.body.appendChild(eTable);
  }


  eTable.style["top"] = left + "px";
  eTable.style["left"] = top + "px";
  eTable.style.zIndex = 100;
  eTable.style.display = 'block';

  if(hiding) clearTimeout(hiding);

}


var hiding = null;
function HideMenu()
{
  hiding = window.setTimeout(function () {document.getElementById('_product_menu').style.display='none'}, 300);
}/*HideMenu*/

