ÿþ/ / * * *   T h i s   c o d e   i s   c o p y r i g h t   2 0 0 3   b y   G a v i n   K i s t n e r ,   g a v i n @ r e f i n e r y . c o m  
 / / * * *   I t   i s   c o v e r e d   u n d e r   t h e   l i c e n s e   v i e w a b l e   a t   h t t p : / / p h r o g z . n e t / J S / _ R e u s e L i c e n s e . t x t  
 / / * * *   R e u s e   o r   m o d i f i c a t i o n   i s   f r e e   p r o v i d e d   y o u   a b i d e   b y   t h e   t e r m s   o f   t h a t   l i c e n s e .  
 / / * * *   ( I n c l u d i n g   t h e   f i r s t   t w o   l i n e s   a b o v e   i n   y o u r   s o u r c e   c o d e   s a t i s f i e s   t h e   c o n d i t i o n s . )  
  
  
 / / * * * C r o s s   b r o w s e r   a t t a c h   e v e n t   f u n c t i o n .   F o r   ' e v t '   p a s s   a   s t r i n g   v a l u e   w i t h   t h e   l e a d i n g   " o n "   o m i t t e d  
 / / * * * e . g .   A t t a c h E v e n t ( w i n d o w , ' l o a d ' , M y F u n c t i o n N a m e W i t h o u t P a r e n t h e s i s , f a l s e ) ;  
  
 f u n c t i o n   A t t a c h E v e n t ( o b j , e v t , f n c , u s e C a p t u r e ) {  
 	 i f   ( ! u s e C a p t u r e )   u s e C a p t u r e = f a l s e ;  
 	 i f   ( o b j . a d d E v e n t L i s t e n e r ) {  
 	 	 o b j . a d d E v e n t L i s t e n e r ( e v t , f n c , u s e C a p t u r e ) ;  
 	 	 r e t u r n   t r u e ;  
 	 }   e l s e   i f   ( o b j . a t t a c h E v e n t )   r e t u r n   o b j . a t t a c h E v e n t ( " o n " + e v t , f n c ) ;  
 	 e l s e {  
 	 	 M y A t t a c h E v e n t ( o b j , e v t , f n c ) ;  
 	 	 o b j [ ' o n ' + e v t ] = f u n c t i o n ( ) {   M y F i r e E v e n t ( o b j , e v t )   } ;  
 	 }  
 }    
  
 / / T h e   f o l l o w i n g   a r e   f o r   b r o w s e r s   l i k e   N S 4   o r   I E 5 M a c   w h i c h   d o n ' t   s u p p o r t   e i t h e r  
 / / a t t a c h E v e n t   o r   a d d E v e n t L i s t e n e r  
 f u n c t i o n   M y A t t a c h E v e n t ( o b j , e v t , f n c ) {  
 	 i f   ( ! o b j . m y E v e n t s )   o b j . m y E v e n t s = { } ;  
 	 i f   ( ! o b j . m y E v e n t s [ e v t ] )   o b j . m y E v e n t s [ e v t ] = [ ] ;  
 	 v a r   e v t s   =   o b j . m y E v e n t s [ e v t ] ;  
 	 e v t s [ e v t s . l e n g t h ] = f n c ;  
 }  
 f u n c t i o n   M y F i r e E v e n t ( o b j , e v t ) {  
 	 i f   ( ! o b j   | |   ! o b j . m y E v e n t s   | |   ! o b j . m y E v e n t s [ e v t ] )   r e t u r n ;  
 	 v a r   e v t s   =   o b j . m y E v e n t s [ e v t ] ;  
 	 f o r   ( v a r   i = 0 , l e n = e v t s . l e n g t h ; i < l e n ; i + + )   e v t s [ i ] ( ) ;  
 } 