/*
  Author:       Directshop - Nicolai Lourens
  Date:         24-11-2005
  Description:  Simple script used for displaying submenu's.

  TODO:         - use central css-classnames instead of some 'dirty' javascript HTML-DOM properties
*/

/* just some global variables */
var obj = null;
var parent = null;
var isshown = false;

/* primary function to show submenu */
function objShow(id, p){
    if (obj != null){
      obj.style.visibility = 'hidden';
      obj = null;
    }

    if (document.getElementById){
      obj = document.getElementById(id);
      parent = p;

      if (obj != null)
        obj.style.visibility = 'visible';

      if (parent != null){
        parent.style.backgroundColor = '#000000';
        parent.style.color = '#ffffff';
      }
      isshown = true;
    }
}

/* primary function to hide the currently shown submenu */
function objHide(){
  if (isshown)
    return;

  if (obj != null){
    window.setTimeout("hideNow()", 250);
  }
}

/* secondary function to hide submenu (is called via <objHide()> */
function hideNow(){
  if (obj != null){
    if (obj.style)
      obj.style.visibility = 'hidden';

    isshown = false;
    obj = null;

    if (parent != null){
      parent.style.backgroundColor = '#ffffff';
      parent.style.color = '#000000';
    }
  }
}

/* function to keep the currently used submenu active */
function stayOpen(id, p){
  isshown = true;
  objShow(id, document.getElementById(p));
}

