Event utility in Javascript