﻿/***********************************************************
 *                     AXiS CMS Version 3
 *
 * Автор:   Александр Кузнецов
 * Файл:    menu-navig.js
 ***********************************************************/

var isOpera   = ((navigator.userAgent.indexOf("Opera") != -1) ? true : false);

var hideTimer = 0;      
var Items     = new Array();

function switchSelects(what)
{
  var sels = document.getElementsByTagName('select');
  var i=0;
  while(sels[i])
  {
    sels[i].style.visibility = what;
    i++;
  }
}


function osx(e)
{
  var x    = 0;
  while(e.offsetParent)
  {
    x   += e.offsetLeft;
    e    = e.offsetParent;
  }
  return x;
}


function osy(e)
{
  var y = 0;
  while(e.offsetParent)
  {
    y   += e.offsetTop;
    e    = e.offsetParent;
  }
  return y;
}

// Основные функции меню

 function overRoot(id)
 {
   var obj = document.getElementById(id);
   
   clearTimeout(hideTimer);
   hiddeAll();
   
   if(obj.style.visibility == 'hidden')
   {
     obj.style.visibility = 'visible';
     obj.style.left = osx(obj.parentNode) + 200;
     obj.style.top  = osy(obj.parentNode) - 22;
     switchSelects('hidden');
   }
 }
 
 function changeClass(obj, classname)
 {
   obj.className = classname;
 }
 
 function outMouse(id)
 {
   hideTimer = setTimeout('lightHide("' + id + '")', 500);
 }
 
 function hiddeAll()
 {
   for(var i = 0; i < Items.length; i++)
   {
     lightHide(Items[i]);
   }
   switchSelects('visible');      
 }
 
 function lightHide(id)
 {
   var obj = document.getElementById(id);
   if(obj != null)
   {
     if(obj.style.visibility == 'visible')
     {
       obj.style.visibility = 'hidden';
       switchSelects('visible');      
     }
   }
 }

