var menuOverBg = new Image();
menuOverBg.src = "images/menuitembg.jpg";

var menuLeft,menuRight,menuTop,menuBottom;
var activeMenu;
var menuTimerID = null;
var mouseOverTimerID = null;

var isie = false;
if(document.all) isie = true;

function newImage(arg) {
   if (document.images) {
      rslt = new Image();
      rslt.src = arg;
      return rslt;
   }
}

function changeImages() {
   if (document.images && (preloadFlag == true)) {
      for (var i=0; i<changeImages.arguments.length; i+=2) {
         document.images[changeImages.arguments[i]].src = changeImages.arguments[i+1];
      }
   }
}

var preloadFlag = false;
function preloadImages() {
   if (document.images) {
      lux_header_contact_over = newImage("images/lux_header_contact-over.gif");
      lux_header_prices_over = newImage("images/lux_header_prices-over.gif");
      menu_salon_over = newImage("images/menu_salon-over.png");
      menu_manicure_over = newImage("images/menu_manicure-over.png");
      menu_spa_over = newImage("images/menu_spa-over.png");
      preloadFlag = true;
   }
}

function displaySubmenu()
{
  mouseOverTimerID = null;
  if (activeMenu.style.visibility == "hidden")
  {
    activeMenu.style.visibility = "visible";
  }
}

function showSubmenu(m,up)
{
  var om = document.getElementById(m);
  if (om == null || om == activeMenu) return;
  
  calcPosition(om,up)
  if (menuTimerID != null) {
    window.clearTimeout(menuTimerID);
    menuTimerID = null;
  }
  om.onmouseover = menuOver;
  om.onmouseout = menuOut;
//  if (om.style.visibility == "hidden")
//  {
//    om.style.visibility = "visible";
    activeMenu = om;
    mouseOverTimerID = window.setTimeout("displaySubmenu()",500);
//  }
}

function menuOut()
{
  if (mouseOverTimerID != null) 
  {
    window.clearTimeout(mouseOverTimerID);
    mouseOverTimerID = null;
    activeMenu = null;
  }
  else
    menuTimerID = window.setTimeout("hideSubmenu()", 400 );
}

function menuOver(o)
{
  if (menuTimerID!=null)
  {
    window.clearTimeout(menuTimerID);
    menuTimerID = null;
  }
}

function hideSubmenu()
{
  if (activeMenu == null) return;
  activeMenu.style.visibility = "hidden";
  activeMenu = null;
  menuTimerID = null;
}

function calcPosition(obj,up)
{
  //  calculate screen position
  var pageX = 0;
  var pageY = 0;
  var o = up;
  
  while(o.offsetParent != null)
  {
    pageX += o.offsetLeft;
    pageY += o.offsetTop;
    o = o.offsetParent;
  }
  obj.style.top = (pageY + up.offsetHeight) + "px";
  obj.style.left = (pageX + 10) + "px";
  
}

var g_Zoom = null;

function menuZoom(menu)
{
  m = document.getElementById(menu);
  if (m == null) return;
  if (g_Zoom != null) 
  {
    g_Zoom.style.display = "none";
  }
  if ( g_Zoom != m)
  {
    g_Zoom = m;
    g_Zoom.style.display = "block";
  }
  else
    g_Zoom = null;
}
