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