Converted navigation JS to CoffeeScript and made it pretty/more robust