add javascript event listeners and associated functions