Some functions to support attachEvent().

This is foundation; I haven't pulled the trigger on this one yet.