ÿþ/ *    
 C o p y r i g h t   ( c )   2 0 0 9 ,   Y a h o o !   I n c .   A l l   r i g h t s   r e s e r v e d .  
 C o d e   l i c e n s e d   u n d e r   t h e   B S D   L i c e n s e :  
 h t t p : / / d e v e l o p e r . y a h o o . n e t / y u i / l i c e n s e . t x t  
 v e r s i o n :   2 . 8 . 0 r 4  
 * /  
 / * *  
   *   P r o v i d e s   A t t r i b u t e   c o n f i g u r a t i o n s .  
   *   @ n a m e s p a c e   Y A H O O . u t i l  
   *   @ c l a s s   A t t r i b u t e  
   *   @ c o n s t r u c t o r  
   *   @ p a r a m   h a s h   { O b j e c t }   T h e   i n t i a l   A t t r i b u t e .  
   *   @ p a r a m   { Y A H O O . u t i l . A t t r i b u t e P r o v i d e r }   T h e   o w n e r   o f   t h e   A t t r i b u t e   i n s t a n c e .  
   * /  
  
 Y A H O O . u t i l . A t t r i b u t e   =   f u n c t i o n ( h a s h ,   o w n e r )   {  
         i f   ( o w n e r )   {    
                 t h i s . o w n e r   =   o w n e r ;  
                 t h i s . c o n f i g u r e ( h a s h ,   t r u e ) ;  
         }  
 } ;  
  
 Y A H O O . u t i l . A t t r i b u t e . p r o t o t y p e   =   {  
         / * *  
           *   T h e   n a m e   o f   t h e   a t t r i b u t e .  
           *   @ p r o p e r t y   n a m e  
           *   @ t y p e   S t r i n g  
           * /  
         n a m e :   u n d e f i n e d ,  
          
         / * *  
           *   T h e   v a l u e   o f   t h e   a t t r i b u t e .  
           *   @ p r o p e r t y   v a l u e  
           *   @ t y p e   S t r i n g  
           * /  
         v a l u e :   n u l l ,  
          
         / * *  
           *   T h e   o w n e r   o f   t h e   a t t r i b u t e .  
           *   @ p r o p e r t y   o w n e r  
           *   @ t y p e   Y A H O O . u t i l . A t t r i b u t e P r o v i d e r  
           * /  
         o w n e r :   n u l l ,  
          
         / * *  
           *   W h e t h e r   o r   n o t   t h e   a t t r i b u t e   i s   r e a d   o n l y .  
           *   @ p r o p e r t y   r e a d O n l y  
           *   @ t y p e   B o o l e a n  
           * /  
         r e a d O n l y :   f a l s e ,  
          
         / * *  
           *   W h e t h e r   o r   n o t   t h e   a t t r i b u t e   c a n   o n l y   b e   w r i t t e n   o n c e .  
           *   @ p r o p e r t y   w r i t e O n c e  
           *   @ t y p e   B o o l e a n  
           * /  
         w r i t e O n c e :   f a l s e ,  
  
         / * *  
           *   T h e   a t t r i b u t e ' s   i n i t i a l   c o n f i g u r a t i o n .  
           *   @ p r i v a t e  
           *   @ p r o p e r t y   _ i n i t i a l C o n f i g  
           *   @ t y p e   O b j e c t  
           * /  
         _ i n i t i a l C o n f i g :   n u l l ,  
          
         / * *  
           *   W h e t h e r   o r   n o t   t h e   a t t r i b u t e ' s   v a l u e   h a s   b e e n   s e t .  
           *   @ p r i v a t e  
           *   @ p r o p e r t y   _ w r i t t e n  
           *   @ t y p e   B o o l e a n  
           * /  
         _ w r i t t e n :   f a l s e ,  
          
         / * *  
           *   A   f u n c t i o n   t o   c a l l   w h e n   s e t t i n g   t h e   a t t r i b u t e ' s   v a l u e .  
           *   T h e   m e t h o d   r e c e i v e s   t h e   n e w   v a l u e   a s   t h e   f i r s t   a r g   a n d   t h e   a t t r i b u t e   n a m e   a s   t h e   2 n d  
           *   @ p r o p e r t y   m e t h o d  
           *   @ t y p e   F u n c t i o n  
           * /  
         m e t h o d :   n u l l ,  
          
         / * *  
           *   T h e   f u n c t i o n   t o   u s e   w h e n   s e t t i n g   t h e   a t t r i b u t e ' s   v a l u e .  
           *   T h e   s e t t e r   r e c e i v e s   t h e   n e w   v a l u e   a s   t h e   f i r s t   a r g   a n d   t h e   a t t r i b u t e   n a m e   a s   t h e   2 n d  
           *   T h e   r e t u r n   v a l u e   o f   t h e   s e t t e r   r e p l a c e s   t h e   v a l u e   p a s s e d   t o   s e t ( ) .    
           *   @ p r o p e r t y   s e t t e r  
           *   @ t y p e   F u n c t i o n  
           * /  
         s e t t e r :   n u l l ,  
          
         / * *  
           *   T h e   f u n c t i o n   t o   u s e   w h e n   g e t t i n g   t h e   a t t r i b u t e ' s   v a l u e .  
           *   T h e   g e t t e r   r e c e i v e s   t h e   n e w   v a l u e   a s   t h e   f i r s t   a r g   a n d   t h e   a t t r i b u t e   n a m e   a s   t h e   2 n d  
           *   T h e   r e t u r n   v a l u e   o f   t h e   g e t t e r   w i l l   b e   u s e d   a s   t h e   r e t u r n   f r o m   g e t ( ) .  
           *   @ p r o p e r t y   g e t t e r  
           *   @ t y p e   F u n c t i o n  
           * /  
         g e t t e r :   n u l l ,  
  
         / * *  
           *   T h e   v a l i d a t o r   t o   u s e   w h e n   s e t t i n g   t h e   a t t r i b u t e ' s   v a l u e .  
           *   @ p r o p e r t y   v a l i d a t o r  
           *   @ t y p e   F u n c t i o n  
           *   @ r e t u r n   B o o l e a n  
           * /  
         v a l i d a t o r :   n u l l ,  
          
         / * *  
           *   R e t r i e v e s   t h e   c u r r e n t   v a l u e   o f   t h e   a t t r i b u t e .  
           *   @ m e t h o d   g e t V a l u e  
           *   @ r e t u r n   { a n y }   T h e   c u r r e n t   v a l u e   o f   t h e   a t t r i b u t e .  
           * /  
         g e t V a l u e :   f u n c t i o n ( )   {  
                 v a r   v a l   =   t h i s . v a l u e ;  
  
                 i f   ( t h i s . g e t t e r )   {  
                         v a l   =   t h i s . g e t t e r . c a l l ( t h i s . o w n e r ,   t h i s . n a m e ,   v a l ) ;  
                 }  
  
                 r e t u r n   v a l ;  
         } ,  
          
         / * *  
           *   S e t s   t h e   v a l u e   o f   t h e   a t t r i b u t e   a n d   f i r e s   b e f o r e C h a n g e   a n d   c h a n g e   e v e n t s .  
           *   @ m e t h o d   s e t V a l u e  
           *   @ p a r a m   { A n y }   v a l u e   T h e   v a l u e   t o   a p p l y   t o   t h e   a t t r i b u t e .  
           *   @ p a r a m   { B o o l e a n }   s i l e n t   I f   t r u e   t h e   c h a n g e   e v e n t s   w i l l   n o t   b e   f i r e d .  
           *   @ r e t u r n   { B o o l e a n }   W h e t h e r   o r   n o t   t h e   v a l u e   w a s   s e t .  
           * /  
         s e t V a l u e :   f u n c t i o n ( v a l u e ,   s i l e n t )   {  
                 v a r   b e f o r e R e t V a l ,  
                         o w n e r   =   t h i s . o w n e r ,  
                         n a m e   =   t h i s . n a m e ;  
                  
                 v a r   e v e n t   =   {  
                         t y p e :   n a m e ,    
                         p r e v V a l u e :   t h i s . g e t V a l u e ( ) ,  
                         n e w V a l u e :   v a l u e  
                 } ;  
                  
                 i f   ( t h i s . r e a d O n l y   | |   (   t h i s . w r i t e O n c e   & &   t h i s . _ w r i t t e n )   )   {  
                         r e t u r n   f a l s e ;   / /   w r i t e   n o t   a l l o w e d  
                 }  
                  
                 i f   ( t h i s . v a l i d a t o r   & &   ! t h i s . v a l i d a t o r . c a l l ( o w n e r ,   v a l u e )   )   {  
                         r e t u r n   f a l s e ;   / /   i n v a l i d   v a l u e  
                 }  
  
                 i f   ( ! s i l e n t )   {  
                         b e f o r e R e t V a l   =   o w n e r . f i r e B e f o r e C h a n g e E v e n t ( e v e n t ) ;  
                         i f   ( b e f o r e R e t V a l   = = =   f a l s e )   {  
                                 r e t u r n   f a l s e ;  
                         }  
                 }  
  
                 i f   ( t h i s . s e t t e r )   {  
                         v a l u e   =   t h i s . s e t t e r . c a l l ( o w n e r ,   v a l u e ,   t h i s . n a m e ) ;  
                         i f   ( v a l u e   = = =   u n d e f i n e d )   {  
                         }  
                 }  
                  
                 i f   ( t h i s . m e t h o d )   {  
                         t h i s . m e t h o d . c a l l ( o w n e r ,   v a l u e ,   t h i s . n a m e ) ;  
                 }  
                  
                 t h i s . v a l u e   =   v a l u e ;   / /   T O D O :   s e t   b e f o r e   c a l l i n g   s e t t e r / m e t h o d ?  
                 t h i s . _ w r i t t e n   =   t r u e ;  
                  
                 e v e n t . t y p e   =   n a m e ;  
                  
                 i f   ( ! s i l e n t )   {  
                         t h i s . o w n e r . f i r e C h a n g e E v e n t ( e v e n t ) ;  
                 }  
                  
                 r e t u r n   t r u e ;  
         } ,  
          
         / * *  
           *   A l l o w s   f o r   c o n f i g u r i n g   t h e   A t t r i b u t e ' s   p r o p e r t i e s .  
           *   @ m e t h o d   c o n f i g u r e  
           *   @ p a r a m   { O b j e c t }   m a p   A   k e y - v a l u e   m a p   o f   A t t r i b u t e   p r o p e r t i e s .  
           *   @ p a r a m   { B o o l e a n }   i n i t   W h e t h e r   o r   n o t   t h i s   s h o u l d   b e c o m e   t h e   i n i t i a l   c o n f i g .  
           * /  
         c o n f i g u r e :   f u n c t i o n ( m a p ,   i n i t )   {  
                 m a p   =   m a p   | |   { } ;  
  
                 i f   ( i n i t )   {  
                         t h i s . _ w r i t t e n   =   f a l s e ;   / /   r e s e t   w r i t e O n c e  
                 }  
  
                 t h i s . _ i n i t i a l C o n f i g   =   t h i s . _ i n i t i a l C o n f i g   | |   { } ;  
                  
                 f o r   ( v a r   k e y   i n   m a p )   {  
                         i f   (   m a p . h a s O w n P r o p e r t y ( k e y )   )   {  
                                 t h i s [ k e y ]   =   m a p [ k e y ] ;  
                                 i f   ( i n i t )   {  
                                         t h i s . _ i n i t i a l C o n f i g [ k e y ]   =   m a p [ k e y ] ;  
                                 }  
                         }  
                 }  
         } ,  
          
         / * *  
           *   R e s e t s   t h e   v a l u e   t o   t h e   i n i t i a l   c o n f i g   v a l u e .  
           *   @ m e t h o d   r e s e t V a l u e  
           *   @ r e t u r n   { B o o l e a n }   W h e t h e r   o r   n o t   t h e   v a l u e   w a s   s e t .  
           * /  
         r e s e t V a l u e :   f u n c t i o n ( )   {  
                 r e t u r n   t h i s . s e t V a l u e ( t h i s . _ i n i t i a l C o n f i g . v a l u e ) ;  
         } ,  
          
         / * *  
           *   R e s e t s   t h e   a t t r i b u t e   c o n f i g   t o   t h e   i n i t i a l   c o n f i g   s t a t e .  
           *   @ m e t h o d   r e s e t C o n f i g  
           * /  
         r e s e t C o n f i g :   f u n c t i o n ( )   {  
                 t h i s . c o n f i g u r e ( t h i s . _ i n i t i a l C o n f i g ,   t r u e ) ;  
         } ,  
          
         / * *  
           *   R e s e t s   t h e   v a l u e   t o   t h e   c u r r e n t   v a l u e .  
           *   U s e f u l   w h e n   v a l u e s   m a y   h a v e   g o t t e n   o u t   o f   s y n c   w i t h   a c t u a l   p r o p e r t i e s .  
           *   @ m e t h o d   r e f r e s h  
           *   @ r e t u r n   { B o o l e a n }   W h e t h e r   o r   n o t   t h e   v a l u e   w a s   s e t .  
           * /  
         r e f r e s h :   f u n c t i o n ( s i l e n t )   {  
                 t h i s . s e t V a l u e ( t h i s . v a l u e ,   s i l e n t ) ;  
         }  
 } ;  
  
 ( f u n c t i o n ( )   {  
         v a r   L a n g   =   Y A H O O . u t i l . L a n g ;  
  
         / *  
         C o p y r i g h t   ( c )   2 0 0 6 ,   Y a h o o !   I n c .   A l l   r i g h t s   r e s e r v e d .  
         C o d e   l i c e n s e d   u n d e r   t h e   B S D   L i c e n s e :  
         h t t p : / / d e v e l o p e r . y a h o o . n e t / y u i / l i c e n s e . t x t  
         * /  
          
         / * *  
           *   P r o v i d e s   a n d   m a n a g e s   Y A H O O . u t i l . A t t r i b u t e   i n s t a n c e s  
           *   @ n a m e s p a c e   Y A H O O . u t i l  
           *   @ c l a s s   A t t r i b u t e P r o v i d e r  
           *   @ u s e s   Y A H O O . u t i l . E v e n t P r o v i d e r  
           * /  
         Y A H O O . u t i l . A t t r i b u t e P r o v i d e r   =   f u n c t i o n ( )   { } ;  
  
         Y A H O O . u t i l . A t t r i b u t e P r o v i d e r . p r o t o t y p e   =   {  
                  
                 / * *  
                   *   A   k e y - v a l u e   m a p   o f   A t t r i b u t e   c o n f i g u r a t i o n s  
                   *   @ p r o p e r t y   _ c o n f i g s  
                   *   @ p r o t e c t e d   ( m a y   b e   u s e d   b y   s u b c l a s s e s   a n d   a u g m e n t o r s )  
                   *   @ p r i v a t e  
                   *   @ t y p e   { O b j e c t }  
                   * /  
                 _ c o n f i g s :   n u l l ,  
                 / * *  
                   *   R e t u r n s   t h e   c u r r e n t   v a l u e   o f   t h e   a t t r i b u t e .  
                   *   @ m e t h o d   g e t  
                   *   @ p a r a m   { S t r i n g }   k e y   T h e   a t t r i b u t e   w h o s e   v a l u e   w i l l   b e   r e t u r n e d .  
                   *   @ r e t u r n   { A n y }   T h e   c u r r e n t   v a l u e   o f   t h e   a t t r i b u t e .  
                   * /  
                 g e t :   f u n c t i o n ( k e y ) {  
                         t h i s . _ c o n f i g s   =   t h i s . _ c o n f i g s   | |   { } ;  
                         v a r   c o n f i g   =   t h i s . _ c o n f i g s [ k e y ] ;  
                          
                         i f   ( ! c o n f i g   | |   ! t h i s . _ c o n f i g s . h a s O w n P r o p e r t y ( k e y ) )   {  
                                 r e t u r n   n u l l ;  
                         }  
                          
                         r e t u r n   c o n f i g . g e t V a l u e ( ) ;  
                 } ,  
                  
                 / * *  
                   *   S e t s   t h e   v a l u e   o f   a   c o n f i g .  
                   *   @ m e t h o d   s e t  
                   *   @ p a r a m   { S t r i n g }   k e y   T h e   n a m e   o f   t h e   a t t r i b u t e  
                   *   @ p a r a m   { A n y }   v a l u e   T h e   v a l u e   t o   a p p l y   t o   t h e   a t t r i b u t e  
                   *   @ p a r a m   { B o o l e a n }   s i l e n t   W h e t h e r   o r   n o t   t o   s u p p r e s s   c h a n g e   e v e n t s  
                   *   @ r e t u r n   { B o o l e a n }   W h e t h e r   o r   n o t   t h e   v a l u e   w a s   s e t .  
                   * /  
                 s e t :   f u n c t i o n ( k e y ,   v a l u e ,   s i l e n t ) {  
                         t h i s . _ c o n f i g s   =   t h i s . _ c o n f i g s   | |   { } ;  
                         v a r   c o n f i g   =   t h i s . _ c o n f i g s [ k e y ] ;  
                          
                         i f   ( ! c o n f i g )   {  
                                 r e t u r n   f a l s e ;  
                         }  
                          
                         r e t u r n   c o n f i g . s e t V a l u e ( v a l u e ,   s i l e n t ) ;  
                 } ,  
          
                 / * *  
                   *   R e t u r n s   a n   a r r a y   o f   a t t r i b u t e   n a m e s .  
                   *   @ m e t h o d   g e t A t t r i b u t e K e y s  
                   *   @ r e t u r n   { A r r a y }   A n   a r r a y   o f   a t t r i b u t e   n a m e s .  
                   * /  
                 g e t A t t r i b u t e K e y s :   f u n c t i o n ( ) {  
                         t h i s . _ c o n f i g s   =   t h i s . _ c o n f i g s ;  
                         v a r   k e y s   =   [ ] ,   k e y ;  
  
                         f o r   ( k e y   i n   t h i s . _ c o n f i g s )   {  
                                 i f   (   L a n g . h a s O w n P r o p e r t y ( t h i s . _ c o n f i g s ,   k e y )   & &    
                                                 ! L a n g . i s U n d e f i n e d ( t h i s . _ c o n f i g s [ k e y ] )   )   {  
                                         k e y s [ k e y s . l e n g t h ]   =   k e y ;  
                                 }  
                         }  
                          
                         r e t u r n   k e y s ;  
                 } ,  
                  
                 / * *  
                   *   S e t s   m u l t i p l e   a t t r i b u t e   v a l u e s .  
                   *   @ m e t h o d   s e t A t t r i b u t e s  
                   *   @ p a r a m   { O b j e c t }   m a p     A   k e y - v a l u e   m a p   o f   a t t r i b u t e s  
                   *   @ p a r a m   { B o o l e a n }   s i l e n t   W h e t h e r   o r   n o t   t o   s u p p r e s s   c h a n g e   e v e n t s  
                   * /  
                 s e t A t t r i b u t e s :   f u n c t i o n ( m a p ,   s i l e n t ) {  
                         f o r   ( v a r   k e y   i n   m a p )   {  
                                 i f   (   L a n g . h a s O w n P r o p e r t y ( m a p ,   k e y )   )   {  
                                         t h i s . s e t ( k e y ,   m a p [ k e y ] ,   s i l e n t ) ;  
                                 }  
                         }  
                 } ,  
          
                 / * *  
                   *   R e s e t s   t h e   s p e c i f i e d   a t t r i b u t e ' s   v a l u e   t o   i t s   i n i t i a l   v a l u e .  
                   *   @ m e t h o d   r e s e t V a l u e  
                   *   @ p a r a m   { S t r i n g }   k e y   T h e   n a m e   o f   t h e   a t t r i b u t e  
                   *   @ p a r a m   { B o o l e a n }   s i l e n t   W h e t h e r   o r   n o t   t o   s u p p r e s s   c h a n g e   e v e n t s  
                   *   @ r e t u r n   { B o o l e a n }   W h e t h e r   o r   n o t   t h e   v a l u e   w a s   s e t  
                   * /  
                 r e s e t V a l u e :   f u n c t i o n ( k e y ,   s i l e n t ) {  
                         t h i s . _ c o n f i g s   =   t h i s . _ c o n f i g s   | |   { } ;  
                         i f   ( t h i s . _ c o n f i g s [ k e y ] )   {  
                                 t h i s . s e t ( k e y ,   t h i s . _ c o n f i g s [ k e y ] . _ i n i t i a l C o n f i g . v a l u e ,   s i l e n t ) ;  
                                 r e t u r n   t r u e ;  
                         }  
                         r e t u r n   f a l s e ;  
                 } ,  
          
                 / * *  
                   *   S e t s   t h e   a t t r i b u t e ' s   v a l u e   t o   i t s   c u r r e n t   v a l u e .  
                   *   @ m e t h o d   r e f r e s h  
                   *   @ p a r a m   { S t r i n g   |   A r r a y }   k e y   T h e   a t t r i b u t e ( s )   t o   r e f r e s h  
                   *   @ p a r a m   { B o o l e a n }   s i l e n t   W h e t h e r   o r   n o t   t o   s u p p r e s s   c h a n g e   e v e n t s  
                   * /  
                 r e f r e s h :   f u n c t i o n ( k e y ,   s i l e n t )   {  
                         t h i s . _ c o n f i g s   =   t h i s . _ c o n f i g s   | |   { } ;  
                         v a r   c o n f i g s   =   t h i s . _ c o n f i g s ;  
                          
                         k e y   =   (   (   L a n g . i s S t r i n g ( k e y )   )   ?   [ k e y ]   :   k e y   )   | |    
                                         t h i s . g e t A t t r i b u t e K e y s ( ) ;  
                          
                         f o r   ( v a r   i   =   0 ,   l e n   =   k e y . l e n g t h ;   i   <   l e n ;   + + i )   {    
                                 i f   ( c o n f i g s . h a s O w n P r o p e r t y ( k e y [ i ] ) )   {  
                                         t h i s . _ c o n f i g s [ k e y [ i ] ] . r e f r e s h ( s i l e n t ) ;  
                                 }  
                         }  
                 } ,  
          
                 / * *  
                   *   A d d s   a n   A t t r i b u t e   t o   t h e   A t t r i b u t e P r o v i d e r   i n s t a n c e .    
                   *   @ m e t h o d   r e g i s t e r  
                   *   @ p a r a m   { S t r i n g }   k e y   T h e   a t t r i b u t e ' s   n a m e  
                   *   @ p a r a m   { O b j e c t }   m a p   A   k e y - v a l u e   m a p   c o n t a i n i n g   t h e  
                   *   a t t r i b u t e ' s   p r o p e r t i e s .  
                   *   @ d e p r e c a t e d   U s e   s e t A t t r i b u t e C o n f i g  
                   * /  
                 r e g i s t e r :   f u n c t i o n ( k e y ,   m a p )   {  
                         t h i s . s e t A t t r i b u t e C o n f i g ( k e y ,   m a p ) ;  
                 } ,  
                  
                  
                 / * *  
                   *   R e t u r n s   t h e   a t t r i b u t e ' s   p r o p e r t i e s .  
                   *   @ m e t h o d   g e t A t t r i b u t e C o n f i g  
                   *   @ p a r a m   { S t r i n g }   k e y   T h e   a t t r i b u t e ' s   n a m e  
                   *   @ p r i v a t e  
                   *   @ r e t u r n   { o b j e c t }   A   k e y - v a l u e   m a p   c o n t a i n i n g   a l l   o f   t h e  
                   *   a t t r i b u t e ' s   p r o p e r t i e s .  
                   * /  
                 g e t A t t r i b u t e C o n f i g :   f u n c t i o n ( k e y )   {  
                         t h i s . _ c o n f i g s   =   t h i s . _ c o n f i g s   | |   { } ;  
                         v a r   c o n f i g   =   t h i s . _ c o n f i g s [ k e y ]   | |   { } ;  
                         v a r   m a p   =   { } ;   / /   r e t u r n i n g   a   c o p y   t o   p r e v e n t   o v e r r i d e s  
                          
                         f o r   ( k e y   i n   c o n f i g )   {  
                                 i f   (   L a n g . h a s O w n P r o p e r t y ( c o n f i g ,   k e y )   )   {  
                                         m a p [ k e y ]   =   c o n f i g [ k e y ] ;  
                                 }  
                         }  
          
                         r e t u r n   m a p ;  
                 } ,  
                  
                 / * *  
                   *   S e t s   o r   u p d a t e s   a n   A t t r i b u t e   i n s t a n c e ' s   p r o p e r t i e s .    
                   *   @ m e t h o d   s e t A t t r i b u t e C o n f i g  
                   *   @ p a r a m   { S t r i n g }   k e y   T h e   a t t r i b u t e ' s   n a m e .  
                   *   @ p a r a m   { O b j e c t }   m a p   A   k e y - v a l u e   m a p   o f   a t t r i b u t e   p r o p e r t i e s  
                   *   @ p a r a m   { B o o l e a n }   i n i t   W h e t h e r   o r   n o t   t h i s   s h o u l d   b e c o m e   t h e   i n t i a l   c o n f i g .  
                   * /  
                 s e t A t t r i b u t e C o n f i g :   f u n c t i o n ( k e y ,   m a p ,   i n i t )   {  
                         t h i s . _ c o n f i g s   =   t h i s . _ c o n f i g s   | |   { } ;  
                         m a p   =   m a p   | |   { } ;  
                         i f   ( ! t h i s . _ c o n f i g s [ k e y ] )   {  
                                 m a p . n a m e   =   k e y ;  
                                 t h i s . _ c o n f i g s [ k e y ]   =   t h i s . c r e a t e A t t r i b u t e ( m a p ) ;  
                         }   e l s e   {  
                                 t h i s . _ c o n f i g s [ k e y ] . c o n f i g u r e ( m a p ,   i n i t ) ;  
                         }  
                 } ,  
                  
                 / * *  
                   *   S e t s   o r   u p d a t e s   a n   A t t r i b u t e   i n s t a n c e ' s   p r o p e r t i e s .    
                   *   @ m e t h o d   c o n f i g u r e A t t r i b u t e  
                   *   @ p a r a m   { S t r i n g }   k e y   T h e   a t t r i b u t e ' s   n a m e .  
                   *   @ p a r a m   { O b j e c t }   m a p   A   k e y - v a l u e   m a p   o f   a t t r i b u t e   p r o p e r t i e s  
                   *   @ p a r a m   { B o o l e a n }   i n i t   W h e t h e r   o r   n o t   t h i s   s h o u l d   b e c o m e   t h e   i n t i a l   c o n f i g .  
                   *   @ d e p r e c a t e d   U s e   s e t A t t r i b u t e C o n f i g  
                   * /  
                 c o n f i g u r e A t t r i b u t e :   f u n c t i o n ( k e y ,   m a p ,   i n i t )   {  
                         t h i s . s e t A t t r i b u t e C o n f i g ( k e y ,   m a p ,   i n i t ) ;  
                 } ,  
                  
                 / * *  
                   *   R e s e t s   a n   a t t r i b u t e   t o   i t s   i n t i a l   c o n f i g u r a t i o n .    
                   *   @ m e t h o d   r e s e t A t t r i b u t e C o n f i g  
                   *   @ p a r a m   { S t r i n g }   k e y   T h e   a t t r i b u t e ' s   n a m e .  
                   *   @ p r i v a t e  
                   * /  
                 r e s e t A t t r i b u t e C o n f i g :   f u n c t i o n ( k e y ) {  
                         t h i s . _ c o n f i g s   =   t h i s . _ c o n f i g s   | |   { } ;  
                         t h i s . _ c o n f i g s [ k e y ] . r e s e t C o n f i g ( ) ;  
                 } ,  
                  
                 / /   w r a p p e r   f o r   E v e n t P r o v i d e r . s u b s c r i b e  
                 / /   t o   c r e a t e   e v e n t s   o n   t h e   f l y  
                 s u b s c r i b e :   f u n c t i o n ( t y p e ,   c a l l b a c k )   {  
                         t h i s . _ e v e n t s   =   t h i s . _ e v e n t s   | |   { } ;  
  
                         i f   (   ! ( t y p e   i n   t h i s . _ e v e n t s )   )   {  
                                 t h i s . _ e v e n t s [ t y p e ]   =   t h i s . c r e a t e E v e n t ( t y p e ) ;  
                         }  
  
                         Y A H O O . u t i l . E v e n t P r o v i d e r . p r o t o t y p e . s u b s c r i b e . a p p l y ( t h i s ,   a r g u m e n t s ) ;  
                 } ,  
  
                 o n :   f u n c t i o n ( )   {  
                         t h i s . s u b s c r i b e . a p p l y ( t h i s ,   a r g u m e n t s ) ;  
                 } ,  
  
                 a d d L i s t e n e r :   f u n c t i o n ( )   {  
                         t h i s . s u b s c r i b e . a p p l y ( t h i s ,   a r g u m e n t s ) ;  
                 } ,  
  
                 / * *  
                   *   F i r e s   t h e   a t t r i b u t e ' s   b e f o r e C h a n g e   e v e n t .    
                   *   @ m e t h o d   f i r e B e f o r e C h a n g e E v e n t  
                   *   @ p a r a m   { S t r i n g }   k e y   T h e   a t t r i b u t e ' s   n a m e .  
                   *   @ p a r a m   { O b j }   e   T h e   e v e n t   o b j e c t   t o   p a s s   t o   h a n d l e r s .  
                   * /  
                 f i r e B e f o r e C h a n g e E v e n t :   f u n c t i o n ( e )   {  
                         v a r   t y p e   =   ' b e f o r e ' ;  
                         t y p e   + =   e . t y p e . c h a r A t ( 0 ) . t o U p p e r C a s e ( )   +   e . t y p e . s u b s t r ( 1 )   +   ' C h a n g e ' ;  
                         e . t y p e   =   t y p e ;  
                         r e t u r n   t h i s . f i r e E v e n t ( e . t y p e ,   e ) ;  
                 } ,  
                  
                 / * *  
                   *   F i r e s   t h e   a t t r i b u t e ' s   c h a n g e   e v e n t .    
                   *   @ m e t h o d   f i r e C h a n g e E v e n t  
                   *   @ p a r a m   { S t r i n g }   k e y   T h e   a t t r i b u t e ' s   n a m e .  
                   *   @ p a r a m   { O b j }   e   T h e   e v e n t   o b j e c t   t o   p a s s   t o   t h e   h a n d l e r s .  
                   * /  
                 f i r e C h a n g e E v e n t :   f u n c t i o n ( e )   {  
                         e . t y p e   + =   ' C h a n g e ' ;  
                         r e t u r n   t h i s . f i r e E v e n t ( e . t y p e ,   e ) ;  
                 } ,  
  
                 c r e a t e A t t r i b u t e :   f u n c t i o n ( m a p )   {  
                         r e t u r n   n e w   Y A H O O . u t i l . A t t r i b u t e ( m a p ,   t h i s ) ;  
                 }  
         } ;  
          
         Y A H O O . a u g m e n t ( Y A H O O . u t i l . A t t r i b u t e P r o v i d e r ,   Y A H O O . u t i l . E v e n t P r o v i d e r ) ;  
 } ) ( ) ;  
  
 ( f u n c t i o n ( )   {  
 / /   i n t e r n a l   s h o r t h a n d  
 v a r   D o m   =   Y A H O O . u t i l . D o m ,  
         A t t r i b u t e P r o v i d e r   =   Y A H O O . u t i l . A t t r i b u t e P r o v i d e r ,  
 	 s p e c i a l T y p e s   =   {  
 	 	 m o u s e e n t e r :   t r u e ,  
 	 	 m o u s e l e a v e :   t r u e  
 	 } ;  
  
 / * *  
   *   E l e m e n t   p r o v i d e s   a n   w r a p p e r   o b j e c t   t o   s i m p l i f y   a d d i n g  
   *   e v e n t   l i s t e n e r s ,   u s i n g   d o m   m e t h o d s ,   a n d   m a n a g i n g   a t t r i b u t e s .    
   *   @ m o d u l e   e l e m e n t  
   *   @ n a m e s p a c e   Y A H O O . u t i l  
   *   @ r e q u i r e s   y a h o o ,   d o m ,   e v e n t  
   * /  
  
 / * *  
   *   E l e m e n t   p r o v i d e s   a n   w r a p p e r   o b j e c t   t o   s i m p l i f y   a d d i n g  
   *   e v e n t   l i s t e n e r s ,   u s i n g   d o m   m e t h o d s ,   a n d   m a n a g i n g   a t t r i b u t e s .    
   *   @ c l a s s   E l e m e n t  
   *   @ u s e s   Y A H O O . u t i l . A t t r i b u t e P r o v i d e r  
   *   @ c o n s t r u c t o r  
   *   @ p a r a m   e l   { H T M L E l e m e n t   |   S t r i n g }   T h e   h t m l   e l e m e n t   t h a t    
   *   r e p r e s e n t s   t h e   E l e m e n t .  
   *   @ p a r a m   { O b j e c t }   m a p   A   k e y - v a l u e   m a p   o f   i n i t i a l   c o n f i g   n a m e s   a n d   v a l u e s  
   * /  
 v a r   E l e m e n t   =   f u n c t i o n ( e l ,   m a p )   {  
         t h i s . i n i t . a p p l y ( t h i s ,   a r g u m e n t s ) ;  
 } ;  
  
 E l e m e n t . D O M _ E V E N T S   =   {  
         ' c l i c k ' :   t r u e ,  
         ' d b l c l i c k ' :   t r u e ,  
         ' k e y d o w n ' :   t r u e ,  
         ' k e y p r e s s ' :   t r u e ,  
         ' k e y u p ' :   t r u e ,  
         ' m o u s e d o w n ' :   t r u e ,  
         ' m o u s e m o v e ' :   t r u e ,  
         ' m o u s e o u t ' :   t r u e ,    
         ' m o u s e o v e r ' :   t r u e ,    
         ' m o u s e u p ' :   t r u e ,  
         ' m o u s e e n t e r ' :   t r u e ,    
         ' m o u s e l e a v e ' :   t r u e ,  
         ' f o c u s ' :   t r u e ,  
         ' b l u r ' :   t r u e ,  
         ' s u b m i t ' :   t r u e ,  
         ' c h a n g e ' :   t r u e  
 } ;  
  
 E l e m e n t . p r o t o t y p e   =   {  
         / * *  
           *   D o m   e v e n t s   s u p p o r t e d   b y   t h e   E l e m e n t   i n s t a n c e .  
           *   @ p r o p e r t y   D O M _ E V E N T S  
           *   @ t y p e   O b j e c t  
           * /  
         D O M _ E V E N T S :   n u l l ,  
  
         D E F A U L T _ H T M L _ S E T T E R :   f u n c t i o n ( v a l u e ,   k e y )   {  
                 v a r   e l   =   t h i s . g e t ( ' e l e m e n t ' ) ;  
                  
                 i f   ( e l )   {  
                         e l [ k e y ]   =   v a l u e ;  
                 }  
  
 	 	 r e t u r n   v a l u e ;  
  
         } ,  
  
         D E F A U L T _ H T M L _ G E T T E R :   f u n c t i o n ( k e y )   {  
                 v a r   e l   =   t h i s . g e t ( ' e l e m e n t ' ) ,  
                         v a l ;  
  
                 i f   ( e l )   {  
                         v a l   =   e l [ k e y ] ;  
                 }  
  
                 r e t u r n   v a l ;  
         } ,  
  
         / * *  
           *   W r a p p e r   f o r   H T M L E l e m e n t   m e t h o d .  
           *   @ m e t h o d   a p p e n d C h i l d  
           *   @ p a r a m   { Y A H O O . u t i l . E l e m e n t   | |   H T M L E l e m e n t }   c h i l d   T h e   e l e m e n t   t o   a p p e n d .    
           *   @ r e t u r n   { H T M L E l e m e n t }   T h e   a p p e n d e d   D O M   e l e m e n t .    
           * /  
         a p p e n d C h i l d :   f u n c t i o n ( c h i l d )   {  
                 c h i l d   =   c h i l d . g e t   ?   c h i l d . g e t ( ' e l e m e n t ' )   :   c h i l d ;  
                 r e t u r n   t h i s . g e t ( ' e l e m e n t ' ) . a p p e n d C h i l d ( c h i l d ) ;  
         } ,  
          
         / * *  
           *   W r a p p e r   f o r   H T M L E l e m e n t   m e t h o d .  
           *   @ m e t h o d   g e t E l e m e n t s B y T a g N a m e  
           *   @ p a r a m   { S t r i n g }   t a g   T h e   t a g N a m e   t o   c o l l e c t  
           *   @ r e t u r n   { H T M L C o l l e c t i o n }   A   c o l l e c t i o n   o f   D O M   e l e m e n t s .    
           * /  
         g e t E l e m e n t s B y T a g N a m e :   f u n c t i o n ( t a g )   {  
                 r e t u r n   t h i s . g e t ( ' e l e m e n t ' ) . g e t E l e m e n t s B y T a g N a m e ( t a g ) ;  
         } ,  
          
         / * *  
           *   W r a p p e r   f o r   H T M L E l e m e n t   m e t h o d .  
           *   @ m e t h o d   h a s C h i l d N o d e s  
           *   @ r e t u r n   { B o o l e a n }   W h e t h e r   o r   n o t   t h e   e l e m e n t   h a s   c h i l d N o d e s  
           * /  
         h a s C h i l d N o d e s :   f u n c t i o n ( )   {  
                 r e t u r n   t h i s . g e t ( ' e l e m e n t ' ) . h a s C h i l d N o d e s ( ) ;  
         } ,  
          
         / * *  
           *   W r a p p e r   f o r   H T M L E l e m e n t   m e t h o d .  
           *   @ m e t h o d   i n s e r t B e f o r e  
           *   @ p a r a m   { H T M L E l e m e n t }   e l e m e n t   T h e   H T M L E l e m e n t   t o   i n s e r t  
           *   @ p a r a m   { H T M L E l e m e n t }   b e f o r e   T h e   H T M L E l e m e n t   t o   i n s e r t  
           *   t h e   e l e m e n t   b e f o r e .  
           *   @ r e t u r n   { H T M L E l e m e n t }   T h e   i n s e r t e d   D O M   e l e m e n t .    
           * /  
         i n s e r t B e f o r e :   f u n c t i o n ( e l e m e n t ,   b e f o r e )   {  
                 e l e m e n t   =   e l e m e n t . g e t   ?   e l e m e n t . g e t ( ' e l e m e n t ' )   :   e l e m e n t ;  
                 b e f o r e   =   ( b e f o r e   & &   b e f o r e . g e t )   ?   b e f o r e . g e t ( ' e l e m e n t ' )   :   b e f o r e ;  
                  
                 r e t u r n   t h i s . g e t ( ' e l e m e n t ' ) . i n s e r t B e f o r e ( e l e m e n t ,   b e f o r e ) ;  
         } ,  
          
         / * *  
           *   W r a p p e r   f o r   H T M L E l e m e n t   m e t h o d .  
           *   @ m e t h o d   r e m o v e C h i l d  
           *   @ p a r a m   { H T M L E l e m e n t }   c h i l d   T h e   H T M L E l e m e n t   t o   r e m o v e  
           *   @ r e t u r n   { H T M L E l e m e n t }   T h e   r e m o v e d   D O M   e l e m e n t .    
           * /  
         r e m o v e C h i l d :   f u n c t i o n ( c h i l d )   {  
                 c h i l d   =   c h i l d . g e t   ?   c h i l d . g e t ( ' e l e m e n t ' )   :   c h i l d ;  
                 r e t u r n   t h i s . g e t ( ' e l e m e n t ' ) . r e m o v e C h i l d ( c h i l d ) ;  
         } ,  
          
         / * *  
           *   W r a p p e r   f o r   H T M L E l e m e n t   m e t h o d .  
           *   @ m e t h o d   r e p l a c e C h i l d  
           *   @ p a r a m   { H T M L E l e m e n t }   n e w N o d e   T h e   H T M L E l e m e n t   t o   i n s e r t  
           *   @ p a r a m   { H T M L E l e m e n t }   o l d N o d e   T h e   H T M L E l e m e n t   t o   r e p l a c e  
           *   @ r e t u r n   { H T M L E l e m e n t }   T h e   r e p l a c e d   D O M   e l e m e n t .    
           * /  
         r e p l a c e C h i l d :   f u n c t i o n ( n e w N o d e ,   o l d N o d e )   {  
                 n e w N o d e   =   n e w N o d e . g e t   ?   n e w N o d e . g e t ( ' e l e m e n t ' )   :   n e w N o d e ;  
                 o l d N o d e   =   o l d N o d e . g e t   ?   o l d N o d e . g e t ( ' e l e m e n t ' )   :   o l d N o d e ;  
                 r e t u r n   t h i s . g e t ( ' e l e m e n t ' ) . r e p l a c e C h i l d ( n e w N o d e ,   o l d N o d e ) ;  
         } ,  
  
          
         / * *  
           *   R e g i s t e r s   E l e m e n t   s p e c i f i c   a t t r i b u t e s .  
           *   @ m e t h o d   i n i t A t t r i b u t e s  
           *   @ p a r a m   { O b j e c t }   m a p   A   k e y - v a l u e   m a p   o f   i n i t i a l   a t t r i b u t e   c o n f i g s  
           * /  
         i n i t A t t r i b u t e s :   f u n c t i o n ( m a p )   {  
         } ,  
  
         / * *  
           *   A d d s   a   l i s t e n e r   f o r   t h e   g i v e n   e v e n t .     T h e s e   m a y   b e   D O M   o r    
           *   c u s t o m E v e n t   l i s t e n e r s .     A n y   e v e n t   t h a t   i s   f i r e d   v i a   f i r e E v e n t  
           *   c a n   b e   l i s t e n e d   f o r .     A l l   h a n d l e r s   r e c e i v e   a n   e v e n t   o b j e c t .    
           *   @ m e t h o d   a d d L i s t e n e r  
           *   @ p a r a m   { S t r i n g }   t y p e   T h e   n a m e   o f   t h e   e v e n t   t o   l i s t e n   f o r  
           *   @ p a r a m   { F u n c t i o n }   f n   T h e   h a n d l e r   t o   c a l l   w h e n   t h e   e v e n t   f i r e s  
           *   @ p a r a m   { A n y }   o b j   A   v a r i a b l e   t o   p a s s   t o   t h e   h a n d l e r  
           *   @ p a r a m   { O b j e c t }   s c o p e   T h e   o b j e c t   t o   u s e   f o r   t h e   s c o p e   o f   t h e   h a n d l e r    
           * /  
         a d d L i s t e n e r :   f u n c t i o n ( t y p e ,   f n ,   o b j ,   s c o p e )   {  
  
                 s c o p e   =   s c o p e   | |   t h i s ;  
  
                 v a r   E v e n t   =   Y A H O O . u t i l . E v e n t ,  
 	 	 	 e l   =   t h i s . g e t ( ' e l e m e n t ' )   | |   t h i s . g e t ( ' i d ' ) ,  
                 	 s e l f   =   t h i s ;  
  
  
 	 	 i f   ( s p e c i a l T y p e s [ t y p e ]   & &   ! E v e n t . _ c r e a t e M o u s e D e l e g a t e )   {  
 	                 r e t u r n   f a l s e ; 	  
 	 	 }  
  
  
                 i f   ( ! t h i s . _ e v e n t s [ t y p e ] )   {   / /   c r e a t e   o n   t h e   f l y  
  
                         i f   ( e l   & &   t h i s . D O M _ E V E N T S [ t y p e ] )   {  
 	 	 	 	 E v e n t . o n ( e l ,   t y p e ,   f u n c t i o n ( e ,   m a t c h e d E l )   {  
  
 	 	 	 	 	 / /   S u p p l e m e n t   I E   w i t h   t a r g e t ,   c u r r e n t T a r g e t   r e l a t e d T a r g e t  
  
 	                                 i f   ( e . s r c E l e m e n t   & &   ! e . t a r g e t )   {    
 	                                         e . t a r g e t   =   e . s r c E l e m e n t ;  
 	                                 }  
  
 	 	 	 	 	 i f   ( ( e . t o E l e m e n t   & &   ! e . r e l a t e d T a r g e t )   | |   ( e . f r o m E l e m e n t   & &   ! e . r e l a t e d T a r g e t ) )   {  
 	 	 	 	 	 	 e . r e l a t e d T a r g e t   =   E v e n t . g e t R e l a t e d T a r g e t ( e ) ;  
 	 	 	 	 	 }  
 	 	 	 	 	  
 	 	 	 	 	 i f   ( ! e . c u r r e n t T a r g e t )   {  
 	 	 	 	 	 	 e . c u r r e n t T a r g e t   =   e l ;  
 	 	 	 	 	 }  
  
 	 	 	 	 	 / / 	 N o t e :   m a t c h e d E l   e l   i s   p a s s e d   b a c k   f o r   d e l e g a t e d   l i s t e n e r s  
 	 	                         s e l f . f i r e E v e n t ( t y p e ,   e ,   m a t c h e d E l ) ;  
  
 	 	                 } ,   o b j ,   s c o p e ) ;  
                         }  
                         t h i s . c r e a t e E v e n t ( t y p e ,   { s c o p e :   t h i s } ) ;  
                 }  
                  
                 r e t u r n   Y A H O O . u t i l . E v e n t P r o v i d e r . p r o t o t y p e . s u b s c r i b e . a p p l y ( t h i s ,   a r g u m e n t s ) ;   / /   n o t i f y   v i a   c u s t o m E v e n t  
         } ,  
  
  
         / * *  
           *   A l i a s   f o r   a d d L i s t e n e r  
           *   @ m e t h o d   o n  
           *   @ p a r a m   { S t r i n g }   t y p e   T h e   n a m e   o f   t h e   e v e n t   t o   l i s t e n   f o r  
           *   @ p a r a m   { F u n c t i o n }   f n   T h e   f u n c t i o n   c a l l   w h e n   t h e   e v e n t   f i r e s  
           *   @ p a r a m   { A n y }   o b j   A   v a r i a b l e   t o   p a s s   t o   t h e   h a n d l e r  
           *   @ p a r a m   { O b j e c t }   s c o p e   T h e   o b j e c t   t o   u s e   f o r   t h e   s c o p e   o f   t h e   h a n d l e r    
           * /  
         o n :   f u n c t i o n ( )   {  
                 r e t u r n   t h i s . a d d L i s t e n e r . a p p l y ( t h i s ,   a r g u m e n t s ) ;  
         } ,  
          
         / * *  
           *   A l i a s   f o r   a d d L i s t e n e r  
           *   @ m e t h o d   s u b s c r i b e  
           *   @ p a r a m   { S t r i n g }   t y p e   T h e   n a m e   o f   t h e   e v e n t   t o   l i s t e n   f o r  
           *   @ p a r a m   { F u n c t i o n }   f n   T h e   f u n c t i o n   c a l l   w h e n   t h e   e v e n t   f i r e s  
           *   @ p a r a m   { A n y }   o b j   A   v a r i a b l e   t o   p a s s   t o   t h e   h a n d l e r  
           *   @ p a r a m   { O b j e c t }   s c o p e   T h e   o b j e c t   t o   u s e   f o r   t h e   s c o p e   o f   t h e   h a n d l e r    
           * /  
         s u b s c r i b e :   f u n c t i o n ( )   {  
                 r e t u r n   t h i s . a d d L i s t e n e r . a p p l y ( t h i s ,   a r g u m e n t s ) ;  
         } ,  
          
         / * *  
           *   R e m o v e   a n   e v e n t   l i s t e n e r  
           *   @ m e t h o d   r e m o v e L i s t e n e r  
           *   @ p a r a m   { S t r i n g }   t y p e   T h e   n a m e   o f   t h e   e v e n t   t o   l i s t e n   f o r  
           *   @ p a r a m   { F u n c t i o n }   f n   T h e   f u n c t i o n   c a l l   w h e n   t h e   e v e n t   f i r e s  
           * /  
         r e m o v e L i s t e n e r :   f u n c t i o n ( t y p e ,   f n )   {  
                 r e t u r n   t h i s . u n s u b s c r i b e . a p p l y ( t h i s ,   a r g u m e n t s ) ;  
         } ,  
          
         / * *  
           *   W r a p p e r   f o r   D o m   m e t h o d .  
           *   @ m e t h o d   a d d C l a s s  
           *   @ p a r a m   { S t r i n g }   c l a s s N a m e   T h e   c l a s s N a m e   t o   a d d  
           * /  
         a d d C l a s s :   f u n c t i o n ( c l a s s N a m e )   {  
                 D o m . a d d C l a s s ( t h i s . g e t ( ' e l e m e n t ' ) ,   c l a s s N a m e ) ;  
         } ,  
          
         / * *  
           *   W r a p p e r   f o r   D o m   m e t h o d .  
           *   @ m e t h o d   g e t E l e m e n t s B y C l a s s N a m e  
           *   @ p a r a m   { S t r i n g }   c l a s s N a m e   T h e   c l a s s N a m e   t o   c o l l e c t  
           *   @ p a r a m   { S t r i n g }   t a g   ( o p t i o n a l )   T h e   t a g   t o   u s e   i n  
           *   c o n j u n c t i o n   w i t h   c l a s s   n a m e  
           *   @ r e t u r n   { A r r a y }   A r r a y   o f   H T M L E l e m e n t s  
           * /  
         g e t E l e m e n t s B y C l a s s N a m e :   f u n c t i o n ( c l a s s N a m e ,   t a g )   {  
                 r e t u r n   D o m . g e t E l e m e n t s B y C l a s s N a m e ( c l a s s N a m e ,   t a g ,  
                                 t h i s . g e t ( ' e l e m e n t ' )   ) ;  
         } ,  
          
         / * *  
           *   W r a p p e r   f o r   D o m   m e t h o d .  
           *   @ m e t h o d   h a s C l a s s  
           *   @ p a r a m   { S t r i n g }   c l a s s N a m e   T h e   c l a s s N a m e   t o   a d d  
           *   @ r e t u r n   { B o o l e a n }   W h e t h e r   o r   n o t   t h e   e l e m e n t   h a s   t h e   c l a s s   n a m e  
           * /  
         h a s C l a s s :   f u n c t i o n ( c l a s s N a m e )   {  
                 r e t u r n   D o m . h a s C l a s s ( t h i s . g e t ( ' e l e m e n t ' ) ,   c l a s s N a m e ) ;    
         } ,  
          
         / * *  
           *   W r a p p e r   f o r   D o m   m e t h o d .  
           *   @ m e t h o d   r e m o v e C l a s s  
           *   @ p a r a m   { S t r i n g }   c l a s s N a m e   T h e   c l a s s N a m e   t o   r e m o v e  
           * /  
         r e m o v e C l a s s :   f u n c t i o n ( c l a s s N a m e )   {  
                 r e t u r n   D o m . r e m o v e C l a s s ( t h i s . g e t ( ' e l e m e n t ' ) ,   c l a s s N a m e ) ;  
         } ,  
          
         / * *  
           *   W r a p p e r   f o r   D o m   m e t h o d .  
           *   @ m e t h o d   r e p l a c e C l a s s  
           *   @ p a r a m   { S t r i n g }   o l d C l a s s N a m e   T h e   c l a s s N a m e   t o   r e p l a c e  
           *   @ p a r a m   { S t r i n g }   n e w C l a s s N a m e   T h e   c l a s s N a m e   t o   a d d  
           * /  
         r e p l a c e C l a s s :   f u n c t i o n ( o l d C l a s s N a m e ,   n e w C l a s s N a m e )   {  
                 r e t u r n   D o m . r e p l a c e C l a s s ( t h i s . g e t ( ' e l e m e n t ' ) ,    
                                 o l d C l a s s N a m e ,   n e w C l a s s N a m e ) ;  
         } ,  
          
         / * *  
           *   W r a p p e r   f o r   D o m   m e t h o d .  
           *   @ m e t h o d   s e t S t y l e  
           *   @ p a r a m   { S t r i n g }   p r o p e r t y   T h e   s t y l e   p r o p e r t y   t o   s e t  
           *   @ p a r a m   { S t r i n g }   v a l u e   T h e   v a l u e   t o   a p p l y   t o   t h e   s t y l e   p r o p e r t y  
           * /  
         s e t S t y l e :   f u n c t i o n ( p r o p e r t y ,   v a l u e )   {  
                 r e t u r n   D o m . s e t S t y l e ( t h i s . g e t ( ' e l e m e n t ' ) ,     p r o p e r t y ,   v a l u e ) ;   / /   T O D O :   a l w a y s   q u e u i n g ?  
         } ,  
          
         / * *  
           *   W r a p p e r   f o r   D o m   m e t h o d .  
           *   @ m e t h o d   g e t S t y l e  
           *   @ p a r a m   { S t r i n g }   p r o p e r t y   T h e   s t y l e   p r o p e r t y   t o   r e t r i e v e  
           *   @ r e t u r n   { S t r i n g }   T h e   c u r r e n t   v a l u e   o f   t h e   p r o p e r t y  
           * /  
         g e t S t y l e :   f u n c t i o n ( p r o p e r t y )   {  
                 r e t u r n   D o m . g e t S t y l e ( t h i s . g e t ( ' e l e m e n t ' ) ,     p r o p e r t y ) ;  
         } ,  
          
         / * *  
           *   A p p l y   a n y   q u e u e d   s e t   c a l l s .  
           *   @ m e t h o d   f i r e Q u e u e  
           * /  
         f i r e Q u e u e :   f u n c t i o n ( )   {  
                 v a r   q u e u e   =   t h i s . _ q u e u e ;  
                 f o r   ( v a r   i   =   0 ,   l e n   =   q u e u e . l e n g t h ;   i   <   l e n ;   + + i )   {  
                         t h i s [ q u e u e [ i ] [ 0 ] ] . a p p l y ( t h i s ,   q u e u e [ i ] [ 1 ] ) ;  
                 }  
         } ,  
          
         / * *  
           *   A p p e n d s   t h e   H T M L E l e m e n t   i n t o   e i t h e r   t h e   s u p p l i e d   p a r e n t N o d e .  
           *   @ m e t h o d   a p p e n d T o  
           *   @ p a r a m   { H T M L E l e m e n t   |   E l e m e n t }   p a r e n t N o d e   T h e   n o d e   t o   a p p e n d   t o  
           *   @ p a r a m   { H T M L E l e m e n t   |   E l e m e n t }   b e f o r e   A n   o p t i o n a l   n o d e   t o   i n s e r t   b e f o r e  
           *   @ r e t u r n   { H T M L E l e m e n t }   T h e   a p p e n d e d   D O M   e l e m e n t .    
           * /  
         a p p e n d T o :   f u n c t i o n ( p a r e n t ,   b e f o r e )   {  
                 p a r e n t   =   ( p a r e n t . g e t )   ?     p a r e n t . g e t ( ' e l e m e n t ' )   :   D o m . g e t ( p a r e n t ) ;  
                  
                 t h i s . f i r e E v e n t ( ' b e f o r e A p p e n d T o ' ,   {  
                         t y p e :   ' b e f o r e A p p e n d T o ' ,  
                         t a r g e t :   p a r e n t  
                 } ) ;  
                  
                  
                 b e f o r e   =   ( b e f o r e   & &   b e f o r e . g e t )   ?    
                                 b e f o r e . g e t ( ' e l e m e n t ' )   :   D o m . g e t ( b e f o r e ) ;  
                 v a r   e l e m e n t   =   t h i s . g e t ( ' e l e m e n t ' ) ;  
                  
                 i f   ( ! e l e m e n t )   {  
                         r e t u r n   f a l s e ;  
                 }  
                  
                 i f   ( ! p a r e n t )   {  
                         r e t u r n   f a l s e ;  
                 }  
                  
                 i f   ( e l e m e n t . p a r e n t   ! =   p a r e n t )   {  
                         i f   ( b e f o r e )   {  
                                 p a r e n t . i n s e r t B e f o r e ( e l e m e n t ,   b e f o r e ) ;  
                         }   e l s e   {  
                                 p a r e n t . a p p e n d C h i l d ( e l e m e n t ) ;  
                         }  
                 }  
                  
                  
                 t h i s . f i r e E v e n t ( ' a p p e n d T o ' ,   {  
                         t y p e :   ' a p p e n d T o ' ,  
                         t a r g e t :   p a r e n t  
                 } ) ;  
  
                 r e t u r n   e l e m e n t ;  
         } ,  
          
         g e t :   f u n c t i o n ( k e y )   {  
                 v a r   c o n f i g s   =   t h i s . _ c o n f i g s   | |   { } ,  
                         e l   =   c o n f i g s . e l e m e n t ;   / /   a v o i d   l o o p   d u e   t o   ' e l e m e n t '  
  
                 i f   ( e l   & &   ! c o n f i g s [ k e y ]   & &   ! Y A H O O . l a n g . i s U n d e f i n e d ( e l . v a l u e [ k e y ] )   )   {  
                         t h i s . _ s e t H T M L A t t r C o n f i g ( k e y ) ;  
                 }  
  
                 r e t u r n   A t t r i b u t e P r o v i d e r . p r o t o t y p e . g e t . c a l l ( t h i s ,   k e y ) ;  
         } ,  
  
         s e t A t t r i b u t e s :   f u n c t i o n ( m a p ,   s i l e n t )   {  
                 / /   s e t   b a s e d   o n   c o n f i g O r d e r  
                 v a r   d o n e   =   { } ,  
                         c o n f i g O r d e r   =   t h i s . _ c o n f i g O r d e r ;  
  
                 / /   s e t   b a s e d   o n   c o n f i g O r d e r  
                 f o r   ( v a r   i   =   0 ,   l e n   =   c o n f i g O r d e r . l e n g t h ;   i   <   l e n ;   + + i )   {  
                         i f   ( m a p [ c o n f i g O r d e r [ i ] ]   ! = =   u n d e f i n e d )   {  
                                 d o n e [ c o n f i g O r d e r [ i ] ]   =   t r u e ;  
                                 t h i s . s e t ( c o n f i g O r d e r [ i ] ,   m a p [ c o n f i g O r d e r [ i ] ] ,   s i l e n t ) ;  
                         }  
                 }  
  
                 / /   u n c o n f i g u r e d   ( e . g .   D o m   a t t r i b u t e s )  
                 f o r   ( v a r   a t t   i n   m a p )   {  
                         i f   ( m a p . h a s O w n P r o p e r t y ( a t t )   & &   ! d o n e [ a t t ] )   {  
                                 t h i s . s e t ( a t t ,   m a p [ a t t ] ,   s i l e n t ) ;  
                         }  
                 }  
         } ,  
  
         s e t :   f u n c t i o n ( k e y ,   v a l u e ,   s i l e n t )   {  
                 v a r   e l   =   t h i s . g e t ( ' e l e m e n t ' ) ;  
                 i f   ( ! e l )   {  
                         t h i s . _ q u e u e [ t h i s . _ q u e u e . l e n g t h ]   =   [ ' s e t ' ,   a r g u m e n t s ] ;  
                         i f   ( t h i s . _ c o n f i g s [ k e y ] )   {  
                                 t h i s . _ c o n f i g s [ k e y ] . v a l u e   =   v a l u e ;   / /   s o   " g e t "   w o r k s   w h i l e   q u e u e i n g  
                          
                         }  
                         r e t u r n ;  
                 }  
                  
                 / /   s e t   i t   o n   t h e   e l e m e n t   i f   n o t   c o n f i g u r e d   a n d   i s   a n   H T M L   a t t r i b u t e  
                 i f   (   ! t h i s . _ c o n f i g s [ k e y ]   & &   ! Y A H O O . l a n g . i s U n d e f i n e d ( e l [ k e y ] )   )   {  
                         t h i s . _ s e t H T M L A t t r C o n f i g ( k e y ) ;  
                 }  
  
                 r e t u r n   A t t r i b u t e P r o v i d e r . p r o t o t y p e . s e t . a p p l y ( t h i s ,   a r g u m e n t s ) ;  
         } ,  
          
         s e t A t t r i b u t e C o n f i g :   f u n c t i o n ( k e y ,   m a p ,   i n i t )   {  
                 t h i s . _ c o n f i g O r d e r . p u s h ( k e y ) ;  
                 A t t r i b u t e P r o v i d e r . p r o t o t y p e . s e t A t t r i b u t e C o n f i g . a p p l y ( t h i s ,   a r g u m e n t s ) ;  
         } ,  
  
         c r e a t e E v e n t :   f u n c t i o n ( t y p e ,   c o n f i g )   {  
                 t h i s . _ e v e n t s [ t y p e ]   =   t r u e ;  
                 r e t u r n   A t t r i b u t e P r o v i d e r . p r o t o t y p e . c r e a t e E v e n t . a p p l y ( t h i s ,   a r g u m e n t s ) ;  
         } ,  
          
         i n i t :   f u n c t i o n ( e l ,   a t t r )   {  
                 t h i s . _ i n i t E l e m e n t ( e l ,   a t t r ) ;    
         } ,  
  
         d e s t r o y :   f u n c t i o n ( )   {  
                 v a r   e l   =   t h i s . g e t ( ' e l e m e n t ' ) ;  
                 Y A H O O . u t i l . E v e n t . p u r g e E l e m e n t ( e l ,   t r u e ) ;   / /   p u r g e   D O M   l i s t e n e r s   r e c u r s i v e l y  
                 t h i s . u n s u b s c r i b e A l l ( ) ;   / /   u n s u b s c r i b e   a l l   c u s t o m   e v e n t s  
  
                 i f   ( e l   & &   e l . p a r e n t N o d e )   {  
                         e l . p a r e n t N o d e . r e m o v e C h i l d ( e l ) ;   / /   p u l l   f r o m   t h e   D O M  
                 }  
  
                 / /   r e v e r t   i n i t i a l   c o n f i g s  
                 t h i s . _ q u e u e   =   [ ] ;  
                 t h i s . _ e v e n t s   =   { } ;  
                 t h i s . _ c o n f i g s   =   { } ;  
                 t h i s . _ c o n f i g O r d e r   =   [ ] ;    
         } ,  
  
         _ i n i t E l e m e n t :   f u n c t i o n ( e l ,   a t t r )   {  
                 t h i s . _ q u e u e   =   t h i s . _ q u e u e   | |   [ ] ;  
                 t h i s . _ e v e n t s   =   t h i s . _ e v e n t s   | |   { } ;  
                 t h i s . _ c o n f i g s   =   t h i s . _ c o n f i g s   | |   { } ;  
                 t h i s . _ c o n f i g O r d e r   =   [ ] ;    
                 a t t r   =   a t t r   | |   { } ;  
                 a t t r . e l e m e n t   =   a t t r . e l e m e n t   | |   e l   | |   n u l l ;  
  
                 v a r   i s R e a d y   =   f a l s e ;     / /   t o   d e t e r m i n e   w h e n   t o   i n i t   H T M L E l e m e n t   a n d   c o n t e n t  
  
                 v a r   D O M _ E V E N T S   =   E l e m e n t . D O M _ E V E N T S ;  
                 t h i s . D O M _ E V E N T S   =   t h i s . D O M _ E V E N T S   | |   { } ;  
  
                 f o r   ( v a r   e v e n t   i n   D O M _ E V E N T S )   {  
                         i f   ( D O M _ E V E N T S . h a s O w n P r o p e r t y ( e v e n t ) )   {  
                                 t h i s . D O M _ E V E N T S [ e v e n t ]   =   D O M _ E V E N T S [ e v e n t ] ;  
                         }  
                 }  
  
                 i f   ( t y p e o f   a t t r . e l e m e n t   = = =   ' s t r i n g ' )   {   / /   r e g i s t e r   I D   f o r   g e t ( )   a c c e s s  
                         t h i s . _ s e t H T M L A t t r C o n f i g ( ' i d ' ,   {   v a l u e :   a t t r . e l e m e n t   } ) ;  
                 }  
  
                 i f   ( D o m . g e t ( a t t r . e l e m e n t ) )   {  
                         i s R e a d y   =   t r u e ;  
                         t h i s . _ i n i t H T M L E l e m e n t ( a t t r ) ;  
                         t h i s . _ i n i t C o n t e n t ( a t t r ) ;  
                 }  
  
                 Y A H O O . u t i l . E v e n t . o n A v a i l a b l e ( a t t r . e l e m e n t ,   f u n c t i o n ( )   {  
                         i f   ( ! i s R e a d y )   {   / /   o t h e r w i s e   a l r e a d y   d o n e  
                                 t h i s . _ i n i t H T M L E l e m e n t ( a t t r ) ;  
                         }  
  
                         t h i s . f i r e E v e n t ( ' a v a i l a b l e ' ,   {   t y p e :   ' a v a i l a b l e ' ,   t a r g e t :   D o m . g e t ( a t t r . e l e m e n t )   } ) ;      
                 } ,   t h i s ,   t r u e ) ;  
                  
                 Y A H O O . u t i l . E v e n t . o n C o n t e n t R e a d y ( a t t r . e l e m e n t ,   f u n c t i o n ( )   {  
                         i f   ( ! i s R e a d y )   {   / /   o t h e r w i s e   a l r e a d y   d o n e  
                                 t h i s . _ i n i t C o n t e n t ( a t t r ) ;  
                         }  
                         t h i s . f i r e E v e n t ( ' c o n t e n t R e a d y ' ,   {   t y p e :   ' c o n t e n t R e a d y ' ,   t a r g e t :   D o m . g e t ( a t t r . e l e m e n t )   } ) ;      
                 } ,   t h i s ,   t r u e ) ;  
         } ,  
  
         _ i n i t H T M L E l e m e n t :   f u n c t i o n ( a t t r )   {  
                 / * *  
                   *   T h e   H T M L E l e m e n t   t h e   E l e m e n t   i n s t a n c e   r e f e r s   t o .  
                   *   @ a t t r i b u t e   e l e m e n t  
                   *   @ t y p e   H T M L E l e m e n t  
                   * /  
                 t h i s . s e t A t t r i b u t e C o n f i g ( ' e l e m e n t ' ,   {  
                         v a l u e :   D o m . g e t ( a t t r . e l e m e n t ) ,  
                         r e a d O n l y :   t r u e  
                   } ) ;  
         } ,  
  
         _ i n i t C o n t e n t :   f u n c t i o n ( a t t r )   {  
                 t h i s . i n i t A t t r i b u t e s ( a t t r ) ;  
                 t h i s . s e t A t t r i b u t e s ( a t t r ,   t r u e ) ;  
                 t h i s . f i r e Q u e u e ( ) ;  
  
         } ,  
  
         / * *  
           *   S e t s   t h e   v a l u e   o f   t h e   p r o p e r t y   a n d   f i r e s   b e f o r e C h a n g e   a n d   c h a n g e   e v e n t s .  
           *   @ p r i v a t e  
           *   @ m e t h o d   _ s e t H T M L A t t r C o n f i g  
           *   @ p a r a m   { Y A H O O . u t i l . E l e m e n t }   e l e m e n t   T h e   E l e m e n t   i n s t a n c e   t o  
           *   r e g i s t e r   t h e   c o n f i g   t o .  
           *   @ p a r a m   { S t r i n g }   k e y   T h e   n a m e   o f   t h e   c o n f i g   t o   r e g i s t e r  
           *   @ p a r a m   { O b j e c t }   m a p   A   k e y - v a l u e   m a p   o f   t h e   c o n f i g ' s   p a r a m s  
           * /  
         _ s e t H T M L A t t r C o n f i g :   f u n c t i o n ( k e y ,   m a p )   {  
                 v a r   e l   =   t h i s . g e t ( ' e l e m e n t ' ) ;  
                 m a p   =   m a p   | |   { } ;  
                 m a p . n a m e   =   k e y ;  
  
                 m a p . s e t t e r   =   m a p . s e t t e r   | |   t h i s . D E F A U L T _ H T M L _ S E T T E R ;  
                 m a p . g e t t e r   =   m a p . g e t t e r   | |   t h i s . D E F A U L T _ H T M L _ G E T T E R ;  
  
                 m a p . v a l u e   =   m a p . v a l u e   | |   e l [ k e y ] ;  
                 t h i s . _ c o n f i g s [ k e y ]   =   n e w   Y A H O O . u t i l . A t t r i b u t e ( m a p ,   t h i s ) ;  
         }  
 } ;  
  
 / * *  
   *   F i r e s   w h e n   t h e   E l e m e n t ' s   H T M L E l e m e n t   c a n   b e   r e t r i e v e d   b y   I d .  
   *   < p > S e e :   < a   h r e f = " # a d d L i s t e n e r " > E l e m e n t . a d d L i s t e n e r < / a > < / p >  
   *   < p > < s t r o n g > E v e n t   f i e l d s : < / s t r o n g > < b r >  
   *   < c o d e > & l t ; S t r i n g & g t ;   t y p e < / c o d e >   a v a i l a b l e < b r >  
   *   < c o d e > & l t ; H T M L E l e m e n t & g t ;  
   *   t a r g e t < / c o d e >   t h e   H T M L E l e m e n t   b o u n d   t o   t h i s   E l e m e n t   i n s t a n c e < b r >  
   *   < p > < s t r o n g > U s a g e : < / s t r o n g > < b r >  
   *   < c o d e > v a r   h a n d l e r   =   f u n c t i o n ( e )   { v a r   t a r g e t   =   e . t a r g e t } ; < b r >  
   *   m y T a b s . a d d L i s t e n e r ( ' a v a i l a b l e ' ,   h a n d l e r ) ; < / c o d e > < / p >  
   *   @ e v e n t   a v a i l a b l e  
   * /  
    
 / * *  
   *   F i r e s   w h e n   t h e   E l e m e n t ' s   H T M L E l e m e n t   s u b t r e e   i s   r e n d e r e d .  
   *   < p > S e e :   < a   h r e f = " # a d d L i s t e n e r " > E l e m e n t . a d d L i s t e n e r < / a > < / p >  
   *   < p > < s t r o n g > E v e n t   f i e l d s : < / s t r o n g > < b r >  
   *   < c o d e > & l t ; S t r i n g & g t ;   t y p e < / c o d e >   c o n t e n t R e a d y < b r >  
   *   < c o d e > & l t ; H T M L E l e m e n t & g t ;  
   *   t a r g e t < / c o d e >   t h e   H T M L E l e m e n t   b o u n d   t o   t h i s   E l e m e n t   i n s t a n c e < b r >  
   *   < p > < s t r o n g > U s a g e : < / s t r o n g > < b r >  
   *   < c o d e > v a r   h a n d l e r   =   f u n c t i o n ( e )   { v a r   t a r g e t   =   e . t a r g e t } ; < b r >  
   *   m y T a b s . a d d L i s t e n e r ( ' c o n t e n t R e a d y ' ,   h a n d l e r ) ; < / c o d e > < / p >  
   *   @ e v e n t   c o n t e n t R e a d y  
   * /  
  
 / * *  
   *   F i r e s   b e f o r e   t h e   E l e m e n t   i s   a p p e n d e d   t o   a n o t h e r   E l e m e n t .  
   *   < p > S e e :   < a   h r e f = " # a d d L i s t e n e r " > E l e m e n t . a d d L i s t e n e r < / a > < / p >  
   *   < p > < s t r o n g > E v e n t   f i e l d s : < / s t r o n g > < b r >  
   *   < c o d e > & l t ; S t r i n g & g t ;   t y p e < / c o d e >   b e f o r e A p p e n d T o < b r >  
   *   < c o d e > & l t ; H T M L E l e m e n t / E l e m e n t & g t ;  
   *   t a r g e t < / c o d e >   t h e   H T M L E l e m e n t / E l e m e n t   b e i n g   a p p e n d e d   t o    
   *   < p > < s t r o n g > U s a g e : < / s t r o n g > < b r >  
   *   < c o d e > v a r   h a n d l e r   =   f u n c t i o n ( e )   { v a r   t a r g e t   =   e . t a r g e t } ; < b r >  
   *   m y T a b s . a d d L i s t e n e r ( ' b e f o r e A p p e n d T o ' ,   h a n d l e r ) ; < / c o d e > < / p >  
   *   @ e v e n t   b e f o r e A p p e n d T o  
   * /  
  
 / * *  
   *   F i r e s   a f t e r   t h e   E l e m e n t   i s   a p p e n d e d   t o   a n o t h e r   E l e m e n t .  
   *   < p > S e e :   < a   h r e f = " # a d d L i s t e n e r " > E l e m e n t . a d d L i s t e n e r < / a > < / p >  
   *   < p > < s t r o n g > E v e n t   f i e l d s : < / s t r o n g > < b r >  
   *   < c o d e > & l t ; S t r i n g & g t ;   t y p e < / c o d e >   a p p e n d T o < b r >  
   *   < c o d e > & l t ; H T M L E l e m e n t / E l e m e n t & g t ;  
   *   t a r g e t < / c o d e >   t h e   H T M L E l e m e n t / E l e m e n t   b e i n g   a p p e n d e d   t o    
   *   < p > < s t r o n g > U s a g e : < / s t r o n g > < b r >  
   *   < c o d e > v a r   h a n d l e r   =   f u n c t i o n ( e )   { v a r   t a r g e t   =   e . t a r g e t } ; < b r >  
   *   m y T a b s . a d d L i s t e n e r ( ' a p p e n d T o ' ,   h a n d l e r ) ; < / c o d e > < / p >  
   *   @ e v e n t   a p p e n d T o  
   * /  
  
 Y A H O O . a u g m e n t ( E l e m e n t ,   A t t r i b u t e P r o v i d e r ) ;  
 Y A H O O . u t i l . E l e m e n t   =   E l e m e n t ;  
 } ) ( ) ;  
  
 Y A H O O . r e g i s t e r ( " e l e m e n t " ,   Y A H O O . u t i l . E l e m e n t ,   { v e r s i o n :   " 2 . 8 . 0 r 4 " ,   b u i l d :   " 2 4 4 9 " } ) ;  
 
