Create onclick events for next and previous buttons, and other supporting functions.