var TITEMS = [ 
 ["Welcome to Online News Screensaver", "content/contents.html", "11"],
 ["System Requirements and Installation", "content/system_requirements.html", "11"],
 ["Using Online News Screensaver", "content/using_index.html", "1",
  ["Configuration Dialog", "content/config_dialog.html", "1",
   ["General tab", "content/config_general.html", "11"],
   ["Channels tab", "content/config_channels.html", "11"],
   ["Ticker tab - Weather", "content/config_weather.html", "11"],
   ["Ticker tab - Date and Time", "content/config_datetime.html", "11"],
   ["Ticker tab - Stock Quotes", "content/config_quotes.html", "11"],
   ["Appearance tab", "content/config_appearance.html", "11"],
   ["Network tab", "content/config_network.html", "11"]
  ],
  ["Channels", "content/channels_index.html", "1",
   ["Requirements to the channels", "content/channels_requirements.html", "11"],
   ["Adding a new template for channel", "content/channels_add_template.html", "11"],
   ["Editing an existing template", "content/channels_edit_template.html", "11"],
   ["Channel Template dialog", "content/channels_template_dialog.html", "11"],
   ["Updating a channels list", "content/channels_update.html", "11"]
  ],
  ["Online News Agent", "content/agent_index.html", "1",
   ["What is the Online News Agent", "content/agent_about.html", "11"],
   ["Key features of the Online News Agent", "content/agent_features.html", "11"]
  ]
 ],
 ["How to...", "content/howto_index.html", "1",
  ["How to open the Configuration dialog", "content/howto_open_config.html", "11"],
  ["How to use the keyboard for navigation", "content/howto_use_keyboard.html", "11"],
  ["How to use mouse for navigation", "content/howto_use_mouse.html", "11"],
  ["Looking through the news details", "content/howto_f5.html", "11"],
  ["Changing the font size and colors", "content/howto_change_appearance.html", "11"]
 ],
 ["License and Registration", "content/registration_index.html", "1",
  ["Product License", "content/registration_license.html", "11"],
  ["How to Register?", "content/registration_howto_register.html", "11"]
 ],
 ["About...", "content/about.html", "11"]
];


function arr_flatten (x) {
   var y = []; if (x == null) return y;
   for (var i=0; i<x.length; i++) {
      if (typeof(x[i]) == "object") {
         var flat = arr_flatten(x[i]);
         for (var j=0; j<flat.length; j++)
             y[y.length]=flat[j];
      } else {
         if ((i%3==0) && (x[i+1] != null))
          y[y.length]=x[i+1];
      }
   }
   return y;
}

function arr_findNext (url, cnt)
{
   var y = arr_flatten(TITEMS);
   for (var i = 0; i<y.length; i++) {
     if (y[i] == url) {
       ni = i + cnt;
       if (ni < 0) ni = 0;
       if (ni > y.length-1) ni = y.length-1;

       return y[ni];
     }
   }
   return "";
}

