// Contains code to be delayed
var timeout = 0;

// Id of active menu
var actveId = 0;

// Rollover normal wrapper
function ro_Normal(imgId)
{
  ro_imgNormal('ro_img_' + imgId);
}

// Rollover over wrapper
function ro_Over(imgId)
{
  ro_imgOver('ro_img_' + imgId);
}

// Rollover normal
function ro_imgNormal(imgName)
{
  if (document.images)
  {
    document[imgName].src = eval(imgName + '_n.src');
  }
}

// Rollover over
function ro_imgOver(imgName)
{
  if (document.images)
  {
    document[imgName].src = eval(imgName + '_o.src');
  }
}

// Same as mainOver, but for items without children
function singleOver(id)
{
  clearTimeout(timeout);
  if(actveId != id)
  {
//alert(actveId + ' ' + id);
    showSubs(actveId, 0);
  }
  ro_Over(id);
}

// Same as mainOut, but for items without children
function singleOut(id)
{
  ro_Normal(id);
}

// Menu item with drop-down children 'Over' process
function mainOver(id)
{
  clearTimeout(timeout);
  if(actveId != id)
  {
//alert(actveId + ' ' + id);
    showSubs(actveId, 0);
    showSubs(id, 1);
  }
  else
  {
    ;
  }
}

// Menu item with drop-down children 'Out' process
function mainOut(id)
{
  timeout = setTimeout('showSubs( "' + id + '", 0)', 500 );
}

// Menu item with drop-down show or hide its children
function showSubs(id, visibility)
{
  if(id)
  {
    subs = document.getElementById(id + "subs");
    if(subs)
    {
      if(visibility)
      {
        subs.style.visibility = 'visible';
        actveId = id;
        ro_imgOver('ro_img_' + id);
      }
      else
      {
        subs.style.visibility = 'hidden';
        actveId = 0;
        ro_imgNormal('ro_img_' + id);
      }
    }
    else
    {
      alert("showSubs: can't find element '" + id + "subs'");
    }
  }
  else
  {
//    window.status = 'showSubs: need Id!';
  }
}

// Change element visibility
function changeVisibility(id, enemyId)
{
  if(id)
  {
    element = document.getElementById(id);
    if(element)
    {
      if(element.style.visibility == 'hidden' || element.style.visibility == '')
      {
        element.style.visibility = 'visible';
        enemyElement = document.getElementById(enemyId);
        if(enemyElement)
        {
          enemyElement.style.visibility = 'hidden';
        }
      }
      else
      {
        element.style.visibility = 'hidden';
      }
    }
    else
    {
      alert("can't find element '" + id + "'");
    }
  }
  else
  {
    window.status = 'changeVisibility: need Id!';
  }
}

function OpenSitemap (url){
  window.open(url,'Sitemap','toolbar=no,scrollbars=yes,resizeable=0,directories=no,menubar=no,width=341,height=600,dependent=yes');
}

function OpenIntro (url){
  window.open(url,'Intro','toolbar=no,scrollbars=no,resizeable=0,directories=no,menubar=no,width=390,height=130,dependent=yes');
}

/**
 * This function is used by Site Map to set the main window object name
 * to be used in target attribute of links
 */
function setOpenerName( newName ){
    opener.top.name=newName;
}

// Same as mainOver, but for items without children
function singleOverText(id)
{
  clearTimeout(timeout);
  if(actveId != id)
  {
//alert(actveId + ' ' + id);
    showSubs(actveId, 0);
  }
//  ro_OverText(id);
}

// Same as mainOut, but for items without children
function singleOutText(id)
{
//  ro_Normal(id);
}

// Menu item with drop-down children 'Over' process
function mainOverText(id)
{
  clearTimeout(timeout);
  if(actveId != id)
  {
//alert(actveId + ' ' + id);
    showSubs(actveId, 0);
    showSubs(id, 1);
  }
  else
  {
    ;
  }
}

// Menu item with drop-down children 'Out' process
function mainOutText(id)
{
  timeout = setTimeout('showSubs( "' + id + '", 0)', 500 );
}

