remove duplicate navigation code

The navigation for the arrow keys and the nav buttons consisted on
duplicate code, which is not a good idea from a maintenance and
debugging perspective.

This commit fixes the duplicate code by adding a `gallnav` object,
containing the common navigation code, which is reused on the
different sections where it's needed.