Restructure the header's expandable nav

The tab order of the nav needed to flow into subnavs after the nav
housing the subnav. To achieve this the HTML was restructured to
have subnavs as children of their parents (e.g. a tree).

Some logic was pulled from the templates from into the Nav class.