Javascript nested custom event system