// (C) Serge Simonov, 2002 
// синтаксис описания меню
// каждая строка состоит из 5 параметров строк
// 1 - наименование меню
// 2 - относительное расположение страницы (относительно домена)
// 3 - принадлежность к группе меню (подменю), 0 - нет группы, для каждой группы свой номер
// 4 - указание статус окна (window.status)
// 5 - использование css for span
// каждая строка,  кроме последней должна заканчиваться запятой
// последняя строка должна быть неизменной

// пример:
//  "Main menu", "index.html", 0, "главная страница", "class='v_link'", 

menu01 = new Array 
(               
  "#  Новости", "index.html", 0, "Новости Гильдии", "class='link'", 
  "#  История", "docs/history.html", 0, "История основания", "class='link'", 
  "#  Устав", "docs/statute.html", 0, "Устав Гильдии", "class='link'", 
  "#  Избранные", "docs/members.html", 0, "Список избранных", "class='link'", 
  "#  Манускрипты", "docs/docs.html", 0, "Древние манускрипты", "class='link'", 
  "#  Портал", "private/index.html", 0, "Частные владения", "class='link'", 
  "#  Перекресток", "links.html", 0, "Перекресток дорог", "class='link'", 
  "#  Путеводитель", "sitemaps.html", 0, "Карта сайта", "class='link'", 
  "#  Форум", "talking/index.php", 0, "Форум Гильдии", "class='link'", 
  "xxx", "xxx", 0,  "",  ""
);

menu02 = new Array 
( 
  "alf", "01.html", 0, "",  "", 
  "arda", "02/02.html", 0, "",  "", 
  "cards", "03.html", 0, "",  "", 
  "xxx", "xxx", 0,  "",  "" 
);

var iNumbVarItem = 5;

function menu_v( dir, name )
{
 create_menu( dir, "v", name );
}

function menu_h( dir, name )
{
 create_menu( dir, "h", name );
}

function create_menu( dir, type, name )
{
 var index = 0;
 var s_index = 0;
 var p_index = -1;
 var number_group = 0;
 var item_numb = 0;
 
 array_menu = new Array();
 copy_array( array_menu, name );

 index = 0;
 while( array_menu[index] != "xxx" )
  {
    p_index = location.href.indexOf(array_menu[index+1]);
    if( ( p_index != -1 )&&array_menu[index+2]&&
        (
         ( array_menu[index].charAt(0) == "&" )||
         ( array_menu[index].charAt(0) == "#" )
        )
      )
     {
      // определили номер группы для меню
      number_group = array_menu[index+2];
      break;
     }
    index += iNumbVarItem;
  };
 
 if( number_group != 0 )
  {
   index = 0;
   while( array_menu[index] != "xxx" )
    {
     if( ( array_menu[index].charAt(0) == "&" )&&
         ( array_menu[index+2] == number_group ) )
      {
       item_numb = index;
       break;
      }
     index += iNumbVarItem;
    };
  };


 document.write( "<table width='100%' border='0' cellspacing='0' cellpadding='0'>");
 if( type == "h" )
  document.write( "<tr>" );

 index = 0;
 while( array_menu[index] != "xxx" )
  {
   if( (array_menu[index+2] != number_group) && 
       (array_menu[index].charAt(0) == "#" ) )
    {
     index += iNumbVarItem;
     continue;
    };
   if( type == "v" )
    document.write( "<tr><td valign='middle' align='left'>" );
   else
    document.write( "<td valign='middle' align='left'>" );
   if( array_menu[index+1] == "" )
    {
     document.write( array_menu[index] );
    }
   else
    {
      if( array_menu[index].charAt(0) == "&" )
       {
        array_menu[index] = array_menu[index].substring( 1, array_menu[index].length );
        if( array_menu[index].charAt(0) == " " )
         write_space(index);
        array_menu[index] = "&" + array_menu[index];
       }
      else if( array_menu[index].charAt(0) == "#" )
       {
        array_menu[index] = array_menu[index].substring( 1, array_menu[index].length );
        if( array_menu[index].charAt(0) == " " )
         write_space(index);
        array_menu[index] = "#" + array_menu[index];
       };
      if( array_menu[index].charAt(0) == " " )
       {
        write_space(index);
       };
      document.write( "<a href='" );
      if( dir == "" )
       document.write( array_menu[index+1] );
      else if( array_menu[index+1] == "#" )
       document.write( "#" );
      else
       document.write( dir + array_menu[index+1] );
      if( array_menu[index+3] != "" )
       {
        var s_str = "' onMouseOver=\"set_statusOn(\'";
        s_str = s_str + array_menu[index+3];
        s_str = s_str + "\');return true;\" ";
        s_str = s_str + "onMouseOut='set_statusOff();return true;";
        document.write( s_str );
       };
      document.write( "'>" );
      if( array_menu[index+4] != "" )
        document.write( "<span " + array_menu[index+4] + ">" );
      if( array_menu[index].charAt(0) == "&" )
        array_menu[index] = array_menu[index].substring( 1, array_menu[index].length );
      else if( array_menu[index].charAt(0) == "#" )
        array_menu[index] = array_menu[index].substring( 1, array_menu[index].length );
      document.write( array_menu[index] );
      if( array_menu[index+4] != "" )
       document.write("</span>");
      document.write( "</a>" );
    };
   if( type == "v" )
    document.write( "</td></tr>" );
   else
    document.write( "</td>" );
   index += iNumbVarItem;
  };
 if( type == "h" )
  document.write( "</tr>" );
 document.write( "</table>");
}

function copy_array( array_menu, name )
{
 var index = 0;
 while( name[index] != "xxx" )
  {
    array_menu[index] = name[index];
    index = index+1;
  }
 array_menu[index] = name[index];
 array_menu[index+1] = name[index+1];
}

function view( numb, type )
{
}

function write_space( index )
{
  var s_index = 0;
  while( array_menu[index].charAt(s_index) == " " )
   {
    document.write( "&#160" );
    s_index = s_index + 1;
    array_menu[index] = array_menu[index].substring( s_index, array_menu[index].length );
   };
}

function set_statusOn( s_status )
{
 window.status = s_status;
}

function set_statusOff()
{
 window.Status = " ";
}
