Refactored router/js/navigate.js into a general library of functions (purely as an example of how to do so)