ÿþf u n c t i o n   a d d E v e n t ( e l e m ,   e v t T y p e ,   f u n c ,   c a p t u r e )   {  
         c a p t u r e   =   ( c a p t u r e )   ?   c a p t u r e   :   f a l s e ;  
         i f   ( e l e m . a d d E v e n t L i s t e n e r )   {  
                 e l e m . a d d E v e n t L i s t e n e r ( e v t T y p e ,   f u n c ,   c a p t u r e ) ;  
         }   e l s e   i f   ( e l e m . a t t a c h E v e n t )   {  
                 e l e m . a t t a c h E v e n t ( " o n "   +   e v t T y p e ,   f u n c ) ;  
         }   e l s e   {  
                 e l e m [ " o n "   +   e v t T y p e ]   =   f u n c ;  
         }  
 }  
  
 f u n c t i o n   r e m o v e E v e n t ( e l e m ,   e v t T y p e ,   f u n c ,   c a p t u r e )   {  
         c a p t u r e   =   ( c a p t u r e )   ?   c a p t u r e   :   f a l s e ;  
         i f   ( e l e m . r e m o v e E v e n t L i s t e n e r )   {  
                 e l e m . r e m o v e E v e n t L i s t e n e r ( e v t T y p e ,   f u n c ,   c a p t u r e ) ;  
         }   e l s e   i f   ( e l e m . a t t a c h E v e n t )   {  
                 e l e m . d e t a c h E v e n t ( " o n "   +   e v t T y p e ,   f u n c ) ;  
         }   e l s e   {  
                 e l e m [ " o n "   +   e v t T y p e ]   =   n u l l ;  
         }  
 }  
  
 f u n c t i o n   a d d O n L o a d E v e n t ( f u n c )   {  
         i f   ( w i n d o w . a d d E v e n t L i s t e n e r   | |   w i n d o w . a t t a c h E v e n t )   {  
                 a d d E v e n t ( w i n d o w ,   " l o a d " ,   f u n c ,   f a l s e ) ;  
         }   e l s e   {  
                 v a r   o l d Q u e u e   =   ( w i n d o w . o n l o a d )   ?   w i n d o w . o n l o a d   :   f u n c t i o n ( )   {   } ;  
                 w i n d o w . o n l o a d   =   f u n c t i o n ( )   {  
                         o l d Q u e u e ( ) ;  
                         f u n c ( ) ;  
                 }  
         }  
 } 
