ÿþ/ *     P r o t o t y p e   J a v a S c r i p t   f r a m e w o r k ,   v e r s i o n   1 . 5 . 1 . 1  
   *     ( c )   2 0 0 5 - 2 0 0 7   S a m   S t e p h e n s o n  
   *  
   *     P r o t o t y p e   i s   f r e e l y   d i s t r i b u t a b l e   u n d e r   t h e   t e r m s   o f   a n   M I T - s t y l e   l i c e n s e .  
   *     F o r   d e t a i l s ,   s e e   t h e   P r o t o t y p e   w e b   s i t e :   h t t p : / / w w w . p r o t o t y p e j s . o r g /  
   *  
 / * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * /  
  
 v a r   P r o t o t y p e   =   {  
     V e r s i o n :   ' 1 . 5 . 1 . 1 ' ,  
  
     B r o w s e r :   {  
         I E :           ! ! ( w i n d o w . a t t a c h E v e n t   & &   ! w i n d o w . o p e r a ) ,  
         O p e r a :     ! ! w i n d o w . o p e r a ,  
         W e b K i t :   n a v i g a t o r . u s e r A g e n t . i n d e x O f ( ' A p p l e W e b K i t / ' )   >   - 1 ,  
         G e c k o :     n a v i g a t o r . u s e r A g e n t . i n d e x O f ( ' G e c k o ' )   >   - 1   & &   n a v i g a t o r . u s e r A g e n t . i n d e x O f ( ' K H T M L ' )   = =   - 1  
     } ,  
  
     B r o w s e r F e a t u r e s :   {  
         X P a t h :   ! ! d o c u m e n t . e v a l u a t e ,  
         E l e m e n t E x t e n s i o n s :   ! ! w i n d o w . H T M L E l e m e n t ,  
         S p e c i f i c E l e m e n t E x t e n s i o n s :  
             ( d o c u m e n t . c r e a t e E l e m e n t ( ' d i v ' ) . _ _ p r o t o _ _   ! = =  
               d o c u m e n t . c r e a t e E l e m e n t ( ' f o r m ' ) . _ _ p r o t o _ _ )  
     } ,  
  
     S c r i p t F r a g m e n t :   ' < s c r i p t [ ^ > ] * > ( [ \ \ S \ \ s ] * ? ) < \ / s c r i p t > ' ,  
     J S O N F i l t e r :   / ^ \ / \ * - s e c u r e - ( [ \ s \ S ] * ) \ * \ / \ s * $ / ,  
  
     e m p t y F u n c t i o n :   f u n c t i o n ( )   {   } ,  
     K :   f u n c t i o n ( x )   {   r e t u r n   x   }  
 }  
  
 v a r   C l a s s   =   {  
     c r e a t e :   f u n c t i o n ( )   {  
         r e t u r n   f u n c t i o n ( )   {  
             t h i s . i n i t i a l i z e . a p p l y ( t h i s ,   a r g u m e n t s ) ;  
         }  
     }  
 }  
  
 v a r   A b s t r a c t   =   n e w   O b j e c t ( ) ;  
  
 O b j e c t . e x t e n d   =   f u n c t i o n ( d e s t i n a t i o n ,   s o u r c e )   {  
     f o r   ( v a r   p r o p e r t y   i n   s o u r c e )   {  
         d e s t i n a t i o n [ p r o p e r t y ]   =   s o u r c e [ p r o p e r t y ] ;  
     }  
     r e t u r n   d e s t i n a t i o n ;  
 }  
  
 O b j e c t . e x t e n d ( O b j e c t ,   {  
     i n s p e c t :   f u n c t i o n ( o b j e c t )   {  
         t r y   {  
             i f   ( o b j e c t   = = =   u n d e f i n e d )   r e t u r n   ' u n d e f i n e d ' ;  
             i f   ( o b j e c t   = = =   n u l l )   r e t u r n   ' n u l l ' ;  
             r e t u r n   o b j e c t . i n s p e c t   ?   o b j e c t . i n s p e c t ( )   :   o b j e c t . t o S t r i n g ( ) ;  
         }   c a t c h   ( e )   {  
             i f   ( e   i n s t a n c e o f   R a n g e E r r o r )   r e t u r n   ' . . . ' ;  
             t h r o w   e ;  
         }  
     } ,  
  
     t o J S O N :   f u n c t i o n ( o b j e c t )   {  
         v a r   t y p e   =   t y p e o f   o b j e c t ;  
         s w i t c h ( t y p e )   {  
             c a s e   ' u n d e f i n e d ' :  
             c a s e   ' f u n c t i o n ' :  
             c a s e   ' u n k n o w n ' :   r e t u r n ;  
             c a s e   ' b o o l e a n ' :   r e t u r n   o b j e c t . t o S t r i n g ( ) ;  
         }  
         i f   ( o b j e c t   = = =   n u l l )   r e t u r n   ' n u l l ' ;  
         i f   ( o b j e c t . t o J S O N )   r e t u r n   o b j e c t . t o J S O N ( ) ;  
         i f   ( o b j e c t . o w n e r D o c u m e n t   = = =   d o c u m e n t )   r e t u r n ;  
         v a r   r e s u l t s   =   [ ] ;  
         f o r   ( v a r   p r o p e r t y   i n   o b j e c t )   {  
             v a r   v a l u e   =   O b j e c t . t o J S O N ( o b j e c t [ p r o p e r t y ] ) ;  
             i f   ( v a l u e   ! = =   u n d e f i n e d )  
                 r e s u l t s . p u s h ( p r o p e r t y . t o J S O N ( )   +   ' :   '   +   v a l u e ) ;  
         }  
         r e t u r n   ' { '   +   r e s u l t s . j o i n ( ' ,   ' )   +   ' } ' ;  
     } ,  
  
     k e y s :   f u n c t i o n ( o b j e c t )   {  
         v a r   k e y s   =   [ ] ;  
         f o r   ( v a r   p r o p e r t y   i n   o b j e c t )  
             k e y s . p u s h ( p r o p e r t y ) ;  
         r e t u r n   k e y s ;  
     } ,  
  
     v a l u e s :   f u n c t i o n ( o b j e c t )   {  
         v a r   v a l u e s   =   [ ] ;  
         f o r   ( v a r   p r o p e r t y   i n   o b j e c t )  
             v a l u e s . p u s h ( o b j e c t [ p r o p e r t y ] ) ;  
         r e t u r n   v a l u e s ;  
     } ,  
  
     c l o n e :   f u n c t i o n ( o b j e c t )   {  
         r e t u r n   O b j e c t . e x t e n d ( { } ,   o b j e c t ) ;  
     }  
 } ) ;  
  
 F u n c t i o n . p r o t o t y p e . b i n d   =   f u n c t i o n ( )   {  
     v a r   _ _ m e t h o d   =   t h i s ,   a r g s   =   $ A ( a r g u m e n t s ) ,   o b j e c t   =   a r g s . s h i f t ( ) ;  
     r e t u r n   f u n c t i o n ( )   {  
         r e t u r n   _ _ m e t h o d . a p p l y ( o b j e c t ,   a r g s . c o n c a t ( $ A ( a r g u m e n t s ) ) ) ;  
     }  
 }  
  
 F u n c t i o n . p r o t o t y p e . b i n d A s E v e n t L i s t e n e r   =   f u n c t i o n ( o b j e c t )   {  
     v a r   _ _ m e t h o d   =   t h i s ,   a r g s   =   $ A ( a r g u m e n t s ) ,   o b j e c t   =   a r g s . s h i f t ( ) ;  
     r e t u r n   f u n c t i o n ( e v e n t )   {  
         r e t u r n   _ _ m e t h o d . a p p l y ( o b j e c t ,   [ e v e n t   | |   w i n d o w . e v e n t ] . c o n c a t ( a r g s ) ) ;  
     }  
 }  
  
 O b j e c t . e x t e n d ( N u m b e r . p r o t o t y p e ,   {  
     t o C o l o r P a r t :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . t o P a d d e d S t r i n g ( 2 ,   1 6 ) ;  
     } ,  
  
     s u c c :   f u n c t i o n ( )   {  
         r e t u r n   t h i s   +   1 ;  
     } ,  
  
     t i m e s :   f u n c t i o n ( i t e r a t o r )   {  
         $ R ( 0 ,   t h i s ,   t r u e ) . e a c h ( i t e r a t o r ) ;  
         r e t u r n   t h i s ;  
     } ,  
  
     t o P a d d e d S t r i n g :   f u n c t i o n ( l e n g t h ,   r a d i x )   {  
         v a r   s t r i n g   =   t h i s . t o S t r i n g ( r a d i x   | |   1 0 ) ;  
         r e t u r n   ' 0 ' . t i m e s ( l e n g t h   -   s t r i n g . l e n g t h )   +   s t r i n g ;  
     } ,  
  
     t o J S O N :   f u n c t i o n ( )   {  
         r e t u r n   i s F i n i t e ( t h i s )   ?   t h i s . t o S t r i n g ( )   :   ' n u l l ' ;  
     }  
 } ) ;  
  
 D a t e . p r o t o t y p e . t o J S O N   =   f u n c t i o n ( )   {  
     r e t u r n   ' " '   +   t h i s . g e t F u l l Y e a r ( )   +   ' - '   +  
         ( t h i s . g e t M o n t h ( )   +   1 ) . t o P a d d e d S t r i n g ( 2 )   +   ' - '   +  
         t h i s . g e t D a t e ( ) . t o P a d d e d S t r i n g ( 2 )   +   ' T '   +  
         t h i s . g e t H o u r s ( ) . t o P a d d e d S t r i n g ( 2 )   +   ' : '   +  
         t h i s . g e t M i n u t e s ( ) . t o P a d d e d S t r i n g ( 2 )   +   ' : '   +  
         t h i s . g e t S e c o n d s ( ) . t o P a d d e d S t r i n g ( 2 )   +   ' " ' ;  
 } ;  
  
 v a r   T r y   =   {  
     t h e s e :   f u n c t i o n ( )   {  
         v a r   r e t u r n V a l u e ;  
  
         f o r   ( v a r   i   =   0 ,   l e n g t h   =   a r g u m e n t s . l e n g t h ;   i   <   l e n g t h ;   i + + )   {  
             v a r   l a m b d a   =   a r g u m e n t s [ i ] ;  
             t r y   {  
                 r e t u r n V a l u e   =   l a m b d a ( ) ;  
                 b r e a k ;  
             }   c a t c h   ( e )   { }  
         }  
  
         r e t u r n   r e t u r n V a l u e ;  
     }  
 }  
  
 / * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * /  
  
 v a r   P e r i o d i c a l E x e c u t e r   =   C l a s s . c r e a t e ( ) ;  
 P e r i o d i c a l E x e c u t e r . p r o t o t y p e   =   {  
     i n i t i a l i z e :   f u n c t i o n ( c a l l b a c k ,   f r e q u e n c y )   {  
         t h i s . c a l l b a c k   =   c a l l b a c k ;  
         t h i s . f r e q u e n c y   =   f r e q u e n c y ;  
         t h i s . c u r r e n t l y E x e c u t i n g   =   f a l s e ;  
  
         t h i s . r e g i s t e r C a l l b a c k ( ) ;  
     } ,  
  
     r e g i s t e r C a l l b a c k :   f u n c t i o n ( )   {  
         t h i s . t i m e r   =   s e t I n t e r v a l ( t h i s . o n T i m e r E v e n t . b i n d ( t h i s ) ,   t h i s . f r e q u e n c y   *   1 0 0 0 ) ;  
     } ,  
  
     s t o p :   f u n c t i o n ( )   {  
         i f   ( ! t h i s . t i m e r )   r e t u r n ;  
         c l e a r I n t e r v a l ( t h i s . t i m e r ) ;  
         t h i s . t i m e r   =   n u l l ;  
     } ,  
  
     o n T i m e r E v e n t :   f u n c t i o n ( )   {  
         i f   ( ! t h i s . c u r r e n t l y E x e c u t i n g )   {  
             t r y   {  
                 t h i s . c u r r e n t l y E x e c u t i n g   =   t r u e ;  
                 t h i s . c a l l b a c k ( t h i s ) ;  
             }   f i n a l l y   {  
                 t h i s . c u r r e n t l y E x e c u t i n g   =   f a l s e ;  
             }  
         }  
     }  
 }  
 O b j e c t . e x t e n d ( S t r i n g ,   {  
     i n t e r p r e t :   f u n c t i o n ( v a l u e )   {  
         r e t u r n   v a l u e   = =   n u l l   ?   ' '   :   S t r i n g ( v a l u e ) ;  
     } ,  
     s p e c i a l C h a r :   {  
         ' \ b ' :   ' \ \ b ' ,  
         ' \ t ' :   ' \ \ t ' ,  
         ' \ n ' :   ' \ \ n ' ,  
         ' \ f ' :   ' \ \ f ' ,  
         ' \ r ' :   ' \ \ r ' ,  
         ' \ \ ' :   ' \ \ \ \ '  
     }  
 } ) ;  
  
 O b j e c t . e x t e n d ( S t r i n g . p r o t o t y p e ,   {  
     g s u b :   f u n c t i o n ( p a t t e r n ,   r e p l a c e m e n t )   {  
         v a r   r e s u l t   =   ' ' ,   s o u r c e   =   t h i s ,   m a t c h ;  
         r e p l a c e m e n t   =   a r g u m e n t s . c a l l e e . p r e p a r e R e p l a c e m e n t ( r e p l a c e m e n t ) ;  
  
         w h i l e   ( s o u r c e . l e n g t h   >   0 )   {  
             i f   ( m a t c h   =   s o u r c e . m a t c h ( p a t t e r n ) )   {  
                 r e s u l t   + =   s o u r c e . s l i c e ( 0 ,   m a t c h . i n d e x ) ;  
                 r e s u l t   + =   S t r i n g . i n t e r p r e t ( r e p l a c e m e n t ( m a t c h ) ) ;  
                 s o u r c e     =   s o u r c e . s l i c e ( m a t c h . i n d e x   +   m a t c h [ 0 ] . l e n g t h ) ;  
             }   e l s e   {  
                 r e s u l t   + =   s o u r c e ,   s o u r c e   =   ' ' ;  
             }  
         }  
         r e t u r n   r e s u l t ;  
     } ,  
  
     s u b :   f u n c t i o n ( p a t t e r n ,   r e p l a c e m e n t ,   c o u n t )   {  
         r e p l a c e m e n t   =   t h i s . g s u b . p r e p a r e R e p l a c e m e n t ( r e p l a c e m e n t ) ;  
         c o u n t   =   c o u n t   = = =   u n d e f i n e d   ?   1   :   c o u n t ;  
  
         r e t u r n   t h i s . g s u b ( p a t t e r n ,   f u n c t i o n ( m a t c h )   {  
             i f   ( - - c o u n t   <   0 )   r e t u r n   m a t c h [ 0 ] ;  
             r e t u r n   r e p l a c e m e n t ( m a t c h ) ;  
         } ) ;  
     } ,  
  
     s c a n :   f u n c t i o n ( p a t t e r n ,   i t e r a t o r )   {  
         t h i s . g s u b ( p a t t e r n ,   i t e r a t o r ) ;  
         r e t u r n   t h i s ;  
     } ,  
  
     t r u n c a t e :   f u n c t i o n ( l e n g t h ,   t r u n c a t i o n )   {  
         l e n g t h   =   l e n g t h   | |   3 0 ;  
         t r u n c a t i o n   =   t r u n c a t i o n   = = =   u n d e f i n e d   ?   ' . . . '   :   t r u n c a t i o n ;  
         r e t u r n   t h i s . l e n g t h   >   l e n g t h   ?  
             t h i s . s l i c e ( 0 ,   l e n g t h   -   t r u n c a t i o n . l e n g t h )   +   t r u n c a t i o n   :   t h i s ;  
     } ,  
  
     s t r i p :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . r e p l a c e ( / ^ \ s + / ,   ' ' ) . r e p l a c e ( / \ s + $ / ,   ' ' ) ;  
     } ,  
  
     s t r i p T a g s :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . r e p l a c e ( / < \ / ? [ ^ > ] + > / g i ,   ' ' ) ;  
     } ,  
  
     s t r i p S c r i p t s :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . r e p l a c e ( n e w   R e g E x p ( P r o t o t y p e . S c r i p t F r a g m e n t ,   ' i m g ' ) ,   ' ' ) ;  
     } ,  
  
     e x t r a c t S c r i p t s :   f u n c t i o n ( )   {  
         v a r   m a t c h A l l   =   n e w   R e g E x p ( P r o t o t y p e . S c r i p t F r a g m e n t ,   ' i m g ' ) ;  
         v a r   m a t c h O n e   =   n e w   R e g E x p ( P r o t o t y p e . S c r i p t F r a g m e n t ,   ' i m ' ) ;  
         r e t u r n   ( t h i s . m a t c h ( m a t c h A l l )   | |   [ ] ) . m a p ( f u n c t i o n ( s c r i p t T a g )   {  
             r e t u r n   ( s c r i p t T a g . m a t c h ( m a t c h O n e )   | |   [ ' ' ,   ' ' ] ) [ 1 ] ;  
         } ) ;  
     } ,  
  
     e v a l S c r i p t s :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . e x t r a c t S c r i p t s ( ) . m a p ( f u n c t i o n ( s c r i p t )   {   r e t u r n   e v a l ( s c r i p t )   } ) ;  
     } ,  
  
     e s c a p e H T M L :   f u n c t i o n ( )   {  
         v a r   s e l f   =   a r g u m e n t s . c a l l e e ;  
         s e l f . t e x t . d a t a   =   t h i s ;  
         r e t u r n   s e l f . d i v . i n n e r H T M L ;  
     } ,  
  
     u n e s c a p e H T M L :   f u n c t i o n ( )   {  
         v a r   d i v   =   d o c u m e n t . c r e a t e E l e m e n t ( ' d i v ' ) ;  
         d i v . i n n e r H T M L   =   t h i s . s t r i p T a g s ( ) ;  
         r e t u r n   d i v . c h i l d N o d e s [ 0 ]   ?   ( d i v . c h i l d N o d e s . l e n g t h   >   1   ?  
             $ A ( d i v . c h i l d N o d e s ) . i n j e c t ( ' ' ,   f u n c t i o n ( m e m o ,   n o d e )   {   r e t u r n   m e m o + n o d e . n o d e V a l u e   } )   :  
             d i v . c h i l d N o d e s [ 0 ] . n o d e V a l u e )   :   ' ' ;  
     } ,  
  
     t o Q u e r y P a r a m s :   f u n c t i o n ( s e p a r a t o r )   {  
         v a r   m a t c h   =   t h i s . s t r i p ( ) . m a t c h ( / ( [ ^ ? # ] * ) ( # . * ) ? $ / ) ;  
         i f   ( ! m a t c h )   r e t u r n   { } ;  
  
         r e t u r n   m a t c h [ 1 ] . s p l i t ( s e p a r a t o r   | |   ' & ' ) . i n j e c t ( { } ,   f u n c t i o n ( h a s h ,   p a i r )   {  
             i f   ( ( p a i r   =   p a i r . s p l i t ( ' = ' ) ) [ 0 ] )   {  
                 v a r   k e y   =   d e c o d e U R I C o m p o n e n t ( p a i r . s h i f t ( ) ) ;  
                 v a r   v a l u e   =   p a i r . l e n g t h   >   1   ?   p a i r . j o i n ( ' = ' )   :   p a i r [ 0 ] ;  
                 i f   ( v a l u e   ! =   u n d e f i n e d )   v a l u e   =   d e c o d e U R I C o m p o n e n t ( v a l u e ) ;  
  
                 i f   ( k e y   i n   h a s h )   {  
                     i f   ( h a s h [ k e y ] . c o n s t r u c t o r   ! =   A r r a y )   h a s h [ k e y ]   =   [ h a s h [ k e y ] ] ;  
                     h a s h [ k e y ] . p u s h ( v a l u e ) ;  
                 }  
                 e l s e   h a s h [ k e y ]   =   v a l u e ;  
             }  
             r e t u r n   h a s h ;  
         } ) ;  
     } ,  
  
     t o A r r a y :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . s p l i t ( ' ' ) ;  
     } ,  
  
     s u c c :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . s l i c e ( 0 ,   t h i s . l e n g t h   -   1 )   +  
             S t r i n g . f r o m C h a r C o d e ( t h i s . c h a r C o d e A t ( t h i s . l e n g t h   -   1 )   +   1 ) ;  
     } ,  
  
     t i m e s :   f u n c t i o n ( c o u n t )   {  
         v a r   r e s u l t   =   ' ' ;  
         f o r   ( v a r   i   =   0 ;   i   <   c o u n t ;   i + + )   r e s u l t   + =   t h i s ;  
         r e t u r n   r e s u l t ;  
     } ,  
  
     c a m e l i z e :   f u n c t i o n ( )   {  
         v a r   p a r t s   =   t h i s . s p l i t ( ' - ' ) ,   l e n   =   p a r t s . l e n g t h ;  
         i f   ( l e n   = =   1 )   r e t u r n   p a r t s [ 0 ] ;  
  
         v a r   c a m e l i z e d   =   t h i s . c h a r A t ( 0 )   = =   ' - '  
             ?   p a r t s [ 0 ] . c h a r A t ( 0 ) . t o U p p e r C a s e ( )   +   p a r t s [ 0 ] . s u b s t r i n g ( 1 )  
             :   p a r t s [ 0 ] ;  
  
         f o r   ( v a r   i   =   1 ;   i   <   l e n ;   i + + )  
             c a m e l i z e d   + =   p a r t s [ i ] . c h a r A t ( 0 ) . t o U p p e r C a s e ( )   +   p a r t s [ i ] . s u b s t r i n g ( 1 ) ;  
  
         r e t u r n   c a m e l i z e d ;  
     } ,  
  
     c a p i t a l i z e :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . c h a r A t ( 0 ) . t o U p p e r C a s e ( )   +   t h i s . s u b s t r i n g ( 1 ) . t o L o w e r C a s e ( ) ;  
     } ,  
  
     u n d e r s c o r e :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . g s u b ( / : : / ,   ' / ' ) . g s u b ( / ( [ A - Z ] + ) ( [ A - Z ] [ a - z ] ) / , ' # { 1 } _ # { 2 } ' ) . g s u b ( / ( [ a - z \ d ] ) ( [ A - Z ] ) / , ' # { 1 } _ # { 2 } ' ) . g s u b ( / - / , ' _ ' ) . t o L o w e r C a s e ( ) ;  
     } ,  
  
     d a s h e r i z e :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . g s u b ( / _ / , ' - ' ) ;  
     } ,  
  
     i n s p e c t :   f u n c t i o n ( u s e D o u b l e Q u o t e s )   {  
         v a r   e s c a p e d S t r i n g   =   t h i s . g s u b ( / [ \ x 0 0 - \ x 1 f \ \ ] / ,   f u n c t i o n ( m a t c h )   {  
             v a r   c h a r a c t e r   =   S t r i n g . s p e c i a l C h a r [ m a t c h [ 0 ] ] ;  
             r e t u r n   c h a r a c t e r   ?   c h a r a c t e r   :   ' \ \ u 0 0 '   +   m a t c h [ 0 ] . c h a r C o d e A t ( ) . t o P a d d e d S t r i n g ( 2 ,   1 6 ) ;  
         } ) ;  
         i f   ( u s e D o u b l e Q u o t e s )   r e t u r n   ' " '   +   e s c a p e d S t r i n g . r e p l a c e ( / " / g ,   ' \ \ " ' )   +   ' " ' ;  
         r e t u r n   " ' "   +   e s c a p e d S t r i n g . r e p l a c e ( / ' / g ,   ' \ \ \ ' ' )   +   " ' " ;  
     } ,  
  
     t o J S O N :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . i n s p e c t ( t r u e ) ;  
     } ,  
  
     u n f i l t e r J S O N :   f u n c t i o n ( f i l t e r )   {  
         r e t u r n   t h i s . s u b ( f i l t e r   | |   P r o t o t y p e . J S O N F i l t e r ,   ' # { 1 } ' ) ;  
     } ,  
  
     i s J S O N :   f u n c t i o n ( )   {  
         v a r   s t r   =   t h i s . r e p l a c e ( / \ \ . / g ,   ' @ ' ) . r e p l a c e ( / " [ ^ " \ \ \ n \ r ] * " / g ,   ' ' ) ;  
         r e t u r n   ( / ^ [ , : { } \ [ \ ] 0 - 9 . \ - + E a e f l n r - u   \ n \ r \ t ] * $ / ) . t e s t ( s t r ) ;  
     } ,  
  
     e v a l J S O N :   f u n c t i o n ( s a n i t i z e )   {  
         v a r   j s o n   =   t h i s . u n f i l t e r J S O N ( ) ;  
         t r y   {  
             i f   ( ! s a n i t i z e   | |   j s o n . i s J S O N ( ) )   r e t u r n   e v a l ( ' ( '   +   j s o n   +   ' ) ' ) ;  
         }   c a t c h   ( e )   {   }  
         t h r o w   n e w   S y n t a x E r r o r ( ' B a d l y   f o r m e d   J S O N   s t r i n g :   '   +   t h i s . i n s p e c t ( ) ) ;  
     } ,  
  
     i n c l u d e :   f u n c t i o n ( p a t t e r n )   {  
         r e t u r n   t h i s . i n d e x O f ( p a t t e r n )   >   - 1 ;  
     } ,  
  
     s t a r t s W i t h :   f u n c t i o n ( p a t t e r n )   {  
         r e t u r n   t h i s . i n d e x O f ( p a t t e r n )   = = =   0 ;  
     } ,  
  
     e n d s W i t h :   f u n c t i o n ( p a t t e r n )   {  
         v a r   d   =   t h i s . l e n g t h   -   p a t t e r n . l e n g t h ;  
         r e t u r n   d   > =   0   & &   t h i s . l a s t I n d e x O f ( p a t t e r n )   = = =   d ;  
     } ,  
  
     e m p t y :   f u n c t i o n ( )   {  
         r e t u r n   t h i s   = =   ' ' ;  
     } ,  
  
     b l a n k :   f u n c t i o n ( )   {  
         r e t u r n   / ^ \ s * $ / . t e s t ( t h i s ) ;  
     }  
 } ) ;  
  
 i f   ( P r o t o t y p e . B r o w s e r . W e b K i t   | |   P r o t o t y p e . B r o w s e r . I E )   O b j e c t . e x t e n d ( S t r i n g . p r o t o t y p e ,   {  
     e s c a p e H T M L :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . r e p l a c e ( / & / g , ' & a m p ; ' ) . r e p l a c e ( / < / g , ' & l t ; ' ) . r e p l a c e ( / > / g , ' & g t ; ' ) ;  
     } ,  
     u n e s c a p e H T M L :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . r e p l a c e ( / & a m p ; / g , ' & ' ) . r e p l a c e ( / & l t ; / g , ' < ' ) . r e p l a c e ( / & g t ; / g , ' > ' ) ;  
     }  
 } ) ;  
  
 S t r i n g . p r o t o t y p e . g s u b . p r e p a r e R e p l a c e m e n t   =   f u n c t i o n ( r e p l a c e m e n t )   {  
     i f   ( t y p e o f   r e p l a c e m e n t   = =   ' f u n c t i o n ' )   r e t u r n   r e p l a c e m e n t ;  
     v a r   t e m p l a t e   =   n e w   T e m p l a t e ( r e p l a c e m e n t ) ;  
     r e t u r n   f u n c t i o n ( m a t c h )   {   r e t u r n   t e m p l a t e . e v a l u a t e ( m a t c h )   } ;  
 }  
  
 S t r i n g . p r o t o t y p e . p a r s e Q u e r y   =   S t r i n g . p r o t o t y p e . t o Q u e r y P a r a m s ;  
  
 O b j e c t . e x t e n d ( S t r i n g . p r o t o t y p e . e s c a p e H T M L ,   {  
     d i v :     d o c u m e n t . c r e a t e E l e m e n t ( ' d i v ' ) ,  
     t e x t :   d o c u m e n t . c r e a t e T e x t N o d e ( ' ' )  
 } ) ;  
  
 w i t h   ( S t r i n g . p r o t o t y p e . e s c a p e H T M L )   d i v . a p p e n d C h i l d ( t e x t ) ;  
  
 v a r   T e m p l a t e   =   C l a s s . c r e a t e ( ) ;  
 T e m p l a t e . P a t t e r n   =   / ( ^ | . | \ r | \ n ) ( # \ { ( . * ? ) \ } ) / ;  
 T e m p l a t e . p r o t o t y p e   =   {  
     i n i t i a l i z e :   f u n c t i o n ( t e m p l a t e ,   p a t t e r n )   {  
         t h i s . t e m p l a t e   =   t e m p l a t e . t o S t r i n g ( ) ;  
         t h i s . p a t t e r n     =   p a t t e r n   | |   T e m p l a t e . P a t t e r n ;  
     } ,  
  
     e v a l u a t e :   f u n c t i o n ( o b j e c t )   {  
         r e t u r n   t h i s . t e m p l a t e . g s u b ( t h i s . p a t t e r n ,   f u n c t i o n ( m a t c h )   {  
             v a r   b e f o r e   =   m a t c h [ 1 ] ;  
             i f   ( b e f o r e   = =   ' \ \ ' )   r e t u r n   m a t c h [ 2 ] ;  
             r e t u r n   b e f o r e   +   S t r i n g . i n t e r p r e t ( o b j e c t [ m a t c h [ 3 ] ] ) ;  
         } ) ;  
     }  
 }  
  
 v a r   $ b r e a k   =   { } ,   $ c o n t i n u e   =   n e w   E r r o r ( ' " t h r o w   $ c o n t i n u e "   i s   d e p r e c a t e d ,   u s e   " r e t u r n "   i n s t e a d ' ) ;  
  
 v a r   E n u m e r a b l e   =   {  
     e a c h :   f u n c t i o n ( i t e r a t o r )   {  
         v a r   i n d e x   =   0 ;  
         t r y   {  
             t h i s . _ e a c h ( f u n c t i o n ( v a l u e )   {  
                 i t e r a t o r ( v a l u e ,   i n d e x + + ) ;  
             } ) ;  
         }   c a t c h   ( e )   {  
             i f   ( e   ! =   $ b r e a k )   t h r o w   e ;  
         }  
         r e t u r n   t h i s ;  
     } ,  
  
     e a c h S l i c e :   f u n c t i o n ( n u m b e r ,   i t e r a t o r )   {  
         v a r   i n d e x   =   - n u m b e r ,   s l i c e s   =   [ ] ,   a r r a y   =   t h i s . t o A r r a y ( ) ;  
         w h i l e   ( ( i n d e x   + =   n u m b e r )   <   a r r a y . l e n g t h )  
             s l i c e s . p u s h ( a r r a y . s l i c e ( i n d e x ,   i n d e x + n u m b e r ) ) ;  
         r e t u r n   s l i c e s . m a p ( i t e r a t o r ) ;  
     } ,  
  
     a l l :   f u n c t i o n ( i t e r a t o r )   {  
         v a r   r e s u l t   =   t r u e ;  
         t h i s . e a c h ( f u n c t i o n ( v a l u e ,   i n d e x )   {  
             r e s u l t   =   r e s u l t   & &   ! ! ( i t e r a t o r   | |   P r o t o t y p e . K ) ( v a l u e ,   i n d e x ) ;  
             i f   ( ! r e s u l t )   t h r o w   $ b r e a k ;  
         } ) ;  
         r e t u r n   r e s u l t ;  
     } ,  
  
     a n y :   f u n c t i o n ( i t e r a t o r )   {  
         v a r   r e s u l t   =   f a l s e ;  
         t h i s . e a c h ( f u n c t i o n ( v a l u e ,   i n d e x )   {  
             i f   ( r e s u l t   =   ! ! ( i t e r a t o r   | |   P r o t o t y p e . K ) ( v a l u e ,   i n d e x ) )  
                 t h r o w   $ b r e a k ;  
         } ) ;  
         r e t u r n   r e s u l t ;  
     } ,  
  
     c o l l e c t :   f u n c t i o n ( i t e r a t o r )   {  
         v a r   r e s u l t s   =   [ ] ;  
         t h i s . e a c h ( f u n c t i o n ( v a l u e ,   i n d e x )   {  
             r e s u l t s . p u s h ( ( i t e r a t o r   | |   P r o t o t y p e . K ) ( v a l u e ,   i n d e x ) ) ;  
         } ) ;  
         r e t u r n   r e s u l t s ;  
     } ,  
  
     d e t e c t :   f u n c t i o n ( i t e r a t o r )   {  
         v a r   r e s u l t ;  
         t h i s . e a c h ( f u n c t i o n ( v a l u e ,   i n d e x )   {  
             i f   ( i t e r a t o r ( v a l u e ,   i n d e x ) )   {  
                 r e s u l t   =   v a l u e ;  
                 t h r o w   $ b r e a k ;  
             }  
         } ) ;  
         r e t u r n   r e s u l t ;  
     } ,  
  
     f i n d A l l :   f u n c t i o n ( i t e r a t o r )   {  
         v a r   r e s u l t s   =   [ ] ;  
         t h i s . e a c h ( f u n c t i o n ( v a l u e ,   i n d e x )   {  
             i f   ( i t e r a t o r ( v a l u e ,   i n d e x ) )  
                 r e s u l t s . p u s h ( v a l u e ) ;  
         } ) ;  
         r e t u r n   r e s u l t s ;  
     } ,  
  
     g r e p :   f u n c t i o n ( p a t t e r n ,   i t e r a t o r )   {  
         v a r   r e s u l t s   =   [ ] ;  
         t h i s . e a c h ( f u n c t i o n ( v a l u e ,   i n d e x )   {  
             v a r   s t r i n g V a l u e   =   v a l u e . t o S t r i n g ( ) ;  
             i f   ( s t r i n g V a l u e . m a t c h ( p a t t e r n ) )  
                 r e s u l t s . p u s h ( ( i t e r a t o r   | |   P r o t o t y p e . K ) ( v a l u e ,   i n d e x ) ) ;  
         } )  
         r e t u r n   r e s u l t s ;  
     } ,  
  
     i n c l u d e :   f u n c t i o n ( o b j e c t )   {  
         v a r   f o u n d   =   f a l s e ;  
         t h i s . e a c h ( f u n c t i o n ( v a l u e )   {  
             i f   ( v a l u e   = =   o b j e c t )   {  
                 f o u n d   =   t r u e ;  
                 t h r o w   $ b r e a k ;  
             }  
         } ) ;  
         r e t u r n   f o u n d ;  
     } ,  
  
     i n G r o u p s O f :   f u n c t i o n ( n u m b e r ,   f i l l W i t h )   {  
         f i l l W i t h   =   f i l l W i t h   = = =   u n d e f i n e d   ?   n u l l   :   f i l l W i t h ;  
         r e t u r n   t h i s . e a c h S l i c e ( n u m b e r ,   f u n c t i o n ( s l i c e )   {  
             w h i l e ( s l i c e . l e n g t h   <   n u m b e r )   s l i c e . p u s h ( f i l l W i t h ) ;  
             r e t u r n   s l i c e ;  
         } ) ;  
     } ,  
  
     i n j e c t :   f u n c t i o n ( m e m o ,   i t e r a t o r )   {  
         t h i s . e a c h ( f u n c t i o n ( v a l u e ,   i n d e x )   {  
             m e m o   =   i t e r a t o r ( m e m o ,   v a l u e ,   i n d e x ) ;  
         } ) ;  
         r e t u r n   m e m o ;  
     } ,  
  
     i n v o k e :   f u n c t i o n ( m e t h o d )   {  
         v a r   a r g s   =   $ A ( a r g u m e n t s ) . s l i c e ( 1 ) ;  
         r e t u r n   t h i s . m a p ( f u n c t i o n ( v a l u e )   {  
             r e t u r n   v a l u e [ m e t h o d ] . a p p l y ( v a l u e ,   a r g s ) ;  
         } ) ;  
     } ,  
  
     m a x :   f u n c t i o n ( i t e r a t o r )   {  
         v a r   r e s u l t ;  
         t h i s . e a c h ( f u n c t i o n ( v a l u e ,   i n d e x )   {  
             v a l u e   =   ( i t e r a t o r   | |   P r o t o t y p e . K ) ( v a l u e ,   i n d e x ) ;  
             i f   ( r e s u l t   = =   u n d e f i n e d   | |   v a l u e   > =   r e s u l t )  
                 r e s u l t   =   v a l u e ;  
         } ) ;  
         r e t u r n   r e s u l t ;  
     } ,  
  
     m i n :   f u n c t i o n ( i t e r a t o r )   {  
         v a r   r e s u l t ;  
         t h i s . e a c h ( f u n c t i o n ( v a l u e ,   i n d e x )   {  
             v a l u e   =   ( i t e r a t o r   | |   P r o t o t y p e . K ) ( v a l u e ,   i n d e x ) ;  
             i f   ( r e s u l t   = =   u n d e f i n e d   | |   v a l u e   <   r e s u l t )  
                 r e s u l t   =   v a l u e ;  
         } ) ;  
         r e t u r n   r e s u l t ;  
     } ,  
  
     p a r t i t i o n :   f u n c t i o n ( i t e r a t o r )   {  
         v a r   t r u e s   =   [ ] ,   f a l s e s   =   [ ] ;  
         t h i s . e a c h ( f u n c t i o n ( v a l u e ,   i n d e x )   {  
             ( ( i t e r a t o r   | |   P r o t o t y p e . K ) ( v a l u e ,   i n d e x )   ?  
                 t r u e s   :   f a l s e s ) . p u s h ( v a l u e ) ;  
         } ) ;  
         r e t u r n   [ t r u e s ,   f a l s e s ] ;  
     } ,  
  
     p l u c k :   f u n c t i o n ( p r o p e r t y )   {  
         v a r   r e s u l t s   =   [ ] ;  
         t h i s . e a c h ( f u n c t i o n ( v a l u e ,   i n d e x )   {  
             r e s u l t s . p u s h ( v a l u e [ p r o p e r t y ] ) ;  
         } ) ;  
         r e t u r n   r e s u l t s ;  
     } ,  
  
     r e j e c t :   f u n c t i o n ( i t e r a t o r )   {  
         v a r   r e s u l t s   =   [ ] ;  
         t h i s . e a c h ( f u n c t i o n ( v a l u e ,   i n d e x )   {  
             i f   ( ! i t e r a t o r ( v a l u e ,   i n d e x ) )  
                 r e s u l t s . p u s h ( v a l u e ) ;  
         } ) ;  
         r e t u r n   r e s u l t s ;  
     } ,  
  
     s o r t B y :   f u n c t i o n ( i t e r a t o r )   {  
         r e t u r n   t h i s . m a p ( f u n c t i o n ( v a l u e ,   i n d e x )   {  
             r e t u r n   { v a l u e :   v a l u e ,   c r i t e r i a :   i t e r a t o r ( v a l u e ,   i n d e x ) } ;  
         } ) . s o r t ( f u n c t i o n ( l e f t ,   r i g h t )   {  
             v a r   a   =   l e f t . c r i t e r i a ,   b   =   r i g h t . c r i t e r i a ;  
             r e t u r n   a   <   b   ?   - 1   :   a   >   b   ?   1   :   0 ;  
         } ) . p l u c k ( ' v a l u e ' ) ;  
     } ,  
  
     t o A r r a y :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . m a p ( ) ;  
     } ,  
  
     z i p :   f u n c t i o n ( )   {  
         v a r   i t e r a t o r   =   P r o t o t y p e . K ,   a r g s   =   $ A ( a r g u m e n t s ) ;  
         i f   ( t y p e o f   a r g s . l a s t ( )   = =   ' f u n c t i o n ' )  
             i t e r a t o r   =   a r g s . p o p ( ) ;  
  
         v a r   c o l l e c t i o n s   =   [ t h i s ] . c o n c a t ( a r g s ) . m a p ( $ A ) ;  
         r e t u r n   t h i s . m a p ( f u n c t i o n ( v a l u e ,   i n d e x )   {  
             r e t u r n   i t e r a t o r ( c o l l e c t i o n s . p l u c k ( i n d e x ) ) ;  
         } ) ;  
     } ,  
  
     s i z e :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . t o A r r a y ( ) . l e n g t h ;  
     } ,  
  
     i n s p e c t :   f u n c t i o n ( )   {  
         r e t u r n   ' # < E n u m e r a b l e : '   +   t h i s . t o A r r a y ( ) . i n s p e c t ( )   +   ' > ' ;  
     }  
 }  
  
 O b j e c t . e x t e n d ( E n u m e r a b l e ,   {  
     m a p :           E n u m e r a b l e . c o l l e c t ,  
     f i n d :         E n u m e r a b l e . d e t e c t ,  
     s e l e c t :     E n u m e r a b l e . f i n d A l l ,  
     m e m b e r :     E n u m e r a b l e . i n c l u d e ,  
     e n t r i e s :   E n u m e r a b l e . t o A r r a y  
 } ) ;  
 v a r   $ A   =   A r r a y . f r o m   =   f u n c t i o n ( i t e r a b l e )   {  
     i f   ( ! i t e r a b l e )   r e t u r n   [ ] ;  
     i f   ( i t e r a b l e . t o A r r a y )   {  
         r e t u r n   i t e r a b l e . t o A r r a y ( ) ;  
     }   e l s e   {  
         v a r   r e s u l t s   =   [ ] ;  
         f o r   ( v a r   i   =   0 ,   l e n g t h   =   i t e r a b l e . l e n g t h ;   i   <   l e n g t h ;   i + + )  
             r e s u l t s . p u s h ( i t e r a b l e [ i ] ) ;  
         r e t u r n   r e s u l t s ;  
     }  
 }  
  
 i f   ( P r o t o t y p e . B r o w s e r . W e b K i t )   {  
     $ A   =   A r r a y . f r o m   =   f u n c t i o n ( i t e r a b l e )   {  
         i f   ( ! i t e r a b l e )   r e t u r n   [ ] ;  
         i f   ( ! ( t y p e o f   i t e r a b l e   = =   ' f u n c t i o n '   & &   i t e r a b l e   = =   ' [ o b j e c t   N o d e L i s t ] ' )   & &  
             i t e r a b l e . t o A r r a y )   {  
             r e t u r n   i t e r a b l e . t o A r r a y ( ) ;  
         }   e l s e   {  
             v a r   r e s u l t s   =   [ ] ;  
             f o r   ( v a r   i   =   0 ,   l e n g t h   =   i t e r a b l e . l e n g t h ;   i   <   l e n g t h ;   i + + )  
                 r e s u l t s . p u s h ( i t e r a b l e [ i ] ) ;  
             r e t u r n   r e s u l t s ;  
         }  
     }  
 }  
  
 O b j e c t . e x t e n d ( A r r a y . p r o t o t y p e ,   E n u m e r a b l e ) ;  
  
 i f   ( ! A r r a y . p r o t o t y p e . _ r e v e r s e )  
     A r r a y . p r o t o t y p e . _ r e v e r s e   =   A r r a y . p r o t o t y p e . r e v e r s e ;  
  
 O b j e c t . e x t e n d ( A r r a y . p r o t o t y p e ,   {  
     _ e a c h :   f u n c t i o n ( i t e r a t o r )   {  
         f o r   ( v a r   i   =   0 ,   l e n g t h   =   t h i s . l e n g t h ;   i   <   l e n g t h ;   i + + )  
             i t e r a t o r ( t h i s [ i ] ) ;  
     } ,  
  
     c l e a r :   f u n c t i o n ( )   {  
         t h i s . l e n g t h   =   0 ;  
         r e t u r n   t h i s ;  
     } ,  
  
     f i r s t :   f u n c t i o n ( )   {  
         r e t u r n   t h i s [ 0 ] ;  
     } ,  
  
     l a s t :   f u n c t i o n ( )   {  
         r e t u r n   t h i s [ t h i s . l e n g t h   -   1 ] ;  
     } ,  
  
     c o m p a c t :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . s e l e c t ( f u n c t i o n ( v a l u e )   {  
             r e t u r n   v a l u e   ! =   n u l l ;  
         } ) ;  
     } ,  
  
     f l a t t e n :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . i n j e c t ( [ ] ,   f u n c t i o n ( a r r a y ,   v a l u e )   {  
             r e t u r n   a r r a y . c o n c a t ( v a l u e   & &   v a l u e . c o n s t r u c t o r   = =   A r r a y   ?  
                 v a l u e . f l a t t e n ( )   :   [ v a l u e ] ) ;  
         } ) ;  
     } ,  
  
     w i t h o u t :   f u n c t i o n ( )   {  
         v a r   v a l u e s   =   $ A ( a r g u m e n t s ) ;  
         r e t u r n   t h i s . s e l e c t ( f u n c t i o n ( v a l u e )   {  
             r e t u r n   ! v a l u e s . i n c l u d e ( v a l u e ) ;  
         } ) ;  
     } ,  
  
     i n d e x O f :   f u n c t i o n ( o b j e c t )   {  
         f o r   ( v a r   i   =   0 ,   l e n g t h   =   t h i s . l e n g t h ;   i   <   l e n g t h ;   i + + )  
             i f   ( t h i s [ i ]   = =   o b j e c t )   r e t u r n   i ;  
         r e t u r n   - 1 ;  
     } ,  
  
     r e v e r s e :   f u n c t i o n ( i n l i n e )   {  
         r e t u r n   ( i n l i n e   ! = =   f a l s e   ?   t h i s   :   t h i s . t o A r r a y ( ) ) . _ r e v e r s e ( ) ;  
     } ,  
  
     r e d u c e :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . l e n g t h   >   1   ?   t h i s   :   t h i s [ 0 ] ;  
     } ,  
  
     u n i q :   f u n c t i o n ( s o r t e d )   {  
         r e t u r n   t h i s . i n j e c t ( [ ] ,   f u n c t i o n ( a r r a y ,   v a l u e ,   i n d e x )   {  
             i f   ( 0   = =   i n d e x   | |   ( s o r t e d   ?   a r r a y . l a s t ( )   ! =   v a l u e   :   ! a r r a y . i n c l u d e ( v a l u e ) ) )  
                 a r r a y . p u s h ( v a l u e ) ;  
             r e t u r n   a r r a y ;  
         } ) ;  
     } ,  
  
     c l o n e :   f u n c t i o n ( )   {  
         r e t u r n   [ ] . c o n c a t ( t h i s ) ;  
     } ,  
  
     s i z e :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . l e n g t h ;  
     } ,  
  
     i n s p e c t :   f u n c t i o n ( )   {  
         r e t u r n   ' [ '   +   t h i s . m a p ( O b j e c t . i n s p e c t ) . j o i n ( ' ,   ' )   +   ' ] ' ;  
     } ,  
  
     t o J S O N :   f u n c t i o n ( )   {  
         v a r   r e s u l t s   =   [ ] ;  
         t h i s . e a c h ( f u n c t i o n ( o b j e c t )   {  
             v a r   v a l u e   =   O b j e c t . t o J S O N ( o b j e c t ) ;  
             i f   ( v a l u e   ! = =   u n d e f i n e d )   r e s u l t s . p u s h ( v a l u e ) ;  
         } ) ;  
         r e t u r n   ' [ '   +   r e s u l t s . j o i n ( ' ,   ' )   +   ' ] ' ;  
     }  
 } ) ;  
  
 A r r a y . p r o t o t y p e . t o A r r a y   =   A r r a y . p r o t o t y p e . c l o n e ;  
  
 f u n c t i o n   $ w ( s t r i n g )   {  
     s t r i n g   =   s t r i n g . s t r i p ( ) ;  
     r e t u r n   s t r i n g   ?   s t r i n g . s p l i t ( / \ s + / )   :   [ ] ;  
 }  
  
 i f   ( P r o t o t y p e . B r o w s e r . O p e r a ) {  
     A r r a y . p r o t o t y p e . c o n c a t   =   f u n c t i o n ( )   {  
         v a r   a r r a y   =   [ ] ;  
         f o r   ( v a r   i   =   0 ,   l e n g t h   =   t h i s . l e n g t h ;   i   <   l e n g t h ;   i + + )   a r r a y . p u s h ( t h i s [ i ] ) ;  
         f o r   ( v a r   i   =   0 ,   l e n g t h   =   a r g u m e n t s . l e n g t h ;   i   <   l e n g t h ;   i + + )   {  
             i f   ( a r g u m e n t s [ i ] . c o n s t r u c t o r   = =   A r r a y )   {  
                 f o r   ( v a r   j   =   0 ,   a r r a y L e n g t h   =   a r g u m e n t s [ i ] . l e n g t h ;   j   <   a r r a y L e n g t h ;   j + + )  
                     a r r a y . p u s h ( a r g u m e n t s [ i ] [ j ] ) ;  
             }   e l s e   {  
                 a r r a y . p u s h ( a r g u m e n t s [ i ] ) ;  
             }  
         }  
         r e t u r n   a r r a y ;  
     }  
 }  
 v a r   H a s h   =   f u n c t i o n ( o b j e c t )   {  
     i f   ( o b j e c t   i n s t a n c e o f   H a s h )   t h i s . m e r g e ( o b j e c t ) ;  
     e l s e   O b j e c t . e x t e n d ( t h i s ,   o b j e c t   | |   { } ) ;  
 } ;  
  
 O b j e c t . e x t e n d ( H a s h ,   {  
     t o Q u e r y S t r i n g :   f u n c t i o n ( o b j )   {  
         v a r   p a r t s   =   [ ] ;  
         p a r t s . a d d   =   a r g u m e n t s . c a l l e e . a d d P a i r ;  
  
         t h i s . p r o t o t y p e . _ e a c h . c a l l ( o b j ,   f u n c t i o n ( p a i r )   {  
             i f   ( ! p a i r . k e y )   r e t u r n ;  
             v a r   v a l u e   =   p a i r . v a l u e ;  
  
             i f   ( v a l u e   & &   t y p e o f   v a l u e   = =   ' o b j e c t ' )   {  
                 i f   ( v a l u e . c o n s t r u c t o r   = =   A r r a y )   v a l u e . e a c h ( f u n c t i o n ( v a l u e )   {  
                     p a r t s . a d d ( p a i r . k e y ,   v a l u e ) ;  
                 } ) ;  
                 r e t u r n ;  
             }  
             p a r t s . a d d ( p a i r . k e y ,   v a l u e ) ;  
         } ) ;  
  
         r e t u r n   p a r t s . j o i n ( ' & ' ) ;  
     } ,  
  
     t o J S O N :   f u n c t i o n ( o b j e c t )   {  
         v a r   r e s u l t s   =   [ ] ;  
         t h i s . p r o t o t y p e . _ e a c h . c a l l ( o b j e c t ,   f u n c t i o n ( p a i r )   {  
             v a r   v a l u e   =   O b j e c t . t o J S O N ( p a i r . v a l u e ) ;  
             i f   ( v a l u e   ! = =   u n d e f i n e d )   r e s u l t s . p u s h ( p a i r . k e y . t o J S O N ( )   +   ' :   '   +   v a l u e ) ;  
         } ) ;  
         r e t u r n   ' { '   +   r e s u l t s . j o i n ( ' ,   ' )   +   ' } ' ;  
     }  
 } ) ;  
  
 H a s h . t o Q u e r y S t r i n g . a d d P a i r   =   f u n c t i o n ( k e y ,   v a l u e ,   p r e f i x )   {  
     k e y   =   e n c o d e U R I C o m p o n e n t ( k e y ) ;  
     i f   ( v a l u e   = = =   u n d e f i n e d )   t h i s . p u s h ( k e y ) ;  
     e l s e   t h i s . p u s h ( k e y   +   ' = '   +   ( v a l u e   = =   n u l l   ?   ' '   :   e n c o d e U R I C o m p o n e n t ( v a l u e ) ) ) ;  
 }  
  
 O b j e c t . e x t e n d ( H a s h . p r o t o t y p e ,   E n u m e r a b l e ) ;  
 O b j e c t . e x t e n d ( H a s h . p r o t o t y p e ,   {  
     _ e a c h :   f u n c t i o n ( i t e r a t o r )   {  
         f o r   ( v a r   k e y   i n   t h i s )   {  
             v a r   v a l u e   =   t h i s [ k e y ] ;  
             i f   ( v a l u e   & &   v a l u e   = =   H a s h . p r o t o t y p e [ k e y ] )   c o n t i n u e ;  
  
             v a r   p a i r   =   [ k e y ,   v a l u e ] ;  
             p a i r . k e y   =   k e y ;  
             p a i r . v a l u e   =   v a l u e ;  
             i t e r a t o r ( p a i r ) ;  
         }  
     } ,  
  
     k e y s :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . p l u c k ( ' k e y ' ) ;  
     } ,  
  
     v a l u e s :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . p l u c k ( ' v a l u e ' ) ;  
     } ,  
  
     m e r g e :   f u n c t i o n ( h a s h )   {  
         r e t u r n   $ H ( h a s h ) . i n j e c t ( t h i s ,   f u n c t i o n ( m e r g e d H a s h ,   p a i r )   {  
             m e r g e d H a s h [ p a i r . k e y ]   =   p a i r . v a l u e ;  
             r e t u r n   m e r g e d H a s h ;  
         } ) ;  
     } ,  
  
     r e m o v e :   f u n c t i o n ( )   {  
         v a r   r e s u l t ;  
         f o r ( v a r   i   =   0 ,   l e n g t h   =   a r g u m e n t s . l e n g t h ;   i   <   l e n g t h ;   i + + )   {  
             v a r   v a l u e   =   t h i s [ a r g u m e n t s [ i ] ] ;  
             i f   ( v a l u e   ! = =   u n d e f i n e d ) {  
                 i f   ( r e s u l t   = = =   u n d e f i n e d )   r e s u l t   =   v a l u e ;  
                 e l s e   {  
                     i f   ( r e s u l t . c o n s t r u c t o r   ! =   A r r a y )   r e s u l t   =   [ r e s u l t ] ;  
                     r e s u l t . p u s h ( v a l u e )  
                 }  
             }  
             d e l e t e   t h i s [ a r g u m e n t s [ i ] ] ;  
         }  
         r e t u r n   r e s u l t ;  
     } ,  
  
     t o Q u e r y S t r i n g :   f u n c t i o n ( )   {  
         r e t u r n   H a s h . t o Q u e r y S t r i n g ( t h i s ) ;  
     } ,  
  
     i n s p e c t :   f u n c t i o n ( )   {  
         r e t u r n   ' # < H a s h : { '   +   t h i s . m a p ( f u n c t i o n ( p a i r )   {  
             r e t u r n   p a i r . m a p ( O b j e c t . i n s p e c t ) . j o i n ( ' :   ' ) ;  
         } ) . j o i n ( ' ,   ' )   +   ' } > ' ;  
     } ,  
  
     t o J S O N :   f u n c t i o n ( )   {  
         r e t u r n   H a s h . t o J S O N ( t h i s ) ;  
     }  
 } ) ;  
  
 f u n c t i o n   $ H ( o b j e c t )   {  
     i f   ( o b j e c t   i n s t a n c e o f   H a s h )   r e t u r n   o b j e c t ;  
     r e t u r n   n e w   H a s h ( o b j e c t ) ;  
 } ;  
  
 / /   S a f a r i   i t e r a t e s   o v e r   s h a d o w e d   p r o p e r t i e s  
 i f   ( f u n c t i o n ( )   {  
     v a r   i   =   0 ,   T e s t   =   f u n c t i o n ( v a l u e )   {   t h i s . k e y   =   v a l u e   } ;  
     T e s t . p r o t o t y p e . k e y   =   ' f o o ' ;  
     f o r   ( v a r   p r o p e r t y   i n   n e w   T e s t ( ' b a r ' ) )   i + + ;  
     r e t u r n   i   >   1 ;  
 } ( ) )   H a s h . p r o t o t y p e . _ e a c h   =   f u n c t i o n ( i t e r a t o r )   {  
     v a r   c a c h e   =   [ ] ;  
     f o r   ( v a r   k e y   i n   t h i s )   {  
         v a r   v a l u e   =   t h i s [ k e y ] ;  
         i f   ( ( v a l u e   & &   v a l u e   = =   H a s h . p r o t o t y p e [ k e y ] )   | |   c a c h e . i n c l u d e ( k e y ) )   c o n t i n u e ;  
         c a c h e . p u s h ( k e y ) ;  
         v a r   p a i r   =   [ k e y ,   v a l u e ] ;  
         p a i r . k e y   =   k e y ;  
         p a i r . v a l u e   =   v a l u e ;  
         i t e r a t o r ( p a i r ) ;  
     }  
 } ;  
 O b j e c t R a n g e   =   C l a s s . c r e a t e ( ) ;  
 O b j e c t . e x t e n d ( O b j e c t R a n g e . p r o t o t y p e ,   E n u m e r a b l e ) ;  
 O b j e c t . e x t e n d ( O b j e c t R a n g e . p r o t o t y p e ,   {  
     i n i t i a l i z e :   f u n c t i o n ( s t a r t ,   e n d ,   e x c l u s i v e )   {  
         t h i s . s t a r t   =   s t a r t ;  
         t h i s . e n d   =   e n d ;  
         t h i s . e x c l u s i v e   =   e x c l u s i v e ;  
     } ,  
  
     _ e a c h :   f u n c t i o n ( i t e r a t o r )   {  
         v a r   v a l u e   =   t h i s . s t a r t ;  
         w h i l e   ( t h i s . i n c l u d e ( v a l u e ) )   {  
             i t e r a t o r ( v a l u e ) ;  
             v a l u e   =   v a l u e . s u c c ( ) ;  
         }  
     } ,  
  
     i n c l u d e :   f u n c t i o n ( v a l u e )   {  
         i f   ( v a l u e   <   t h i s . s t a r t )  
             r e t u r n   f a l s e ;  
         i f   ( t h i s . e x c l u s i v e )  
             r e t u r n   v a l u e   <   t h i s . e n d ;  
         r e t u r n   v a l u e   < =   t h i s . e n d ;  
     }  
 } ) ;  
  
 v a r   $ R   =   f u n c t i o n ( s t a r t ,   e n d ,   e x c l u s i v e )   {  
     r e t u r n   n e w   O b j e c t R a n g e ( s t a r t ,   e n d ,   e x c l u s i v e ) ;  
 }  
  
 v a r   A j a x   =   {  
     g e t T r a n s p o r t :   f u n c t i o n ( )   {  
         r e t u r n   T r y . t h e s e (  
             f u n c t i o n ( )   { r e t u r n   n e w   X M L H t t p R e q u e s t ( ) } ,  
             f u n c t i o n ( )   { r e t u r n   n e w   A c t i v e X O b j e c t ( ' M s x m l 2 . X M L H T T P ' ) } ,  
             f u n c t i o n ( )   { r e t u r n   n e w   A c t i v e X O b j e c t ( ' M i c r o s o f t . X M L H T T P ' ) }  
         )   | |   f a l s e ;  
     } ,  
  
     a c t i v e R e q u e s t C o u n t :   0  
 }  
  
 A j a x . R e s p o n d e r s   =   {  
     r e s p o n d e r s :   [ ] ,  
  
     _ e a c h :   f u n c t i o n ( i t e r a t o r )   {  
         t h i s . r e s p o n d e r s . _ e a c h ( i t e r a t o r ) ;  
     } ,  
  
     r e g i s t e r :   f u n c t i o n ( r e s p o n d e r )   {  
         i f   ( ! t h i s . i n c l u d e ( r e s p o n d e r ) )  
             t h i s . r e s p o n d e r s . p u s h ( r e s p o n d e r ) ;  
     } ,  
  
     u n r e g i s t e r :   f u n c t i o n ( r e s p o n d e r )   {  
         t h i s . r e s p o n d e r s   =   t h i s . r e s p o n d e r s . w i t h o u t ( r e s p o n d e r ) ;  
     } ,  
  
     d i s p a t c h :   f u n c t i o n ( c a l l b a c k ,   r e q u e s t ,   t r a n s p o r t ,   j s o n )   {  
         t h i s . e a c h ( f u n c t i o n ( r e s p o n d e r )   {  
             i f   ( t y p e o f   r e s p o n d e r [ c a l l b a c k ]   = =   ' f u n c t i o n ' )   {  
                 t r y   {  
                     r e s p o n d e r [ c a l l b a c k ] . a p p l y ( r e s p o n d e r ,   [ r e q u e s t ,   t r a n s p o r t ,   j s o n ] ) ;  
                 }   c a t c h   ( e )   { }  
             }  
         } ) ;  
     }  
 } ;  
  
 O b j e c t . e x t e n d ( A j a x . R e s p o n d e r s ,   E n u m e r a b l e ) ;  
  
 A j a x . R e s p o n d e r s . r e g i s t e r ( {  
     o n C r e a t e :   f u n c t i o n ( )   {  
         A j a x . a c t i v e R e q u e s t C o u n t + + ;  
     } ,  
     o n C o m p l e t e :   f u n c t i o n ( )   {  
         A j a x . a c t i v e R e q u e s t C o u n t - - ;  
     }  
 } ) ;  
  
 A j a x . B a s e   =   f u n c t i o n ( )   { } ;  
 A j a x . B a s e . p r o t o t y p e   =   {  
     s e t O p t i o n s :   f u n c t i o n ( o p t i o n s )   {  
         t h i s . o p t i o n s   =   {  
             m e t h o d :               ' p o s t ' ,  
             a s y n c h r o n o u s :   t r u e ,  
             c o n t e n t T y p e :     ' a p p l i c a t i o n / x - w w w - f o r m - u r l e n c o d e d ' ,  
             e n c o d i n g :           ' U T F - 8 ' ,  
             p a r a m e t e r s :       ' '  
         }  
         O b j e c t . e x t e n d ( t h i s . o p t i o n s ,   o p t i o n s   | |   { } ) ;  
  
         t h i s . o p t i o n s . m e t h o d   =   t h i s . o p t i o n s . m e t h o d . t o L o w e r C a s e ( ) ;  
         i f   ( t y p e o f   t h i s . o p t i o n s . p a r a m e t e r s   = =   ' s t r i n g ' )  
             t h i s . o p t i o n s . p a r a m e t e r s   =   t h i s . o p t i o n s . p a r a m e t e r s . t o Q u e r y P a r a m s ( ) ;  
     }  
 }  
  
 A j a x . R e q u e s t   =   C l a s s . c r e a t e ( ) ;  
 A j a x . R e q u e s t . E v e n t s   =  
     [ ' U n i n i t i a l i z e d ' ,   ' L o a d i n g ' ,   ' L o a d e d ' ,   ' I n t e r a c t i v e ' ,   ' C o m p l e t e ' ] ;  
  
 A j a x . R e q u e s t . p r o t o t y p e   =   O b j e c t . e x t e n d ( n e w   A j a x . B a s e ( ) ,   {  
     _ c o m p l e t e :   f a l s e ,  
  
     i n i t i a l i z e :   f u n c t i o n ( u r l ,   o p t i o n s )   {  
         t h i s . t r a n s p o r t   =   A j a x . g e t T r a n s p o r t ( ) ;  
         t h i s . s e t O p t i o n s ( o p t i o n s ) ;  
         t h i s . r e q u e s t ( u r l ) ;  
     } ,  
  
     r e q u e s t :   f u n c t i o n ( u r l )   {  
         t h i s . u r l   =   u r l ;  
         t h i s . m e t h o d   =   t h i s . o p t i o n s . m e t h o d ;  
         v a r   p a r a m s   =   O b j e c t . c l o n e ( t h i s . o p t i o n s . p a r a m e t e r s ) ;  
  
         i f   ( ! [ ' g e t ' ,   ' p o s t ' ] . i n c l u d e ( t h i s . m e t h o d ) )   {  
             / /   s i m u l a t e   o t h e r   v e r b s   o v e r   p o s t  
             p a r a m s [ ' _ m e t h o d ' ]   =   t h i s . m e t h o d ;  
             t h i s . m e t h o d   =   ' p o s t ' ;  
         }  
  
         t h i s . p a r a m e t e r s   =   p a r a m s ;  
  
         i f   ( p a r a m s   =   H a s h . t o Q u e r y S t r i n g ( p a r a m s ) )   {  
             / /   w h e n   G E T ,   a p p e n d   p a r a m e t e r s   t o   U R L  
             i f   ( t h i s . m e t h o d   = =   ' g e t ' )  
                 t h i s . u r l   + =   ( t h i s . u r l . i n c l u d e ( ' ? ' )   ?   ' & '   :   ' ? ' )   +   p a r a m s ;  
             e l s e   i f   ( / K o n q u e r o r | S a f a r i | K H T M L / . t e s t ( n a v i g a t o r . u s e r A g e n t ) )  
                 p a r a m s   + =   ' & _ = ' ;  
         }  
  
         t r y   {  
             i f   ( t h i s . o p t i o n s . o n C r e a t e )   t h i s . o p t i o n s . o n C r e a t e ( t h i s . t r a n s p o r t ) ;  
             A j a x . R e s p o n d e r s . d i s p a t c h ( ' o n C r e a t e ' ,   t h i s ,   t h i s . t r a n s p o r t ) ;  
  
             t h i s . t r a n s p o r t . o p e n ( t h i s . m e t h o d . t o U p p e r C a s e ( ) ,   t h i s . u r l ,  
                 t h i s . o p t i o n s . a s y n c h r o n o u s ) ;  
  
             i f   ( t h i s . o p t i o n s . a s y n c h r o n o u s )  
                 s e t T i m e o u t ( f u n c t i o n ( )   {   t h i s . r e s p o n d T o R e a d y S t a t e ( 1 )   } . b i n d ( t h i s ) ,   1 0 ) ;  
  
             t h i s . t r a n s p o r t . o n r e a d y s t a t e c h a n g e   =   t h i s . o n S t a t e C h a n g e . b i n d ( t h i s ) ;  
             t h i s . s e t R e q u e s t H e a d e r s ( ) ;  
  
             t h i s . b o d y   =   t h i s . m e t h o d   = =   ' p o s t '   ?   ( t h i s . o p t i o n s . p o s t B o d y   | |   p a r a m s )   :   n u l l ;  
             t h i s . t r a n s p o r t . s e n d ( t h i s . b o d y ) ;  
  
             / *   F o r c e   F i r e f o x   t o   h a n d l e   r e a d y   s t a t e   4   f o r   s y n c h r o n o u s   r e q u e s t s   * /  
             i f   ( ! t h i s . o p t i o n s . a s y n c h r o n o u s   & &   t h i s . t r a n s p o r t . o v e r r i d e M i m e T y p e )  
                 t h i s . o n S t a t e C h a n g e ( ) ;  
  
         }  
         c a t c h   ( e )   {  
             t h i s . d i s p a t c h E x c e p t i o n ( e ) ;  
         }  
     } ,  
  
     o n S t a t e C h a n g e :   f u n c t i o n ( )   {  
         v a r   r e a d y S t a t e   =   t h i s . t r a n s p o r t . r e a d y S t a t e ;  
         i f   ( r e a d y S t a t e   >   1   & &   ! ( ( r e a d y S t a t e   = =   4 )   & &   t h i s . _ c o m p l e t e ) )  
             t h i s . r e s p o n d T o R e a d y S t a t e ( t h i s . t r a n s p o r t . r e a d y S t a t e ) ;  
     } ,  
  
     s e t R e q u e s t H e a d e r s :   f u n c t i o n ( )   {  
         v a r   h e a d e r s   =   {  
             ' X - R e q u e s t e d - W i t h ' :   ' X M L H t t p R e q u e s t ' ,  
             ' X - P r o t o t y p e - V e r s i o n ' :   P r o t o t y p e . V e r s i o n ,  
             ' A c c e p t ' :   ' t e x t / j a v a s c r i p t ,   t e x t / h t m l ,   a p p l i c a t i o n / x m l ,   t e x t / x m l ,   * / * '  
         } ;  
  
         i f   ( t h i s . m e t h o d   = =   ' p o s t ' )   {  
             h e a d e r s [ ' C o n t e n t - t y p e ' ]   =   t h i s . o p t i o n s . c o n t e n t T y p e   +  
                 ( t h i s . o p t i o n s . e n c o d i n g   ?   ' ;   c h a r s e t = '   +   t h i s . o p t i o n s . e n c o d i n g   :   ' ' ) ;  
  
             / *   F o r c e   " C o n n e c t i o n :   c l o s e "   f o r   o l d e r   M o z i l l a   b r o w s e r s   t o   w o r k  
               *   a r o u n d   a   b u g   w h e r e   X M L H t t p R e q u e s t   s e n d s   a n   i n c o r r e c t  
               *   C o n t e n t - l e n g t h   h e a d e r .   S e e   M o z i l l a   B u g z i l l a   # 2 4 6 6 5 1 .  
               * /  
             i f   ( t h i s . t r a n s p o r t . o v e r r i d e M i m e T y p e   & &  
                     ( n a v i g a t o r . u s e r A g e n t . m a t c h ( / G e c k o \ / ( \ d { 4 } ) / )   | |   [ 0 , 2 0 0 5 ] ) [ 1 ]   <   2 0 0 5 )  
                         h e a d e r s [ ' C o n n e c t i o n ' ]   =   ' c l o s e ' ;  
         }  
  
         / /   u s e r - d e f i n e d   h e a d e r s  
         i f   ( t y p e o f   t h i s . o p t i o n s . r e q u e s t H e a d e r s   = =   ' o b j e c t ' )   {  
             v a r   e x t r a s   =   t h i s . o p t i o n s . r e q u e s t H e a d e r s ;  
  
             i f   ( t y p e o f   e x t r a s . p u s h   = =   ' f u n c t i o n ' )  
                 f o r   ( v a r   i   =   0 ,   l e n g t h   =   e x t r a s . l e n g t h ;   i   <   l e n g t h ;   i   + =   2 )  
                     h e a d e r s [ e x t r a s [ i ] ]   =   e x t r a s [ i + 1 ] ;  
             e l s e  
                 $ H ( e x t r a s ) . e a c h ( f u n c t i o n ( p a i r )   {   h e a d e r s [ p a i r . k e y ]   =   p a i r . v a l u e   } ) ;  
         }  
  
         f o r   ( v a r   n a m e   i n   h e a d e r s )  
             t h i s . t r a n s p o r t . s e t R e q u e s t H e a d e r ( n a m e ,   h e a d e r s [ n a m e ] ) ;  
     } ,  
  
     s u c c e s s :   f u n c t i o n ( )   {  
         r e t u r n   ! t h i s . t r a n s p o r t . s t a t u s  
                 | |   ( t h i s . t r a n s p o r t . s t a t u s   > =   2 0 0   & &   t h i s . t r a n s p o r t . s t a t u s   <   3 0 0 ) ;  
     } ,  
  
     r e s p o n d T o R e a d y S t a t e :   f u n c t i o n ( r e a d y S t a t e )   {  
         v a r   s t a t e   =   A j a x . R e q u e s t . E v e n t s [ r e a d y S t a t e ] ;  
         v a r   t r a n s p o r t   =   t h i s . t r a n s p o r t ,   j s o n   =   t h i s . e v a l J S O N ( ) ;  
  
         i f   ( s t a t e   = =   ' C o m p l e t e ' )   {  
             t r y   {  
                 t h i s . _ c o m p l e t e   =   t r u e ;  
                 ( t h i s . o p t i o n s [ ' o n '   +   t h i s . t r a n s p o r t . s t a t u s ]  
                   | |   t h i s . o p t i o n s [ ' o n '   +   ( t h i s . s u c c e s s ( )   ?   ' S u c c e s s '   :   ' F a i l u r e ' ) ]  
                   | |   P r o t o t y p e . e m p t y F u n c t i o n ) ( t r a n s p o r t ,   j s o n ) ;  
             }   c a t c h   ( e )   {  
                 t h i s . d i s p a t c h E x c e p t i o n ( e ) ;  
             }  
  
             v a r   c o n t e n t T y p e   =   t h i s . g e t H e a d e r ( ' C o n t e n t - t y p e ' ) ;  
             i f   ( c o n t e n t T y p e   & &   c o n t e n t T y p e . s t r i p ( ) .  
                 m a t c h ( / ^ ( t e x t | a p p l i c a t i o n ) \ / ( x - ) ? ( j a v a | e c m a ) s c r i p t ( ; . * ) ? $ / i ) )  
                     t h i s . e v a l R e s p o n s e ( ) ;  
         }  
  
         t r y   {  
             ( t h i s . o p t i o n s [ ' o n '   +   s t a t e ]   | |   P r o t o t y p e . e m p t y F u n c t i o n ) ( t r a n s p o r t ,   j s o n ) ;  
             A j a x . R e s p o n d e r s . d i s p a t c h ( ' o n '   +   s t a t e ,   t h i s ,   t r a n s p o r t ,   j s o n ) ;  
         }   c a t c h   ( e )   {  
             t h i s . d i s p a t c h E x c e p t i o n ( e ) ;  
         }  
  
         i f   ( s t a t e   = =   ' C o m p l e t e ' )   {  
             / /   a v o i d   m e m o r y   l e a k   i n   M S I E :   c l e a n   u p  
             t h i s . t r a n s p o r t . o n r e a d y s t a t e c h a n g e   =   P r o t o t y p e . e m p t y F u n c t i o n ;  
         }  
     } ,  
  
     g e t H e a d e r :   f u n c t i o n ( n a m e )   {  
         t r y   {  
             r e t u r n   t h i s . t r a n s p o r t . g e t R e s p o n s e H e a d e r ( n a m e ) ;  
         }   c a t c h   ( e )   {   r e t u r n   n u l l   }  
     } ,  
  
     e v a l J S O N :   f u n c t i o n ( )   {  
         t r y   {  
             v a r   j s o n   =   t h i s . g e t H e a d e r ( ' X - J S O N ' ) ;  
             r e t u r n   j s o n   ?   j s o n . e v a l J S O N ( )   :   n u l l ;  
         }   c a t c h   ( e )   {   r e t u r n   n u l l   }  
     } ,  
  
     e v a l R e s p o n s e :   f u n c t i o n ( )   {  
         t r y   {  
             r e t u r n   e v a l ( ( t h i s . t r a n s p o r t . r e s p o n s e T e x t   | |   ' ' ) . u n f i l t e r J S O N ( ) ) ;  
         }   c a t c h   ( e )   {  
             t h i s . d i s p a t c h E x c e p t i o n ( e ) ;  
         }  
     } ,  
  
     d i s p a t c h E x c e p t i o n :   f u n c t i o n ( e x c e p t i o n )   {  
         ( t h i s . o p t i o n s . o n E x c e p t i o n   | |   P r o t o t y p e . e m p t y F u n c t i o n ) ( t h i s ,   e x c e p t i o n ) ;  
         A j a x . R e s p o n d e r s . d i s p a t c h ( ' o n E x c e p t i o n ' ,   t h i s ,   e x c e p t i o n ) ;  
     }  
 } ) ;  
  
 A j a x . U p d a t e r   =   C l a s s . c r e a t e ( ) ;  
  
 O b j e c t . e x t e n d ( O b j e c t . e x t e n d ( A j a x . U p d a t e r . p r o t o t y p e ,   A j a x . R e q u e s t . p r o t o t y p e ) ,   {  
     i n i t i a l i z e :   f u n c t i o n ( c o n t a i n e r ,   u r l ,   o p t i o n s )   {  
         t h i s . c o n t a i n e r   =   {  
             s u c c e s s :   ( c o n t a i n e r . s u c c e s s   | |   c o n t a i n e r ) ,  
             f a i l u r e :   ( c o n t a i n e r . f a i l u r e   | |   ( c o n t a i n e r . s u c c e s s   ?   n u l l   :   c o n t a i n e r ) )  
         }  
  
         t h i s . t r a n s p o r t   =   A j a x . g e t T r a n s p o r t ( ) ;  
         t h i s . s e t O p t i o n s ( o p t i o n s ) ;  
  
         v a r   o n C o m p l e t e   =   t h i s . o p t i o n s . o n C o m p l e t e   | |   P r o t o t y p e . e m p t y F u n c t i o n ;  
         t h i s . o p t i o n s . o n C o m p l e t e   =   ( f u n c t i o n ( t r a n s p o r t ,   p a r a m )   {  
             t h i s . u p d a t e C o n t e n t ( ) ;  
             o n C o m p l e t e ( t r a n s p o r t ,   p a r a m ) ;  
         } ) . b i n d ( t h i s ) ;  
  
         t h i s . r e q u e s t ( u r l ) ;  
     } ,  
  
     u p d a t e C o n t e n t :   f u n c t i o n ( )   {  
         v a r   r e c e i v e r   =   t h i s . c o n t a i n e r [ t h i s . s u c c e s s ( )   ?   ' s u c c e s s '   :   ' f a i l u r e ' ] ;  
         v a r   r e s p o n s e   =   t h i s . t r a n s p o r t . r e s p o n s e T e x t ;  
  
         i f   ( ! t h i s . o p t i o n s . e v a l S c r i p t s )   r e s p o n s e   =   r e s p o n s e . s t r i p S c r i p t s ( ) ;  
  
         i f   ( r e c e i v e r   =   $ ( r e c e i v e r ) )   {  
             i f   ( t h i s . o p t i o n s . i n s e r t i o n )  
                 n e w   t h i s . o p t i o n s . i n s e r t i o n ( r e c e i v e r ,   r e s p o n s e ) ;  
             e l s e  
                 r e c e i v e r . u p d a t e ( r e s p o n s e ) ;  
         }  
  
         i f   ( t h i s . s u c c e s s ( ) )   {  
             i f   ( t h i s . o n C o m p l e t e )  
                 s e t T i m e o u t ( t h i s . o n C o m p l e t e . b i n d ( t h i s ) ,   1 0 ) ;  
         }  
     }  
 } ) ;  
  
 A j a x . P e r i o d i c a l U p d a t e r   =   C l a s s . c r e a t e ( ) ;  
 A j a x . P e r i o d i c a l U p d a t e r . p r o t o t y p e   =   O b j e c t . e x t e n d ( n e w   A j a x . B a s e ( ) ,   {  
     i n i t i a l i z e :   f u n c t i o n ( c o n t a i n e r ,   u r l ,   o p t i o n s )   {  
         t h i s . s e t O p t i o n s ( o p t i o n s ) ;  
         t h i s . o n C o m p l e t e   =   t h i s . o p t i o n s . o n C o m p l e t e ;  
  
         t h i s . f r e q u e n c y   =   ( t h i s . o p t i o n s . f r e q u e n c y   | |   2 ) ;  
         t h i s . d e c a y   =   ( t h i s . o p t i o n s . d e c a y   | |   1 ) ;  
  
         t h i s . u p d a t e r   =   { } ;  
         t h i s . c o n t a i n e r   =   c o n t a i n e r ;  
         t h i s . u r l   =   u r l ;  
  
         t h i s . s t a r t ( ) ;  
     } ,  
  
     s t a r t :   f u n c t i o n ( )   {  
         t h i s . o p t i o n s . o n C o m p l e t e   =   t h i s . u p d a t e C o m p l e t e . b i n d ( t h i s ) ;  
         t h i s . o n T i m e r E v e n t ( ) ;  
     } ,  
  
     s t o p :   f u n c t i o n ( )   {  
         t h i s . u p d a t e r . o p t i o n s . o n C o m p l e t e   =   u n d e f i n e d ;  
         c l e a r T i m e o u t ( t h i s . t i m e r ) ;  
         ( t h i s . o n C o m p l e t e   | |   P r o t o t y p e . e m p t y F u n c t i o n ) . a p p l y ( t h i s ,   a r g u m e n t s ) ;  
     } ,  
  
     u p d a t e C o m p l e t e :   f u n c t i o n ( r e q u e s t )   {  
         i f   ( t h i s . o p t i o n s . d e c a y )   {  
             t h i s . d e c a y   =   ( r e q u e s t . r e s p o n s e T e x t   = =   t h i s . l a s t T e x t   ?  
                 t h i s . d e c a y   *   t h i s . o p t i o n s . d e c a y   :   1 ) ;  
  
             t h i s . l a s t T e x t   =   r e q u e s t . r e s p o n s e T e x t ;  
         }  
         t h i s . t i m e r   =   s e t T i m e o u t ( t h i s . o n T i m e r E v e n t . b i n d ( t h i s ) ,  
             t h i s . d e c a y   *   t h i s . f r e q u e n c y   *   1 0 0 0 ) ;  
     } ,  
  
     o n T i m e r E v e n t :   f u n c t i o n ( )   {  
         t h i s . u p d a t e r   =   n e w   A j a x . U p d a t e r ( t h i s . c o n t a i n e r ,   t h i s . u r l ,   t h i s . o p t i o n s ) ;  
     }  
 } ) ;  
 f u n c t i o n   $ ( e l e m e n t )   {  
     i f   ( a r g u m e n t s . l e n g t h   >   1 )   {  
         f o r   ( v a r   i   =   0 ,   e l e m e n t s   =   [ ] ,   l e n g t h   =   a r g u m e n t s . l e n g t h ;   i   <   l e n g t h ;   i + + )  
             e l e m e n t s . p u s h ( $ ( a r g u m e n t s [ i ] ) ) ;  
         r e t u r n   e l e m e n t s ;  
     }  
     i f   ( t y p e o f   e l e m e n t   = =   ' s t r i n g ' )  
         e l e m e n t   =   d o c u m e n t . g e t E l e m e n t B y I d ( e l e m e n t ) ;  
     r e t u r n   E l e m e n t . e x t e n d ( e l e m e n t ) ;  
 }  
  
 i f   ( P r o t o t y p e . B r o w s e r F e a t u r e s . X P a t h )   {  
     d o c u m e n t . _ g e t E l e m e n t s B y X P a t h   =   f u n c t i o n ( e x p r e s s i o n ,   p a r e n t E l e m e n t )   {  
         v a r   r e s u l t s   =   [ ] ;  
         v a r   q u e r y   =   d o c u m e n t . e v a l u a t e ( e x p r e s s i o n ,   $ ( p a r e n t E l e m e n t )   | |   d o c u m e n t ,  
             n u l l ,   X P a t h R e s u l t . O R D E R E D _ N O D E _ S N A P S H O T _ T Y P E ,   n u l l ) ;  
         f o r   ( v a r   i   =   0 ,   l e n g t h   =   q u e r y . s n a p s h o t L e n g t h ;   i   <   l e n g t h ;   i + + )  
             r e s u l t s . p u s h ( q u e r y . s n a p s h o t I t e m ( i ) ) ;  
         r e t u r n   r e s u l t s ;  
     } ;  
  
     d o c u m e n t . 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 ,   p a r e n t E l e m e n t )   {  
         v a r   q   =   " . / / * [ c o n t a i n s ( c o n c a t ( '   ' ,   @ c l a s s ,   '   ' ) ,   '   "   +   c l a s s N a m e   +   "   ' ) ] " ;  
         r e t u r n   d o c u m e n t . _ g e t E l e m e n t s B y X P a t h ( q ,   p a r e n t E l e m e n t ) ;  
     }  
  
 }   e l s e   d o c u m e n t . 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 ,   p a r e n t E l e m e n t )   {  
     v a r   c h i l d r e n   =   ( $ ( p a r e n t E l e m e n t )   | |   d o c u m e n t . b o d y ) . g e t E l e m e n t s B y T a g N a m e ( ' * ' ) ;  
     v a r   e l e m e n t s   =   [ ] ,   c h i l d ,   p a t t e r n   =   n e w   R e g E x p ( " ( ^ | \ \ s ) "   +   c l a s s N a m e   +   " ( \ \ s | $ ) " ) ;  
     f o r   ( v a r   i   =   0 ,   l e n g t h   =   c h i l d r e n . l e n g t h ;   i   <   l e n g t h ;   i + + )   {  
         c h i l d   =   c h i l d r e n [ i ] ;  
         v a r   e l e m e n t C l a s s N a m e   =   c h i l d . c l a s s N a m e ;  
         i f   ( e l e m e n t C l a s s N a m e . l e n g t h   = =   0 )   c o n t i n u e ;  
         i f   ( e l e m e n t C l a s s N a m e   = =   c l a s s N a m e   | |   e l e m e n t C l a s s N a m e . m a t c h ( p a t t e r n ) )  
             e l e m e n t s . p u s h ( E l e m e n t . e x t e n d ( c h i l d ) ) ;  
     }  
     r e t u r n   e l e m e n t s ;  
 } ;  
  
 / * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * /  
  
 i f   ( ! w i n d o w . E l e m e n t )   v a r   E l e m e n t   =   { } ;  
  
 E l e m e n t . e x t e n d   =   f u n c t i o n ( e l e m e n t )   {  
     v a r   F   =   P r o t o t y p e . B r o w s e r F e a t u r e s ;  
     i f   ( ! e l e m e n t   | |   ! e l e m e n t . t a g N a m e   | |   e l e m e n t . n o d e T y p e   = =   3   | |  
       e l e m e n t . _ e x t e n d e d   | |   F . S p e c i f i c E l e m e n t E x t e n s i o n s   | |   e l e m e n t   = =   w i n d o w )  
         r e t u r n   e l e m e n t ;  
  
     v a r   m e t h o d s   =   { } ,   t a g N a m e   =   e l e m e n t . t a g N a m e ,   c a c h e   =   E l e m e n t . e x t e n d . c a c h e ,  
       T   =   E l e m e n t . M e t h o d s . B y T a g ;  
  
     / /   e x t e n d   m e t h o d s   f o r   a l l   t a g s   ( S a f a r i   d o e s n ' t   n e e d   t h i s )  
     i f   ( ! F . E l e m e n t E x t e n s i o n s )   {  
         O b j e c t . e x t e n d ( m e t h o d s ,   E l e m e n t . M e t h o d s ) ,  
         O b j e c t . e x t e n d ( m e t h o d s ,   E l e m e n t . M e t h o d s . S i m u l a t e d ) ;  
     }  
  
     / /   e x t e n d   m e t h o d s   f o r   s p e c i f i c   t a g s  
     i f   ( T [ t a g N a m e ] )   O b j e c t . e x t e n d ( m e t h o d s ,   T [ t a g N a m e ] ) ;  
  
     f o r   ( v a r   p r o p e r t y   i n   m e t h o d s )   {  
         v a r   v a l u e   =   m e t h o d s [ p r o p e r t y ] ;  
         i f   ( t y p e o f   v a l u e   = =   ' f u n c t i o n '   & &   ! ( p r o p e r t y   i n   e l e m e n t ) )  
             e l e m e n t [ p r o p e r t y ]   =   c a c h e . f i n d O r S t o r e ( v a l u e ) ;  
     }  
  
     e l e m e n t . _ e x t e n d e d   =   P r o t o t y p e . e m p t y F u n c t i o n ;  
     r e t u r n   e l e m e n t ;  
 } ;  
  
 E l e m e n t . e x t e n d . c a c h e   =   {  
     f i n d O r S t o r e :   f u n c t i o n ( v a l u e )   {  
         r e t u r n   t h i s [ v a l u e ]   =   t h i s [ v a l u e ]   | |   f u n c t i o n ( )   {  
             r e t u r n   v a l u e . a p p l y ( n u l l ,   [ t h i s ] . c o n c a t ( $ A ( a r g u m e n t s ) ) ) ;  
         }  
     }  
 } ;  
  
 E l e m e n t . M e t h o d s   =   {  
     v i s i b l e :   f u n c t i o n ( e l e m e n t )   {  
         r e t u r n   $ ( e l e m e n t ) . s t y l e . d i s p l a y   ! =   ' n o n e ' ;  
     } ,  
  
     t o g g l e :   f u n c t i o n ( e l e m e n t )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         E l e m e n t [ E l e m e n t . v i s i b l e ( e l e m e n t )   ?   ' h i d e '   :   ' s h o w ' ] ( e l e m e n t ) ;  
         r e t u r n   e l e m e n t ;  
     } ,  
  
     h i d e :   f u n c t i o n ( e l e m e n t )   {  
         $ ( e l e m e n t ) . s t y l e . d i s p l a y   =   ' n o n e ' ;  
         r e t u r n   e l e m e n t ;  
     } ,  
  
     s h o w :   f u n c t i o n ( e l e m e n t )   {  
         $ ( e l e m e n t ) . s t y l e . d i s p l a y   =   ' ' ;  
         r e t u r n   e l e m e n t ;  
     } ,  
  
     r e m o v e :   f u n c t i o n ( e l e m e n t )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         e l e m e n t . p a r e n t N o d e . r e m o v e C h i l d ( e l e m e n t ) ;  
         r e t u r n   e l e m e n t ;  
     } ,  
  
     u p d a t e :   f u n c t i o n ( e l e m e n t ,   h t m l )   {  
         h t m l   =   t y p e o f   h t m l   = =   ' u n d e f i n e d '   ?   ' '   :   h t m l . t o S t r i n g ( ) ;  
         $ ( e l e m e n t ) . i n n e r H T M L   =   h t m l . s t r i p S c r i p t s ( ) ;  
         s e t T i m e o u t ( f u n c t i o n ( )   { h t m l . e v a l S c r i p t s ( ) } ,   1 0 ) ;  
         r e t u r n   e l e m e n t ;  
     } ,  
  
     r e p l a c e :   f u n c t i o n ( e l e m e n t ,   h t m l )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         h t m l   =   t y p e o f   h t m l   = =   ' u n d e f i n e d '   ?   ' '   :   h t m l . t o S t r i n g ( ) ;  
         i f   ( e l e m e n t . o u t e r H T M L )   {  
             e l e m e n t . o u t e r H T M L   =   h t m l . s t r i p S c r i p t s ( ) ;  
         }   e l s e   {  
             v a r   r a n g e   =   e l e m e n t . o w n e r D o c u m e n t . c r e a t e R a n g e ( ) ;  
             r a n g e . s e l e c t N o d e C o n t e n t s ( e l e m e n t ) ;  
             e l e m e n t . p a r e n t N o d e . r e p l a c e C h i l d (  
                 r a n g e . c r e a t e C o n t e x t u a l F r a g m e n t ( h t m l . s t r i p S c r i p t s ( ) ) ,   e l e m e n t ) ;  
         }  
         s e t T i m e o u t ( f u n c t i o n ( )   { h t m l . e v a l S c r i p t s ( ) } ,   1 0 ) ;  
         r e t u r n   e l e m e n t ;  
     } ,  
  
     i n s p e c t :   f u n c t i o n ( e l e m e n t )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         v a r   r e s u l t   =   ' < '   +   e l e m e n t . t a g N a m e . t o L o w e r C a s e ( ) ;  
         $ H ( { ' i d ' :   ' i d ' ,   ' c l a s s N a m e ' :   ' c l a s s ' } ) . e a c h ( f u n c t i o n ( p a i r )   {  
             v a r   p r o p e r t y   =   p a i r . f i r s t ( ) ,   a t t r i b u t e   =   p a i r . l a s t ( ) ;  
             v a r   v a l u e   =   ( e l e m e n t [ p r o p e r t y ]   | |   ' ' ) . t o S t r i n g ( ) ;  
             i f   ( v a l u e )   r e s u l t   + =   '   '   +   a t t r i b u t e   +   ' = '   +   v a l u e . i n s p e c t ( t r u e ) ;  
         } ) ;  
         r e t u r n   r e s u l t   +   ' > ' ;  
     } ,  
  
     r e c u r s i v e l y C o l l e c t :   f u n c t i o n ( e l e m e n t ,   p r o p e r t y )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         v a r   e l e m e n t s   =   [ ] ;  
         w h i l e   ( e l e m e n t   =   e l e m e n t [ p r o p e r t y ] )  
             i f   ( e l e m e n t . n o d e T y p e   = =   1 )  
                 e l e m e n t s . p u s h ( E l e m e n t . e x t e n d ( e l e m e n t ) ) ;  
         r e t u r n   e l e m e n t s ;  
     } ,  
  
     a n c e s t o r s :   f u n c t i o n ( e l e m e n t )   {  
         r e t u r n   $ ( e l e m e n t ) . r e c u r s i v e l y C o l l e c t ( ' p a r e n t N o d e ' ) ;  
     } ,  
  
     d e s c e n d a n t s :   f u n c t i o n ( e l e m e n t )   {  
         r e t u r n   $ A ( $ ( 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 ( ' * ' ) ) . e a c h ( E l e m e n t . e x t e n d ) ;  
     } ,  
  
     f i r s t D e s c e n d a n t :   f u n c t i o n ( e l e m e n t )   {  
         e l e m e n t   =   $ ( e l e m e n t ) . f i r s t C h i l d ;  
         w h i l e   ( e l e m e n t   & &   e l e m e n t . n o d e T y p e   ! =   1 )   e l e m e n t   =   e l e m e n t . n e x t S i b l i n g ;  
         r e t u r n   $ ( e l e m e n t ) ;  
     } ,  
  
     i m m e d i a t e D e s c e n d a n t s :   f u n c t i o n ( e l e m e n t )   {  
         i f   ( ! ( e l e m e n t   =   $ ( e l e m e n t ) . f i r s t C h i l d ) )   r e t u r n   [ ] ;  
         w h i l e   ( e l e m e n t   & &   e l e m e n t . n o d e T y p e   ! =   1 )   e l e m e n t   =   e l e m e n t . n e x t S i b l i n g ;  
         i f   ( e l e m e n t )   r e t u r n   [ e l e m e n t ] . c o n c a t ( $ ( e l e m e n t ) . n e x t S i b l i n g s ( ) ) ;  
         r e t u r n   [ ] ;  
     } ,  
  
     p r e v i o u s S i b l i n g s :   f u n c t i o n ( e l e m e n t )   {  
         r e t u r n   $ ( e l e m e n t ) . r e c u r s i v e l y C o l l e c t ( ' p r e v i o u s S i b l i n g ' ) ;  
     } ,  
  
     n e x t S i b l i n g s :   f u n c t i o n ( e l e m e n t )   {  
         r e t u r n   $ ( e l e m e n t ) . r e c u r s i v e l y C o l l e c t ( ' n e x t S i b l i n g ' ) ;  
     } ,  
  
     s i b l i n g s :   f u n c t i o n ( e l e m e n t )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         r e t u r n   e l e m e n t . p r e v i o u s S i b l i n g s ( ) . r e v e r s e ( ) . c o n c a t ( e l e m e n t . n e x t S i b l i n g s ( ) ) ;  
     } ,  
  
     m a t c h :   f u n c t i o n ( e l e m e n t ,   s e l e c t o r )   {  
         i f   ( t y p e o f   s e l e c t o r   = =   ' s t r i n g ' )  
             s e l e c t o r   =   n e w   S e l e c t o r ( s e l e c t o r ) ;  
         r e t u r n   s e l e c t o r . m a t c h ( $ ( e l e m e n t ) ) ;  
     } ,  
  
     u p :   f u n c t i o n ( e l e m e n t ,   e x p r e s s i o n ,   i n d e x )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         i f   ( a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   $ ( e l e m e n t . p a r e n t N o d e ) ;  
         v a r   a n c e s t o r s   =   e l e m e n t . a n c e s t o r s ( ) ;  
         r e t u r n   e x p r e s s i o n   ?   S e l e c t o r . f i n d E l e m e n t ( a n c e s t o r s ,   e x p r e s s i o n ,   i n d e x )   :  
             a n c e s t o r s [ i n d e x   | |   0 ] ;  
     } ,  
  
     d o w n :   f u n c t i o n ( e l e m e n t ,   e x p r e s s i o n ,   i n d e x )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         i f   ( a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   e l e m e n t . f i r s t D e s c e n d a n t ( ) ;  
         v a r   d e s c e n d a n t s   =   e l e m e n t . d e s c e n d a n t s ( ) ;  
         r e t u r n   e x p r e s s i o n   ?   S e l e c t o r . f i n d E l e m e n t ( d e s c e n d a n t s ,   e x p r e s s i o n ,   i n d e x )   :  
             d e s c e n d a n t s [ i n d e x   | |   0 ] ;  
     } ,  
  
     p r e v i o u s :   f u n c t i o n ( e l e m e n t ,   e x p r e s s i o n ,   i n d e x )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         i f   ( a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   $ ( S e l e c t o r . h a n d l e r s . p r e v i o u s E l e m e n t S i b l i n g ( e l e m e n t ) ) ;  
         v a r   p r e v i o u s S i b l i n g s   =   e l e m e n t . p r e v i o u s S i b l i n g s ( ) ;  
         r e t u r n   e x p r e s s i o n   ?   S e l e c t o r . f i n d E l e m e n t ( p r e v i o u s S i b l i n g s ,   e x p r e s s i o n ,   i n d e x )   :  
             p r e v i o u s S i b l i n g s [ i n d e x   | |   0 ] ;  
     } ,  
  
     n e x t :   f u n c t i o n ( e l e m e n t ,   e x p r e s s i o n ,   i n d e x )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         i f   ( a r g u m e n t s . l e n g t h   = =   1 )   r e t u r n   $ ( S e l e c t o r . h a n d l e r s . n e x t E l e m e n t S i b l i n g ( e l e m e n t ) ) ;  
         v a r   n e x t S i b l i n g s   =   e l e m e n t . n e x t S i b l i n g s ( ) ;  
         r e t u r n   e x p r e s s i o n   ?   S e l e c t o r . f i n d E l e m e n t ( n e x t S i b l i n g s ,   e x p r e s s i o n ,   i n d e x )   :  
             n e x t S i b l i n g s [ i n d e x   | |   0 ] ;  
     } ,  
  
     g e t E l e m e n t s B y S e l e c t o r :   f u n c t i o n ( )   {  
         v a r   a r g s   =   $ A ( a r g u m e n t s ) ,   e l e m e n t   =   $ ( a r g s . s h i f t ( ) ) ;  
         r e t u r n   S e l e c t o r . f i n d C h i l d E l e m e n t s ( e l e m e n t ,   a r g 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 ( e l e m e n t ,   c l a s s N a m e )   {  
         r e t u r n   d o c u m e n t . 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 ,   e l e m e n t ) ;  
     } ,  
  
     r e a d A t t r i b u t e :   f u n c t i o n ( e l e m e n t ,   n a m e )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         i f   ( P r o t o t y p e . B r o w s e r . I E )   {  
             i f   ( ! e l e m e n t . a t t r i b u t e s )   r e t u r n   n u l l ;  
             v a r   t   =   E l e m e n t . _ a t t r i b u t e T r a n s l a t i o n s ;  
             i f   ( t . v a l u e s [ n a m e ] )   r e t u r n   t . v a l u e s [ n a m e ] ( e l e m e n t ,   n a m e ) ;  
             i f   ( t . n a m e s [ n a m e ] )     n a m e   =   t . n a m e s [ n a m e ] ;  
             v a r   a t t r i b u t e   =   e l e m e n t . a t t r i b u t e s [ n a m e ] ;  
             r e t u r n   a t t r i b u t e   ?   a t t r i b u t e . n o d e V a l u e   :   n u l l ;  
         }  
         r e t u r n   e l e m e n t . g e t A t t r i b u t e ( n a m e ) ;  
     } ,  
  
     g e t H e i g h t :   f u n c t i o n ( e l e m e n t )   {  
         r e t u r n   $ ( e l e m e n t ) . g e t D i m e n s i o n s ( ) . h e i g h t ;  
     } ,  
  
     g e t W i d t h :   f u n c t i o n ( e l e m e n t )   {  
         r e t u r n   $ ( e l e m e n t ) . g e t D i m e n s i o n s ( ) . w i d t h ;  
     } ,  
  
     c l a s s N a m e s :   f u n c t i o n ( e l e m e n t )   {  
         r e t u r n   n e w   E l e m e n t . C l a s s N a m e s ( e l e m e n t ) ;  
     } ,  
  
     h a s C l a s s N a m e :   f u n c t i o n ( e l e m e n t ,   c l a s s N a m e )   {  
         i f   ( ! ( e l e m e n t   =   $ ( e l e m e n t ) ) )   r e t u r n ;  
         v a r   e l e m e n t C l a s s N a m e   =   e l e m e n t . c l a s s N a m e ;  
         i f   ( e l e m e n t C l a s s N a m e . l e n g t h   = =   0 )   r e t u r n   f a l s e ;  
         i f   ( e l e m e n t C l a s s N a m e   = =   c l a s s N a m e   | |  
                 e l e m e n t C l a s s N a m e . m a t c h ( n e w   R e g E x p ( " ( ^ | \ \ s ) "   +   c l a s s N a m e   +   " ( \ \ s | $ ) " ) ) )  
             r e t u r n   t r u e ;  
         r e t u r n   f a l s e ;  
     } ,  
  
     a d d C l a s s N a m e :   f u n c t i o n ( e l e m e n t ,   c l a s s N a m e )   {  
         i f   ( ! ( e l e m e n t   =   $ ( e l e m e n t ) ) )   r e t u r n ;  
         E l e m e n t . c l a s s N a m e s ( e l e m e n t ) . a d d ( c l a s s N a m e ) ;  
         r e t u r n   e l e m e n t ;  
     } ,  
  
     r e m o v e C l a s s N a m e :   f u n c t i o n ( e l e m e n t ,   c l a s s N a m e )   {  
         i f   ( ! ( e l e m e n t   =   $ ( e l e m e n t ) ) )   r e t u r n ;  
         E l e m e n t . c l a s s N a m e s ( e l e m e n t ) . r e m o v e ( c l a s s N a m e ) ;  
         r e t u r n   e l e m e n t ;  
     } ,  
  
     t o g g l e C l a s s N a m e :   f u n c t i o n ( e l e m e n t ,   c l a s s N a m e )   {  
         i f   ( ! ( e l e m e n t   =   $ ( e l e m e n t ) ) )   r e t u r n ;  
         E l e m e n t . c l a s s N a m e s ( e l e m e n t ) [ e l e m e n t . h a s C l a s s N a m e ( c l a s s N a m e )   ?   ' r e m o v e '   :   ' a d d ' ] ( c l a s s N a m e ) ;  
         r e t u r n   e l e m e n t ;  
     } ,  
  
     o b s e r v e :   f u n c t i o n ( )   {  
         E v e n t . o b s e r v e . a p p l y ( E v e n t ,   a r g u m e n t s ) ;  
         r e t u r n   $ A ( a r g u m e n t s ) . f i r s t ( ) ;  
     } ,  
  
     s t o p O b s e r v i n g :   f u n c t i o n ( )   {  
         E v e n t . s t o p O b s e r v i n g . a p p l y ( E v e n t ,   a r g u m e n t s ) ;  
         r e t u r n   $ A ( a r g u m e n t s ) . f i r s t ( ) ;  
     } ,  
  
     / /   r e m o v e s   w h i t e s p a c e - o n l y   t e x t   n o d e   c h i l d r e n  
     c l e a n W h i t e s p a c e :   f u n c t i o n ( e l e m e n t )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         v a r   n o d e   =   e l e m e n t . f i r s t C h i l d ;  
         w h i l e   ( n o d e )   {  
             v a r   n e x t N o d e   =   n o d e . n e x t S i b l i n g ;  
             i f   ( n o d e . n o d e T y p e   = =   3   & &   ! / \ S / . t e s t ( n o d e . n o d e V a l u e ) )  
                 e l e m e n t . r e m o v e C h i l d ( n o d e ) ;  
             n o d e   =   n e x t N o d e ;  
         }  
         r e t u r n   e l e m e n t ;  
     } ,  
  
     e m p t y :   f u n c t i o n ( e l e m e n t )   {  
         r e t u r n   $ ( e l e m e n t ) . i n n e r H T M L . b l a n k ( ) ;  
     } ,  
  
     d e s c e n d a n t O f :   f u n c t i o n ( e l e m e n t ,   a n c e s t o r )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ,   a n c e s t o r   =   $ ( a n c e s t o r ) ;  
         w h i l e   ( e l e m e n t   =   e l e m e n t . p a r e n t N o d e )  
             i f   ( e l e m e n t   = =   a n c e s t o r )   r e t u r n   t r u e ;  
         r e t u r n   f a l s e ;  
     } ,  
  
     s c r o l l T o :   f u n c t i o n ( e l e m e n t )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         v a r   p o s   =   P o s i t i o n . c u m u l a t i v e O f f s e t ( e l e m e n t ) ;  
         w i n d o w . s c r o l l T o ( p o s [ 0 ] ,   p o s [ 1 ] ) ;  
         r e t u r n   e l e m e n t ;  
     } ,  
  
     g e t S t y l e :   f u n c t i o n ( e l e m e n t ,   s t y l e )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         s t y l e   =   s t y l e   = =   ' f l o a t '   ?   ' c s s F l o a t '   :   s t y l e . c a m e l i z e ( ) ;  
         v a r   v a l u e   =   e l e m e n t . s t y l e [ s t y l e ] ;  
         i f   ( ! v a l u e )   {  
             v a r   c s s   =   d o c u m e n t . d e f a u l t V i e w . g e t C o m p u t e d S t y l e ( e l e m e n t ,   n u l l ) ;  
             v a l u e   =   c s s   ?   c s s [ s t y l e ]   :   n u l l ;  
         }  
         i f   ( s t y l e   = =   ' o p a c i t y ' )   r e t u r n   v a l u e   ?   p a r s e F l o a t ( v a l u e )   :   1 . 0 ;  
         r e t u r n   v a l u e   = =   ' a u t o '   ?   n u l l   :   v a l u e ;  
     } ,  
  
     g e t O p a c i t y :   f u n c t i o n ( e l e m e n t )   {  
         r e t u r n   $ ( e l e m e n t ) . g e t S t y l e ( ' o p a c i t y ' ) ;  
     } ,  
  
     s e t S t y l e :   f u n c t i o n ( e l e m e n t ,   s t y l e s ,   c a m e l i z e d )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         v a r   e l e m e n t S t y l e   =   e l e m e n t . s t y l e ;  
  
         f o r   ( v a r   p r o p e r t y   i n   s t y l e s )  
             i f   ( p r o p e r t y   = =   ' o p a c i t y ' )   e l e m e n t . s e t O p a c i t y ( s t y l e s [ p r o p e r t y ] )  
             e l s e  
                 e l e m e n t S t y l e [ ( p r o p e r t y   = =   ' f l o a t '   | |   p r o p e r t y   = =   ' c s s F l o a t ' )   ?  
                     ( e l e m e n t S t y l e . s t y l e F l o a t   = = =   u n d e f i n e d   ?   ' c s s F l o a t '   :   ' s t y l e F l o a t ' )   :  
                     ( c a m e l i z e d   ?   p r o p e r t y   :   p r o p e r t y . c a m e l i z e ( ) ) ]   =   s t y l e s [ p r o p e r t y ] ;  
  
         r e t u r n   e l e m e n t ;  
     } ,  
  
     s e t O p a c i t y :   f u n c t i o n ( e l e m e n t ,   v a l u e )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         e l e m e n t . s t y l e . o p a c i t y   =   ( v a l u e   = =   1   | |   v a l u e   = = =   ' ' )   ?   ' '   :  
             ( v a l u e   <   0 . 0 0 0 0 1 )   ?   0   :   v a l u e ;  
         r e t u r n   e l e m e n t ;  
     } ,  
  
     g e t D i m e n s i o n s :   f u n c t i o n ( e l e m e n t )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         v a r   d i s p l a y   =   $ ( e l e m e n t ) . g e t S t y l e ( ' d i s p l a y ' ) ;  
         i f   ( d i s p l a y   ! =   ' n o n e '   & &   d i s p l a y   ! =   n u l l )   / /   S a f a r i   b u g  
             r e t u r n   { w i d t h :   e l e m e n t . o f f s e t W i d t h ,   h e i g h t :   e l e m e n t . o f f s e t H e i g h t } ;  
  
         / /   A l l   * W i d t h   a n d   * H e i g h t   p r o p e r t i e s   g i v e   0   o n   e l e m e n t s   w i t h   d i s p l a y   n o n e ,  
         / /   s o   e n a b l e   t h e   e l e m e n t   t e m p o r a r i l y  
         v a r   e l s   =   e l e m e n t . s t y l e ;  
         v a r   o r i g i n a l V i s i b i l i t y   =   e l s . v i s i b i l i t y ;  
         v a r   o r i g i n a l P o s i t i o n   =   e l s . p o s i t i o n ;  
         v a r   o r i g i n a l D i s p l a y   =   e l s . d i s p l a y ;  
         e l s . v i s i b i l i t y   =   ' h i d d e n ' ;  
         e l s . p o s i t i o n   =   ' a b s o l u t e ' ;  
         e l s . d i s p l a y   =   ' b l o c k ' ;  
         v a r   o r i g i n a l W i d t h   =   e l e m e n t . c l i e n t W i d t h ;  
         v a r   o r i g i n a l H e i g h t   =   e l e m e n t . c l i e n t H e i g h t ;  
         e l s . d i s p l a y   =   o r i g i n a l D i s p l a y ;  
         e l s . p o s i t i o n   =   o r i g i n a l P o s i t i o n ;  
         e l s . v i s i b i l i t y   =   o r i g i n a l V i s i b i l i t y ;  
         r e t u r n   { w i d t h :   o r i g i n a l W i d t h ,   h e i g h t :   o r i g i n a l H e i g h t } ;  
     } ,  
  
     m a k e P o s i t i o n e d :   f u n c t i o n ( e l e m e n t )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         v a r   p o s   =   E l e m e n t . g e t S t y l e ( e l e m e n t ,   ' p o s i t i o n ' ) ;  
         i f   ( p o s   = =   ' s t a t i c '   | |   ! p o s )   {  
             e l e m e n t . _ m a d e P o s i t i o n e d   =   t r u e ;  
             e l e m e n t . s t y l e . p o s i t i o n   =   ' r e l a t i v e ' ;  
             / /   O p e r a   r e t u r n s   t h e   o f f s e t   r e l a t i v e   t o   t h e   p o s i t i o n i n g   c o n t e x t ,   w h e n   a n  
             / /   e l e m e n t   i s   p o s i t i o n   r e l a t i v e   b u t   t o p   a n d   l e f t   h a v e   n o t   b e e n   d e f i n e d  
             i f   ( w i n d o w . o p e r a )   {  
                 e l e m e n t . s t y l e . t o p   =   0 ;  
                 e l e m e n t . s t y l e . l e f t   =   0 ;  
             }  
         }  
         r e t u r n   e l e m e n t ;  
     } ,  
  
     u n d o P o s i t i o n e d :   f u n c t i o n ( e l e m e n t )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         i f   ( e l e m e n t . _ m a d e P o s i t i o n e d )   {  
             e l e m e n t . _ m a d e P o s i t i o n e d   =   u n d e f i n e d ;  
             e l e m e n t . s t y l e . p o s i t i o n   =  
                 e l e m e n t . s t y l e . t o p   =  
                 e l e m e n t . s t y l e . l e f t   =  
                 e l e m e n t . s t y l e . b o t t o m   =  
                 e l e m e n t . s t y l e . r i g h t   =   ' ' ;  
         }  
         r e t u r n   e l e m e n t ;  
     } ,  
  
     m a k e C l i p p i n g :   f u n c t i o n ( e l e m e n t )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         i f   ( e l e m e n t . _ o v e r f l o w )   r e t u r n   e l e m e n t ;  
         e l e m e n t . _ o v e r f l o w   =   e l e m e n t . s t y l e . o v e r f l o w   | |   ' a u t o ' ;  
         i f   ( ( E l e m e n t . g e t S t y l e ( e l e m e n t ,   ' o v e r f l o w ' )   | |   ' v i s i b l e ' )   ! =   ' h i d d e n ' )  
             e l e m e n t . s t y l e . o v e r f l o w   =   ' h i d d e n ' ;  
         r e t u r n   e l e m e n t ;  
     } ,  
  
     u n d o C l i p p i n g :   f u n c t i o n ( e l e m e n t )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         i f   ( ! e l e m e n t . _ o v e r f l o w )   r e t u r n   e l e m e n t ;  
         e l e m e n t . s t y l e . o v e r f l o w   =   e l e m e n t . _ o v e r f l o w   = =   ' a u t o '   ?   ' '   :   e l e m e n t . _ o v e r f l o w ;  
         e l e m e n t . _ o v e r f l o w   =   n u l l ;  
         r e t u r n   e l e m e n t ;  
     }  
 } ;  
  
 O b j e c t . e x t e n d ( E l e m e n t . M e t h o d s ,   {  
     c h i l d O f :   E l e m e n t . M e t h o d s . d e s c e n d a n t O f ,  
     c h i l d E l e m e n t s :   E l e m e n t . M e t h o d s . i m m e d i a t e D e s c e n d a n t s  
 } ) ;  
  
 i f   ( P r o t o t y p e . B r o w s e r . O p e r a )   {  
     E l e m e n t . M e t h o d s . _ g e t S t y l e   =   E l e m e n t . M e t h o d s . g e t S t y l e ;  
     E l e m e n t . M e t h o d s . g e t S t y l e   =   f u n c t i o n ( e l e m e n t ,   s t y l e )   {  
         s w i t c h ( s t y l e )   {  
             c a s e   ' l e f t ' :  
             c a s e   ' t o p ' :  
             c a s e   ' r i g h t ' :  
             c a s e   ' b o t t o m ' :  
                 i f   ( E l e m e n t . _ g e t S t y l e ( e l e m e n t ,   ' p o s i t i o n ' )   = =   ' s t a t i c ' )   r e t u r n   n u l l ;  
             d e f a u l t :   r e t u r n   E l e m e n t . _ g e t S t y l e ( e l e m e n t ,   s t y l e ) ;  
         }  
     } ;  
 }  
 e l s e   i f   ( P r o t o t y p e . B r o w s e r . I E )   {  
     E l e m e n t . M e t h o d s . g e t S t y l e   =   f u n c t i o n ( e l e m e n t ,   s t y l e )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         s t y l e   =   ( s t y l e   = =   ' f l o a t '   | |   s t y l e   = =   ' c s s F l o a t ' )   ?   ' s t y l e F l o a t '   :   s t y l e . c a m e l i z e ( ) ;  
         v a r   v a l u e   =   e l e m e n t . s t y l e [ s t y l e ] ;  
         i f   ( ! v a l u e   & &   e l e m e n t . c u r r e n t S t y l e )   v a l u e   =   e l e m e n t . c u r r e n t S t y l e [ s t y l e ] ;  
  
         i f   ( s t y l e   = =   ' o p a c i t y ' )   {  
             i f   ( v a l u e   =   ( e l e m e n t . g e t S t y l e ( ' f i l t e r ' )   | |   ' ' ) . m a t c h ( / a l p h a \ ( o p a c i t y = ( . * ) \ ) / ) )  
                 i f   ( v a l u e [ 1 ] )   r e t u r n   p a r s e F l o a t ( v a l u e [ 1 ] )   /   1 0 0 ;  
             r e t u r n   1 . 0 ;  
         }  
  
         i f   ( v a l u e   = =   ' a u t o ' )   {  
             i f   ( ( s t y l e   = =   ' w i d t h '   | |   s t y l e   = =   ' h e i g h t ' )   & &   ( e l e m e n t . g e t S t y l e ( ' d i s p l a y ' )   ! =   ' n o n e ' ) )  
                 r e t u r n   e l e m e n t [ ' o f f s e t ' + s t y l e . c a p i t a l i z e ( ) ]   +   ' p x ' ;  
             r e t u r n   n u l l ;  
         }  
         r e t u r n   v a l u e ;  
     } ;  
  
     E l e m e n t . M e t h o d s . s e t O p a c i t y   =   f u n c t i o n ( e l e m e n t ,   v a l u e )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         v a r   f i l t e r   =   e l e m e n t . g e t S t y l e ( ' f i l t e r ' ) ,   s t y l e   =   e l e m e n t . s t y l e ;  
         i f   ( v a l u e   = =   1   | |   v a l u e   = = =   ' ' )   {  
             s t y l e . f i l t e r   =   f i l t e r . r e p l a c e ( / a l p h a \ ( [ ^ \ ) ] * \ ) / g i , ' ' ) ;  
             r e t u r n   e l e m e n t ;  
         }   e l s e   i f   ( v a l u e   <   0 . 0 0 0 0 1 )   v a l u e   =   0 ;  
         s t y l e . f i l t e r   =   f i l t e r . r e p l a c e ( / a l p h a \ ( [ ^ \ ) ] * \ ) / g i ,   ' ' )   +  
             ' a l p h a ( o p a c i t y = '   +   ( v a l u e   *   1 0 0 )   +   ' ) ' ;  
         r e t u r n   e l e m e n t ;  
     } ;  
  
     / /   I E   i s   m i s s i n g   . i n n e r H T M L   s u p p o r t   f o r   T A B L E - r e l a t e d   e l e m e n t s  
     E l e m e n t . M e t h o d s . u p d a t e   =   f u n c t i o n ( e l e m e n t ,   h t m l )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         h t m l   =   t y p e o f   h t m l   = =   ' u n d e f i n e d '   ?   ' '   :   h t m l . t o S t r i n g ( ) ;  
         v a r   t a g N a m e   =   e l e m e n t . t a g N a m e . t o U p p e r C a s e ( ) ;  
         i f   ( [ ' T H E A D ' , ' T B O D Y ' , ' T R ' , ' T D ' ] . i n c l u d e ( t a g N a m e ) )   {  
             v a r   d i v   =   d o c u m e n t . c r e a t e E l e m e n t ( ' d i v ' ) ;  
             s w i t c h   ( t a g N a m e )   {  
                 c a s e   ' T H E A D ' :  
                 c a s e   ' T B O D Y ' :  
                     d i v . i n n e r H T M L   =   ' < t a b l e > < t b o d y > '   +     h t m l . s t r i p S c r i p t s ( )   +   ' < / t b o d y > < / t a b l e > ' ;  
                     d e p t h   =   2 ;  
                     b r e a k ;  
                 c a s e   ' T R ' :  
                     d i v . i n n e r H T M L   =   ' < t a b l e > < t b o d y > < t r > '   +     h t m l . s t r i p S c r i p t s ( )   +   ' < / t r > < / t b o d y > < / t a b l e > ' ;  
                     d e p t h   =   3 ;  
                     b r e a k ;  
                 c a s e   ' T D ' :  
                     d i v . i n n e r H T M L   =   ' < t a b l e > < t b o d y > < t r > < t d > '   +     h t m l . s t r i p S c r i p t s ( )   +   ' < / t d > < / t r > < / t b o d y > < / t a b l e > ' ;  
                     d e p t h   =   4 ;  
             }  
             $ A ( e l e m e n t . c h i l d N o d e s ) . e a c h ( f u n c t i o n ( n o d e )   {   e l e m e n t . r e m o v e C h i l d ( n o d e )   } ) ;  
             d e p t h . t i m e s ( f u n c t i o n ( )   {   d i v   =   d i v . f i r s t C h i l d   } ) ;  
             $ A ( d i v . c h i l d N o d e s ) . e a c h ( f u n c t i o n ( n o d e )   {   e l e m e n t . a p p e n d C h i l d ( n o d e )   } ) ;  
         }   e l s e   {  
             e l e m e n t . i n n e r H T M L   =   h t m l . s t r i p S c r i p t s ( ) ;  
         }  
         s e t T i m e o u t ( f u n c t i o n ( )   {   h t m l . e v a l S c r i p t s ( )   } ,   1 0 ) ;  
         r e t u r n   e l e m e n t ;  
     }  
 }  
 e l s e   i f   ( P r o t o t y p e . B r o w s e r . G e c k o )   {  
     E l e m e n t . M e t h o d s . s e t O p a c i t y   =   f u n c t i o n ( e l e m e n t ,   v a l u e )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         e l e m e n t . s t y l e . o p a c i t y   =   ( v a l u e   = =   1 )   ?   0 . 9 9 9 9 9 9   :  
             ( v a l u e   = = =   ' ' )   ?   ' '   :   ( v a l u e   <   0 . 0 0 0 0 1 )   ?   0   :   v a l u e ;  
         r e t u r n   e l e m e n t ;  
     } ;  
 }  
  
 E l e m e n t . _ a t t r i b u t e T r a n s l a t i o n s   =   {  
     n a m e s :   {  
         c o l s p a n :       " c o l S p a n " ,  
         r o w s p a n :       " r o w S p a n " ,  
         v a l i g n :         " v A l i g n " ,  
         d a t e t i m e :     " d a t e T i m e " ,  
         a c c e s s k e y :   " a c c e s s K e y " ,  
         t a b i n d e x :     " t a b I n d e x " ,  
         e n c t y p e :       " e n c T y p e " ,  
         m a x l e n g t h :   " m a x L e n g t h " ,  
         r e a d o n l y :     " r e a d O n l y " ,  
         l o n g d e s c :     " l o n g D e s c "  
     } ,  
     v a l u e s :   {  
         _ g e t A t t r :   f u n c t i o n ( e l e m e n t ,   a t t r i b u t e )   {  
             r e t u r n   e l e m e n t . g e t A t t r i b u t e ( a t t r i b u t e ,   2 ) ;  
         } ,  
         _ f l a g :   f u n c t i o n ( e l e m e n t ,   a t t r i b u t e )   {  
             r e t u r n   $ ( e l e m e n t ) . h a s A t t r i b u t e ( a t t r i b u t e )   ?   a t t r i b u t e   :   n u l l ;  
         } ,  
         s t y l e :   f u n c t i o n ( e l e m e n t )   {  
             r e t u r n   e l e m e n t . s t y l e . c s s T e x t . t o L o w e r C a s e ( ) ;  
         } ,  
         t i t l e :   f u n c t i o n ( e l e m e n t )   {  
             v a r   n o d e   =   e l e m e n t . g e t A t t r i b u t e N o d e ( ' t i t l e ' ) ;  
             r e t u r n   n o d e . s p e c i f i e d   ?   n o d e . n o d e V a l u e   :   n u l l ;  
         }  
     }  
 } ;  
  
 ( f u n c t i o n ( )   {  
     O b j e c t . e x t e n d ( t h i s ,   {  
         h r e f :   t h i s . _ g e t A t t r ,  
         s r c :     t h i s . _ g e t A t t r ,  
         t y p e :   t h i s . _ g e t A t t r ,  
         d i s a b l e d :   t h i s . _ f l a g ,  
         c h e c k e d :     t h i s . _ f l a g ,  
         r e a d o n l y :   t h i s . _ f l a g ,  
         m u l t i p l e :   t h i s . _ f l a g  
     } ) ;  
 } ) . c a l l ( E l e m e n t . _ a t t r i b u t e T r a n s l a t i o n s . v a l u e s ) ;  
  
 E l e m e n t . M e t h o d s . S i m u l a t e d   =   {  
     h a s A t t r i b u t e :   f u n c t i o n ( e l e m e n t ,   a t t r i b u t e )   {  
         v a r   t   =   E l e m e n t . _ a t t r i b u t e T r a n s l a t i o n s ,   n o d e ;  
         a t t r i b u t e   =   t . n a m e s [ a t t r i b u t e ]   | |   a t t r i b u t e ;  
         n o d e   =   $ ( e l e m e n t ) . g e t A t t r i b u t e N o d e ( a t t r i b u t e ) ;  
         r e t u r n   n o d e   & &   n o d e . s p e c i f i e d ;  
     }  
 } ;  
  
 E l e m e n t . M e t h o d s . B y T a g   =   { } ;  
  
 O b j e c t . e x t e n d ( E l e m e n t ,   E l e m e n t . M e t h o d s ) ;  
  
 i f   ( ! P r o t o t y p e . B r o w s e r F e a t u r e s . E l e m e n t E x t e n s i o n s   & &  
   d o c u m e n t . c r e a t e E l e m e n t ( ' d i v ' ) . _ _ p r o t o _ _ )   {  
     w i n d o w . H T M L E l e m e n t   =   { } ;  
     w i n d o w . H T M L E l e m e n t . p r o t o t y p e   =   d o c u m e n t . c r e a t e E l e m e n t ( ' d i v ' ) . _ _ p r o t o _ _ ;  
     P r o t o t y p e . B r o w s e r F e a t u r e s . E l e m e n t E x t e n s i o n s   =   t r u e ;  
 }  
  
 E l e m e n t . h a s A t t r i b u t e   =   f u n c t i o n ( e l e m e n t ,   a t t r i b u t e )   {  
     i f   ( e l e m e n t . h a s A t t r i b u t e )   r e t u r n   e l e m e n t . h a s A t t r i b u t e ( a t t r i b u t e ) ;  
     r e t u r n   E l e m e n t . M e t h o d s . S i m u l a t e d . h a s A t t r i b u t e ( e l e m e n t ,   a t t r i b u t e ) ;  
 } ;  
  
 E l e m e n t . a d d M e t h o d s   =   f u n c t i o n ( m e t h o d s )   {  
     v a r   F   =   P r o t o t y p e . B r o w s e r F e a t u r e s ,   T   =   E l e m e n t . M e t h o d s . B y T a g ;  
  
     i f   ( ! m e t h o d s )   {  
         O b j e c t . e x t e n d ( F o r m ,   F o r m . M e t h o d s ) ;  
         O b j e c t . e x t e n d ( F o r m . E l e m e n t ,   F o r m . E l e m e n t . M e t h o d s ) ;  
         O b j e c t . e x t e n d ( E l e m e n t . M e t h o d s . B y T a g ,   {  
             " F O R M " :           O b j e c t . c l o n e ( F o r m . M e t h o d s ) ,  
             " I N P U T " :         O b j e c t . c l o n e ( F o r m . E l e m e n t . M e t h o d s ) ,  
             " S E L E C T " :       O b j e c t . c l o n e ( F o r m . E l e m e n t . M e t h o d s ) ,  
             " T E X T A R E A " :   O b j e c t . c l o n e ( F o r m . E l e m e n t . M e t h o d s )  
         } ) ;  
     }  
  
     i f   ( a r g u m e n t s . l e n g t h   = =   2 )   {  
         v a r   t a g N a m e   =   m e t h o d s ;  
         m e t h o d s   =   a r g u m e n t s [ 1 ] ;  
     }  
  
     i f   ( ! t a g N a m e )   O b j e c t . e x t e n d ( E l e m e n t . M e t h o d s ,   m e t h o d s   | |   { } ) ;  
     e l s e   {  
         i f   ( t a g N a m e . c o n s t r u c t o r   = =   A r r a y )   t a g N a m e . e a c h ( e x t e n d ) ;  
         e l s e   e x t e n d ( t a g N a m e ) ;  
     }  
  
     f u n c t i o n   e x t e n d ( t a g N a m e )   {  
         t a g N a m e   =   t a g N a m e . t o U p p e r C a s e ( ) ;  
         i f   ( ! E l e m e n t . M e t h o d s . B y T a g [ t a g N a m e ] )  
             E l e m e n t . M e t h o d s . B y T a g [ t a g N a m e ]   =   { } ;  
         O b j e c t . e x t e n d ( E l e m e n t . M e t h o d s . B y T a g [ t a g N a m e ] ,   m e t h o d s ) ;  
     }  
  
     f u n c t i o n   c o p y ( m e t h o d s ,   d e s t i n a t i o n ,   o n l y I f A b s e n t )   {  
         o n l y I f A b s e n t   =   o n l y I f A b s e n t   | |   f a l s e ;  
         v a r   c a c h e   =   E l e m e n t . e x t e n d . c a c h e ;  
         f o r   ( v a r   p r o p e r t y   i n   m e t h o d s )   {  
             v a r   v a l u e   =   m e t h o d s [ p r o p e r t y ] ;  
             i f   ( ! o n l y I f A b s e n t   | |   ! ( p r o p e r t y   i n   d e s t i n a t i o n ) )  
                 d e s t i n a t i o n [ p r o p e r t y ]   =   c a c h e . f i n d O r S t o r e ( v a l u e ) ;  
         }  
     }  
  
     f u n c t i o n   f i n d D O M C l a s s ( t a g N a m e )   {  
         v a r   k l a s s ;  
         v a r   t r a n s   =   {  
             " O P T G R O U P " :   " O p t G r o u p " ,   " T E X T A R E A " :   " T e x t A r e a " ,   " P " :   " P a r a g r a p h " ,  
             " F I E L D S E T " :   " F i e l d S e t " ,   " U L " :   " U L i s t " ,   " O L " :   " O L i s t " ,   " D L " :   " D L i s t " ,  
             " D I R " :   " D i r e c t o r y " ,   " H 1 " :   " H e a d i n g " ,   " H 2 " :   " H e a d i n g " ,   " H 3 " :   " H e a d i n g " ,  
             " H 4 " :   " H e a d i n g " ,   " H 5 " :   " H e a d i n g " ,   " H 6 " :   " H e a d i n g " ,   " Q " :   " Q u o t e " ,  
             " I N S " :   " M o d " ,   " D E L " :   " M o d " ,   " A " :   " A n c h o r " ,   " I M G " :   " I m a g e " ,   " C A P T I O N " :  
             " T a b l e C a p t i o n " ,   " C O L " :   " T a b l e C o l " ,   " C O L G R O U P " :   " T a b l e C o l " ,   " T H E A D " :  
             " T a b l e S e c t i o n " ,   " T F O O T " :   " T a b l e S e c t i o n " ,   " T B O D Y " :   " T a b l e S e c t i o n " ,   " T R " :  
             " T a b l e R o w " ,   " T H " :   " T a b l e C e l l " ,   " T D " :   " T a b l e C e l l " ,   " F R A M E S E T " :  
             " F r a m e S e t " ,   " I F R A M E " :   " I F r a m e "  
         } ;  
         i f   ( t r a n s [ t a g N a m e ] )   k l a s s   =   ' H T M L '   +   t r a n s [ t a g N a m e ]   +   ' E l e m e n t ' ;  
         i f   ( w i n d o w [ k l a s s ] )   r e t u r n   w i n d o w [ k l a s s ] ;  
         k l a s s   =   ' H T M L '   +   t a g N a m e   +   ' E l e m e n t ' ;  
         i f   ( w i n d o w [ k l a s s ] )   r e t u r n   w i n d o w [ k l a s s ] ;  
         k l a s s   =   ' H T M L '   +   t a g N a m e . c a p i t a l i z e ( )   +   ' E l e m e n t ' ;  
         i f   ( w i n d o w [ k l a s s ] )   r e t u r n   w i n d o w [ k l a s s ] ;  
  
         w i n d o w [ k l a s s ]   =   { } ;  
         w i n d o w [ k l a s s ] . p r o t o t y p e   =   d o c u m e n t . c r e a t e E l e m e n t ( t a g N a m e ) . _ _ p r o t o _ _ ;  
         r e t u r n   w i n d o w [ k l a s s ] ;  
     }  
  
     i f   ( F . E l e m e n t E x t e n s i o n s )   {  
         c o p y ( E l e m e n t . M e t h o d s ,   H T M L E l e m e n t . p r o t o t y p e ) ;  
         c o p y ( E l e m e n t . M e t h o d s . S i m u l a t e d ,   H T M L E l e m e n t . p r o t o t y p e ,   t r u e ) ;  
     }  
  
     i f   ( F . S p e c i f i c E l e m e n t E x t e n s i o n s )   {  
         f o r   ( v a r   t a g   i n   E l e m e n t . M e t h o d s . B y T a g )   {  
             v a r   k l a s s   =   f i n d D O M C l a s s ( t a g ) ;  
             i f   ( t y p e o f   k l a s s   = =   " u n d e f i n e d " )   c o n t i n u e ;  
             c o p y ( T [ t a g ] ,   k l a s s . p r o t o t y p e ) ;  
         }  
     }  
  
     O b j e c t . e x t e n d ( E l e m e n t ,   E l e m e n t . M e t h o d s ) ;  
     d e l e t e   E l e m e n t . B y T a g ;  
 } ;  
  
 v a r   T o g g l e   =   {   d i s p l a y :   E l e m e n t . t o g g l e   } ;  
  
 / * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * /  
  
 A b s t r a c t . I n s e r t i o n   =   f u n c t i o n ( a d j a c e n c y )   {  
     t h i s . a d j a c e n c y   =   a d j a c e n c y ;  
 }  
  
 A b s t r a c t . I n s e r t i o n . p r o t o t y p e   =   {  
     i n i t i a l i z e :   f u n c t i o n ( e l e m e n t ,   c o n t e n t )   {  
         t h i s . e l e m e n t   =   $ ( e l e m e n t ) ;  
         t h i s . c o n t e n t   =   c o n t e n t . s t r i p S c r i p t s ( ) ;  
  
         i f   ( t h i s . a d j a c e n c y   & &   t h i s . e l e m e n t . i n s e r t A d j a c e n t H T M L )   {  
             t r y   {  
                 t h i s . e l e m e n t . i n s e r t A d j a c e n t H T M L ( t h i s . a d j a c e n c y ,   t h i s . c o n t e n t ) ;  
             }   c a t c h   ( e )   {  
                 v a r   t a g N a m e   =   t h i s . e l e m e n t . t a g N a m e . t o U p p e r C a s e ( ) ;  
                 i f   ( [ ' T B O D Y ' ,   ' T R ' ] . i n c l u d e ( t a g N a m e ) )   {  
                     t h i s . i n s e r t C o n t e n t ( t h i s . c o n t e n t F r o m A n o n y m o u s T a b l e ( ) ) ;  
                 }   e l s e   {  
                     t h r o w   e ;  
                 }  
             }  
         }   e l s e   {  
             t h i s . r a n g e   =   t h i s . e l e m e n t . o w n e r D o c u m e n t . c r e a t e R a n g e ( ) ;  
             i f   ( t h i s . i n i t i a l i z e R a n g e )   t h i s . i n i t i a l i z e R a n g e ( ) ;  
             t h i s . i n s e r t C o n t e n t ( [ t h i s . r a n g e . c r e a t e C o n t e x t u a l F r a g m e n t ( t h i s . c o n t e n t ) ] ) ;  
         }  
  
         s e t T i m e o u t ( f u n c t i o n ( )   { c o n t e n t . e v a l S c r i p t s ( ) } ,   1 0 ) ;  
     } ,  
  
     c o n t e n t F r o m A n o n y m o u s T a b l e :   f u n c t i o n ( )   {  
         v a r   d i v   =   d o c u m e n t . c r e a t e E l e m e n t ( ' d i v ' ) ;  
         d i v . i n n e r H T M L   =   ' < t a b l e > < t b o d y > '   +   t h i s . c o n t e n t   +   ' < / t b o d y > < / t a b l e > ' ;  
         r e t u r n   $ A ( d i v . c h i l d N o d e s [ 0 ] . c h i l d N o d e s [ 0 ] . c h i l d N o d e s ) ;  
     }  
 }  
  
 v a r   I n s e r t i o n   =   n e w   O b j e c t ( ) ;  
  
 I n s e r t i o n . B e f o r e   =   C l a s s . c r e a t e ( ) ;  
 I n s e r t i o n . B e f o r e . p r o t o t y p e   =   O b j e c t . e x t e n d ( n e w   A b s t r a c t . I n s e r t i o n ( ' b e f o r e B e g i n ' ) ,   {  
     i n i t i a l i z e R a n g e :   f u n c t i o n ( )   {  
         t h i s . r a n g e . s e t S t a r t B e f o r e ( t h i s . e l e m e n t ) ;  
     } ,  
  
     i n s e r t C o n t e n t :   f u n c t i o n ( f r a g m e n t s )   {  
         f r a g m e n t s . e a c h ( ( f u n c t i o n ( f r a g m e n t )   {  
             t h i s . e l e m e n t . p a r e n t N o d e . i n s e r t B e f o r e ( f r a g m e n t ,   t h i s . e l e m e n t ) ;  
         } ) . b i n d ( t h i s ) ) ;  
     }  
 } ) ;  
  
 I n s e r t i o n . T o p   =   C l a s s . c r e a t e ( ) ;  
 I n s e r t i o n . T o p . p r o t o t y p e   =   O b j e c t . e x t e n d ( n e w   A b s t r a c t . I n s e r t i o n ( ' a f t e r B e g i n ' ) ,   {  
     i n i t i a l i z e R a n g e :   f u n c t i o n ( )   {  
         t h i s . r a n g e . s e l e c t N o d e C o n t e n t s ( t h i s . e l e m e n t ) ;  
         t h i s . r a n g e . c o l l a p s e ( t r u e ) ;  
     } ,  
  
     i n s e r t C o n t e n t :   f u n c t i o n ( f r a g m e n t s )   {  
         f r a g m e n t s . r e v e r s e ( f a l s e ) . e a c h ( ( f u n c t i o n ( f r a g m e n t )   {  
             t h i s . e l e m e n t . i n s e r t B e f o r e ( f r a g m e n t ,   t h i s . e l e m e n t . f i r s t C h i l d ) ;  
         } ) . b i n d ( t h i s ) ) ;  
     }  
 } ) ;  
  
 I n s e r t i o n . B o t t o m   =   C l a s s . c r e a t e ( ) ;  
 I n s e r t i o n . B o t t o m . p r o t o t y p e   =   O b j e c t . e x t e n d ( n e w   A b s t r a c t . I n s e r t i o n ( ' b e f o r e E n d ' ) ,   {  
     i n i t i a l i z e R a n g e :   f u n c t i o n ( )   {  
         t h i s . r a n g e . s e l e c t N o d e C o n t e n t s ( t h i s . e l e m e n t ) ;  
         t h i s . r a n g e . c o l l a p s e ( t h i s . e l e m e n t ) ;  
     } ,  
  
     i n s e r t C o n t e n t :   f u n c t i o n ( f r a g m e n t s )   {  
         f r a g m e n t s . e a c h ( ( f u n c t i o n ( f r a g m e n t )   {  
             t h i s . e l e m e n t . a p p e n d C h i l d ( f r a g m e n t ) ;  
         } ) . b i n d ( t h i s ) ) ;  
     }  
 } ) ;  
  
 I n s e r t i o n . A f t e r   =   C l a s s . c r e a t e ( ) ;  
 I n s e r t i o n . A f t e r . p r o t o t y p e   =   O b j e c t . e x t e n d ( n e w   A b s t r a c t . I n s e r t i o n ( ' a f t e r E n d ' ) ,   {  
     i n i t i a l i z e R a n g e :   f u n c t i o n ( )   {  
         t h i s . r a n g e . s e t S t a r t A f t e r ( t h i s . e l e m e n t ) ;  
     } ,  
  
     i n s e r t C o n t e n t :   f u n c t i o n ( f r a g m e n t s )   {  
         f r a g m e n t s . e a c h ( ( f u n c t i o n ( f r a g m e n t )   {  
             t h i s . e l e m e n t . p a r e n t N o d e . i n s e r t B e f o r e ( f r a g m e n t ,  
                 t h i s . e l e m e n t . n e x t S i b l i n g ) ;  
         } ) . b i n d ( t h i s ) ) ;  
     }  
 } ) ;  
  
 / * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * /  
  
 E l e m e n t . C l a s s N a m e s   =   C l a s s . c r e a t e ( ) ;  
 E l e m e n t . C l a s s N a m e s . p r o t o t y p e   =   {  
     i n i t i a l i z e :   f u n c t i o n ( e l e m e n t )   {  
         t h i s . e l e m e n t   =   $ ( e l e m e n t ) ;  
     } ,  
  
     _ e a c h :   f u n c t i o n ( i t e r a t o r )   {  
         t h i s . e l e m e n t . c l a s s N a m e . s p l i t ( / \ s + / ) . s e l e c t ( f u n c t i o n ( n a m e )   {  
             r e t u r n   n a m e . l e n g t h   >   0 ;  
         } ) . _ e a c h ( i t e r a t o r ) ;  
     } ,  
  
     s e t :   f u n c t i o n ( c l a s s N a m e )   {  
         t h i s . e l e m e n t . c l a s s N a m e   =   c l a s s N a m e ;  
     } ,  
  
     a d d :   f u n c t i o n ( c l a s s N a m e T o A d d )   {  
         i f   ( t h i s . i n c l u d e ( c l a s s N a m e T o A d d ) )   r e t u r n ;  
         t h i s . s e t ( $ A ( t h i s ) . c o n c a t ( c l a s s N a m e T o A d d ) . j o i n ( '   ' ) ) ;  
     } ,  
  
     r e m o v e :   f u n c t i o n ( c l a s s N a m e T o R e m o v e )   {  
         i f   ( ! t h i s . i n c l u d e ( c l a s s N a m e T o R e m o v e ) )   r e t u r n ;  
         t h i s . s e t ( $ A ( t h i s ) . w i t h o u t ( c l a s s N a m e T o R e m o v e ) . j o i n ( '   ' ) ) ;  
     } ,  
  
     t o S t r i n g :   f u n c t i o n ( )   {  
         r e t u r n   $ A ( t h i s ) . j o i n ( '   ' ) ;  
     }  
 } ;  
  
 O b j e c t . e x t e n d ( E l e m e n t . C l a s s N a m e s . p r o t o t y p e ,   E n u m e r a b l e ) ;  
 / *   P o r t i o n s   o f   t h e   S e l e c t o r   c l a s s   a r e   d e r i v e d   f r o m   J a c k   S l o c u m  s   D o m Q u e r y ,  
   *   p a r t   o f   Y U I - E x t   v e r s i o n   0 . 4 0 ,   d i s t r i b u t e d   u n d e r   t h e   t e r m s   o f   a n   M I T - s t y l e  
   *   l i c e n s e .     P l e a s e   s e e   h t t p : / / w w w . y u i - e x t . c o m /   f o r   m o r e   i n f o r m a t i o n .   * /  
  
 v a r   S e l e c t o r   =   C l a s s . c r e a t e ( ) ;  
  
 S e l e c t o r . p r o t o t y p e   =   {  
     i n i t i a l i z e :   f u n c t i o n ( e x p r e s s i o n )   {  
         t h i s . e x p r e s s i o n   =   e x p r e s s i o n . s t r i p ( ) ;  
         t h i s . c o m p i l e M a t c h e r ( ) ;  
     } ,  
  
     c o m p i l e M a t c h e r :   f u n c t i o n ( )   {  
         / /   S e l e c t o r s   w i t h   n a m e s p a c e d   a t t r i b u t e s   c a n ' t   u s e   t h e   X P a t h   v e r s i o n  
         i f   ( P r o t o t y p e . B r o w s e r F e a t u r e s . X P a t h   & &   ! ( / \ [ [ \ w - ] * ? : / ) . t e s t ( t h i s . e x p r e s s i o n ) )  
             r e t u r n   t h i s . c o m p i l e X P a t h M a t c h e r ( ) ;  
  
         v a r   e   =   t h i s . e x p r e s s i o n ,   p s   =   S e l e c t o r . p a t t e r n s ,   h   =   S e l e c t o r . h a n d l e r s ,  
                 c   =   S e l e c t o r . c r i t e r i a ,   l e ,   p ,   m ;  
  
         i f   ( S e l e c t o r . _ c a c h e [ e ] )   {  
             t h i s . m a t c h e r   =   S e l e c t o r . _ c a c h e [ e ] ;   r e t u r n ;  
         }  
         t h i s . m a t c h e r   =   [ " t h i s . m a t c h e r   =   f u n c t i o n ( r o o t )   { " ,  
                                         " v a r   r   =   r o o t ,   h   =   S e l e c t o r . h a n d l e r s ,   c   =   f a l s e ,   n ; " ] ;  
  
         w h i l e   ( e   & &   l e   ! =   e   & &   ( / \ S / ) . t e s t ( e ) )   {  
             l e   =   e ;  
             f o r   ( v a r   i   i n   p s )   {  
                 p   =   p s [ i ] ;  
                 i f   ( m   =   e . m a t c h ( p ) )   {  
                     t h i s . m a t c h e r . p u s h ( t y p e o f   c [ i ]   = =   ' f u n c t i o n '   ?   c [ i ] ( m )   :  
         	             n e w   T e m p l a t e ( c [ i ] ) . e v a l u a t e ( m ) ) ;  
                     e   =   e . r e p l a c e ( m [ 0 ] ,   ' ' ) ;  
                     b r e a k ;  
                 }  
             }  
         }  
  
         t h i s . m a t c h e r . p u s h ( " r e t u r n   h . u n i q u e ( n ) ; \ n } " ) ;  
         e v a l ( t h i s . m a t c h e r . j o i n ( ' \ n ' ) ) ;  
         S e l e c t o r . _ c a c h e [ t h i s . e x p r e s s i o n ]   =   t h i s . m a t c h e r ;  
     } ,  
  
     c o m p i l e X P a t h M a t c h e r :   f u n c t i o n ( )   {  
         v a r   e   =   t h i s . e x p r e s s i o n ,   p s   =   S e l e c t o r . p a t t e r n s ,  
                 x   =   S e l e c t o r . x p a t h ,   l e ,     m ;  
  
         i f   ( S e l e c t o r . _ c a c h e [ e ] )   {  
             t h i s . x p a t h   =   S e l e c t o r . _ c a c h e [ e ] ;   r e t u r n ;  
         }  
  
         t h i s . m a t c h e r   =   [ ' . / / * ' ] ;  
         w h i l e   ( e   & &   l e   ! =   e   & &   ( / \ S / ) . t e s t ( e ) )   {  
             l e   =   e ;  
             f o r   ( v a r   i   i n   p s )   {  
                 i f   ( m   =   e . m a t c h ( p s [ i ] ) )   {  
                     t h i s . m a t c h e r . p u s h ( t y p e o f   x [ i ]   = =   ' f u n c t i o n '   ?   x [ i ] ( m )   :  
                         n e w   T e m p l a t e ( x [ i ] ) . e v a l u a t e ( m ) ) ;  
                     e   =   e . r e p l a c e ( m [ 0 ] ,   ' ' ) ;  
                     b r e a k ;  
                 }  
             }  
         }  
  
         t h i s . x p a t h   =   t h i s . m a t c h e r . j o i n ( ' ' ) ;  
         S e l e c t o r . _ c a c h e [ t h i s . e x p r e s s i o n ]   =   t h i s . x p a t h ;  
     } ,  
  
     f i n d E l e m e n t s :   f u n c t i o n ( r o o t )   {  
         r o o t   =   r o o t   | |   d o c u m e n t ;  
         i f   ( t h i s . x p a t h )   r e t u r n   d o c u m e n t . _ g e t E l e m e n t s B y X P a t h ( t h i s . x p a t h ,   r o o t ) ;  
         r e t u r n   t h i s . m a t c h e r ( r o o t ) ;  
     } ,  
  
     m a t c h :   f u n c t i o n ( e l e m e n t )   {  
         r e t u r n   t h i s . f i n d E l e m e n t s ( d o c u m e n t ) . i n c l u d e ( e l e m e n t ) ;  
     } ,  
  
     t o S t r i n g :   f u n c t i o n ( )   {  
         r e t u r n   t h i s . e x p r e s s i o n ;  
     } ,  
  
     i n s p e c t :   f u n c t i o n ( )   {  
         r e t u r n   " # < S e l e c t o r : "   +   t h i s . e x p r e s s i o n . i n s p e c t ( )   +   " > " ;  
     }  
 } ;  
  
 O b j e c t . e x t e n d ( S e l e c t o r ,   {  
     _ c a c h e :   { } ,  
  
     x p a t h :   {  
         d e s c e n d a n t :       " / / * " ,  
         c h i l d :                 " / * " ,  
         a d j a c e n t :           " / f o l l o w i n g - s i b l i n g : : * [ 1 ] " ,  
         l a t e r S i b l i n g :   ' / f o l l o w i n g - s i b l i n g : : * ' ,  
         t a g N a m e :             f u n c t i o n ( m )   {  
             i f   ( m [ 1 ]   = =   ' * ' )   r e t u r n   ' ' ;  
             r e t u r n   " [ l o c a l - n a m e ( ) = ' "   +   m [ 1 ] . t o L o w e r C a s e ( )   +  
                           " '   o r   l o c a l - n a m e ( ) = ' "   +   m [ 1 ] . t o U p p e r C a s e ( )   +   " ' ] " ;  
         } ,  
         c l a s s N a m e :         " [ c o n t a i n s ( c o n c a t ( '   ' ,   @ c l a s s ,   '   ' ) ,   '   # { 1 }   ' ) ] " ,  
         i d :                       " [ @ i d = ' # { 1 } ' ] " ,  
         a t t r P r e s e n c e :   " [ @ # { 1 } ] " ,  
         a t t r :   f u n c t i o n ( m )   {  
             m [ 3 ]   =   m [ 5 ]   | |   m [ 6 ] ;  
             r e t u r n   n e w   T e m p l a t e ( S e l e c t o r . x p a t h . o p e r a t o r s [ m [ 2 ] ] ) . e v a l u a t e ( m ) ;  
         } ,  
         p s e u d o :   f u n c t i o n ( m )   {  
             v a r   h   =   S e l e c t o r . x p a t h . p s e u d o s [ m [ 1 ] ] ;  
             i f   ( ! h )   r e t u r n   ' ' ;  
             i f   ( t y p e o f   h   = = =   ' f u n c t i o n ' )   r e t u r n   h ( m ) ;  
             r e t u r n   n e w   T e m p l a t e ( S e l e c t o r . x p a t h . p s e u d o s [ m [ 1 ] ] ) . e v a l u a t e ( m ) ;  
         } ,  
         o p e r a t o r s :   {  
             ' = ' :     " [ @ # { 1 } = ' # { 3 } ' ] " ,  
             ' ! = ' :   " [ @ # { 1 } ! = ' # { 3 } ' ] " ,  
             ' ^ = ' :   " [ s t a r t s - w i t h ( @ # { 1 } ,   ' # { 3 } ' ) ] " ,  
             ' $ = ' :   " [ s u b s t r i n g ( @ # { 1 } ,   ( s t r i n g - l e n g t h ( @ # { 1 } )   -   s t r i n g - l e n g t h ( ' # { 3 } ' )   +   1 ) ) = ' # { 3 } ' ] " ,  
             ' * = ' :   " [ c o n t a i n s ( @ # { 1 } ,   ' # { 3 } ' ) ] " ,  
             ' ~ = ' :   " [ c o n t a i n s ( c o n c a t ( '   ' ,   @ # { 1 } ,   '   ' ) ,   '   # { 3 }   ' ) ] " ,  
             ' | = ' :   " [ c o n t a i n s ( c o n c a t ( ' - ' ,   @ # { 1 } ,   ' - ' ) ,   ' - # { 3 } - ' ) ] "  
         } ,  
         p s e u d o s :   {  
             ' f i r s t - c h i l d ' :   ' [ n o t ( p r e c e d i n g - s i b l i n g : : * ) ] ' ,  
             ' l a s t - c h i l d ' :     ' [ n o t ( f o l l o w i n g - s i b l i n g : : * ) ] ' ,  
             ' o n l y - c h i l d ' :     ' [ n o t ( p r e c e d i n g - s i b l i n g : : *   o r   f o l l o w i n g - s i b l i n g : : * ) ] ' ,  
             ' e m p t y ' :               " [ c o u n t ( * )   =   0   a n d   ( c o u n t ( t e x t ( ) )   =   0   o r   t r a n s l a t e ( t e x t ( ) ,   '   \ t \ r \ n ' ,   ' ' )   =   ' ' ) ] " ,  
             ' c h e c k e d ' :           " [ @ c h e c k e d ] " ,  
             ' d i s a b l e d ' :         " [ @ d i s a b l e d ] " ,  
             ' e n a b l e d ' :           " [ n o t ( @ d i s a b l e d ) ] " ,  
             ' n o t ' :   f u n c t i o n ( m )   {  
                 v a r   e   =   m [ 6 ] ,   p   =   S e l e c t o r . p a t t e r n s ,  
                         x   =   S e l e c t o r . x p a t h ,   l e ,   m ,   v ;  
  
                 v a r   e x c l u s i o n   =   [ ] ;  
                 w h i l e   ( e   & &   l e   ! =   e   & &   ( / \ S / ) . t e s t ( e ) )   {  
                     l e   =   e ;  
                     f o r   ( v a r   i   i n   p )   {  
                         i f   ( m   =   e . m a t c h ( p [ i ] ) )   {  
                             v   =   t y p e o f   x [ i ]   = =   ' f u n c t i o n '   ?   x [ i ] ( m )   :   n e w   T e m p l a t e ( x [ i ] ) . e v a l u a t e ( m ) ;  
                             e x c l u s i o n . p u s h ( " ( "   +   v . s u b s t r i n g ( 1 ,   v . l e n g t h   -   1 )   +   " ) " ) ;  
                             e   =   e . r e p l a c e ( m [ 0 ] ,   ' ' ) ;  
                             b r e a k ;  
                         }  
                     }  
                 }  
                 r e t u r n   " [ n o t ( "   +   e x c l u s i o n . j o i n ( "   a n d   " )   +   " ) ] " ;  
             } ,  
             ' n t h - c h i l d ' :             f u n c t i o n ( m )   {  
                 r e t u r n   S e l e c t o r . x p a t h . p s e u d o s . n t h ( " ( c o u n t ( . / p r e c e d i n g - s i b l i n g : : * )   +   1 )   " ,   m ) ;  
             } ,  
             ' n t h - l a s t - c h i l d ' :   f u n c t i o n ( m )   {  
                 r e t u r n   S e l e c t o r . x p a t h . p s e u d o s . n t h ( " ( c o u n t ( . / f o l l o w i n g - s i b l i n g : : * )   +   1 )   " ,   m ) ;  
             } ,  
             ' n t h - o f - t y p e ' :         f u n c t i o n ( m )   {  
                 r e t u r n   S e l e c t o r . x p a t h . p s e u d o s . n t h ( " p o s i t i o n ( )   " ,   m ) ;  
             } ,  
             ' n t h - l a s t - o f - t y p e ' :   f u n c t i o n ( m )   {  
                 r e t u r n   S e l e c t o r . x p a t h . p s e u d o s . n t h ( " ( l a s t ( )   +   1   -   p o s i t i o n ( ) )   " ,   m ) ;  
             } ,  
             ' f i r s t - o f - t y p e ' :     f u n c t i o n ( m )   {  
                 m [ 6 ]   =   " 1 " ;   r e t u r n   S e l e c t o r . x p a t h . p s e u d o s [ ' n t h - o f - t y p e ' ] ( m ) ;  
             } ,  
             ' l a s t - o f - t y p e ' :       f u n c t i o n ( m )   {  
                 m [ 6 ]   =   " 1 " ;   r e t u r n   S e l e c t o r . x p a t h . p s e u d o s [ ' n t h - l a s t - o f - t y p e ' ] ( m ) ;  
             } ,  
             ' o n l y - o f - t y p e ' :       f u n c t i o n ( m )   {  
                 v a r   p   =   S e l e c t o r . x p a t h . p s e u d o s ;   r e t u r n   p [ ' f i r s t - o f - t y p e ' ] ( m )   +   p [ ' l a s t - o f - t y p e ' ] ( m ) ;  
             } ,  
             n t h :   f u n c t i o n ( f r a g m e n t ,   m )   {  
                 v a r   m m ,   f o r m u l a   =   m [ 6 ] ,   p r e d i c a t e ;  
                 i f   ( f o r m u l a   = =   ' e v e n ' )   f o r m u l a   =   ' 2 n + 0 ' ;  
                 i f   ( f o r m u l a   = =   ' o d d ' )     f o r m u l a   =   ' 2 n + 1 ' ;  
                 i f   ( m m   =   f o r m u l a . m a t c h ( / ^ ( \ d + ) $ / ) )   / /   d i g i t   o n l y  
                     r e t u r n   ' [ '   +   f r a g m e n t   +   " =   "   +   m m [ 1 ]   +   ' ] ' ;  
                 i f   ( m m   =   f o r m u l a . m a t c h ( / ^ ( - ? \ d * ) ? n ( ( [ + - ] ) ( \ d + ) ) ? / ) )   {   / /   a n + b  
                     i f   ( m m [ 1 ]   = =   " - " )   m m [ 1 ]   =   - 1 ;  
                     v a r   a   =   m m [ 1 ]   ?   N u m b e r ( m m [ 1 ] )   :   1 ;  
                     v a r   b   =   m m [ 2 ]   ?   N u m b e r ( m m [ 2 ] )   :   0 ;  
                     p r e d i c a t e   =   " [ ( ( # { f r a g m e n t }   -   # { b } )   m o d   # { a }   =   0 )   a n d   "   +  
                     " ( ( # { f r a g m e n t }   -   # { b } )   d i v   # { a }   > =   0 ) ] " ;  
                     r e t u r n   n e w   T e m p l a t e ( p r e d i c a t e ) . e v a l u a t e ( {  
                         f r a g m e n t :   f r a g m e n t ,   a :   a ,   b :   b   } ) ;  
                 }  
             }  
         }  
     } ,  
  
     c r i t e r i a :   {  
         t a g N a m e :             ' n   =   h . t a g N a m e ( n ,   r ,   " # { 1 } " ,   c ) ;       c   =   f a l s e ; ' ,  
         c l a s s N a m e :         ' n   =   h . c l a s s N a m e ( n ,   r ,   " # { 1 } " ,   c ) ;   c   =   f a l s e ; ' ,  
         i d :                       ' n   =   h . i d ( n ,   r ,   " # { 1 } " ,   c ) ;                 c   =   f a l s e ; ' ,  
         a t t r P r e s e n c e :   ' n   =   h . a t t r P r e s e n c e ( n ,   r ,   " # { 1 } " ) ;   c   =   f a l s e ; ' ,  
         a t t r :   f u n c t i o n ( m )   {  
             m [ 3 ]   =   ( m [ 5 ]   | |   m [ 6 ] ) ;  
             r e t u r n   n e w   T e m p l a t e ( ' n   =   h . a t t r ( n ,   r ,   " # { 1 } " ,   " # { 3 } " ,   " # { 2 } " ) ;   c   =   f a l s e ; ' ) . e v a l u a t e ( m ) ;  
         } ,  
         p s e u d o :               f u n c t i o n ( m )   {  
             i f   ( m [ 6 ] )   m [ 6 ]   =   m [ 6 ] . r e p l a c e ( / " / g ,   ' \ \ " ' ) ;  
             r e t u r n   n e w   T e m p l a t e ( ' n   =   h . p s e u d o ( n ,   " # { 1 } " ,   " # { 6 } " ,   r ,   c ) ;   c   =   f a l s e ; ' ) . e v a l u a t e ( m ) ;  
         } ,  
         d e s c e n d a n t :       ' c   =   " d e s c e n d a n t " ; ' ,  
         c h i l d :                 ' c   =   " c h i l d " ; ' ,  
         a d j a c e n t :           ' c   =   " a d j a c e n t " ; ' ,  
         l a t e r S i b l i n g :   ' c   =   " l a t e r S i b l i n g " ; '  
     } ,  
  
     p a t t e r n s :   {  
         / /   c o m b i n a t o r s   m u s t   b e   l i s t e d   f i r s t  
         / /   ( a n d   d e s c e n d a n t   n e e d s   t o   b e   l a s t   c o m b i n a t o r )  
         l a t e r S i b l i n g :   / ^ \ s * ~ \ s * / ,  
         c h i l d :                 / ^ \ s * > \ s * / ,  
         a d j a c e n t :           / ^ \ s * \ + \ s * / ,  
         d e s c e n d a n t :       / ^ \ s / ,  
  
         / /   s e l e c t o r s   f o l l o w  
         t a g N a m e :             / ^ \ s * ( \ * | [ \ w \ - ] + ) ( \ b | $ ) ? / ,  
         i d :                       / ^ # ( [ \ w \ - \ * ] + ) ( \ b | $ ) / ,  
         c l a s s N a m e :         / ^ \ . ( [ \ w \ - \ * ] + ) ( \ b | $ ) / ,  
         p s e u d o :               / ^ : ( ( f i r s t | l a s t | n t h | n t h - l a s t | o n l y ) ( - c h i l d | - o f - t y p e ) | e m p t y | c h e c k e d | ( e n | d i s ) a b l e d | n o t ) ( \ ( ( . * ? ) \ ) ) ? ( \ b | $ | \ s | ( ? = : ) ) / ,  
         a t t r P r e s e n c e :   / ^ \ [ ( [ \ w ] + ) \ ] / ,  
         a t t r :                   / \ [ ( ( ? : [ \ w - ] * : ) ? [ \ w - ] + ) \ s * ( ? : ( [ ! ^ $ * ~ | ] ? = ) \ s * ( ( [ ' " ] ) ( [ ^ \ ] ] * ? ) \ 4 | ( [ ^ ' " ] [ ^ \ ] ] * ? ) ) ) ? \ ] /  
     } ,  
  
     h a n d l e r s :   {  
         / /   U T I L I T Y   F U N C T I O N S  
         / /   j o i n s   t w o   c o l l e c t i o n s  
         c o n c a t :   f u n c t i o n ( a ,   b )   {  
             f o r   ( v a r   i   =   0 ,   n o d e ;   n o d e   =   b [ i ] ;   i + + )  
                 a . p u s h ( n o d e ) ;  
             r e t u r n   a ;  
         } ,  
  
         / /   m a r k s   a n   a r r a y   o f   n o d e s   f o r   c o u n t i n g  
         m a r k :   f u n c t i o n ( n o d e s )   {  
             f o r   ( v a r   i   =   0 ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )  
                 n o d e . _ c o u n t e d   =   t r u e ;  
             r e t u r n   n o d e s ;  
         } ,  
  
         u n m a r k :   f u n c t i o n ( n o d e s )   {  
             f o r   ( v a r   i   =   0 ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )  
                 n o d e . _ c o u n t e d   =   u n d e f i n e d ;  
             r e t u r n   n o d e s ;  
         } ,  
  
         / /   m a r k   e a c h   c h i l d   n o d e   w i t h   i t s   p o s i t i o n   ( f o r   n t h   c a l l s )  
         / /   " o f T y p e "   f l a g   i n d i c a t e s   w h e t h e r   w e ' r e   i n d e x i n g   f o r   n t h - o f - t y p e  
         / /   r a t h e r   t h a n   n t h - c h i l d  
         i n d e x :   f u n c t i o n ( p a r e n t N o d e ,   r e v e r s e ,   o f T y p e )   {  
             p a r e n t N o d e . _ c o u n t e d   =   t r u e ;  
             i f   ( r e v e r s e )   {  
                 f o r   ( v a r   n o d e s   =   p a r e n t N o d e . c h i l d N o d e s ,   i   =   n o d e s . l e n g t h   -   1 ,   j   =   1 ;   i   > =   0 ;   i - - )   {  
                     n o d e   =   n o d e s [ i ] ;  
                     i f   ( n o d e . n o d e T y p e   = =   1   & &   ( ! o f T y p e   | |   n o d e . _ c o u n t e d ) )   n o d e . n o d e I n d e x   =   j + + ;  
                 }  
             }   e l s e   {  
                 f o r   ( v a r   i   =   0 ,   j   =   1 ,   n o d e s   =   p a r e n t N o d e . c h i l d N o d e s ;   n o d e   =   n o d e s [ i ] ;   i + + )  
                     i f   ( n o d e . n o d e T y p e   = =   1   & &   ( ! o f T y p e   | |   n o d e . _ c o u n t e d ) )   n o d e . n o d e I n d e x   =   j + + ;  
             }  
         } ,  
  
         / /   f i l t e r s   o u t   d u p l i c a t e s   a n d   e x t e n d s   a l l   n o d e s  
         u n i q u e :   f u n c t i o n ( n o d e s )   {  
             i f   ( n o d e s . l e n g t h   = =   0 )   r e t u r n   n o d e s ;  
             v a r   r e s u l t s   =   [ ] ,   n ;  
             f o r   ( v a r   i   =   0 ,   l   =   n o d e s . l e n g t h ;   i   <   l ;   i + + )  
                 i f   ( ! ( n   =   n o d e s [ i ] ) . _ c o u n t e d )   {  
                     n . _ c o u n t e d   =   t r u e ;  
                     r e s u l t s . p u s h ( E l e m e n t . e x t e n d ( n ) ) ;  
                 }  
             r e t u r n   S e l e c t o r . h a n d l e r s . u n m a r k ( r e s u l t s ) ;  
         } ,  
  
         / /   C O M B I N A T O R   F U N C T I O N S  
         d e s c e n d a n t :   f u n c t i o n ( n o d e s )   {  
             v a r   h   =   S e l e c t o r . h a n d l e r s ;  
             f o r   ( v a r   i   =   0 ,   r e s u l t s   =   [ ] ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )  
                 h . c o n c a t ( r e s u l t s ,   n o d e . g e t E l e m e n t s B y T a g N a m e ( ' * ' ) ) ;  
             r e t u r n   r e s u l t s ;  
         } ,  
  
         c h i l d :   f u n c t i o n ( n o d e s )   {  
             v a r   h   =   S e l e c t o r . h a n d l e r s ;  
             f o r   ( v a r   i   =   0 ,   r e s u l t s   =   [ ] ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )   {  
                 f o r   ( v a r   j   =   0 ,   c h i l d r e n   =   [ ] ,   c h i l d ;   c h i l d   =   n o d e . c h i l d N o d e s [ j ] ;   j + + )  
                     i f   ( c h i l d . n o d e T y p e   = =   1   & &   c h i l d . t a g N a m e   ! =   ' ! ' )   r e s u l t s . p u s h ( c h i l d ) ;  
             }  
             r e t u r n   r e s u l t s ;  
         } ,  
  
         a d j a c e n t :   f u n c t i o n ( n o d e s )   {  
             f o r   ( v a r   i   =   0 ,   r e s u l t s   =   [ ] ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )   {  
                 v a r   n e x t   =   t h i s . n e x t E l e m e n t S i b l i n g ( n o d e ) ;  
                 i f   ( n e x t )   r e s u l t s . p u s h ( n e x t ) ;  
             }  
             r e t u r n   r e s u l t s ;  
         } ,  
  
         l a t e r S i b l i n g :   f u n c t i o n ( n o d e s )   {  
             v a r   h   =   S e l e c t o r . h a n d l e r s ;  
             f o r   ( v a r   i   =   0 ,   r e s u l t s   =   [ ] ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )  
                 h . c o n c a t ( r e s u l t s ,   E l e m e n t . n e x t S i b l i n g s ( n o d e ) ) ;  
             r e t u r n   r e s u l t s ;  
         } ,  
  
         n e x t E l e m e n t S i b l i n g :   f u n c t i o n ( n o d e )   {  
             w h i l e   ( n o d e   =   n o d e . n e x t S i b l i n g )  
 	             i f   ( n o d e . n o d e T y p e   = =   1 )   r e t u r n   n o d e ;  
             r e t u r n   n u l l ;  
         } ,  
  
         p r e v i o u s E l e m e n t S i b l i n g :   f u n c t i o n ( n o d e )   {  
             w h i l e   ( n o d e   =   n o d e . p r e v i o u s S i b l i n g )  
                 i f   ( n o d e . n o d e T y p e   = =   1 )   r e t u r n   n o d e ;  
             r e t u r n   n u l l ;  
         } ,  
  
         / /   T O K E N   F U N C T I O N S  
         t a g N a m e :   f u n c t i o n ( n o d e s ,   r o o t ,   t a g N a m e ,   c o m b i n a t o r )   {  
             t a g N a m e   =   t a g N a m e . t o U p p e r C a s e ( ) ;  
             v a r   r e s u l t s   =   [ ] ,   h   =   S e l e c t o r . h a n d l e r s ;  
             i f   ( n o d e s )   {  
                 i f   ( c o m b i n a t o r )   {  
                     / /   f a s t l a n e   f o r   o r d i n a r y   d e s c e n d a n t   c o m b i n a t o r s  
                     i f   ( c o m b i n a t o r   = =   " d e s c e n d a n t " )   {  
                         f o r   ( v a r   i   =   0 ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )  
                             h . c o n c a t ( r e s u l t s ,   n o d e . g e t E l e m e n t s B y T a g N a m e ( t a g N a m e ) ) ;  
                         r e t u r n   r e s u l t s ;  
                     }   e l s e   n o d e s   =   t h i s [ c o m b i n a t o r ] ( n o d e s ) ;  
                     i f   ( t a g N a m e   = =   " * " )   r e t u r n   n o d e s ;  
                 }  
                 f o r   ( v a r   i   =   0 ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )  
                     i f   ( n o d e . t a g N a m e . t o U p p e r C a s e ( )   = =   t a g N a m e )   r e s u l t s . p u s h ( n o d e ) ;  
                 r e t u r n   r e s u l t s ;  
             }   e l s e   r e t u r n   r o o t . g e t E l e m e n t s B y T a g N a m e ( t a g N a m e ) ;  
         } ,  
  
         i d :   f u n c t i o n ( n o d e s ,   r o o t ,   i d ,   c o m b i n a t o r )   {  
             v a r   t a r g e t N o d e   =   $ ( i d ) ,   h   =   S e l e c t o r . h a n d l e r s ;  
             i f   ( ! n o d e s   & &   r o o t   = =   d o c u m e n t )   r e t u r n   t a r g e t N o d e   ?   [ t a r g e t N o d e ]   :   [ ] ;  
             i f   ( n o d e s )   {  
                 i f   ( c o m b i n a t o r )   {  
                     i f   ( c o m b i n a t o r   = =   ' c h i l d ' )   {  
                         f o r   ( v a r   i   =   0 ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )  
                             i f   ( t a r g e t N o d e . p a r e n t N o d e   = =   n o d e )   r e t u r n   [ t a r g e t N o d e ] ;  
                     }   e l s e   i f   ( c o m b i n a t o r   = =   ' d e s c e n d a n t ' )   {  
                         f o r   ( v a r   i   =   0 ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )  
                             i f   ( E l e m e n t . d e s c e n d a n t O f ( t a r g e t N o d e ,   n o d e ) )   r e t u r n   [ t a r g e t N o d e ] ;  
                     }   e l s e   i f   ( c o m b i n a t o r   = =   ' a d j a c e n t ' )   {  
                         f o r   ( v a r   i   =   0 ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )  
                             i f   ( S e l e c t o r . h a n d l e r s . p r e v i o u s E l e m e n t S i b l i n g ( t a r g e t N o d e )   = =   n o d e )  
                                 r e t u r n   [ t a r g e t N o d e ] ;  
                     }   e l s e   n o d e s   =   h [ c o m b i n a t o r ] ( n o d e s ) ;  
                 }  
                 f o r   ( v a r   i   =   0 ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )  
                     i f   ( n o d e   = =   t a r g e t N o d e )   r e t u r n   [ t a r g e t N o d e ] ;  
                 r e t u r n   [ ] ;  
             }  
             r e t u r n   ( t a r g e t N o d e   & &   E l e m e n t . d e s c e n d a n t O f ( t a r g e t N o d e ,   r o o t ) )   ?   [ t a r g e t N o d e ]   :   [ ] ;  
         } ,  
  
         c l a s s N a m e :   f u n c t i o n ( n o d e s ,   r o o t ,   c l a s s N a m e ,   c o m b i n a t o r )   {  
             i f   ( n o d e s   & &   c o m b i n a t o r )   n o d e s   =   t h i s [ c o m b i n a t o r ] ( n o d e s ) ;  
             r e t u r n   S e l e c t o r . h a n d l e r s . b y C l a s s N a m e ( n o d e s ,   r o o t ,   c l a s s N a m e ) ;  
         } ,  
  
         b y C l a s s N a m e :   f u n c t i o n ( n o d e s ,   r o o t ,   c l a s s N a m e )   {  
             i f   ( ! n o d e s )   n o d e s   =   S e l e c t o r . h a n d l e r s . d e s c e n d a n t ( [ r o o t ] ) ;  
             v a r   n e e d l e   =   '   '   +   c l a s s N a m e   +   '   ' ;  
             f o r   ( v a r   i   =   0 ,   r e s u l t s   =   [ ] ,   n o d e ,   n o d e C l a s s N a m e ;   n o d e   =   n o d e s [ i ] ;   i + + )   {  
                 n o d e C l a s s N a m e   =   n o d e . c l a s s N a m e ;  
                 i f   ( n o d e C l a s s N a m e . l e n g t h   = =   0 )   c o n t i n u e ;  
                 i f   ( n o d e C l a s s N a m e   = =   c l a s s N a m e   | |   ( '   '   +   n o d e C l a s s N a m e   +   '   ' ) . i n c l u d e ( n e e d l e ) )  
                     r e s u l t s . p u s h ( n o d e ) ;  
             }  
             r e t u r n   r e s u l t s ;  
         } ,  
  
         a t t r P r e s e n c e :   f u n c t i o n ( n o d e s ,   r o o t ,   a t t r )   {  
             v a r   r e s u l t s   =   [ ] ;  
             f o r   ( v a r   i   =   0 ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )  
                 i f   ( E l e m e n t . h a s A t t r i b u t e ( n o d e ,   a t t r ) )   r e s u l t s . p u s h ( n o d e ) ;  
             r e t u r n   r e s u l t s ;  
         } ,  
  
         a t t r :   f u n c t i o n ( n o d e s ,   r o o t ,   a t t r ,   v a l u e ,   o p e r a t o r )   {  
             i f   ( ! n o d e s )   n o d e s   =   r o o t . g e t E l e m e n t s B y T a g N a m e ( " * " ) ;  
             v a r   h a n d l e r   =   S e l e c t o r . o p e r a t o r s [ o p e r a t o r ] ,   r e s u l t s   =   [ ] ;  
             f o r   ( v a r   i   =   0 ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )   {  
                 v a r   n o d e V a l u e   =   E l e m e n t . r e a d A t t r i b u t e ( n o d e ,   a t t r ) ;  
                 i f   ( n o d e V a l u e   = = =   n u l l )   c o n t i n u e ;  
                 i f   ( h a n d l e r ( n o d e V a l u e ,   v a l u e ) )   r e s u l t s . p u s h ( n o d e ) ;  
             }  
             r e t u r n   r e s u l t s ;  
         } ,  
  
         p s e u d o :   f u n c t i o n ( n o d e s ,   n a m e ,   v a l u e ,   r o o t ,   c o m b i n a t o r )   {  
             i f   ( n o d e s   & &   c o m b i n a t o r )   n o d e s   =   t h i s [ c o m b i n a t o r ] ( n o d e s ) ;  
             i f   ( ! n o d e s )   n o d e s   =   r o o t . g e t E l e m e n t s B y T a g N a m e ( " * " ) ;  
             r e t u r n   S e l e c t o r . p s e u d o s [ n a m e ] ( n o d e s ,   v a l u e ,   r o o t ) ;  
         }  
     } ,  
  
     p s e u d o s :   {  
         ' f i r s t - c h i l d ' :   f u n c t i o n ( n o d e s ,   v a l u e ,   r o o t )   {  
             f o r   ( v a r   i   =   0 ,   r e s u l t s   =   [ ] ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )   {  
                 i f   ( S e l e c t o r . h a n d l e r s . p r e v i o u s E l e m e n t S i b l i n g ( n o d e ) )   c o n t i n u e ;  
                     r e s u l t s . p u s h ( n o d e ) ;  
             }  
             r e t u r n   r e s u l t s ;  
         } ,  
         ' l a s t - c h i l d ' :   f u n c t i o n ( n o d e s ,   v a l u e ,   r o o t )   {  
             f o r   ( v a r   i   =   0 ,   r e s u l t s   =   [ ] ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )   {  
                 i f   ( S e l e c t o r . h a n d l e r s . n e x t E l e m e n t S i b l i n g ( n o d e ) )   c o n t i n u e ;  
                     r e s u l t s . p u s h ( n o d e ) ;  
             }  
             r e t u r n   r e s u l t s ;  
         } ,  
         ' o n l y - c h i l d ' :   f u n c t i o n ( n o d e s ,   v a l u e ,   r o o t )   {  
             v a r   h   =   S e l e c t o r . h a n d l e r s ;  
             f o r   ( v a r   i   =   0 ,   r e s u l t s   =   [ ] ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )  
                 i f   ( ! h . p r e v i o u s E l e m e n t S i b l i n g ( n o d e )   & &   ! h . n e x t E l e m e n t S i b l i n g ( n o d e ) )  
                     r e s u l t s . p u s h ( n o d e ) ;  
             r e t u r n   r e s u l t s ;  
         } ,  
         ' n t h - c h i l d ' :                 f u n c t i o n ( n o d e s ,   f o r m u l a ,   r o o t )   {  
             r e t u r n   S e l e c t o r . p s e u d o s . n t h ( n o d e s ,   f o r m u l a ,   r o o t ) ;  
         } ,  
         ' n t h - l a s t - c h i l d ' :       f u n c t i o n ( n o d e s ,   f o r m u l a ,   r o o t )   {  
             r e t u r n   S e l e c t o r . p s e u d o s . n t h ( n o d e s ,   f o r m u l a ,   r o o t ,   t r u e ) ;  
         } ,  
         ' n t h - o f - t y p e ' :             f u n c t i o n ( n o d e s ,   f o r m u l a ,   r o o t )   {  
             r e t u r n   S e l e c t o r . p s e u d o s . n t h ( n o d e s ,   f o r m u l a ,   r o o t ,   f a l s e ,   t r u e ) ;  
         } ,  
         ' n t h - l a s t - o f - t y p e ' :   f u n c t i o n ( n o d e s ,   f o r m u l a ,   r o o t )   {  
             r e t u r n   S e l e c t o r . p s e u d o s . n t h ( n o d e s ,   f o r m u l a ,   r o o t ,   t r u e ,   t r u e ) ;  
         } ,  
         ' f i r s t - o f - t y p e ' :         f u n c t i o n ( n o d e s ,   f o r m u l a ,   r o o t )   {  
             r e t u r n   S e l e c t o r . p s e u d o s . n t h ( n o d e s ,   " 1 " ,   r o o t ,   f a l s e ,   t r u e ) ;  
         } ,  
         ' l a s t - o f - t y p e ' :           f u n c t i o n ( n o d e s ,   f o r m u l a ,   r o o t )   {  
             r e t u r n   S e l e c t o r . p s e u d o s . n t h ( n o d e s ,   " 1 " ,   r o o t ,   t r u e ,   t r u e ) ;  
         } ,  
         ' o n l y - o f - t y p e ' :           f u n c t i o n ( n o d e s ,   f o r m u l a ,   r o o t )   {  
             v a r   p   =   S e l e c t o r . p s e u d o s ;  
             r e t u r n   p [ ' l a s t - o f - t y p e ' ] ( p [ ' f i r s t - o f - t y p e ' ] ( n o d e s ,   f o r m u l a ,   r o o t ) ,   f o r m u l a ,   r o o t ) ;  
         } ,  
  
         / /   h a n d l e s   t h e   a n + b   l o g i c  
         g e t I n d i c e s :   f u n c t i o n ( a ,   b ,   t o t a l )   {  
             i f   ( a   = =   0 )   r e t u r n   b   >   0   ?   [ b ]   :   [ ] ;  
             r e t u r n   $ R ( 1 ,   t o t a l ) . i n j e c t ( [ ] ,   f u n c t i o n ( m e m o ,   i )   {  
                 i f   ( 0   = =   ( i   -   b )   %   a   & &   ( i   -   b )   /   a   > =   0 )   m e m o . p u s h ( i ) ;  
                 r e t u r n   m e m o ;  
             } ) ;  
         } ,  
  
         / /   h a n d l e s   n t h ( - l a s t ) - c h i l d ,   n t h ( - l a s t ) - o f - t y p e ,   a n d   ( f i r s t | l a s t ) - o f - t y p e  
         n t h :   f u n c t i o n ( n o d e s ,   f o r m u l a ,   r o o t ,   r e v e r s e ,   o f T y p e )   {  
             i f   ( n o d e s . l e n g t h   = =   0 )   r e t u r n   [ ] ;  
             i f   ( f o r m u l a   = =   ' e v e n ' )   f o r m u l a   =   ' 2 n + 0 ' ;  
             i f   ( f o r m u l a   = =   ' o d d ' )     f o r m u l a   =   ' 2 n + 1 ' ;  
             v a r   h   =   S e l e c t o r . h a n d l e r s ,   r e s u l t s   =   [ ] ,   i n d e x e d   =   [ ] ,   m ;  
             h . m a r k ( n o d e s ) ;  
             f o r   ( v a r   i   =   0 ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )   {  
                 i f   ( ! n o d e . p a r e n t N o d e . _ c o u n t e d )   {  
                     h . i n d e x ( n o d e . p a r e n t N o d e ,   r e v e r s e ,   o f T y p e ) ;  
                     i n d e x e d . p u s h ( n o d e . p a r e n t N o d e ) ;  
                 }  
             }  
             i f   ( f o r m u l a . m a t c h ( / ^ \ d + $ / ) )   {   / /   j u s t   a   n u m b e r  
                 f o r m u l a   =   N u m b e r ( f o r m u l a ) ;  
                 f o r   ( v a r   i   =   0 ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )  
                     i f   ( n o d e . n o d e I n d e x   = =   f o r m u l a )   r e s u l t s . p u s h ( n o d e ) ;  
             }   e l s e   i f   ( m   =   f o r m u l a . m a t c h ( / ^ ( - ? \ d * ) ? n ( ( [ + - ] ) ( \ d + ) ) ? / ) )   {   / /   a n + b  
                 i f   ( m [ 1 ]   = =   " - " )   m [ 1 ]   =   - 1 ;  
                 v a r   a   =   m [ 1 ]   ?   N u m b e r ( m [ 1 ] )   :   1 ;  
                 v a r   b   =   m [ 2 ]   ?   N u m b e r ( m [ 2 ] )   :   0 ;  
                 v a r   i n d i c e s   =   S e l e c t o r . p s e u d o s . g e t I n d i c e s ( a ,   b ,   n o d e s . l e n g t h ) ;  
                 f o r   ( v a r   i   =   0 ,   n o d e ,   l   =   i n d i c e s . l e n g t h ;   n o d e   =   n o d e s [ i ] ;   i + + )   {  
                     f o r   ( v a r   j   =   0 ;   j   <   l ;   j + + )  
                         i f   ( n o d e . n o d e I n d e x   = =   i n d i c e s [ j ] )   r e s u l t s . p u s h ( n o d e ) ;  
                 }  
             }  
             h . u n m a r k ( n o d e s ) ;  
             h . u n m a r k ( i n d e x e d ) ;  
             r e t u r n   r e s u l t s ;  
         } ,  
  
         ' e m p t y ' :   f u n c t i o n ( n o d e s ,   v a l u e ,   r o o t )   {  
             f o r   ( v a r   i   =   0 ,   r e s u l t s   =   [ ] ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )   {  
                 / /   I E   t r e a t s   c o m m e n t s   a s   e l e m e n t   n o d e s  
                 i f   ( n o d e . t a g N a m e   = =   ' ! '   | |   ( n o d e . f i r s t C h i l d   & &   ! n o d e . i n n e r H T M L . m a t c h ( / ^ \ s * $ / ) ) )   c o n t i n u e ;  
                 r e s u l t s . p u s h ( n o d e ) ;  
             }  
             r e t u r n   r e s u l t s ;  
         } ,  
  
         ' n o t ' :   f u n c t i o n ( n o d e s ,   s e l e c t o r ,   r o o t )   {  
             v a r   h   =   S e l e c t o r . h a n d l e r s ,   s e l e c t o r T y p e ,   m ;  
             v a r   e x c l u s i o n s   =   n e w   S e l e c t o r ( s e l e c t o r ) . f i n d E l e m e n t s ( r o o t ) ;  
             h . m a r k ( e x c l u s i o n s ) ;  
             f o r   ( v a r   i   =   0 ,   r e s u l t s   =   [ ] ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )  
                 i f   ( ! n o d e . _ c o u n t e d )   r e s u l t s . p u s h ( n o d e ) ;  
             h . u n m a r k ( e x c l u s i o n s ) ;  
             r e t u r n   r e s u l t s ;  
         } ,  
  
         ' e n a b l e d ' :   f u n c t i o n ( n o d e s ,   v a l u e ,   r o o t )   {  
             f o r   ( v a r   i   =   0 ,   r e s u l t s   =   [ ] ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )  
                 i f   ( ! n o d e . d i s a b l e d )   r e s u l t s . p u s h ( n o d e ) ;  
             r e t u r n   r e s u l t s ;  
         } ,  
  
         ' d i s a b l e d ' :   f u n c t i o n ( n o d e s ,   v a l u e ,   r o o t )   {  
             f o r   ( v a r   i   =   0 ,   r e s u l t s   =   [ ] ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )  
                 i f   ( n o d e . d i s a b l e d )   r e s u l t s . p u s h ( n o d e ) ;  
             r e t u r n   r e s u l t s ;  
         } ,  
  
         ' c h e c k e d ' :   f u n c t i o n ( n o d e s ,   v a l u e ,   r o o t )   {  
             f o r   ( v a r   i   =   0 ,   r e s u l t s   =   [ ] ,   n o d e ;   n o d e   =   n o d e s [ i ] ;   i + + )  
                 i f   ( n o d e . c h e c k e d )   r e s u l t s . p u s h ( n o d e ) ;  
             r e t u r n   r e s u l t s ;  
         }  
     } ,  
  
     o p e r a t o r s :   {  
         ' = ' :     f u n c t i o n ( n v ,   v )   {   r e t u r n   n v   = =   v ;   } ,  
         ' ! = ' :   f u n c t i o n ( n v ,   v )   {   r e t u r n   n v   ! =   v ;   } ,  
         ' ^ = ' :   f u n c t i o n ( n v ,   v )   {   r e t u r n   n v . s t a r t s W i t h ( v ) ;   } ,  
         ' $ = ' :   f u n c t i o n ( n v ,   v )   {   r e t u r n   n v . e n d s W i t h ( v ) ;   } ,  
         ' * = ' :   f u n c t i o n ( n v ,   v )   {   r e t u r n   n v . i n c l u d e ( v ) ;   } ,  
         ' ~ = ' :   f u n c t i o n ( n v ,   v )   {   r e t u r n   ( '   '   +   n v   +   '   ' ) . i n c l u d e ( '   '   +   v   +   '   ' ) ;   } ,  
         ' | = ' :   f u n c t i o n ( n v ,   v )   {   r e t u r n   ( ' - '   +   n v . t o U p p e r C a s e ( )   +   ' - ' ) . i n c l u d e ( ' - '   +   v . t o U p p e r C a s e ( )   +   ' - ' ) ;   }  
     } ,  
  
     m a t c h E l e m e n t s :   f u n c t i o n ( e l e m e n t s ,   e x p r e s s i o n )   {  
         v a r   m a t c h e s   =   n e w   S e l e c t o r ( e x p r e s s i o n ) . f i n d E l e m e n t s ( ) ,   h   =   S e l e c t o r . h a n d l e r s ;  
         h . m a r k ( m a t c h e s ) ;  
         f o r   ( v a r   i   =   0 ,   r e s u l t s   =   [ ] ,   e l e m e n t ;   e l e m e n t   =   e l e m e n t s [ i ] ;   i + + )  
             i f   ( e l e m e n t . _ c o u n t e d )   r e s u l t s . p u s h ( e l e m e n t ) ;  
         h . u n m a r k ( m a t c h e s ) ;  
         r e t u r n   r e s u l t s ;  
     } ,  
  
     f i n d E l e m e n t :   f u n c t i o n ( e l e m e n t s ,   e x p r e s s i o n ,   i n d e x )   {  
         i f   ( t y p e o f   e x p r e s s i o n   = =   ' n u m b e r ' )   {  
             i n d e x   =   e x p r e s s i o n ;   e x p r e s s i o n   =   f a l s e ;  
         }  
         r e t u r n   S e l e c t o r . m a t c h E l e m e n t s ( e l e m e n t s ,   e x p r e s s i o n   | |   ' * ' ) [ i n d e x   | |   0 ] ;  
     } ,  
  
     f i n d C h i l d E l e m e n t s :   f u n c t i o n ( e l e m e n t ,   e x p r e s s i o n s )   {  
         v a r   e x p r s   =   e x p r e s s i o n s . j o i n ( ' , ' ) ,   e x p r e s s i o n s   =   [ ] ;  
         e x p r s . s c a n ( / ( ( [ \ w # : . ~ > + ( ) \ s - ] + | \ * | \ [ . * ? \ ] ) + ) \ s * ( , | $ ) / ,   f u n c t i o n ( m )   {  
             e x p r e s s i o n s . p u s h ( m [ 1 ] . s t r i p ( ) ) ;  
         } ) ;  
         v a r   r e s u l t s   =   [ ] ,   h   =   S e l e c t o r . h a n d l e r s ;  
         f o r   ( v a r   i   =   0 ,   l   =   e x p r e s s i o n s . l e n g t h ,   s e l e c t o r ;   i   <   l ;   i + + )   {  
             s e l e c t o r   =   n e w   S e l e c t o r ( e x p r e s s i o n s [ i ] . s t r i p ( ) ) ;  
             h . c o n c a t ( r e s u l t s ,   s e l e c t o r . f i n d E l e m e n t s ( e l e m e n t ) ) ;  
         }  
         r e t u r n   ( l   >   1 )   ?   h . u n i q u e ( r e s u l t s )   :   r e s u l t s ;  
     }  
 } ) ;  
  
 f u n c t i o n   $ $ ( )   {  
     r e t u r n   S e l e c t o r . f i n d C h i l d E l e m e n t s ( d o c u m e n t ,   $ A ( a r g u m e n t s ) ) ;  
 }  
 v a r   F o r m   =   {  
     r e s e t :   f u n c t i o n ( f o r m )   {  
         $ ( f o r m ) . r e s e t ( ) ;  
         r e t u r n   f o r m ;  
     } ,  
  
     s e r i a l i z e E l e m e n t s :   f u n c t i o n ( e l e m e n t s ,   g e t H a s h )   {  
         v a r   d a t a   =   e l e m e n t s . i n j e c t ( { } ,   f u n c t i o n ( r e s u l t ,   e l e m e n t )   {  
             i f   ( ! e l e m e n t . d i s a b l e d   & &   e l e m e n t . n a m e )   {  
                 v a r   k e y   =   e l e m e n t . n a m e ,   v a l u e   =   $ ( e l e m e n t ) . g e t V a l u e ( ) ;  
                 i f   ( v a l u e   ! =   n u l l )   {  
                   	 i f   ( k e y   i n   r e s u l t )   {  
                         i f   ( r e s u l t [ k e y ] . c o n s t r u c t o r   ! =   A r r a y )   r e s u l t [ k e y ]   =   [ r e s u l t [ k e y ] ] ;  
                         r e s u l t [ k e y ] . p u s h ( v a l u e ) ;  
                     }  
                     e l s e   r e s u l t [ k e y ]   =   v a l u e ;  
                 }  
             }  
             r e t u r n   r e s u l t ;  
         } ) ;  
  
         r e t u r n   g e t H a s h   ?   d a t a   :   H a s h . t o Q u e r y S t r i n g ( d a t a ) ;  
     }  
 } ;  
  
 F o r m . M e t h o d s   =   {  
     s e r i a l i z e :   f u n c t i o n ( f o r m ,   g e t H a s h )   {  
         r e t u r n   F o r m . s e r i a l i z e E l e m e n t s ( F o r m . g e t E l e m e n t s ( f o r m ) ,   g e t H a s h ) ;  
     } ,  
  
     g e t E l e m e n t s :   f u n c t i o n ( f o r m )   {  
         r e t u r n   $ A ( $ ( f o r m ) . g e t E l e m e n t s B y T a g N a m e ( ' * ' ) ) . i n j e c t ( [ ] ,  
             f u n c t i o n ( e l e m e n t s ,   c h i l d )   {  
                 i f   ( F o r m . E l e m e n t . S e r i a l i z e r s [ c h i l d . t a g N a m e . t o L o w e r C a s e ( ) ] )  
                     e l e m e n t s . p u s h ( E l e m e n t . e x t e n d ( c h i l d ) ) ;  
                 r e t u r n   e l e m e n t s ;  
             }  
         ) ;  
     } ,  
  
     g e t I n p u t s :   f u n c t i o n ( f o r m ,   t y p e N a m e ,   n a m e )   {  
         f o r m   =   $ ( f o r m ) ;  
         v a r   i n p u t s   =   f o r m . g e t E l e m e n t s B y T a g N a m e ( ' i n p u t ' ) ;  
  
         i f   ( ! t y p e N a m e   & &   ! n a m e )   r e t u r n   $ A ( i n p u t s ) . m a p ( E l e m e n t . e x t e n d ) ;  
  
         f o r   ( v a r   i   =   0 ,   m a t c h i n g I n p u t s   =   [ ] ,   l e n g t h   =   i n p u t s . l e n g t h ;   i   <   l e n g t h ;   i + + )   {  
             v a r   i n p u t   =   i n p u t s [ i ] ;  
             i f   ( ( t y p e N a m e   & &   i n p u t . t y p e   ! =   t y p e N a m e )   | |   ( n a m e   & &   i n p u t . n a m e   ! =   n a m e ) )  
                 c o n t i n u e ;  
             m a t c h i n g I n p u t s . p u s h ( E l e m e n t . e x t e n d ( i n p u t ) ) ;  
         }  
  
         r e t u r n   m a t c h i n g I n p u t s ;  
     } ,  
  
     d i s a b l e :   f u n c t i o n ( f o r m )   {  
         f o r m   =   $ ( f o r m ) ;  
         F o r m . g e t E l e m e n t s ( f o r m ) . i n v o k e ( ' d i s a b l e ' ) ;  
         r e t u r n   f o r m ;  
     } ,  
  
     e n a b l e :   f u n c t i o n ( f o r m )   {  
         f o r m   =   $ ( f o r m ) ;  
         F o r m . g e t E l e m e n t s ( f o r m ) . i n v o k e ( ' e n a b l e ' ) ;  
         r e t u r n   f o r m ;  
     } ,  
  
     f i n d F i r s t E l e m e n t :   f u n c t i o n ( f o r m )   {  
         r e t u r n   $ ( f o r m ) . g e t E l e m e n t s ( ) . f i n d ( f u n c t i o n ( e l e m e n t )   {  
             r e t u r n   e l e m e n t . t y p e   ! =   ' h i d d e n '   & &   ! e l e m e n t . d i s a b l e d   & &  
                 [ ' i n p u t ' ,   ' s e l e c t ' ,   ' t e x t a r e a ' ] . i n c l u d e ( e l e m e n t . t a g N a m e . t o L o w e r C a s e ( ) ) ;  
         } ) ;  
     } ,  
  
     f o c u s F i r s t E l e m e n t :   f u n c t i o n ( f o r m )   {  
         f o r m   =   $ ( f o r m ) ;  
         f o r m . f i n d F i r s t E l e m e n t ( ) . a c t i v a t e ( ) ;  
         r e t u r n   f o r m ;  
     } ,  
  
     r e q u e s t :   f u n c t i o n ( f o r m ,   o p t i o n s )   {  
         f o r m   =   $ ( f o r m ) ,   o p t i o n s   =   O b j e c t . c l o n e ( o p t i o n s   | |   { } ) ;  
  
         v a r   p a r a m s   =   o p t i o n s . p a r a m e t e r s ;  
         o p t i o n s . p a r a m e t e r s   =   f o r m . s e r i a l i z e ( t r u e ) ;  
  
         i f   ( p a r a m s )   {  
             i f   ( t y p e o f   p a r a m s   = =   ' s t r i n g ' )   p a r a m s   =   p a r a m s . t o Q u e r y P a r a m s ( ) ;  
             O b j e c t . e x t e n d ( o p t i o n s . p a r a m e t e r s ,   p a r a m s ) ;  
         }  
  
         i f   ( f o r m . h a s A t t r i b u t e ( ' m e t h o d ' )   & &   ! o p t i o n s . m e t h o d )  
             o p t i o n s . m e t h o d   =   f o r m . m e t h o d ;  
  
         r e t u r n   n e w   A j a x . R e q u e s t ( f o r m . r e a d A t t r i b u t e ( ' a c t i o n ' ) ,   o p t i o n s ) ;  
     }  
 }  
  
 / * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * /  
  
 F o r m . E l e m e n t   =   {  
     f o c u s :   f u n c t i o n ( e l e m e n t )   {  
         $ ( e l e m e n t ) . f o c u s ( ) ;  
         r e t u r n   e l e m e n t ;  
     } ,  
  
     s e l e c t :   f u n c t i o n ( e l e m e n t )   {  
         $ ( e l e m e n t ) . s e l e c t ( ) ;  
         r e t u r n   e l e m e n t ;  
     }  
 }  
  
 F o r m . E l e m e n t . M e t h o d s   =   {  
     s e r i a l i z e :   f u n c t i o n ( e l e m e n t )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         i f   ( ! e l e m e n t . d i s a b l e d   & &   e l e m e n t . n a m e )   {  
             v a r   v a l u e   =   e l e m e n t . g e t V a l u e ( ) ;  
             i f   ( v a l u e   ! =   u n d e f i n e d )   {  
                 v a r   p a i r   =   { } ;  
                 p a i r [ e l e m e n t . n a m e ]   =   v a l u e ;  
                 r e t u r n   H a s h . t o Q u e r y S t r i n g ( p a i r ) ;  
             }  
         }  
         r e t u r n   ' ' ;  
     } ,  
  
     g e t V a l u e :   f u n c t i o n ( e l e m e n t )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         v a r   m e t h o d   =   e l e m e n t . t a g N a m e . t o L o w e r C a s e ( ) ;  
         r e t u r n   F o r m . E l e m e n t . S e r i a l i z e r s [ m e t h o d ] ( e l e m e n t ) ;  
     } ,  
  
     c l e a r :   f u n c t i o n ( e l e m e n t )   {  
         $ ( e l e m e n t ) . v a l u e   =   ' ' ;  
         r e t u r n   e l e m e n t ;  
     } ,  
  
     p r e s e n t :   f u n c t i o n ( e l e m e n t )   {  
         r e t u r n   $ ( e l e m e n t ) . v a l u e   ! =   ' ' ;  
     } ,  
  
     a c t i v a t e :   f u n c t i o n ( e l e m e n t )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         t r y   {  
             e l e m e n t . f o c u s ( ) ;  
             i f   ( e l e m e n t . s e l e c t   & &   ( e l e m e n t . t a g N a m e . t o L o w e r C a s e ( )   ! =   ' i n p u t '   | |  
                 ! [ ' b u t t o n ' ,   ' r e s e t ' ,   ' s u b m i t ' ] . i n c l u d e ( e l e m e n t . t y p e ) ) )  
                 e l e m e n t . s e l e c t ( ) ;  
         }   c a t c h   ( e )   { }  
         r e t u r n   e l e m e n t ;  
     } ,  
  
     d i s a b l e :   f u n c t i o n ( e l e m e n t )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         e l e m e n t . b l u r ( ) ;  
         e l e m e n t . d i s a b l e d   =   t r u e ;  
         r e t u r n   e l e m e n t ;  
     } ,  
  
     e n a b l e :   f u n c t i o n ( e l e m e n t )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         e l e m e n t . d i s a b l e d   =   f a l s e ;  
         r e t u r n   e l e m e n t ;  
     }  
 }  
  
 / * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * /  
  
 v a r   F i e l d   =   F o r m . E l e m e n t ;  
 v a r   $ F   =   F o r m . E l e m e n t . M e t h o d s . g e t V a l u e ;  
  
 / * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * /  
  
 F o r m . E l e m e n t . S e r i a l i z e r s   =   {  
     i n p u t :   f u n c t i o n ( e l e m e n t )   {  
         s w i t c h   ( e l e m e n t . t y p e . t o L o w e r C a s e ( ) )   {  
             c a s e   ' c h e c k b o x ' :  
             c a s e   ' r a d i o ' :  
                 r e t u r n   F o r m . E l e m e n t . S e r i a l i z e r s . i n p u t S e l e c t o r ( e l e m e n t ) ;  
             d e f a u l t :  
                 r e t u r n   F o r m . E l e m e n t . S e r i a l i z e r s . t e x t a r e a ( e l e m e n t ) ;  
         }  
     } ,  
  
     i n p u t S e l e c t o r :   f u n c t i o n ( e l e m e n t )   {  
         r e t u r n   e l e m e n t . c h e c k e d   ?   e l e m e n t . v a l u e   :   n u l l ;  
     } ,  
  
     t e x t a r e a :   f u n c t i o n ( e l e m e n t )   {  
         r e t u r n   e l e m e n t . v a l u e ;  
     } ,  
  
     s e l e c t :   f u n c t i o n ( e l e m e n t )   {  
         r e t u r n   t h i s [ e l e m e n t . t y p e   = =   ' s e l e c t - o n e '   ?  
             ' s e l e c t O n e '   :   ' s e l e c t M a n y ' ] ( e l e m e n t ) ;  
     } ,  
  
     s e l e c t O n e :   f u n c t i o n ( e l e m e n t )   {  
         v a r   i n d e x   =   e l e m e n t . s e l e c t e d I n d e x ;  
         r e t u r n   i n d e x   > =   0   ?   t h i s . o p t i o n V a l u e ( e l e m e n t . o p t i o n s [ i n d e x ] )   :   n u l l ;  
     } ,  
  
     s e l e c t M a n y :   f u n c t i o n ( e l e m e n t )   {  
         v a r   v a l u e s ,   l e n g t h   =   e l e m e n t . l e n g t h ;  
         i f   ( ! l e n g t h )   r e t u r n   n u l l ;  
  
         f o r   ( v a r   i   =   0 ,   v a l u e s   =   [ ] ;   i   <   l e n g t h ;   i + + )   {  
             v a r   o p t   =   e l e m e n t . o p t i o n s [ i ] ;  
             i f   ( o p t . s e l e c t e d )   v a l u e s . p u s h ( t h i s . o p t i o n V a l u e ( o p t ) ) ;  
         }  
         r e t u r n   v a l u e s ;  
     } ,  
  
     o p t i o n V a l u e :   f u n c t i o n ( o p t )   {  
         / /   e x t e n d   e l e m e n t   b e c a u s e   h a s A t t r i b u t e   m a y   n o t   b e   n a t i v e  
         r e t u r n   E l e m e n t . e x t e n d ( o p t ) . h a s A t t r i b u t e ( ' v a l u e ' )   ?   o p t . v a l u e   :   o p t . t e x t ;  
     }  
 }  
  
 / * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * /  
  
 A b s t r a c t . T i m e d O b s e r v e r   =   f u n c t i o n ( )   { }  
 A b s t r a c t . T i m e d O b s e r v e r . p r o t o t y p e   =   {  
     i n i t i a l i z e :   f u n c t i o n ( e l e m e n t ,   f r e q u e n c y ,   c a l l b a c k )   {  
         t h i s . f r e q u e n c y   =   f r e q u e n c y ;  
         t h i s . e l e m e n t       =   $ ( e l e m e n t ) ;  
         t h i s . c a l l b a c k     =   c a l l b a c k ;  
  
         t h i s . l a s t V a l u e   =   t h i s . g e t V a l u e ( ) ;  
         t h i s . r e g i s t e r C a l l b a c k ( ) ;  
     } ,  
  
     r e g i s t e r C a l l b a c k :   f u n c t i o n ( )   {  
         s e t I n t e r v a l ( t h i s . o n T i m e r E v e n t . b i n d ( t h i s ) ,   t h i s . f r e q u e n c y   *   1 0 0 0 ) ;  
     } ,  
  
     o n T i m e r E v e n t :   f u n c t i o n ( )   {  
         v a r   v a l u e   =   t h i s . g e t V a l u e ( ) ;  
         v a r   c h a n g e d   =   ( ' s t r i n g '   = =   t y p e o f   t h i s . l a s t V a l u e   & &   ' s t r i n g '   = =   t y p e o f   v a l u e  
             ?   t h i s . l a s t V a l u e   ! =   v a l u e   :   S t r i n g ( t h i s . l a s t V a l u e )   ! =   S t r i n g ( v a l u e ) ) ;  
         i f   ( c h a n g e d )   {  
             t h i s . c a l l b a c k ( t h i s . e l e m e n t ,   v a l u e ) ;  
             t h i s . l a s t V a l u e   =   v a l u e ;  
         }  
     }  
 }  
  
 F o r m . E l e m e n t . O b s e r v e r   =   C l a s s . c r e a t e ( ) ;  
 F o r m . E l e m e n t . O b s e r v e r . p r o t o t y p e   =   O b j e c t . e x t e n d ( n e w   A b s t r a c t . T i m e d O b s e r v e r ( ) ,   {  
     g e t V a l u e :   f u n c t i o n ( )   {  
         r e t u r n   F o r m . E l e m e n t . g e t V a l u e ( t h i s . e l e m e n t ) ;  
     }  
 } ) ;  
  
 F o r m . O b s e r v e r   =   C l a s s . c r e a t e ( ) ;  
 F o r m . O b s e r v e r . p r o t o t y p e   =   O b j e c t . e x t e n d ( n e w   A b s t r a c t . T i m e d O b s e r v e r ( ) ,   {  
     g e t V a l u e :   f u n c t i o n ( )   {  
         r e t u r n   F o r m . s e r i a l i z e ( t h i s . e l e m e n t ) ;  
     }  
 } ) ;  
  
 / * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * /  
  
 A b s t r a c t . E v e n t O b s e r v e r   =   f u n c t i o n ( )   { }  
 A b s t r a c t . E v e n t O b s e r v e r . p r o t o t y p e   =   {  
     i n i t i a l i z e :   f u n c t i o n ( e l e m e n t ,   c a l l b a c k )   {  
         t h i s . e l e m e n t     =   $ ( e l e m e n t ) ;  
         t h i s . c a l l b a c k   =   c a l l b a c k ;  
  
         t h i s . l a s t V a l u e   =   t h i s . g e t V a l u e ( ) ;  
         i f   ( t h i s . e l e m e n t . t a g N a m e . t o L o w e r C a s e ( )   = =   ' f o r m ' )  
             t h i s . r e g i s t e r F o r m C a l l b a c k s ( ) ;  
         e l s e  
             t h i s . r e g i s t e r C a l l b a c k ( t h i s . e l e m e n t ) ;  
     } ,  
  
     o n E l e m e n t E v e n t :   f u n c t i o n ( )   {  
         v a r   v a l u e   =   t h i s . g e t V a l u e ( ) ;  
         i f   ( t h i s . l a s t V a l u e   ! =   v a l u e )   {  
             t h i s . c a l l b a c k ( t h i s . e l e m e n t ,   v a l u e ) ;  
             t h i s . l a s t V a l u e   =   v a l u e ;  
         }  
     } ,  
  
     r e g i s t e r F o r m C a l l b a c k s :   f u n c t i o n ( )   {  
         F o r m . g e t E l e m e n t s ( t h i s . e l e m e n t ) . e a c h ( t h i s . r e g i s t e r C a l l b a c k . b i n d ( t h i s ) ) ;  
     } ,  
  
     r e g i s t e r C a l l b a c k :   f u n c t i o n ( e l e m e n t )   {  
         i f   ( e l e m e n t . t y p e )   {  
             s w i t c h   ( e l e m e n t . t y p e . t o L o w e r C a s e ( ) )   {  
                 c a s e   ' c h e c k b o x ' :  
                 c a s e   ' r a d i o ' :  
                     E v e n t . o b s e r v e ( e l e m e n t ,   ' c l i c k ' ,   t h i s . o n E l e m e n t E v e n t . b i n d ( t h i s ) ) ;  
                     b r e a k ;  
                 d e f a u l t :  
                     E v e n t . o b s e r v e ( e l e m e n t ,   ' c h a n g e ' ,   t h i s . o n E l e m e n t E v e n t . b i n d ( t h i s ) ) ;  
                     b r e a k ;  
             }  
         }  
     }  
 }  
  
 F o r m . E l e m e n t . E v e n t O b s e r v e r   =   C l a s s . c r e a t e ( ) ;  
 F o r m . E l e m e n t . E v e n t O b s e r v e r . p r o t o t y p e   =   O b j e c t . e x t e n d ( n e w   A b s t r a c t . E v e n t O b s e r v e r ( ) ,   {  
     g e t V a l u e :   f u n c t i o n ( )   {  
         r e t u r n   F o r m . E l e m e n t . g e t V a l u e ( t h i s . e l e m e n t ) ;  
     }  
 } ) ;  
  
 F o r m . E v e n t O b s e r v e r   =   C l a s s . c r e a t e ( ) ;  
 F o r m . E v e n t O b s e r v e r . p r o t o t y p e   =   O b j e c t . e x t e n d ( n e w   A b s t r a c t . E v e n t O b s e r v e r ( ) ,   {  
     g e t V a l u e :   f u n c t i o n ( )   {  
         r e t u r n   F o r m . s e r i a l i z e ( t h i s . e l e m e n t ) ;  
     }  
 } ) ;  
 i f   ( ! w i n d o w . E v e n t )   {  
     v a r   E v e n t   =   n e w   O b j e c t ( ) ;  
 }  
  
 O b j e c t . e x t e n d ( E v e n t ,   {  
     K E Y _ B A C K S P A C E :   8 ,  
     K E Y _ T A B :               9 ,  
     K E Y _ R E T U R N :       1 3 ,  
     K E Y _ E S C :             2 7 ,  
     K E Y _ L E F T :           3 7 ,  
     K E Y _ U P :               3 8 ,  
     K E Y _ R I G H T :         3 9 ,  
     K E Y _ D O W N :           4 0 ,  
     K E Y _ D E L E T E :       4 6 ,  
     K E Y _ H O M E :           3 6 ,  
     K E Y _ E N D :             3 5 ,  
     K E Y _ P A G E U P :       3 3 ,  
     K E Y _ P A G E D O W N :   3 4 ,  
  
     e l e m e n t :   f u n c t i o n ( e v e n t )   {  
         r e t u r n   $ ( e v e n t . t a r g e t   | |   e v e n t . s r c E l e m e n t ) ;  
     } ,  
  
     i s L e f t C l i c k :   f u n c t i o n ( e v e n t )   {  
         r e t u r n   ( ( ( e v e n t . w h i c h )   & &   ( e v e n t . w h i c h   = =   1 ) )   | |  
                         ( ( e v e n t . b u t t o n )   & &   ( e v e n t . b u t t o n   = =   1 ) ) ) ;  
     } ,  
  
     p o i n t e r X :   f u n c t i o n ( e v e n t )   {  
         r e t u r n   e v e n t . p a g e X   | |   ( e v e n t . c l i e n t X   +  
             ( d o c u m e n t . d o c u m e n t E l e m e n t . s c r o l l L e f t   | |   d o c u m e n t . b o d y . s c r o l l L e f t ) ) ;  
     } ,  
  
     p o i n t e r Y :   f u n c t i o n ( e v e n t )   {  
         r e t u r n   e v e n t . p a g e Y   | |   ( e v e n t . c l i e n t Y   +  
             ( d o c u m e n t . d o c u m e n t E l e m e n t . s c r o l l T o p   | |   d o c u m e n t . b o d y . s c r o l l T o p ) ) ;  
     } ,  
  
     s t o p :   f u n c t i o n ( e v e n t )   {  
         i f   ( e v e n t . p r e v e n t D e f a u l t )   {  
             e v e n t . p r e v e n t D e f a u l t ( ) ;  
             e v e n t . s t o p P r o p a g a t i o n ( ) ;  
         }   e l s e   {  
             e v e n t . r e t u r n V a l u e   =   f a l s e ;  
             e v e n t . c a n c e l B u b b l e   =   t r u e ;  
         }  
     } ,  
  
     / /   f i n d   t h e   f i r s t   n o d e   w i t h   t h e   g i v e n   t a g N a m e ,   s t a r t i n g   f r o m   t h e  
     / /   n o d e   t h e   e v e n t   w a s   t r i g g e r e d   o n ;   t r a v e r s e s   t h e   D O M   u p w a r d s  
     f i n d E l e m e n t :   f u n c t i o n ( e v e n t ,   t a g N a m e )   {  
         v a r   e l e m e n t   =   E v e n t . e l e m e n t ( e v e n t ) ;  
         w h i l e   ( e l e m e n t . p a r e n t N o d e   & &   ( ! e l e m e n t . t a g N a m e   | |  
                 ( e l e m e n t . t a g N a m e . t o U p p e r C a s e ( )   ! =   t a g N a m e . t o U p p e r C a s e ( ) ) ) )  
             e l e m e n t   =   e l e m e n t . p a r e n t N o d e ;  
         r e t u r n   e l e m e n t ;  
     } ,  
  
     o b s e r v e r s :   f a l s e ,  
  
     _ o b s e r v e A n d C a c h e :   f u n c t i o n ( e l e m e n t ,   n a m e ,   o b s e r v e r ,   u s e C a p t u r e )   {  
         i f   ( ! t h i s . o b s e r v e r s )   t h i s . o b s e r v e r s   =   [ ] ;  
         i f   ( e l e m e n t . a d d E v e n t L i s t e n e r )   {  
             t h i s . o b s e r v e r s . p u s h ( [ e l e m e n t ,   n a m e ,   o b s e r v e r ,   u s e C a p t u r e ] ) ;  
             e l e m e n t . a d d E v e n t L i s t e n e r ( n a m e ,   o b s e r v e r ,   u s e C a p t u r e ) ;  
         }   e l s e   i f   ( e l e m e n t . a t t a c h E v e n t )   {  
             t h i s . o b s e r v e r s . p u s h ( [ e l e m e n t ,   n a m e ,   o b s e r v e r ,   u s e C a p t u r e ] ) ;  
             e l e m e n t . a t t a c h E v e n t ( ' o n '   +   n a m e ,   o b s e r v e r ) ;  
         }  
     } ,  
  
     u n l o a d C a c h e :   f u n c t i o n ( )   {  
         i f   ( ! E v e n t . o b s e r v e r s )   r e t u r n ;  
         f o r   ( v a r   i   =   0 ,   l e n g t h   =   E v e n t . o b s e r v e r s . l e n g t h ;   i   <   l e n g t h ;   i + + )   {  
             E v e n t . s t o p O b s e r v i n g . a p p l y ( t h i s ,   E v e n t . o b s e r v e r s [ i ] ) ;  
             E v e n t . o b s e r v e r s [ i ] [ 0 ]   =   n u l l ;  
         }  
         E v e n t . o b s e r v e r s   =   f a l s e ;  
     } ,  
  
     o b s e r v e :   f u n c t i o n ( e l e m e n t ,   n a m e ,   o b s e r v e r ,   u s e C a p t u r e )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         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   ( n a m e   = =   ' k e y p r e s s '   & &  
             ( P r o t o t y p e . B r o w s e r . W e b K i t   | |   e l e m e n t . a t t a c h E v e n t ) )  
             n a m e   =   ' k e y d o w n ' ;  
  
         E v e n t . _ o b s e r v e A n d C a c h e ( e l e m e n t ,   n a m e ,   o b s e r v e r ,   u s e C a p t u r e ) ;  
     } ,  
  
     s t o p O b s e r v i n g :   f u n c t i o n ( e l e m e n t ,   n a m e ,   o b s e r v e r ,   u s e C a p t u r e )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         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   ( n a m e   = =   ' k e y p r e s s '   & &  
                 ( P r o t o t y p e . B r o w s e r . W e b K i t   | |   e l e m e n t . a t t a c h E v e n t ) )  
             n a m e   =   ' k e y d o w n ' ;  
  
         i f   ( e l e m e n t . r e m o v e E v e n t L i s t e n e r )   {  
             e l e m e n t . r e m o v e E v e n t L i s t e n e r ( n a m e ,   o b s e r v e r ,   u s e C a p t u r e ) ;  
         }   e l s e   i f   ( e l e m e n t . d e t a c h E v e n t )   {  
             t r y   {  
                 e l e m e n t . d e t a c h E v e n t ( ' o n '   +   n a m e ,   o b s e r v e r ) ;  
             }   c a t c h   ( e )   { }  
         }  
     }  
 } ) ;  
  
 / *   p r e v e n t   m e m o r y   l e a k s   i n   I E   * /  
 i f   ( P r o t o t y p e . B r o w s e r . I E )  
     E v e n t . o b s e r v e ( w i n d o w ,   ' u n l o a d ' ,   E v e n t . u n l o a d C a c h e ,   f a l s e ) ;  
 v a r   P o s i t i o n   =   {  
     / /   s e t   t o   t r u e   i f   n e e d e d ,   w a r n i n g :   f i r e f o x   p e r f o r m a n c e   p r o b l e m s  
     / /   N O T   n e e e d e d   f o r   p a g e   s c r o l l i n g ,   o n l y   i f   d r a g g a b l e   c o n t a i n e d   i n  
     / /   s c r o l l a b l e   e l e m e n t s  
     i n c l u d e S c r o l l O f f s e t s :   f a l s e ,  
  
     / /   m u s t   b e   c a l l e d   b e f o r e   c a l l i n g   w i t h i n I n c l u d i n g S c r o l l o f f s e t ,   e v e r y   t i m e   t h e  
     / /   p a g e   i s   s c r o l l e d  
     p r e p a r e :   f u n c t i o n ( )   {  
         t h i s . d e l t a X   =     w i n d o w . p a g e X O f f s e t  
                                 | |   d o c u m e n t . d o c u m e n t E l e m e n t . s c r o l l L e f t  
                                 | |   d o c u m e n t . b o d y . s c r o l l L e f t  
                                 | |   0 ;  
         t h i s . d e l t a Y   =     w i n d o w . p a g e Y O f f s e t  
                                 | |   d o c u m e n t . d o c u m e n t E l e m e n t . s c r o l l T o p  
                                 | |   d o c u m e n t . b o d y . s c r o l l T o p  
                                 | |   0 ;  
     } ,  
  
     r e a l O f f s e t :   f u n c t i o n ( e l e m e n t )   {  
         v a r   v a l u e T   =   0 ,   v a l u e L   =   0 ;  
         d o   {  
             v a l u e T   + =   e l e m e n t . s c r o l l T o p     | |   0 ;  
             v a l u e L   + =   e l e m e n t . s c r o l l L e f t   | |   0 ;  
             e l e m e n t   =   e l e m e n t . p a r e n t N o d e ;  
         }   w h i l e   ( e l e m e n t ) ;  
         r e t u r n   [ v a l u e L ,   v a l u e T ] ;  
     } ,  
  
     c u m u l a t i v e O f f s e t :   f u n c t i o n ( e l e m e n t )   {  
         v a r   v a l u e T   =   0 ,   v a l u e L   =   0 ;  
         d o   {  
             v a l u e T   + =   e l e m e n t . o f f s e t T o p     | |   0 ;  
             v a l u e L   + =   e l e m e n t . o f f s e t L e f t   | |   0 ;  
             e l e m e n t   =   e l e m e n t . o f f s e t P a r e n t ;  
         }   w h i l e   ( e l e m e n t ) ;  
         r e t u r n   [ v a l u e L ,   v a l u e T ] ;  
     } ,  
  
     p o s i t i o n e d O f f s e t :   f u n c t i o n ( e l e m e n t )   {  
         v a r   v a l u e T   =   0 ,   v a l u e L   =   0 ;  
         d o   {  
             v a l u e T   + =   e l e m e n t . o f f s e t T o p     | |   0 ;  
             v a l u e L   + =   e l e m e n t . o f f s e t L e f t   | |   0 ;  
             e l e m e n t   =   e l e m e n t . o f f s e t P a r e n t ;  
             i f   ( e l e m e n t )   {  
                 i f ( e l e m e n t . t a g N a m e = = ' B O D Y ' )   b r e a k ;  
                 v a r   p   =   E l e m e n t . g e t S t y l e ( e l e m e n t ,   ' p o s i t i o n ' ) ;  
                 i f   ( p   = =   ' r e l a t i v e '   | |   p   = =   ' a b s o l u t e ' )   b r e a k ;  
             }  
         }   w h i l e   ( e l e m e n t ) ;  
         r e t u r n   [ v a l u e L ,   v a l u e T ] ;  
     } ,  
  
     o f f s e t P a r e n t :   f u n c t i o n ( e l e m e n t )   {  
         i f   ( e l e m e n t . o f f s e t P a r e n t )   r e t u r n   e l e m e n t . o f f s e t P a r e n t ;  
         i f   ( e l e m e n t   = =   d o c u m e n t . b o d y )   r e t u r n   e l e m e n t ;  
  
         w h i l e   ( ( e l e m e n t   =   e l e m e n t . p a r e n t N o d e )   & &   e l e m e n t   ! =   d o c u m e n t . b o d y )  
             i f   ( E l e m e n t . g e t S t y l e ( e l e m e n t ,   ' p o s i t i o n ' )   ! =   ' s t a t i c ' )  
                 r e t u r n   e l e m e n t ;  
  
         r e t u r n   d o c u m e n t . b o d y ;  
     } ,  
  
     / /   c a c h e s   x / y   c o o r d i n a t e   p a i r   t o   u s e   w i t h   o v e r l a p  
     w i t h i n :   f u n c t i o n ( e l e m e n t ,   x ,   y )   {  
         i f   ( t h i s . i n c l u d e S c r o l l O f f s e t s )  
             r e t u r n   t h i s . w i t h i n I n c l u d i n g S c r o l l o f f s e t s ( e l e m e n t ,   x ,   y ) ;  
         t h i s . x c o m p   =   x ;  
         t h i s . y c o m p   =   y ;  
         t h i s . o f f s e t   =   t h i s . c u m u l a t i v e O f f s e t ( e l e m e n t ) ;  
  
         r e t u r n   ( y   > =   t h i s . o f f s e t [ 1 ]   & &  
                         y   <     t h i s . o f f s e t [ 1 ]   +   e l e m e n t . o f f s e t H e i g h t   & &  
                         x   > =   t h i s . o f f s e t [ 0 ]   & &  
                         x   <     t h i s . o f f s e t [ 0 ]   +   e l e m e n t . o f f s e t W i d t h ) ;  
     } ,  
  
     w i t h i n I n c l u d i n g S c r o l l o f f s e t s :   f u n c t i o n ( e l e m e n t ,   x ,   y )   {  
         v a r   o f f s e t c a c h e   =   t h i s . r e a l O f f s e t ( e l e m e n t ) ;  
  
         t h i s . x c o m p   =   x   +   o f f s e t c a c h e [ 0 ]   -   t h i s . d e l t a X ;  
         t h i s . y c o m p   =   y   +   o f f s e t c a c h e [ 1 ]   -   t h i s . d e l t a Y ;  
         t h i s . o f f s e t   =   t h i s . c u m u l a t i v e O f f s e t ( e l e m e n t ) ;  
  
         r e t u r n   ( t h i s . y c o m p   > =   t h i s . o f f s e t [ 1 ]   & &  
                         t h i s . y c o m p   <     t h i s . o f f s e t [ 1 ]   +   e l e m e n t . o f f s e t H e i g h t   & &  
                         t h i s . x c o m p   > =   t h i s . o f f s e t [ 0 ]   & &  
                         t h i s . x c o m p   <     t h i s . o f f s e t [ 0 ]   +   e l e m e n t . o f f s e t W i d t h ) ;  
     } ,  
  
     / /   w i t h i n   m u s t   b e   c a l l e d   d i r e c t l y   b e f o r e  
     o v e r l a p :   f u n c t i o n ( m o d e ,   e l e m e n t )   {  
         i f   ( ! m o d e )   r e t u r n   0 ;  
         i f   ( m o d e   = =   ' v e r t i c a l ' )  
             r e t u r n   ( ( t h i s . o f f s e t [ 1 ]   +   e l e m e n t . o f f s e t H e i g h t )   -   t h i s . y c o m p )   /  
                 e l e m e n t . o f f s e t H e i g h t ;  
         i f   ( m o d e   = =   ' h o r i z o n t a l ' )  
             r e t u r n   ( ( t h i s . o f f s e t [ 0 ]   +   e l e m e n t . o f f s e t W i d t h )   -   t h i s . x c o m p )   /  
                 e l e m e n t . o f f s e t W i d t h ;  
     } ,  
  
     p a g e :   f u n c t i o n ( f o r E l e m e n t )   {  
         v a r   v a l u e T   =   0 ,   v a l u e L   =   0 ;  
  
         v a r   e l e m e n t   =   f o r E l e m e n t ;  
         d o   {  
             v a l u e T   + =   e l e m e n t . o f f s e t T o p     | |   0 ;  
             v a l u e L   + =   e l e m e n t . o f f s e t L e f t   | |   0 ;  
  
             / /   S a f a r i   f i x  
             i f   ( e l e m e n t . o f f s e t P a r e n t   = =   d o c u m e n t . b o d y )  
                 i f   ( E l e m e n t . g e t S t y l e ( e l e m e n t , ' p o s i t i o n ' ) = = ' a b s o l u t e ' )   b r e a k ;  
  
         }   w h i l e   ( e l e m e n t   =   e l e m e n t . o f f s e t P a r e n t ) ;  
  
         e l e m e n t   =   f o r E l e m e n t ;  
         d o   {  
             i f   ( ! w i n d o w . o p e r a   | |   e l e m e n t . t a g N a m e = = ' B O D Y ' )   {  
                 v a l u e T   - =   e l e m e n t . s c r o l l T o p     | |   0 ;  
                 v a l u e L   - =   e l e m e n t . s c r o l l L e f t   | |   0 ;  
             }  
         }   w h i l e   ( e l e m e n t   =   e l e m e n t . p a r e n t N o d e ) ;  
  
         r e t u r n   [ v a l u e L ,   v a l u e T ] ;  
     } ,  
  
     c l o n e :   f u n c t i o n ( s o u r c e ,   t a r g e t )   {  
         v a r   o p t i o n s   =   O b j e c t . e x t e n d ( {  
             s e t L e f t :         t r u e ,  
             s e t T o p :           t r u e ,  
             s e t W i d t h :       t r u e ,  
             s e t H e i g h t :     t r u e ,  
             o f f s e t T o p :     0 ,  
             o f f s e t L e f t :   0  
         } ,   a r g u m e n t s [ 2 ]   | |   { } )  
  
         / /   f i n d   p a g e   p o s i t i o n   o f   s o u r c e  
         s o u r c e   =   $ ( s o u r c e ) ;  
         v a r   p   =   P o s i t i o n . p a g e ( s o u r c e ) ;  
  
         / /   f i n d   c o o r d i n a t e   s y s t e m   t o   u s e  
         t a r g e t   =   $ ( t a r g e t ) ;  
         v a r   d e l t a   =   [ 0 ,   0 ] ;  
         v a r   p a r e n t   =   n u l l ;  
         / /   d e l t a   [ 0 , 0 ]   w i l l   d o   f i n e   w i t h   p o s i t i o n :   f i x e d   e l e m e n t s ,  
         / /   p o s i t i o n : a b s o l u t e   n e e d s   o f f s e t P a r e n t   d e l t a s  
         i f   ( E l e m e n t . g e t S t y l e ( t a r g e t , ' p o s i t i o n ' )   = =   ' a b s o l u t e ' )   {  
             p a r e n t   =   P o s i t i o n . o f f s e t P a r e n t ( t a r g e t ) ;  
             d e l t a   =   P o s i t i o n . p a g e ( p a r e n t ) ;  
         }  
  
         / /   c o r r e c t   b y   b o d y   o f f s e t s   ( f i x e s   S a f a r i )  
         i f   ( p a r e n t   = =   d o c u m e n t . b o d y )   {  
             d e l t a [ 0 ]   - =   d o c u m e n t . b o d y . o f f s e t L e f t ;  
             d e l t a [ 1 ]   - =   d o c u m e n t . b o d y . o f f s e t T o p ;  
         }  
  
         / /   s e t   p o s i t i o n  
         i f ( o p t i o n s . s e t L e f t )       t a r g e t . s t y l e . l e f t     =   ( p [ 0 ]   -   d e l t a [ 0 ]   +   o p t i o n s . o f f s e t L e f t )   +   ' p x ' ;  
         i f ( o p t i o n s . s e t T o p )         t a r g e t . s t y l e . t o p       =   ( p [ 1 ]   -   d e l t a [ 1 ]   +   o p t i o n s . o f f s e t T o p )   +   ' p x ' ;  
         i f ( o p t i o n s . s e t W i d t h )     t a r g e t . s t y l e . w i d t h   =   s o u r c e . o f f s e t W i d t h   +   ' p x ' ;  
         i f ( o p t i o n s . s e t H e i g h t )   t a r g e t . s t y l e . h e i g h t   =   s o u r c e . o f f s e t H e i g h t   +   ' p x ' ;  
     } ,  
  
     a b s o l u t i z e :   f u n c t i o n ( e l e m e n t )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         i f   ( e l e m e n t . s t y l e . p o s i t i o n   = =   ' a b s o l u t e ' )   r e t u r n ;  
         P o s i t i o n . p r e p a r e ( ) ;  
  
         v a r   o f f s e t s   =   P o s i t i o n . p o s i t i o n e d O f f s e t ( e l e m e n t ) ;  
         v a r   t o p           =   o f f s e t s [ 1 ] ;  
         v a r   l e f t         =   o f f s e t s [ 0 ] ;  
         v a r   w i d t h       =   e l e m e n t . c l i e n t W i d t h ;  
         v a r   h e i g h t     =   e l e m e n t . c l i e n t H e i g h t ;  
  
         e l e m e n t . _ o r i g i n a l L e f t       =   l e f t   -   p a r s e F l o a t ( e l e m e n t . s t y l e . l e f t     | |   0 ) ;  
         e l e m e n t . _ o r i g i n a l T o p         =   t o p     -   p a r s e F l o a t ( e l e m e n t . s t y l e . t o p   | |   0 ) ;  
         e l e m e n t . _ o r i g i n a l W i d t h     =   e l e m e n t . s t y l e . w i d t h ;  
         e l e m e n t . _ o r i g i n a l H e i g h t   =   e l e m e n t . s t y l e . h e i g h t ;  
  
         e l e m e n t . s t y l e . p o s i t i o n   =   ' a b s o l u t e ' ;  
         e l e m e n t . s t y l e . t o p         =   t o p   +   ' p x ' ;  
         e l e m e n t . s t y l e . l e f t       =   l e f t   +   ' p x ' ;  
         e l e m e n t . s t y l e . w i d t h     =   w i d t h   +   ' p x ' ;  
         e l e m e n t . s t y l e . h e i g h t   =   h e i g h t   +   ' p x ' ;  
     } ,  
  
     r e l a t i v i z e :   f u n c t i o n ( e l e m e n t )   {  
         e l e m e n t   =   $ ( e l e m e n t ) ;  
         i f   ( e l e m e n t . s t y l e . p o s i t i o n   = =   ' r e l a t i v e ' )   r e t u r n ;  
         P o s i t i o n . p r e p a r e ( ) ;  
  
         e l e m e n t . s t y l e . p o s i t i o n   =   ' r e l a t i v e ' ;  
         v a r   t o p     =   p a r s e F l o a t ( e l e m e n t . s t y l e . t o p     | |   0 )   -   ( e l e m e n t . _ o r i g i n a l T o p   | |   0 ) ;  
         v a r   l e f t   =   p a r s e F l o a t ( e l e m e n t . s t y l e . l e f t   | |   0 )   -   ( e l e m e n t . _ o r i g i n a l L e f t   | |   0 ) ;  
  
         e l e m e n t . s t y l e . t o p         =   t o p   +   ' p x ' ;  
         e l e m e n t . s t y l e . l e f t       =   l e f t   +   ' p x ' ;  
         e l e m e n t . s t y l e . h e i g h t   =   e l e m e n t . _ o r i g i n a l H e i g h t ;  
         e l e m e n t . s t y l e . w i d t h     =   e l e m e n t . _ o r i g i n a l W i d t h ;  
     }  
 }  
  
 / /   S a f a r i   r e t u r n s   m a r g i n s   o n   b o d y   w h i c h   i s   i n c o r r e c t   i f   t h e   c h i l d   i s   a b s o l u t e l y  
 / /   p o s i t i o n e d .     F o r   p e r f o r m a n c e   r e a s o n s ,   r e d e f i n e   P o s i t i o n . c u m u l a t i v e O f f s e t   f o r  
 / /   K H T M L / W e b K i t   o n l y .  
 i f   ( P r o t o t y p e . B r o w s e r . W e b K i t )   {  
     P o s i t i o n . c u m u l a t i v e O f f s e t   =   f u n c t i o n ( e l e m e n t )   {  
         v a r   v a l u e T   =   0 ,   v a l u e L   =   0 ;  
         d o   {  
             v a l u e T   + =   e l e m e n t . o f f s e t T o p     | |   0 ;  
             v a l u e L   + =   e l e m e n t . o f f s e t L e f t   | |   0 ;  
             i f   ( e l e m e n t . o f f s e t P a r e n t   = =   d o c u m e n t . b o d y )  
                 i f   ( E l e m e n t . g e t S t y l e ( e l e m e n t ,   ' p o s i t i o n ' )   = =   ' a b s o l u t e ' )   b r e a k ;  
  
             e l e m e n t   =   e l e m e n t . o f f s e t P a r e n t ;  
         }   w h i l e   ( e l e m e n t ) ;  
  
         r e t u r n   [ v a l u e L ,   v a l u e T ] ;  
     }  
 }  
  
 E l e m e n t . a d d M e t h o d s ( ) ; 
