var timerID = 0;
var reg = new Array();
var over = new Array();
var lockmenu = 0;

function initMenuImg()
{
//window.document.getElementById('menuimg').style.top = getAbsTop('maintext')+window.document.getElementById('maintext').offsetHeight-100;
//window.document.getElementById('menuimg').style.left = getAbsLeft('maintext')+window.document.getElementById('maintext').offsetWidth-420;
}

function divHide(id)
{
//window.document.getElementById('menuimg').style.visibility = 'hidden';
window.document.getElementById(id).style.visibility='hidden';
//window.document.getElementById('maintext').style.visibility='visible';
if(timerID)clearInterval(timerID);
}

function regOver(id, status)
{
over[id] = status;
}

function divShow(id, where, dir)
{
divHideAll();

//window.document.getElementById('menuimg').style.visibility = 'visible';

window.document.getElementById(id).style.top =  3+getAbsTop(where)+window.document.getElementById(where).offsetHeight-dir*(window.document.getElementById(id).offsetHeight+20);//window.document.getElementById(where).offsetHeight;
msg('top = '+getAbsTop(where)+"+"+window.document.getElementById(where).offsetHeight+"\n");

window.document.getElementById(id).style.left =
 getAbsLeft(where)+
 window.document.getElementById(where).offsetWidth/2-
 window.document.getElementById(id).offsetWidth/2;
msg('left = '+getAbsLeft(where)+"+"+window.document.getElementById(where).offsetWidth/2+"-"+window.document.getElementById(id).offsetWidth/2+"\n");

window.document.getElementById(id).style.visibility='visible';
//window.document.getElementById('maintext').style.visibility='hidden';

timerID = setInterval("hideOld('"+id+"')", 400);
}

function divHideAll()
{
  divHide('capsm');
  //divHide('aboutm');
  //divHide('techm');
  var reg = new Array();
  var over = new Array();
  lockmenu = 0;
}


function regMove(id)
{
reg[id] = 1;
}

function hideOld(id)
{
  if(!(reg[id]==1 || over[id]==1 || lockmenu)) divHide(id);
  else { reg[id] = 0;
 }
 msg("reg[id]:"+reg[id]+", over[id]:"+over[id]+", lockmenu:"+lockmenu);
}


function getAbsLeft(oNode){
   var oCurrentNode=window.document.getElementById(oNode);
   var iLeft=0;
   while(oCurrentNode.tagName!="BODY"){
      iLeft+=oCurrentNode.offsetLeft;
      oCurrentNode=oCurrentNode.offsetParent;
   }
   return iLeft;
}

function getAbsTop(oNode){
   var oCurrentNode=window.document.getElementById(oNode);
   var iTop=0;
   while(oCurrentNode.tagName!="BODY"){
      iTop+=oCurrentNode.offsetTop;
      oCurrentNode=oCurrentNode.offsetParent;
   }
   return iTop;
}

function msg(a)
{
 //window.document.getElementById('tarea').value += a;
}

function init(id)
{
 msg("in init");

 var nav = document.getElementById(id);
 var items = nav.getElementsByTagName('td');
 msg(nav+"\n"+items+"\n"+items.length+"=len\n");
 for(var i=0; i<items.length; i++)
 {
 items[i].onmouseover = itemOver;
 items[i].onmouseout = itemOut;
 }
}

function itemOver()
{
  msg("OVER\n");
  lockmenu = 1;
  this.style.backgroundColor = menuOCol;
  window.status = this.innerText;
}

function itemOut()
{
  msg("OUT\n");
  lockmenu = 0;
  this.style.backgroundColor = 'F0F0F0';
  window.status = '';
}

function showPromote()
{
  if(lockmenu)return;
  window.status = 'Þðèäè÷åñêîå àãåíòñòâî "ÐÓÑÑÊÀß ÏÐÀÂÄÀ"';
}
setInterval("showPromote()", 1000);

