Reorganize navbar javascript