Updated JS

Updated JS so that events were assigned to document