Reworked JS so that functions only load on appropriate pages