Rewrite Events using parallel classes and DOM types

Possible approach to #7.  Moves many methods into simple functions with
appropriate type constraints, reducing redundant implementations.  Adds
some run-time casts (asObject, asMouseEvent, ...).  Mainly an example to
try out this approach.