Cleaned up more javascript, with working previous and next