var TITEMS = [ 
 ["STEMgis", "dwMain Features.htm", "11"],
 ["STEMgis Manager", "dwLoader Overview.htm", "1",
  ["Basic Building Blocks", "dwLoader BasicPrinc.htm", "11"],
  ["Basic Philosphy in STEMgis Design", "dwLoader Philosophy.htm", "11"],
  ["Database Design Considerations", "dwLoader Design.htm", "11"],
  ["Database Hierarchy", "dwLoader Hierarchy.htm", "11"],
  ["File Formats", null, "1",
   ["CSV File Formats", "dwLoader Format.htm", "11"],
   ["Example CSV File", "dwLoader CSV.htm", "11"],
   ["Defining Dates Outside 01/01/100 to 31/12/9999", "dwLoader DateRange.htm", "11"],
   ["List of Available Projections", "dwLoader ProjList.htm", "11"],
   ["Defining Text Position Relative to Locations", "dwLoader TextPos.htm", "11"],
   ["List of Available Units", "dwLoader UnitList.htm", "11"],
   ["Data Types", "dwLoader DataTypes.htm", "11"]
  ],
  ["Using the STEMgis Manager", "dwLoader Menu Bar.htm", "1",
   ["File Menu", "dwLoader FileMenu.htm", "11"],
   ["Insert Menu", "dwLoader InsertMenu.htm", "11"],
   ["Delete Menu", "dwLoader DeleteMenu.htm", "11"],
   ["Tools Menu", "dwLoader ToolMenu.htm", "1",
    ["Manage Features/Attributes etc", "dwLoader ManageFeatures.htm", "11"],
    ["Define/EditMetadata", "dwLoader Metadata.htm", "11"],
    ["Linking Metadata to Data", "dwLoader LinkMetadata.htm", "11"],
    ["Set Export Restrictions", "dwLoader ExportRestrict.htm", "11"],
    ["Set Processing Restrictions", "dwLoader ProcessRestrict.htm", "11"],
    ["Security Options", "dwLoader Security.htm", "11"],
    ["Edit Dataset Details", "dwLoader EditDetails.htm", "11"],
    ["Change Projection Code", "dwLoader ChangeProjCode.htm", "11"]
   ]
  ]
 ],
 ["STEMgis Viewer", "dwOverview_content.htm", "1",
  ["Screen Layout", "dwScreen Components.htm", "1",
   ["Menu Bar", "dwTool Bar.htm", "11"],
   ["Tool Bar", "dwTool Bar.htm", "1",
    ["Zoom and Pan Controls", "dwPan Zoom.htm", "11"],
    ["Map Projections", "dwProjections.htm", "11"],
    ["Query Wizard", "dwQuery Wizard.htm", "11"],
    ["Animation Tool", "dwAnimator Tool.htm", "11"],
    ["Graph Tool", "dwGraph Tool.htm", "11"],
    ["Drawing Transects", "dwDraw Transect.htm", "11"],
    ["Interpolation Tool", "dwInterpolation Tool.htm", "11"],
    ["Perspective View Tool", "dwPerspective View Mode.htm", "11"],
    ["Drawing Vectors", "dwDraw Vector.htm", "11"],
    ["Viewing Metadata", "dwView Metadata.htm", "11"]
   ],
   ["Map Window", "dwMap Window.htm", "11"],
   ["Locator Window", "dwLocator Window.htm", "11"],
   ["Layer Manager", "dwLayer Manager.htm", "11"],
   ["Album of Views", "dwAlbum.htm", "11"]
  ],
  ["Using the STEMgis Viewer", "dwMenu Bar.htm", "1",
   ["File Menu", "dwFile Menu.htm", "11"],
   ["Getting the Most out of the Viewer", "dwViewer GettingTheMost.htm", "11"],
   ["View Menu", "dwView Menu.htm", "11"],
   ["Layer Menu", "dwLayer Menu.htm", "11"],
   ["Select menu", "dwSelect Menu.htm", "11"],
   ["Tools Menu", "dwTools Menu.htm", "11"],
   ["Help Menu", "dwHelp Menu.htm", "11"]
  ]
 ],
 ["STEMgis Publicist", "dwPublisher Overview.htm", "1",
  ["Using the STEMgis Publicist", "dwPublisher Use.htm", "1",
   ["Step 1 - Opening a Database", "dwPublisher Open.htm", "11"],
   ["Step 2 - Customizing the Splash Screen", "dwPublisher SplashScreen.htm", "11"],
   ["Step 3 - Specify Web Links", "dwPublisher WebLinks.htm", "11"],
   ["Step 4 - Change Security Level Passwords", "dwPublisher Security.htm", "11"],
   ["Step 5 - Setup the Virtual Publication", "dwPublisher DocAndMap.htm", "11"],
   ["Step 6 - Select Map Projection", "dwPublisher Projection.htm", "11"],
   ["Step 7 - Define Banner Text Details", "dwPublisher Banner.htm", "11"],
   ["Step 8 - Create Virtual Publication", "dwPublisher Virtual.htm", "11"],
   ["Step 9 - Test the Installation", "dwPublisher Test.htm", "11"],
   ["Step 10 - Distribute the Virtual Publication", "dwPublisher Write.htm", "11"]
  ]
 ],
 ["Tutorials", "dwtutorials.htm", "1",
  ["Tutorial 1 - Using the demo database to get to know the Viewer", "dwtutorial1main.htm", "11"],
  ["Tutorial 2 - Adding your first dataset", "dwDMSTutMain.htm", "1",
   ["Step 1 - Create a STEMgis Database", "dwDMSTutCreate.htm", "11"],
   ["Step 2 - Creating Feature Types", "dwDMSTutFtype.htm", "11"],
   ["Step 3 - Creating Attributes", "dwDMSTutAttrib.htm", "11"],
   ["Step 4 - Loading Data", "dwDMSTutLoad.htm", "11"],
   ["Step 5 - Viewing Data", "dwDMSTutView.htm", "11"]
  ],
  ["Tutorial 3 - Creating CSV files", "dwtutorial3main.htm", "11"],
  ["Tutorial 4 - Loading and viewing depth profile data", "dwtutorial4main.htm", "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 "";
}

