/**    
 * lCMS version 1.0 (c) 2005-2010 Hannes Friederich. All rights reserved. 
 **/

var Navigation = new Object();
Navigation.showTimer = null;
Navigation.showGroup = "";
Navigation.showSection = "";
Navigation.hideTimer = null;
Navigation.hideGroup = "";
Navigation.hideSection = "";

Navigation.mouseOver = function(groupId, sectionId, delay)
{
  if (Navigation.showTimer != null) {
    window.clearTimeout(Navigation.showTimer); 
    Navigation.showGroup = '';
    Navigation.showSection = '';
  }

  var argument = "Navigation.showSubsections('" + groupId + 
                 "', '" + sectionId + "')";
  Navigation.showTimer = window.setTimeout(argument, delay);
  Navigation.showGroup = groupId;
  Navigation.showSection = sectionId;

  // stop the hide timer if the groupId and sectionId matches
  if (Navigation.hideTimer != null && Navigation.hideGroup == groupId && 
      Navigation.hideSection == sectionId) {
    window.clearTimeout(Navigation.hideTimer);
    Navigation.hideTimer = null;
    Navigation.hideGroup = '';
    Navigation.hideSection = '';
  }
}

Navigation.mouseOut = function (groupId, sectionId)
{
  // stop the show timer
  if (Navigation.showTimer != null && Navigation.showGroup == groupId &&
      Navigation.showSection == sectionId) {
    window.clearTimeout(Navigation.showTimer);
    Navigation.showGroup = '';
    Navigation.showSection = '';
  }

  if (Navigation.hideTimer != null) {
    window.clearTimeout(Navigation.hideTimer);
    // force the hide
    Navigation.hideSubsections(groupId, sectionId);
  }

  var argument = "Navigation.hideSubsections('" + groupId + 
      "', '" + sectionId + "')";
      
  Navigation.hideTimer = window.setTimeout(argument, 0);
  Navigation.hideGroup = groupId;
  Navigation.hideSection = sectionId;
}

Navigation.showSubsections = function(groupId, sectionId)
{
  Navigation.showTimer = null;
  Navigation.showGroup = '';
  Navigation.showSection = '';

  // the id refers to the <a>, but the parent <li> is needed
  var id = 'nav_' + groupId + '_' + sectionId;
  var element = getElement(id).parentNode;
  addClass(element, 'hover');
}

Navigation.hideSubsections = function(groupId, sectionId)
{
  Navigation.hideTimer = null;
  Navigation.hideGroup = '';
  Navigation.hideSection = '';

  // the id refers to the <a>, but the parent <li> is needed
  var id = 'nav_' + groupId + '_' + sectionId;
  var element = getElement(id).parentNode;
  removeClass(element, 'hover');
}


