Add event capabilities to a Javascript Object