function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


var submenuTimer, submenu2Timer;
var submenuId, submenu2Id;
var hideOnMenuObjs = new Array;
var path;

function setPath(v) {
  path = v;
}

function initHideOnMenu()
{
  if (!document.getElementsByName)
    return false;

  return hideOnMenuObjs = document.getElementsByName('hideOnMenu');
}

function initMenu(id, name) {
  showMenu(id, name);
}

function showMenu(id, name)
{
  var menu, menuTop, menuLeft, img;

  if (!document.getElementById)
    return false;

    
  // reset submenus
  for (var i = 0; i < submenuIds.length; ++i) {
    if (submenuTimer != 0 && submenuId == id) {
      clearTimeout(submenuTimer);
      break;
    }
    if (submenuIds[i] != id && (menu = document.getElementById('submenu' + submenuIds[i])))
      menu.style.display = 'none';
  }

  submenuId = id;
  swapNavImg(id, name, true);

  if (!(menu = document.getElementById('submenu' + id)))
    return false;

  if (!(container = document.getElementById('contentTable')))
    return false;

  img = document.getElementById('menu_' + id);
  menu.style.top = (container.offsetTop + 409) + 'px';
  menu.style.left = (container.offsetLeft + img.offsetLeft + img.width) + 'px';
  menu.style.display = 'block';

  return true;
} // end func showMenu


function hideMenu(id, name)
{
  var menu, s, i;

  if (!document.getElementById)
    return false;

  id = parseInt(id);
  s = "swapNavImg(" + id + ",'" + name + "', false);";
  if (menu = document.getElementById('submenu' + id))
    s += "document.getElementById('submenu" + id + "').style.display = 'none';";

  submenuTimer = setTimeout(s, 10);

  // set hidden objects as visible
  for (i = 0; i < hideOnMenuObjs.length; ++i) {
    hideOnMenuObjs[i].style.visibility = 'visible';
  }

  return true;
} // end func hideMenu


function swapNavImg(id, name, mode)
{
  var left, right;

  if (!document.getElementById || id < 1)
    return false;

  if (mode || id == CURRENT_NAV) { 
    document.getElementById('menu_' + id).src = BASE_PATH + name + '_2.gif';
  } else {
    document.getElementById('menu_' + id).src = BASE_PATH + name + '.gif';
  }
 
  return true;
} // end func swapNavImg


var menus  = new Array('praxis', 'prophy', 'zahnhe', 'labor', 'service', 'kontakt');
var anzahl = menus.length;
var show;
//var menumoved = new Array;
function showSub(menu, cur_id) {
  show = menu;

  for (i = 0; i < anzahl; i++) {
    if (menus[i] != menu && document.getElementById)
      hideIt(menus[i], cur_id);
  }
  document.getElementById(menu).style.visibility = 'visible';
  if (!(container = document.getElementById('contentTable')))
  return false;
 
  img = document.getElementById(menu + 'img');
  //document.getElementById(menu).style.top  = (container.offsetTop + 150) + 'px';
  document.getElementById(menu).style.top = (img.offsetTop + 26) + 'px';
  document.getElementById(menu).style.left = (container.offsetLeft + img.offsetLeft) + 'px';
  img.src = '/images/menu/' + menu + '2.gif';
  return true;
}

function initHide(menu, cur_id) {
  show = false;
  s = "hideSub('" + menu + "', '" + cur_id + "');";
  setTimeout(s, 1000);
}

function hideIt(menu, cur_id) {
  document.getElementById(menu).style.visibility = 'hidden';
  if (menu != cur_id) {
    document.getElementById(menu + 'img').src = '/images/menu/' + menu + '.gif';
  }
  //document.getElementById(menu + 'font').style.color = '#A4B4D5';
}
function hideAll() {
  for (i = 0; i < anzahl; i++) {
      hideSub(menus[i]);
  }
}
function hideSub(menu, cur_id) {
  if (show != menu)
    hideIt(menu, cur_id);
}


function openWin(uri)
{
  window.open(uri, 'popup', 'width=640,height=480,resizable=yes,scrollbars=yes,menubar');
}


function showSubMenu(parentId, name, id, offset)
{
  var menu, menuTop, menuLeft, img, img2;

  if (!document.getElementById)
    return false;

  // reset submenus
  for (var i = 0; i < submenuIds.length; ++i) {
    if (submenu2Timer != 0 && submenu2Id == id) {
      clearTimeout(submenu2Timer);
      break;
    }
    if (submenuIds[i] != id && (menu = document.getElementById('submenu' + submenuIds[i])))
      menu.style.display = 'none';
  }

  submenu2Id = id;

  if (!(menu = document.getElementById('submenu' + parentId + '_' + id)))
    return false;

  if (!(container = document.getElementById('contentTable')))
    return false;

  img = document.getElementById('menu_' + parentId);
  img2 = document.getElementById('submenu_' + parentId + '_' + id);
  menu.style.top = (container.offsetTop + 431) + 'px';
  menu.style.left = (container.offsetLeft + img.offsetLeft + img.width + offset) + 'px';
  menu.style.display = 'block';

  showMenu(parentId, name);

  return true;
} // end func showSubMenu


function hideSubMenu(parentId, name, id)
{
  var menu, s, i;

  if (!document.getElementById)
    return false;

  id = parseInt(id);
  if (menu = document.getElementById('submenu' + parentId + '_' + id)) {
    s = "document.getElementById('submenu" + parentId + '_' + id + "').style.display = 'none';";
    submenu2Timer = setTimeout(s, 10);
  }

  hideMenu(parentId, name);

  return true;
} // end func hideSubMenu

