JavaScript event publish/subscribe fun