var acolor = "000080";
var abgcolor = "000080";
var ahovercolor = "FFFFFF";
var ahoverbgcolor = "006699";
var mmenuhovercolor = "006699";
var mmenuhoverbgcolor = "white";


var main_menu = false;
var sub_menu_active = false;
menusshown=new Array(false, false, false, false, false, false, false, false);
var drop_menu_count = 9;

function hidemenu(menuid)
  {
  if (menusshown[menuid])
    return;
  sub_menu = false;
  var obj;
  var mobj;
  obj = document.getElementById("menu" + menuid);
  mobj = document.getElementById("mmenu" + menuid);
  obj.style.pixelTop = 0;
  obj.style.pixelLeft = 0;
  obj.style.visibility = "hidden";
/*
    obj = document.getElementById("menuvisible" + menuid);
    obj.style.color= mmenuhoverbgcolor;
    obj.style.backgroundColor= mmenuhovercolor;
*/
  }

function showmenu(menuid)
  {
  var obj;
  var mobj;
  obj = document.getElementById("menu" + menuid);
  if (menuid == 9)
    {
//    var mobj_;
    mobj = document.getElementById("mmenu2");
    mobj_ = document.getElementById("menu2");
    obj.style.top = mobj.offsetTop + mobj.offsetHeight + mobj.offsetParent.offsetTop - (obj.offsetHeight / 2) + mobj_.offsetHeight;
//    obj.style.width = mobj.offsetWidth;
    obj.style.left = mobj.offsetLeft + mobj.offsetParent.offsetLeft - obj.offsetWidth + 10;
    }
  else
  {
  mobj = document.getElementById("mmenu" + menuid);
  obj.style.top = mobj.offsetTop + mobj.offsetHeight + mobj.offsetParent.offsetTop;
  obj.style.left = mobj.offsetLeft + mobj.offsetParent.offsetLeft;
  obj.style.width = mobj.offsetWidth;
  }
//  obj.innerHTML = "FONTTTTTT" + obj.style.zIndex;
  obj.style.visibility = "visible";
  menusshown[menuid] = true;
  main_menu = true;
  sub_menu_active = true;
/*
  obj = document.getElementById("menuvisible" + menuid);
    obj.style.color= mmenuhovercolor;
    obj.style.backgroundColor= mmenuhoverbgcolor;
*/
  }

function hidemenus()
  {
  if (sub_menu_active)
    {
    for (i = 1; i <= drop_menu_count; i++)
      if (menusshown[i])
        {
        menusshown[i] = false;
        hidemenu(i);
        }
    }
  sub_menu_active = false;
  }

function togglemenu(menuid, flag)
  {
  if (flag)
    {
    var obj;
    obj = document.getElementById("menu" + menuid);
    obj.style.visibility = "visible";
    menusshown[menuid] = true;
    }
  else
    {
    menusshown[menuid] = false;
    hidemenu(menuid);
    }
  }

function out_of_menu()
  {
  menu = false;
  today = new Date();
  second = today.getSeconds();
  s = second;

  while ((s - second) <= 2)
    s = today.getSeconds();

  if (!menu)
    hidemenus();
  }

function changeAcolors()
  {
  for (i=0; i < document.links.length; i++)
         {
         if (document.links[i].className == "page")
           document.links[i].style.color= "000080";
         }
  }

function pagesArollover(caller)
  {
  if (caller.className == "page")
    {
    caller.style.color= ahovercolor;
    caller.style.backgroundColor= ahoverbgcolor;
    }
  }

function pagesArollout(caller)
  {
  if (caller.className == "page")
    {
    caller.style.color= acolor;
    caller.style.backgroundColor= document.bgColor;//"D4D4D4";
    }
  }

function show_background()
  {
  var obj, mobj;
  obj = document.getElementById("background");
  mobj = document.getElementById("mmenu1");
  obj.style.pixelTop = mobj.offsetTop + mobj.offsetHeight + mobj.offsetParent.offsetTop;
//  obj.style.pixelWidth = document.Width;
//  obj.style.visibility = "visible";
  }

function HighLight()
  {
/*
  var url;
  var ulen;
  var tip;
  url = document.URL;
  ulen = url.search("highlight"); // индекс первого символа = 0
  var pos;
  pos = url.substring((ulen+("highlight").length), url.length);
  tip = open("", "ATTENTION", "scrollbars=no,width=400,height=200");
  tip.document.write("<HEAD><TITLE>Внимание!!!</TITLE></HEAD>");
  tip.document.writeln('<body>');
  tip.document.writeln('</body>');
  tip.document.writeln("Url is: " + url + "<br>And the result of the search is: " + ulen);
  tip.document.writeln("<br>URL Length = " + url.length + "<br>Pos is: " + pos);
  tip.document.close();
*/
  }

function Centerize()
  {
  var bar, top_image, menuplace, posleft;
  bar = document.getElementById("menubar");
  top_image = document.getElementById("top_td");
  menuplace = document.getElementById("menuplace");

  posleft = top_image.offsetLeft + ((top_image.offsetWidth - bar.offsetWidth)/2);
  postop = top_image.offsetTop + 94;//top_image.offsetTop + top_image.offsetHeight;// + 22;//menuplace.offsetHeight;

  bar.style.top = postop;  // Если нажать в Яндексе "показать найденные слова", меню будет не на месте!!!

  if (posleft < 0)
    {
    bar.style.left = 0;
    }
  else
    bar.style.left = posleft;

//  bar = document.getElementById("bottombar");
//  bar.style.left = 10;
//  bar.style.top = document.documentElement.offsetHeight - bar.offsetHeight - 5;
//  bar.style.width = document.documentElement.offsetWidth - 40;
//  bar.style.top = document.parentWindow.document.documentElement.offsetHeight - bar.offsetHeight - 5;
//  bar.style.width = document.parentWindow.document.documentElement.offsetWidth - 30;
  }

function yashin_over(caller)
  {
//  caller = document.getElementById("menubar");
  if (caller.className == "yashin")
    {
    caller.style.color= ahovercolor;
    }
  }
