javascript functionality for events