ÿþ/ /   p r e v e n t   e x e c u t i o n   o f   j Q u e r y   i f   i n c l u d e d   m o r e   t h a n   o n c e  
 i f ( t y p e o f   w i n d o w . j Q u e r y   = =   " u n d e f i n e d " )   {  
 / *  
   *   j Q u e r y   1 . 1 . 3 . 1   -   N e w   W a v e   J a v a s c r i p t  
   *  
   *   C o p y r i g h t   ( c )   2 0 0 7   J o h n   R e s i g   ( j q u e r y . c o m )  
   *   D u a l   l i c e n s e d   u n d e r   t h e   M I T   ( M I T - L I C E N S E . t x t )  
   *   a n d   G P L   ( G P L - L I C E N S E . t x t )   l i c e n s e s .  
   *  
   *   $ D a t e :   2 0 0 7 - 0 7 - 0 5   0 0 : 4 3 : 2 4   - 0 4 0 0   ( T h u ,   0 5   J u l   2 0 0 7 )   $  
   *   $ R e v :   2 2 4 3   $  
   * /  
  
 / /   G l o b a l   u n d e f i n e d   v a r i a b l e  
 w i n d o w . u n d e f i n e d   =   w i n d o w . u n d e f i n e d ;  
 v a r   j Q u e r y   =   f u n c t i o n ( a , c )   {  
 	 / /   I f   t h e   c o n t e x t   i s   g l o b a l ,   r e t u r n   a   n e w   o b j e c t  
 	 i f   (   w i n d o w   = =   t h i s   | |   ! t h i s . i n i t   )  
 	 	 r e t u r n   n e w   j Q u e r y ( a , c ) ;  
 	  
 	 r e t u r n   t h i s . i n i t ( a , c ) ;  
 } ;  
  
 / /   M a p   o v e r   t h e   $   i n   c a s e   o f   o v e r w r i t e  
 i f   (   t y p e o f   $   ! =   " u n d e f i n e d "   )  
 	 j Q u e r y . _ $   =   $ ;  
 	  
 / /   M a p   t h e   j Q u e r y   n a m e s p a c e   t o   t h e   ' $ '   o n e  
 v a r   $   =   j Q u e r y ;  
  
 j Q u e r y . f n   =   j Q u e r y . p r o t o t y p e   =   {  
 	 i n i t :   f u n c t i o n ( a , c )   {  
 	 	 / /   M a k e   s u r e   t h a t   a   s e l e c t i o n   w a s   p r o v i d e d  
 	 	 a   =   a   | |   d o c u m e n t ;  
  
 	 	 / /   H A N D L E :   $ ( f u n c t i o n )  
 	 	 / /   S h o r t c u t   f o r   d o c u m e n t   r e a d y  
 	 	 i f   (   j Q u e r y . i s F u n c t i o n ( a )   )  
 	 	 	 r e t u r n   n e w   j Q u e r y ( d o c u m e n t ) [   j Q u e r y . f n . r e a d y   ?   " r e a d y "   :   " l o a d "   ] (   a   ) ;  
  
 	 	 / /   H a n d l e   H T M L   s t r i n g s  
 	 	 i f   (   t y p e o f   a     = =   " s t r i n g "   )   {  
 	 	 	 / /   H A N D L E :   $ ( h t m l )   - >   $ ( a r r a y )  
 	 	 	 v a r   m   =   / ^ [ ^ < ] * ( < ( . | \ s ) + > ) [ ^ > ] * $ / . e x e c ( a ) ;  
 	 	 	 i f   (   m   )  
 	 	 	 	 a   =   j Q u e r y . c l e a n (   [   m [ 1 ]   ]   ) ;  
  
 	 	 	 / /   H A N D L E :   $ ( e x p r )  
 	 	 	 e l s e  
 	 	 	 	 r e t u r n   n e w   j Q u e r y (   c   ) . f i n d (   a   ) ;  
 	 	 }  
  
 	 	 r e t u r n   t h i s . s e t A r r a y (  
 	 	 	 / /   H A N D L E :   $ ( a r r a y )  
 	 	 	 a . c o n s t r u c t o r   = =   A r r a y   & &   a   | |  
  
 	 	 	 / /   H A N D L E :   $ ( a r r a y l i k e )  
 	 	 	 / /   W a t c h   f o r   w h e n   a n   a r r a y - l i k e   o b j e c t   i s   p a s s e d   a s   t h e   s e l e c t o r  
 	 	 	 ( a . j q u e r y   | |   a . l e n g t h   & &   a   ! =   w i n d o w   & &   ! a . n o d e T y p e   & &   a [ 0 ]   ! =   u n d e f i n e d   & &   a [ 0 ] . n o d e T y p e )   & &   j Q u e r y . m a k e A r r a y (   a   )   | |  
  
 	 	 	 / /   H A N D L E :   $ ( * )  
 	 	 	 [   a   ]   ) ;  
 	 } ,  
 	 j q u e r y :   " 1 . 1 . 3 . 1 " ,  
  
 	 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 ;  
 	 } ,  
 	  
 	 l e n g t h :   0 ,  
  
 	 g e t :   f u n c t i o n (   n u m   )   {  
 	 	 r e t u r n   n u m   = =   u n d e f i n e d   ?  
  
 	 	 	 / /   R e t u r n   a   ' c l e a n '   a r r a y  
 	 	 	 j Q u e r y . m a k e A r r a y (   t h i s   )   :  
  
 	 	 	 / /   R e t u r n   j u s t   t h e   o b j e c t  
 	 	 	 t h i s [ n u m ] ;  
 	 } ,  
 	 p u s h S t a c k :   f u n c t i o n (   a   )   {  
 	 	 v a r   r e t   =   j Q u e r y ( a ) ;  
 	 	 r e t . p r e v O b j e c t   =   t h i s ;  
 	 	 r e t u r n   r e t ;  
 	 } ,  
 	 s e t A r r a y :   f u n c t i o n (   a   )   {  
 	 	 t h i s . l e n g t h   =   0 ;  
 	 	 [ ] . p u s h . a p p l y (   t h i s ,   a   ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
 	 e a c h :   f u n c t i o n (   f n ,   a r g s   )   {  
 	 	 r e t u r n   j Q u e r y . e a c h (   t h i s ,   f n ,   a r g s   ) ;  
 	 } ,  
 	 i n d e x :   f u n c t i o n (   o b j   )   {  
 	 	 v a r   p o s   =   - 1 ;  
 	 	 t h i s . e a c h ( f u n c t i o n ( i ) {  
 	 	 	 i f   (   t h i s   = =   o b j   )   p o s   =   i ;  
 	 	 } ) ;  
 	 	 r e t u r n   p o s ;  
 	 } ,  
  
 	 a t t r :   f u n c t i o n (   k e y ,   v a l u e ,   t y p e   )   {  
 	 	 v a r   o b j   =   k e y ;  
 	 	  
 	 	 / /   L o o k   f o r   t h e   c a s e   w h e r e   w e ' r e   a c c e s s i n g   a   s t y l e   v a l u e  
 	 	 i f   (   k e y . c o n s t r u c t o r   = =   S t r i n g   )  
 	 	 	 i f   (   v a l u e   = =   u n d e f i n e d   )  
 	 	 	 	 r e t u r n   t h i s . l e n g t h   & &   j Q u e r y [   t y p e   | |   " a t t r "   ] (   t h i s [ 0 ] ,   k e y   )   | |   u n d e f i n e d ;  
 	 	 	 e l s e   {  
 	 	 	 	 o b j   =   { } ;  
 	 	 	 	 o b j [   k e y   ]   =   v a l u e ;  
 	 	 	 }  
 	 	  
 	 	 / /   C h e c k   t o   s e e   i f   w e ' r e   s e t t i n g   s t y l e   v a l u e s  
 	 	 r e t u r n   t h i s . e a c h ( f u n c t i o n ( i n d e x ) {  
 	 	 	 / /   S e t   a l l   t h e   s t y l e s  
 	 	 	 f o r   (   v a r   p r o p   i n   o b j   )  
 	 	 	 	 j Q u e r y . a t t r (  
 	 	 	 	 	 t y p e   ?   t h i s . s t y l e   :   t h i s ,  
 	 	 	 	 	 p r o p ,   j Q u e r y . p r o p ( t h i s ,   o b j [ p r o p ] ,   t y p e ,   i n d e x ,   p r o p )  
 	 	 	 	 ) ;  
 	 	 } ) ;  
 	 } ,  
  
 	 c s s :   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 . a t t r (   k e y ,   v a l u e ,   " c u r C S S "   ) ;  
 	 } ,  
  
 	 t e x t :   f u n c t i o n ( e )   {  
 	 	 i f   (   t y p e o f   e   = =   " s t r i n g "   )  
 	 	 	 r e t u r n   t h i s . e m p t y ( ) . a p p e n d (   d o c u m e n t . c r e a t e T e x t N o d e (   e   )   ) ;  
  
 	 	 v a r   t   =   " " ;  
 	 	 j Q u e r y . e a c h (   e   | |   t h i s ,   f u n c t i o n ( ) {  
 	 	 	 j Q u e r y . e a c h (   t h i s . c h i l d N o d e s ,   f u n c t i o n ( ) {  
 	 	 	 	 i f   (   t h i s . n o d e T y p e   ! =   8   )  
 	 	 	 	 	 t   + =   t h i s . n o d e T y p e   ! =   1   ?  
 	 	 	 	 	 	 t h i s . n o d e V a l u e   :   j Q u e r y . f n . t e x t ( [   t h i s   ] ) ;  
 	 	 	 } ) ;  
 	 	 } ) ;  
 	 	 r e t u r n   t ;  
 	 } ,  
  
 	 w r a p :   f u n c t i o n ( )   {  
 	 	 / /   T h e   e l e m e n t s   t o   w r a p   t h e   t a r g e t   a r o u n d  
 	 	 v a r   a ,   a r g s   =   a r g u m e n t s ;  
  
 	 	 / /   W r a p   e a c h   o f   t h e   m a t c h e d   e l e m e n t s   i n d i v i d u a l l y  
 	 	 r e t u r n   t h i s . e a c h ( f u n c t i o n ( ) {  
 	 	 	 i f   (   ! a   )  
 	 	 	 	 a   =   j Q u e r y . c l e a n ( a r g s ,   t h i s . o w n e r D o c u m e n t ) ;  
  
 	 	 	 / /   C l o n e   t h e   s t r u c t u r e   t h a t   w e ' r e   u s i n g   t o   w r a p  
 	 	 	 v a r   b   =   a [ 0 ] . c l o n e N o d e ( t r u e ) ;  
  
 	 	 	 / /   I n s e r t   i t   b e f o r e   t h e   e l e m e n t   t o   b e   w r a p p e d  
 	 	 	 t h i s . p a r e n t N o d e . i n s e r t B e f o r e (   b ,   t h i s   ) ;  
  
 	 	 	 / /   F i n d   t h e   d e e p e s t   p o i n t   i n   t h e   w r a p   s t r u c t u r e  
 	 	 	 w h i l e   (   b . f i r s t C h i l d   )  
 	 	 	 	 b   =   b . f i r s t C h i l d ;  
  
 	 	 	 / /   M o v e   t h e   m a t c h e d   e l e m e n t   t o   w i t h i n   t h e   w r a p   s t r u c t u r e  
 	 	 	 b . a p p e n d C h i l d (   t h i s   ) ;  
 	 	 } ) ;  
 	 } ,  
 	 a p p e n d :   f u n c t i o n ( )   {  
 	 	 r e t u r n   t h i s . d o m M a n i p ( a r g u m e n t s ,   t r u e ,   1 ,   f u n c t i o n ( a ) {  
 	 	 	 t h i s . a p p e n d C h i l d (   a   ) ;  
 	 	 } ) ;  
 	 } ,  
 	 p r e p e n d :   f u n c t i o n ( )   {  
 	 	 r e t u r n   t h i s . d o m M a n i p ( a r g u m e n t s ,   t r u e ,   - 1 ,   f u n c t i o n ( a ) {  
 	 	 	 t h i s . i n s e r t B e f o r e (   a ,   t h i s . f i r s t C h i l d   ) ;  
 	 	 } ) ;  
 	 } ,  
 	 b e f o r e :   f u n c t i o n ( )   {  
 	 	 r e t u r n   t h i s . d o m M a n i p ( a r g u m e n t s ,   f a l s e ,   1 ,   f u n c t i o n ( a ) {  
 	 	 	 t h i s . p a r e n t N o d e . i n s e r t B e f o r e (   a ,   t h i s   ) ;  
 	 	 } ) ;  
 	 } ,  
 	 a f t e r :   f u n c t i o n ( )   {  
 	 	 r e t u r n   t h i s . d o m M a n i p ( a r g u m e n t s ,   f a l s e ,   - 1 ,   f u n c t i o n ( a ) {  
 	 	 	 t h i s . p a r e n t N o d e . i n s e r t B e f o r e (   a ,   t h i s . n e x t S i b l i n g   ) ;  
 	 	 } ) ;  
 	 } ,  
 	 e n d :   f u n c t i o n ( )   {  
 	 	 r e t u r n   t h i s . p r e v O b j e c t   | |   j Q u e r y ( [ ] ) ;  
 	 } ,  
 	 f i n d :   f u n c t i o n ( t )   {  
 	 	 v a r   d a t a   =   j Q u e r y . m a p ( t h i s ,   f u n c t i o n ( a ) {   r e t u r n   j Q u e r y . f i n d ( t , a ) ;   } ) ;  
 	 	 r e t u r n   t h i s . p u s h S t a c k (   / [ ^ + > ]   [ ^ + > ] / . t e s t (   t   )   | |   t . i n d e x O f ( " . . " )   >   - 1   ?  
 	 	 	 j Q u e r y . u n i q u e (   d a t a   )   :   d a t a   ) ;  
 	 } ,  
 	 c l o n e :   f u n c t i o n ( d e e p )   {  
 	 	 / /   N e e d   t o   r e m o v e   e v e n t s   o n   t h e   e l e m e n t   a n d   i t s   d e s c e n d a n t s  
 	 	 v a r   $ t h i s   =   t h i s . a d d ( t h i s . f i n d ( " * " ) ) ;  
 	 	 $ t h i s . e a c h ( f u n c t i o n ( )   {  
 	 	 	 t h i s . _ $ e v e n t s   =   { } ;  
 	 	 	 f o r   ( v a r   t y p e   i n   t h i s . $ e v e n t s )  
 	 	 	 	 t h i s . _ $ e v e n t s [ t y p e ]   =   j Q u e r y . e x t e n d ( { } , t h i s . $ e v e n t s [ t y p e ] ) ;  
 	 	 } ) . u n b i n d ( ) ;  
  
 	 	 / /   D o   t h e   c l o n e  
 	 	 v a r   r   =   t h i s . p u s h S t a c k (   j Q u e r y . m a p (   t h i s ,   f u n c t i o n ( a ) {  
 	 	 	 r e t u r n   a . c l o n e N o d e (   d e e p   ! =   u n d e f i n e d   ?   d e e p   :   t r u e   ) ;  
 	 	 } )   ) ;  
  
 	 	 / /   A d d   t h e   e v e n t s   b a c k   t o   t h e   o r i g i n a l   a n d   i t s   d e s c e n d a n t s  
 	 	 $ t h i s . e a c h ( f u n c t i o n ( )   {  
 	 	 	 v a r   e v e n t s   =   t h i s . _ $ e v e n t s ;  
 	 	 	 f o r   ( v a r   t y p e   i n   e v e n t s )  
 	 	 	 	 f o r   ( v a r   h a n d l e r   i n   e v e n t s [ t y p e ] )  
 	 	 	 	 	 j Q u e r y . e v e n t . a d d ( t h i s ,   t y p e ,   e v e n t s [ t y p e ] [ h a n d l e r ] ,   e v e n t s [ t y p e ] [ h a n d l e r ] . d a t a ) ;  
 	 	 	 t h i s . _ $ e v e n t s   =   n u l l ;  
 	 	 } ) ;  
  
 	 	 / /   R e t u r n   t h e   c l o n e d   s e t  
 	 	 r e t u r n   r ;  
 	 } ,  
  
 	 f i l t e r :   f u n c t i o n ( t )   {  
 	 	 r e t u r n   t h i s . p u s h S t a c k (  
 	 	 	 j Q u e r y . i s F u n c t i o n (   t   )   & &  
 	 	 	 j Q u e r y . g r e p ( t h i s ,   f u n c t i o n ( e l ,   i n d e x ) {  
 	 	 	 	 r e t u r n   t . a p p l y ( e l ,   [ i n d e x ] )  
 	 	 	 } )   | |  
  
 	 	 	 j Q u e r y . m u l t i F i l t e r ( t , t h i s )   ) ;  
 	 } ,  
  
 	 n o t :   f u n c t i o n ( t )   {  
 	 	 r e t u r n   t h i s . p u s h S t a c k (  
 	 	 	 t . c o n s t r u c t o r   = =   S t r i n g   & &  
 	 	 	 j Q u e r y . m u l t i F i l t e r ( t ,   t h i s ,   t r u e )   | |  
  
 	 	 	 j Q u e r y . g r e p ( t h i s ,   f u n c t i o n ( a )   {  
 	 	 	 	 r e t u r n   (   t . c o n s t r u c t o r   = =   A r r a y   | |   t . j q u e r y   )  
 	 	 	 	 	 ?   j Q u e r y . i n A r r a y (   a ,   t   )   <   0  
 	 	 	 	 	 :   a   ! =   t ;  
 	 	 	 } )  
 	 	 ) ;  
 	 } ,  
  
 	 a d d :   f u n c t i o n ( t )   {  
 	 	 r e t u r n   t h i s . p u s h S t a c k (   j Q u e r y . m e r g e (  
 	 	 	 t h i s . g e t ( ) ,  
 	 	 	 t . c o n s t r u c t o r   = =   S t r i n g   ?  
 	 	 	 	 j Q u e r y ( t ) . g e t ( )   :  
 	 	 	 	 t . l e n g t h   ! =   u n d e f i n e d   & &   ( ! t . n o d e N a m e   | |   t . n o d e N a m e   = =   " F O R M " )   ?  
 	 	 	 	 	 t   :   [ t ]   )  
 	 	 ) ;  
 	 } ,  
 	 i s :   f u n c t i o n ( e x p r )   {  
 	 	 r e t u r n   e x p r   ?   j Q u e r y . m u l t i F i l t e r ( e x p r , t h i s ) . l e n g t h   >   0   :   f a l s e ;  
 	 } ,  
  
 	 v a l :   f u n c t i o n (   v a l   )   {  
 	 	 r e t u r n   v a l   = =   u n d e f i n e d   ?  
 	 	 	 (   t h i s . l e n g t h   ?   t h i s [ 0 ] . v a l u e   :   n u l l   )   :  
 	 	 	 t h i s . a t t r (   " v a l u e " ,   v a l   ) ;  
 	 } ,  
  
 	 h t m l :   f u n c t i o n (   v a l   )   {  
 	 	 r e t u r n   v a l   = =   u n d e f i n e d   ?  
 	 	 	 (   t h i s . l e n g t h   ?   t h i s [ 0 ] . i n n e r H T M L   :   n u l l   )   :  
 	 	 	 t h i s . e m p t y ( ) . a p p e n d (   v a l   ) ;  
 	 } ,  
 	 d o m M a n i p :   f u n c t i o n ( a r g s ,   t a b l e ,   d i r ,   f n ) {  
 	 	 v a r   c l o n e   =   t h i s . l e n g t h   >   1 ,   a ;    
  
 	 	 r e t u r n   t h i s . e a c h ( f u n c t i o n ( ) {  
 	 	 	 i f   (   ! a   )   {  
 	 	 	 	 a   =   j Q u e r y . c l e a n ( a r g s ,   t h i s . o w n e r D o c u m e n t ) ;  
 	 	 	 	 i f   (   d i r   <   0   )  
 	 	 	 	 	 a . r e v e r s e ( ) ;  
 	 	 	 }  
  
 	 	 	 v a r   o b j   =   t h i s ;  
  
 	 	 	 i f   (   t a b l e   & &   j Q u e r y . n o d e N a m e ( t h i s ,   " t a b l e " )   & &   j Q u e r y . n o d e N a m e ( a [ 0 ] ,   " t r " )   )  
 	 	 	 	 o b j   =   t h i s . g e t E l e m e n t s B y T a g N a m e ( " t b o d y " ) [ 0 ]   | |   t h i s . a p p e n d C h i l d ( d o c u m e n t . c r e a t e E l e m e n t ( " t b o d y " ) ) ;  
  
 	 	 	 j Q u e r y . e a c h (   a ,   f u n c t i o n ( ) {  
 	 	 	 	 f n . a p p l y (   o b j ,   [   c l o n e   ?   t h i s . c l o n e N o d e ( t r u e )   :   t h i s   ]   ) ;  
 	 	 	 } ) ;  
  
 	 	 } ) ;  
 	 }  
 } ;  
  
 j Q u e r y . e x t e n d   =   j Q u e r y . f n . e x t e n d   =   f u n c t i o n ( )   {  
 	 / /   c o p y   r e f e r e n c e   t o   t a r g e t   o b j e c t  
 	 v a r   t a r g e t   =   a r g u m e n t s [ 0 ] ,   a   =   1 ;  
  
 	 / /   e x t e n d   j Q u e r y   i t s e l f   i f   o n l y   o n e   a r g u m e n t   i s   p a s s e d  
 	 i f   (   a r g u m e n t s . l e n g t h   = =   1   )   {  
 	 	 t a r g e t   =   t h i s ;  
 	 	 a   =   0 ;  
 	 }  
 	 v a r   p r o p ;  
 	 w h i l e   (   ( p r o p   =   a r g u m e n t s [ a + + ] )   ! =   n u l l   )  
 	 	 / /   E x t e n d   t h e   b a s e   o b j e c t  
 	 	 f o r   (   v a r   i   i n   p r o p   )   t a r g e t [ i ]   =   p r o p [ i ] ;  
  
 	 / /   R e t u r n   t h e   m o d i f i e d   o b j e c t  
 	 r e t u r n   t a r g e t ;  
 } ;  
  
 j Q u e r y . e x t e n d ( {  
 	 n o C o n f l i c t :   f u n c t i o n ( )   {  
 	 	 i f   (   j Q u e r y . _ $   )  
 	 	 	 $   =   j Q u e r y . _ $ ;  
 	 	 r e t u r n   j Q u e r y ;  
 	 } ,  
  
 	 / /   T h i s   m a y   s e e m   l i k e   s o m e   c r a z y   c o d e ,   b u t   t r u s t   m e   w h e n   I   s a y   t h a t   t h i s  
 	 / /   i s   t h e   o n l y   c r o s s - b r o w s e r   w a y   t o   d o   t h i s .   - - J o h n  
 	 i s F u n c t i o n :   f u n c t i o n (   f n   )   {  
 	 	 r e t u r n   ! ! f n   & &   t y p e o f   f n   ! =   " s t r i n g "   & &   ! f n . n o d e N a m e   & &    
 	 	 	 f n . c o n s t r u c t o r   ! =   A r r a y   & &   / f u n c t i o n / i . t e s t (   f n   +   " "   ) ;  
 	 } ,  
 	  
 	 / /   c h e c k   i f   a n   e l e m e n t   i s   i n   a   X M L   d o c u m e n t  
 	 i s X M L D o c :   f u n c t i o n ( e l e m )   {  
 	 	 r e t u r n   e l e m . t a g N a m e   & &   e l e m . o w n e r D o c u m e n t   & &   ! e l e m . o w n e r D o c u m e n t . b o d y ;  
 	 } ,  
  
 	 n o d e N a m e :   f u n c t i o n (   e l e m ,   n a m e   )   {  
 	 	 r e t u r n   e l e m . n o d e N a m e   & &   e l e m . n o d e N a m e . t o U p p e r C a s e ( )   = =   n a m e . t o U p p e r C a s e ( ) ;  
 	 } ,  
 	 / /   a r g s   i s   f o r   i n t e r n a l   u s a g e   o n l y  
 	 e a c h :   f u n c t i o n (   o b j ,   f n ,   a r g s   )   {  
 	 	 i f   (   o b j . l e n g t h   = =   u n d e f i n e d   )  
 	 	 	 f o r   (   v a r   i   i n   o b j   )  
 	 	 	 	 f n . a p p l y (   o b j [ i ] ,   a r g s   | |   [ i ,   o b j [ i ] ]   ) ;  
 	 	 e l s e  
 	 	 	 f o r   (   v a r   i   =   0 ,   o l   =   o b j . l e n g t h ;   i   <   o l ;   i + +   )  
 	 	 	 	 i f   (   f n . a p p l y (   o b j [ i ] ,   a r g s   | |   [ i ,   o b j [ i ] ]   )   = = =   f a l s e   )   b r e a k ;  
 	 	 r e t u r n   o b j ;  
 	 } ,  
 	  
 	 p r o p :   f u n c t i o n ( e l e m ,   v a l u e ,   t y p e ,   i n d e x ,   p r o p ) {  
 	 	 	 / /   H a n d l e   e x e c u t a b l e   f u n c t i o n s  
 	 	 	 i f   (   j Q u e r y . i s F u n c t i o n (   v a l u e   )   )  
 	 	 	 	 v a l u e   =   v a l u e . c a l l (   e l e m ,   [ i n d e x ]   ) ;  
 	 	 	 	  
 	 	 	 / /   e x c l u d e   t h e   f o l l o w i n g   c s s   p r o p e r t i e s   t o   a d d   p x  
 	 	 	 v a r   e x c l u d e   =   / z - ? i n d e x | f o n t - ? w e i g h t | o p a c i t y | z o o m | l i n e - ? h e i g h t / i ;  
  
 	 	 	 / /   H a n d l e   p a s s i n g   i n   a   n u m b e r   t o   a   C S S   p r o p e r t y  
 	 	 	 r e t u r n   v a l u e   & &   v a l u e . c o n s t r u c t o r   = =   N u m b e r   & &   t y p e   = =   " c u r C S S "   & &   ! e x c l u d e . t e s t ( p r o p )   ?  
 	 	 	 	 v a l u e   +   " p x "   :  
 	 	 	 	 v a l u e ;  
 	 } ,  
  
 	 c l a s s N a m e :   {  
 	 	 / /   i n t e r n a l   o n l y ,   u s e   a d d C l a s s ( " c l a s s " )  
 	 	 a d d :   f u n c t i o n (   e l e m ,   c   ) {  
 	 	 	 j Q u e r y . e a c h (   c . s p l i t ( / \ s + / ) ,   f u n c t i o n ( i ,   c u r ) {  
 	 	 	 	 i f   (   ! j Q u e r y . c l a s s N a m e . h a s (   e l e m . c l a s s N a m e ,   c u r   )   )  
 	 	 	 	 	 e l e m . c l a s s N a m e   + =   (   e l e m . c l a s s N a m e   ?   "   "   :   " "   )   +   c u r ;  
 	 	 	 } ) ;  
 	 	 } ,  
  
 	 	 / /   i n t e r n a l   o n l y ,   u s e   r e m o v e C l a s s ( " c l a s s " )  
 	 	 r e m o v e :   f u n c t i o n (   e l e m ,   c   ) {  
 	 	 	 e l e m . c l a s s N a m e   =   c   ! =   u n d e f i n e d   ?  
 	 	 	 	 j Q u e r y . g r e p (   e l e m . c l a s s N a m e . s p l i t ( / \ s + / ) ,   f u n c t i o n ( c u r ) {  
 	 	 	 	 	 r e t u r n   ! j Q u e r y . c l a s s N a m e . h a s (   c ,   c u r   ) ; 	  
 	 	 	 	 } ) . j o i n ( "   " )   :   " " ;  
 	 	 } ,  
  
 	 	 / /   i n t e r n a l   o n l y ,   u s e   i s ( " . c l a s s " )  
 	 	 h a s :   f u n c t i o n (   t ,   c   )   {  
 	 	 	 r e t u r n   j Q u e r y . i n A r r a y (   c ,   ( t . c l a s s N a m e   | |   t ) . t o S t r i n g ( ) . s p l i t ( / \ s + / )   )   >   - 1 ;  
 	 	 }  
 	 } ,  
 	 s w a p :   f u n c t i o n ( e , o , f )   {  
 	 	 f o r   (   v a r   i   i n   o   )   {  
 	 	 	 e . s t y l e [ " o l d " + i ]   =   e . s t y l e [ i ] ;  
 	 	 	 e . s t y l e [ i ]   =   o [ i ] ;  
 	 	 }  
 	 	 f . a p p l y (   e ,   [ ]   ) ;  
 	 	 f o r   (   v a r   i   i n   o   )  
 	 	 	 e . s t y l e [ i ]   =   e . s t y l e [ " o l d " + i ] ;  
 	 } ,  
  
 	 c s s :   f u n c t i o n ( e , p )   {  
 	 	 i f   (   p   = =   " h e i g h t "   | |   p   = =   " w i d t h "   )   {  
 	 	 	 v a r   o l d   =   { } ,   o H e i g h t ,   o W i d t h ,   d   =   [ " T o p " , " B o t t o m " , " R i g h t " , " L e f t " ] ;  
  
 	 	 	 j Q u e r y . e a c h (   d ,   f u n c t i o n ( ) {  
 	 	 	 	 o l d [ " p a d d i n g "   +   t h i s ]   =   0 ;  
 	 	 	 	 o l d [ " b o r d e r "   +   t h i s   +   " W i d t h " ]   =   0 ;  
 	 	 	 } ) ;  
  
 	 	 	 j Q u e r y . s w a p (   e ,   o l d ,   f u n c t i o n ( )   {  
 	 	 	 	 i f   (   j Q u e r y ( e ) . i s ( ' : v i s i b l e ' )   )   {  
 	 	 	 	 	 o H e i g h t   =   e . o f f s e t H e i g h t ;  
 	 	 	 	 	 o W i d t h   =   e . o f f s e t W i d t h ;  
 	 	 	 	 }   e l s e   {  
 	 	 	 	 	 e   =   j Q u e r y ( e . c l o n e N o d e ( t r u e ) )  
 	 	 	 	 	 	 . f i n d ( " : r a d i o " ) . r e m o v e A t t r ( " c h e c k e d " ) . e n d ( )  
 	 	 	 	 	 	 . c s s ( {  
 	 	 	 	 	 	 	 v i s i b i l i t y :   " h i d d e n " ,   p o s i t i o n :   " a b s o l u t e " ,   d i s p l a y :   " b l o c k " ,   r i g h t :   " 0 " ,   l e f t :   " 0 "  
 	 	 	 	 	 	 } ) . a p p e n d T o ( e . p a r e n t N o d e ) [ 0 ] ;  
  
 	 	 	 	 	 v a r   p a r P o s   =   j Q u e r y . c s s ( e . p a r e n t N o d e , " p o s i t i o n " )   | |   " s t a t i c " ;  
 	 	 	 	 	 i f   (   p a r P o s   = =   " s t a t i c "   )  
 	 	 	 	 	 	 e . p a r e n t N o d e . s t y l e . p o s i t i o n   =   " r e l a t i v e " ;  
  
 	 	 	 	 	 o H e i g h t   =   e . c l i e n t H e i g h t ;  
 	 	 	 	 	 o W i d t h   =   e . c l i e n t W i d t h ;  
  
 	 	 	 	 	 i f   (   p a r P o s   = =   " s t a t i c "   )  
 	 	 	 	 	 	 e . p a r e n t N o d e . s t y l e . p o s i t i o n   =   " s t a t i c " ;  
  
 	 	 	 	 	 e . p a r e n t N o d e . r e m o v e C h i l d ( e ) ;  
 	 	 	 	 }  
 	 	 	 } ) ;  
  
 	 	 	 r e t u r n   p   = =   " h e i g h t "   ?   o H e i g h t   :   o W i d t h ;  
 	 	 }  
  
 	 	 r e t u r n   j Q u e r y . c u r C S S (   e ,   p   ) ;  
 	 } ,  
  
 	 c u r C S S :   f u n c t i o n ( e l e m ,   p r o p ,   f o r c e )   {  
 	 	 v a r   r e t ;  
  
 	 	 i f   ( p r o p   = =   " o p a c i t y "   & &   j Q u e r y . b r o w s e r . m s i e )   {  
 	 	 	 r e t   =   j Q u e r y . a t t r ( e l e m . s t y l e ,   " o p a c i t y " ) ;  
 	 	 	 r e t u r n   r e t   = =   " "   ?   " 1 "   :   r e t ;  
 	 	 }  
 	 	  
 	 	 i f   ( p r o p . m a t c h ( / f l o a t / i ) )  
 	 	 	 p r o p   =   j Q u e r y . s t y l e F l o a t ;  
  
 	 	 i f   ( ! f o r c e   & &   e l e m . s t y l e [ p r o p ] )  
 	 	 	 r e t   =   e l e m . s t y l e [ p r o p ] ;  
  
 	 	 e l s e   i f   ( d o c u m e n t . d e f a u l t V i e w   & &   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 )   {  
  
 	 	 	 i f   ( p r o p . m a t c h ( / f l o a t / i ) )  
 	 	 	 	 p r o p   =   " f l o a t " ;  
  
 	 	 	 p r o p   =   p r o p . r e p l a c e ( / ( [ A - Z ] ) / g , " - $ 1 " ) . t o L o w e r C a s e ( ) ;  
 	 	 	 v a r   c u r   =   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 ,   n u l l ) ;  
  
 	 	 	 i f   (   c u r   )  
 	 	 	 	 r e t   =   c u r . g e t P r o p e r t y V a l u e ( p r o p ) ;  
 	 	 	 e l s e   i f   (   p r o p   = =   " d i s p l a y "   )  
 	 	 	 	 r e t   =   " n o n e " ;  
 	 	 	 e l s e  
 	 	 	 	 j Q u e r y . s w a p ( e l e m ,   {   d i s p l a y :   " b l o c k "   } ,   f u n c t i o n ( )   {  
 	 	 	 	         v a r   c   =   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 ( t h i s ,   " " ) ;  
 	 	 	 	         r e t   =   c   & &   c . g e t P r o p e r t y V a l u e ( p r o p )   | |   " " ;  
 	 	 	 	 } ) ;  
  
 	 	 }   e l s e   i f   ( e l e m . c u r r e n t S t y l e )   {  
 	 	 	 v a r   n e w P r o p   =   p r o p . r e p l a c e ( / \ - ( \ w ) / g , f u n c t i o n ( m , c ) { r e t u r n   c . t o U p p e r C a s e ( ) ; } ) ;  
 	 	 	 r e t   =   e l e m . c u r r e n t S t y l e [ p r o p ]   | |   e l e m . c u r r e n t S t y l e [ n e w P r o p ] ;  
 	 	 }  
  
 	 	 r e t u r n   r e t ;  
 	 } ,  
 	  
 	 c l e a n :   f u n c t i o n ( a ,   d o c )   {  
 	 	 v a r   r   =   [ ] ;  
 	 	 d o c   =   d o c   | |   d o c u m e n t ;  
  
 	 	 j Q u e r y . e a c h (   a ,   f u n c t i o n ( i , a r g ) {  
 	 	 	 i f   (   ! a r g   )   r e t u r n ;  
  
 	 	 	 i f   (   a r g . c o n s t r u c t o r   = =   N u m b e r   )  
 	 	 	 	 a r g   =   a r g . t o S t r i n g ( ) ;  
 	 	 	  
 	 	 	 / /   C o n v e r t   h t m l   s t r i n g   i n t o   D O M   n o d e s  
 	 	 	 i f   (   t y p e o f   a r g   = =   " s t r i n g "   )   {  
 	 	 	 	 / /   T r i m   w h i t e s p a c e ,   o t h e r w i s e   i n d e x O f   w o n ' t   w o r k   a s   e x p e c t e d  
 	 	 	 	 v a r   s   =   j Q u e r y . t r i m ( a r g ) . t o L o w e r C a s e ( ) ,   d i v   =   d o c . c r e a t e E l e m e n t ( " d i v " ) ,   t b   =   [ ] ;  
  
 	 	 	 	 v a r   w r a p   =  
 	 	 	 	 	 / /   o p t i o n   o r   o p t g r o u p  
 	 	 	 	 	 ! s . i n d e x O f ( " < o p t " )   & &  
 	 	 	 	 	 [ 1 ,   " < s e l e c t > " ,   " < / s e l e c t > " ]   | |  
 	 	 	 	 	  
 	 	 	 	 	 ! s . i n d e x O f ( " < l e g " )   & &  
 	 	 	 	 	 [ 1 ,   " < f i e l d s e t > " ,   " < / f i e l d s e t > " ]   | |  
 	 	 	 	 	  
 	 	 	 	 	 ( ! s . i n d e x O f ( " < t h e a d " )   | |   ! s . i n d e x O f ( " < t b o d y " )   | |   ! s . i n d e x O f ( " < t f o o t " )   | |   ! s . i n d e x O f ( " < c o l g " ) )   & &  
 	 	 	 	 	 [ 1 ,   " < t a b l e > " ,   " < / t a b l e > " ]   | |  
 	 	 	 	 	  
 	 	 	 	 	 ! s . i n d e x O f ( " < t r " )   & &  
 	 	 	 	 	 [ 2 ,   " < t a b l e > < t b o d y > " ,   " < / t b o d y > < / t a b l e > " ]   | |  
 	 	 	 	 	  
 	 	 	 	   	 / /   < t h e a d >   m a t c h e d   a b o v e  
 	 	 	 	 	 ( ! s . i n d e x O f ( " < t d " )   | |   ! s . i n d e x O f ( " < t h " ) )   & &  
 	 	 	 	 	 [ 3 ,   " < t a b l e > < t b o d y > < t r > " ,   " < / t r > < / t b o d y > < / t a b l e > " ]   | |  
 	 	 	 	 	  
 	 	 	 	 	 ! s . i n d e x O f ( " < c o l " )   & &  
 	 	 	 	 	 [ 2 ,   " < t a b l e > < c o l g r o u p > " ,   " < / c o l g r o u p > < / t a b l e > " ]   | |  
 	 	 	 	 	  
 	 	 	 	 	 [ 0 , " " , " " ] ;  
  
 	 	 	 	 / /   G o   t o   h t m l   a n d   b a c k ,   t h e n   p e e l   o f f   e x t r a   w r a p p e r s  
 	 	 	 	 d i v . i n n e r H T M L   =   w r a p [ 1 ]   +   a r g   +   w r a p [ 2 ] ;  
 	 	 	 	  
 	 	 	 	 / /   M o v e   t o   t h e   r i g h t   d e p t h  
 	 	 	 	 w h i l e   (   w r a p [ 0 ] - -   )  
 	 	 	 	 	 d i v   =   d i v . f i r s t C h i l d ;  
 	 	 	 	  
 	 	 	 	 / /   R e m o v e   I E ' s   a u t o i n s e r t e d   < t b o d y >   f r o m   t a b l e   f r a g m e n t s  
 	 	 	 	 i f   (   j Q u e r y . b r o w s e r . m s i e   )   {  
 	 	 	 	 	  
 	 	 	 	 	 / /   S t r i n g   w a s   a   < t a b l e > ,   * m a y *   h a v e   s p u r i o u s   < t b o d y >  
 	 	 	 	 	 i f   (   ! s . i n d e x O f ( " < t a b l e " )   & &   s . i n d e x O f ( " < t b o d y " )   <   0   )    
 	 	 	 	 	 	 t b   =   d i v . f i r s t C h i l d   & &   d i v . f i r s t C h i l d . c h i l d N o d e s ;  
 	 	 	 	 	 	  
 	 	 	 	 	 / /   S t r i n g   w a s   a   b a r e   < t h e a d >   o r   < t f o o t >  
 	 	 	 	 	 e l s e   i f   (   w r a p [ 1 ]   = =   " < t a b l e > "   & &   s . i n d e x O f ( " < t b o d y " )   <   0   )  
 	 	 	 	 	 	 t b   =   d i v . c h i l d N o d e s ;  
  
 	 	 	 	 	 f o r   (   v a r   n   =   t b . l e n g t h - 1 ;   n   > =   0   ;   - - n   )  
 	 	 	 	 	 	 i f   (   j Q u e r y . n o d e N a m e ( t b [ n ] ,   " t b o d y " )   & &   ! t b [ n ] . c h i l d N o d e s . l e n g t h   )  
 	 	 	 	 	 	 	 t b [ n ] . p a r e n t N o d e . r e m o v e C h i l d ( t b [ n ] ) ;  
 	 	 	 	 	  
 	 	 	 	 }  
 	 	 	 	  
 	 	 	 	 a r g   =   j Q u e r y . m a k e A r r a y (   d i v . c h i l d N o d e s   ) ;  
 	 	 	 }  
  
 	 	 	 i f   (   0   = = =   a r g . l e n g t h   & &   ( ! j Q u e r y . n o d e N a m e ( a r g ,   " f o r m " )   & &   ! j Q u e r y . n o d e N a m e ( a r g ,   " s e l e c t " ) )   )  
 	 	 	 	 r e t u r n ;  
  
 	 	 	 i f   (   a r g [ 0 ]   = =   u n d e f i n e d   | |   j Q u e r y . n o d e N a m e ( a r g ,   " f o r m " )   | |   a r g . o p t i o n s   )  
 	 	 	 	 r . p u s h (   a r g   ) ;  
 	 	 	 e l s e  
 	 	 	 	 r   =   j Q u e r y . m e r g e (   r ,   a r g   ) ;  
  
 	 	 } ) ;  
  
 	 	 r e t u r n   r ;  
 	 } ,  
 	  
 	 a t t r :   f u n c t i o n ( e l e m ,   n a m e ,   v a l u e ) {  
 	 	 v a r   f i x   =   j Q u e r y . i s X M L D o c ( e l e m )   ?   { }   :   j Q u e r y . p r o p s ;  
 	 	  
 	 	 / /   C e r t a i n   a t t r i b u t e s   o n l y   w o r k   w h e n   a c c e s s e d   v i a   t h e   o l d   D O M   0   w a y  
 	 	 i f   (   f i x [ n a m e ]   )   {  
 	 	 	 i f   (   v a l u e   ! =   u n d e f i n e d   )   e l e m [ f i x [ n a m e ] ]   =   v a l u e ;  
 	 	 	 r e t u r n   e l e m [ f i x [ n a m e ] ] ;  
  
 	 	 }   e l s e   i f   (   v a l u e   = =   u n d e f i n e d   & &   j Q u e r y . b r o w s e r . m s i e   & &   j Q u e r y . n o d e N a m e ( e l e m ,   " f o r m " )   & &   ( n a m e   = =   " a c t i o n "   | |   n a m e   = =   " m e t h o d " )   )  
 	 	 	 r e t u r n   e l e m . g e t A t t r i b u t e N o d e ( n a m e ) . n o d e V a l u e ;  
  
 	 	 / /   I E   e l e m . g e t A t t r i b u t e   p a s s e s   e v e n   f o r   s t y l e  
 	 	 e l s e   i f   (   e l e m . t a g N a m e   )   {  
 	 	 	  
  
 	 	 	 i f   (   v a l u e   ! =   u n d e f i n e d   )   e l e m . s e t A t t r i b u t e (   n a m e ,   v a l u e   ) ;  
 	 	 	 i f   (   j Q u e r y . b r o w s e r . m s i e   & &   / h r e f | s r c / . t e s t ( n a m e )   & &   ! j Q u e r y . i s X M L D o c ( e l e m )   )    
 	 	 	 	 r e t u r n   e l e m . g e t A t t r i b u t e (   n a m e ,   2   ) ;  
 	 	 	 r e t u r n   e l e m . g e t A t t r i b u t e (   n a m e   ) ;  
  
 	 	 / /   e l e m   i s   a c t u a l l y   e l e m . s t y l e   . . .   s e t   t h e   s t y l e  
 	 	 }   e l s e   {  
 	 	 	 / /   I E   a c t u a l l y   u s e s   f i l t e r s   f o r   o p a c i t y  
 	 	 	 i f   (   n a m e   = =   " o p a c i t y "   & &   j Q u e r y . b r o w s e r . m s i e   )   {  
 	 	 	 	 i f   (   v a l u e   ! =   u n d e f i n e d   )   {  
 	 	 	 	 	 / /   I E   h a s   t r o u b l e   w i t h   o p a c i t y   i f   i t   d o e s   n o t   h a v e   l a y o u t  
 	 	 	 	 	 / /   F o r c e   i t   b y   s e t t i n g   t h e   z o o m   l e v e l  
 	 	 	 	 	 e l e m . z o o m   =   1 ;    
 	  
 	 	 	 	 	 / /   S e t   t h e   a l p h a   f i l t e r   t o   s e t   t h e   o p a c i t y  
 	 	 	 	 	 e l e m . f i l t e r   =   ( e l e m . f i l t e r   | |   " " ) . r e p l a c e ( / a l p h a \ ( [ ^ ) ] * \ ) / , " " )   +  
 	 	 	 	 	 	 ( p a r s e F l o a t ( v a l u e ) . t o S t r i n g ( )   = =   " N a N "   ?   " "   :   " 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 . f i l t e r   ?    
 	 	 	 	 	 ( p a r s e F l o a t (   e l e m . f i l t e r . m a t c h ( / o p a c i t y = ( [ ^ ) ] * ) / ) [ 1 ]   )   /   1 0 0 ) . t o S t r i n g ( )   :   " " ;  
 	 	 	 }  
 	 	 	 n a m e   =   n a m e . r e p l a c e ( / - ( [ a - z ] ) / i g , f u n c t i o n ( z , b ) { r e t u r n   b . t o U p p e r C a s e ( ) ; } ) ;  
 	 	 	 i f   (   v a l u e   ! =   u n d e f i n e d   )   e l e m [ n a m e ]   =   v a l u e ;  
 	 	 	 r e t u r n   e l e m [ n a m e ] ;  
 	 	 }  
 	 } ,  
 	 t r i m :   f u n c t i o n ( t ) {  
 	 	 r e t u r n   t . r e p l a c e ( / ^ \ s + | \ s + $ / g ,   " " ) ;  
 	 } ,  
  
 	 m a k e A r r a y :   f u n c t i o n (   a   )   {  
 	 	 v a r   r   =   [ ] ;  
  
 	 	 / /   N e e d   t o   u s e   t y p e o f   t o   f i g h t   S a f a r i   c h i l d N o d e s   c r a s h e s  
 	 	 i f   (   t y p e o f   a   ! =   " a r r a y "   )  
 	 	 	 f o r   (   v a r   i   =   0 ,   a l   =   a . l e n g t h ;   i   <   a l ;   i + +   )  
 	 	 	 	 r . p u s h (   a [ i ]   ) ;  
 	 	 e l s e  
 	 	 	 r   =   a . s l i c e (   0   ) ;  
  
 	 	 r e t u r n   r ;  
 	 } ,  
  
 	 i n A r r a y :   f u n c t i o n (   b ,   a   )   {  
 	 	 f o r   (   v a r   i   =   0 ,   a l   =   a . l e n g t h ;   i   <   a l ;   i + +   )  
 	 	 	 i f   (   a [ i ]   = =   b   )  
 	 	 	 	 r e t u r n   i ;  
 	 	 r e t u r n   - 1 ;  
 	 } ,  
 	 m e r g e :   f u n c t i o n ( f i r s t ,   s e c o n d )   {  
 	 	 / /   W e   h a v e   t o   l o o p   t h i s   w a y   b e c a u s e   I E   &   O p e r a   o v e r w r i t e   t h e   l e n g t h  
 	 	 / /   e x p a n d o   o f   g e t E l e m e n t s B y T a g N a m e  
 	 	 f o r   (   v a r   i   =   0 ;   s e c o n d [ i ] ;   i + +   )  
 	 	 	 f i r s t . p u s h ( s e c o n d [ i ] ) ;  
 	 	 r e t u r n   f i r s t ;  
 	 } ,  
 	 u n i q u e :   f u n c t i o n ( f i r s t )   {  
 	 	 v a r   r   =   [ ] ,   n u m   =   j Q u e r y . m e r g e N u m + + ;  
  
 	 	 f o r   (   v a r   i   =   0 ,   f l   =   f i r s t . l e n g t h ;   i   <   f l ;   i + +   )  
 	 	 	 i f   (   n u m   ! =   f i r s t [ i ] . m e r g e N u m   )   {  
 	 	 	 	 f i r s t [ i ] . m e r g e N u m   =   n u m ;  
 	 	 	 	 r . p u s h ( f i r s t [ i ] ) ;  
 	 	 	 }  
  
 	 	 r e t u r n   r ;  
 	 } ,  
  
 	 m e r g e N u m :   0 ,  
 	 g r e p :   f u n c t i o n ( e l e m s ,   f n ,   i n v )   {  
 	 	 / /   I f   a   s t r i n g   i s   p a s s e d   i n   f o r   t h e   f u n c t i o n ,   m a k e   a   f u n c t i o n  
 	 	 / /   f o r   i t   ( a   h a n d y   s h o r t c u t )  
 	 	 i f   (   t y p e o f   f n   = =   " s t r i n g "   )  
 	 	 	 f n   =   n e w   F u n c t i o n ( " a " , " i " , " r e t u r n   "   +   f n ) ;  
  
 	 	 v a r   r e s u l t   =   [ ] ;  
  
 	 	 / /   G o   t h r o u g h   t h e   a r r a y ,   o n l y   s a v i n g   t h e   i t e m s  
 	 	 / /   t h a t   p a s s   t h e   v a l i d a t o r   f u n c t i o n  
 	 	 f o r   (   v a r   i   =   0 ,   e l   =   e l e m s . l e n g t h ;   i   <   e l ;   i + +   )  
 	 	 	 i f   (   ! i n v   & &   f n ( e l e m s [ i ] , i )   | |   i n v   & &   ! f n ( e l e m s [ i ] , i )   )  
 	 	 	 	 r e s u l t . p u s h (   e l e m s [ i ]   ) ;  
  
 	 	 r e t u r n   r e s u l t ;  
 	 } ,  
 	 m a p :   f u n c t i o n ( e l e m s ,   f n )   {  
 	 	 / /   I f   a   s t r i n g   i s   p a s s e d   i n   f o r   t h e   f u n c t i o n ,   m a k e   a   f u n c t i o n  
 	 	 / /   f o r   i t   ( a   h a n d y   s h o r t c u t )  
 	 	 i f   (   t y p e o f   f n   = =   " s t r i n g "   )  
 	 	 	 f n   =   n e w   F u n c t i o n ( " a " , " r e t u r n   "   +   f n ) ;  
  
 	 	 v a r   r e s u l t   =   [ ] ;  
  
 	 	 / /   G o   t h r o u g h   t h e   a r r a y ,   t r a n s l a t i n g   e a c h   o f   t h e   i t e m s   t o   t h e i r  
 	 	 / /   n e w   v a l u e   ( o r   v a l u e s ) .  
 	 	 f o r   (   v a r   i   =   0 ,   e l   =   e l e m s . l e n g t h ;   i   <   e l ;   i + +   )   {  
 	 	 	 v a r   v a l   =   f n ( e l e m s [ i ] , i ) ;  
  
 	 	 	 i f   (   v a l   ! = =   n u l l   & &   v a l   ! =   u n d e f i n e d   )   {  
 	 	 	 	 i f   (   v a l . c o n s t r u c t o r   ! =   A r r a y   )   v a l   =   [ v a l ] ;  
 	 	 	 	 r e s u l t   =   r e s u l t . c o n c a t (   v a l   ) ;  
 	 	 	 }  
 	 	 }  
  
 	 	 r e t u r n   r e s u l t ;  
 	 }  
 } ) ;  
    
 / *  
   *   W h e t h e r   t h e   W 3 C   c o m p l i a n t   b o x   m o d e l   i s   b e i n g   u s e d .  
   *  
   *   @ p r o p e r t y  
   *   @ n a m e   $ . b o x M o d e l  
   *   @ t y p e   B o o l e a n  
   *   @ c a t   J a v a S c r i p t  
   * /  
 n e w   f u n c t i o n ( )   {  
 	 v a r   b   =   n a v i g a t o r . u s e r A g e n t . t o L o w e r C a s e ( ) ;  
  
 	 / /   F i g u r e   o u t   w h a t   b r o w s e r   i s   b e i n g   u s e d  
 	 j Q u e r y . b r o w s e r   =   {  
 	 	 v e r s i o n :   ( b . m a t c h ( / . + ( ? : r v | i t | r a | i e ) [ \ / :   ] ( [ \ d . ] + ) / )   | |   [ ] ) [ 1 ] ,  
 	 	 s a f a r i :   / w e b k i t / . t e s t ( b ) ,  
 	 	 o p e r a :   / o p e r a / . t e s t ( b ) ,  
 	 	 m s i e :   / m s i e / . t e s t ( b )   & &   ! / o p e r a / . t e s t ( b ) ,  
 	 	 m o z i l l a :   / m o z i l l a / . t e s t ( b )   & &   ! / ( c o m p a t i b l e | w e b k i t ) / . t e s t ( b )  
 	 } ;  
  
 	 / /   C h e c k   t o   s e e   i f   t h e   W 3 C   b o x   m o d e l   i s   b e i n g   u s e d  
 	 j Q u e r y . b o x M o d e l   =   ! j Q u e r y . b r o w s e r . m s i e   | |   d o c u m e n t . c o m p a t M o d e   = =   " C S S 1 C o m p a t " ;  
  
 	 j Q u e r y . s t y l e F l o a t   =   j Q u e r y . b r o w s e r . m s i e   ?   " s t y l e F l o a t "   :   " c s s F l o a t " ,  
  
 	 j Q u e r y . p r o p s   =   {  
 	 	 " f o r " :   " h t m l F o r " ,  
 	 	 " c l a s s " :   " c l a s s N a m e " ,  
 	 	 " f l o a t " :   j Q u e r y . s t y l e F l o a t ,  
 	 	 c s s F l o a t :   j Q u e r y . s t y l e F l o a t ,  
 	 	 s t y l e F l o a t :   j Q u e r y . s t y l e F l o a t ,  
 	 	 i n n e r H T M L :   " i n n e r H T M L " ,  
 	 	 c l a s s N a m e :   " c l a s s N a m e " ,  
 	 	 v a l u e :   " v a l u e " ,  
 	 	 d i s a b l e d :   " d i s a b l e d " ,  
 	 	 c h e c k e d :   " c h e c k e d " ,  
 	 	 r e a d o n l y :   " r e a d O n l y " ,  
 	 	 s e l e c t e d :   " s e l e c t e d " ,  
 	 	 m a x l e n g t h :   " m a x L e n g t h "  
 	 } ;  
 } ;  
  
 j Q u e r y . e a c h ( {  
 	 p a r e n t :   " a . p a r e n t N o d e " ,  
 	 p a r e n t s :   " j Q u e r y . p a r e n t s ( a ) " ,  
 	 n e x t :   " j Q u e r y . n t h ( a , 2 , ' n e x t S i b l i n g ' ) " ,  
 	 p r e v :   " j Q u e r y . n t h ( a , 2 , ' p r e v i o u s S i b l i n g ' ) " ,  
 	 s i b l i n g s :   " j Q u e r y . s i b l i n g ( a . p a r e n t N o d e . f i r s t C h i l d , a ) " ,  
 	 c h i l d r e n :   " j Q u e r y . s i b l i n g ( a . f i r s t C h i l d ) "  
 } ,   f u n c t i o n ( i , n ) {  
 	 j Q u e r y . f n [   i   ]   =   f u n c t i o n ( a )   {  
 	 	 v a r   r e t   =   j Q u e r y . m a p ( t h i s , n ) ;  
 	 	 i f   (   a   & &   t y p e o f   a   = =   " s t r i n g "   )  
 	 	 	 r e t   =   j Q u e r y . m u l t i F i l t e r ( a , r e t ) ;  
 	 	 r e t u r n   t h i s . p u s h S t a c k (   r e t   ) ;  
 	 } ;  
 } ) ;  
  
 j Q u e r y . e a c h ( {  
 	 a p p e n d T o :   " a p p e n d " ,  
 	 p r e p e n d T o :   " p r e p e n d " ,  
 	 i n s e r t B e f o r e :   " b e f o r e " ,  
 	 i n s e r t A f t e r :   " a f t e r "  
 } ,   f u n c t i o n ( i , n ) {  
 	 j Q u e r y . f n [   i   ]   =   f u n c t i o n ( ) {  
 	 	 v a r   a   =   a r g u m e n t s ;  
 	 	 r e t u r n   t h i s . e a c h ( f u n c t i o n ( ) {  
 	 	 	 f o r   (   v a r   j   =   0 ,   a l   =   a . l e n g t h ;   j   <   a l ;   j + +   )  
 	 	 	 	 j Q u e r y ( a [ j ] ) [ n ] (   t h i s   ) ;  
 	 	 } ) ;  
 	 } ;  
 } ) ;  
  
 j Q u e r y . e a c h (   {  
 	 r e m o v e A t t r :   f u n c t i o n (   k e y   )   {  
 	 	 j Q u e r y . a t t r (   t h i s ,   k e y ,   " "   ) ;  
 	 	 t h i s . r e m o v e A t t r i b u t e (   k e y   ) ;  
 	 } ,  
 	 a d d C l a s s :   f u n c t i o n ( c ) {  
 	 	 j Q u e r y . c l a s s N a m e . a d d ( t h i s , c ) ;  
 	 } ,  
 	 r e m o v e C l a s s :   f u n c t i o n ( c ) {  
 	 	 j Q u e r y . c l a s s N a m e . r e m o v e ( t h i s , c ) ;  
 	 } ,  
 	 t o g g l e C l a s s :   f u n c t i o n (   c   ) {  
 	 	 j Q u e r y . c l a s s N a m e [   j Q u e r y . c l a s s N a m e . h a s ( t h i s , c )   ?   " r e m o v e "   :   " a d d "   ] ( t h i s ,   c ) ;  
 	 } ,  
 	 r e m o v e :   f u n c t i o n ( a ) {  
 	 	 i f   (   ! a   | |   j Q u e r y . f i l t e r (   a ,   [ t h i s ]   ) . r . l e n g t h   )  
 	 	 	 t h i s . p a r e n t N o d e . r e m o v e C h i l d (   t h i s   ) ;  
 	 } ,  
 	 e m p t y :   f u n c t i o n ( )   {  
 	 	 w h i l e   (   t h i s . f i r s t C h i l d   )  
 	 	 	 t h i s . r e m o v e C h i l d (   t h i s . f i r s t C h i l d   ) ;  
 	 }  
 } ,   f u n c t i o n ( i , n ) {  
 	 j Q u e r y . f n [   i   ]   =   f u n c t i o n ( )   {  
 	 	 r e t u r n   t h i s . e a c h (   n ,   a r g u m e n t s   ) ;  
 	 } ;  
 } ) ;  
  
 j Q u e r y . e a c h (   [   " e q " ,   " l t " ,   " g t " ,   " c o n t a i n s "   ] ,   f u n c t i o n ( i , n ) {  
 	 j Q u e r y . f n [   n   ]   =   f u n c t i o n ( n u m , f n )   {  
 	 	 r e t u r n   t h i s . f i l t e r (   " : "   +   n   +   " ( "   +   n u m   +   " ) " ,   f n   ) ;  
 	 } ;  
 } ) ;  
  
 j Q u e r y . e a c h (   [   " h e i g h t " ,   " w i d t h "   ] ,   f u n c t i o n ( i , n ) {  
 	 j Q u e r y . f n [   n   ]   =   f u n c t i o n ( h )   {  
 	 	 r e t u r n   h   = =   u n d e f i n e d   ?  
 	 	 	 (   t h i s . l e n g t h   ?   j Q u e r y . c s s (   t h i s [ 0 ] ,   n   )   :   n u l l   )   :  
 	 	 	 t h i s . c s s (   n ,   h . c o n s t r u c t o r   = =   S t r i n g   ?   h   :   h   +   " p x "   ) ;  
 	 } ;  
 } ) ;  
 j Q u e r y . e x t e n d ( {  
 	 e x p r :   {  
 	 	 " " :   " m [ 2 ] = = ' * ' | | j Q u e r y . n o d e N a m e ( a , m [ 2 ] ) " ,  
 	 	 " # " :   " a . g e t A t t r i b u t e ( ' i d ' ) = = m [ 2 ] " ,  
 	 	 " : " :   {  
 	 	 	 / /   P o s i t i o n   C h e c k s  
 	 	 	 l t :   " i < m [ 3 ] - 0 " ,  
 	 	 	 g t :   " i > m [ 3 ] - 0 " ,  
 	 	 	 n t h :   " m [ 3 ] - 0 = = i " ,  
 	 	 	 e q :   " m [ 3 ] - 0 = = i " ,  
 	 	 	 f i r s t :   " i = = 0 " ,  
 	 	 	 l a s t :   " i = = r . l e n g t h - 1 " ,  
 	 	 	 e v e n :   " i % 2 = = 0 " ,  
 	 	 	 o d d :   " i % 2 " ,  
  
 	 	 	 / /   C h i l d   C h e c k s  
 	 	 	 " f i r s t - c h i l d " :   " a . p a r e n t N o d e . g e t E l e m e n t s B y T a g N a m e ( ' * ' ) [ 0 ] = = a " ,  
 	 	 	 " l a s t - c h i l d " :   " j Q u e r y . n t h ( a . p a r e n t N o d e . l a s t C h i l d , 1 , ' p r e v i o u s S i b l i n g ' ) = = a " ,  
 	 	 	 " o n l y - c h i l d " :   " ! j Q u e r y . n t h ( a . p a r e n t N o d e . l a s t C h i l d , 2 , ' p r e v i o u s S i b l i n g ' ) " ,  
  
 	 	 	 / /   P a r e n t   C h e c k s  
 	 	 	 p a r e n t :   " a . f i r s t C h i l d " ,  
 	 	 	 e m p t y :   " ! a . f i r s t C h i l d " ,  
  
 	 	 	 / /   T e x t   C h e c k  
 	 	 	 c o n t a i n s :   " ( a . t e x t C o n t e n t | | a . i n n e r T e x t | | ' ' ) . i n d e x O f ( m [ 3 ] ) > = 0 " ,  
  
 	 	 	 / /   V i s i b i l i t y  
 	 	 	 v i s i b l e :   ' " h i d d e n " ! = a . t y p e & & j Q u e r y . c s s ( a , " d i s p l a y " ) ! = " n o n e " & & j Q u e r y . c s s ( a , " v i s i b i l i t y " ) ! = " h i d d e n " ' ,  
 	 	 	 h i d d e n :   ' " h i d d e n " = = a . t y p e | | j Q u e r y . c s s ( a , " d i s p l a y " ) = = " n o n e " | | j Q u e r y . c s s ( a , " v i s i b i l i t y " ) = = " h i d d e n " ' ,  
  
 	 	 	 / /   F o r m   a t t r i b u t e s  
 	 	 	 e n a b l e d :   " ! a . d i s a b l e d " ,  
 	 	 	 d i s a b l e d :   " a . d i s a b l e d " ,  
 	 	 	 c h e c k e d :   " a . c h e c k e d " ,  
 	 	 	 s e l e c t e d :   " a . s e l e c t e d | | j Q u e r y . a t t r ( a , ' s e l e c t e d ' ) " ,  
  
 	 	 	 / /   F o r m   e l e m e n t s  
 	 	 	 t e x t :   " ' t e x t ' = = a . t y p e " ,  
 	 	 	 r a d i o :   " ' r a d i o ' = = a . t y p e " ,  
 	 	 	 c h e c k b o x :   " ' c h e c k b o x ' = = a . t y p e " ,  
 	 	 	 f i l e :   " ' f i l e ' = = a . t y p e " ,  
 	 	 	 p a s s w o r d :   " ' p a s s w o r d ' = = a . t y p e " ,  
 	 	 	 s u b m i t :   " ' s u b m i t ' = = a . t y p e " ,  
 	 	 	 i m a g e :   " ' i m a g e ' = = a . t y p e " ,  
 	 	 	 r e s e t :   " ' r e s e t ' = = a . t y p e " ,  
 	 	 	 b u t t o n :   ' " b u t t o n " = = a . t y p e | | j Q u e r y . n o d e N a m e ( a , " b u t t o n " ) ' ,  
 	 	 	 i n p u t :   " / i n p u t | s e l e c t | t e x t a r e a | b u t t o n / i . t e s t ( a . n o d e N a m e ) "  
 	 	 } ,  
 	 	 " [ " :   " j Q u e r y . f i n d ( m [ 2 ] , a ) . l e n g t h "  
 	 } ,  
 	  
 	 / /   T h e   r e g u l a r   e x p r e s s i o n s   t h a t   p o w e r   t h e   p a r s i n g   e n g i n e  
 	 p a r s e :   [  
 	 	 / /   M a t c h :   [ @ v a l u e = ' t e s t ' ] ,   [ @ f o o ]  
 	 	 / ^ \ [   * ( @ ) ( [ \ w - ] + )   * ( [ ! * $ ^ ~ = ] * )   * ( ' ? " ? ) ( . * ? ) \ 4   * \ ] / ,  
  
 	 	 / /   M a t c h :   [ d i v ] ,   [ d i v   p ]  
 	 	 / ^ ( \ [ ) \ s * ( . * ? ( \ [ . * ? \ ] ) ? [ ^ [ ] * ? ) \ s * \ ] / ,  
  
 	 	 / /   M a t c h :   : c o n t a i n s ( ' f o o ' )  
 	 	 / ^ ( : ) ( [ \ w - ] + ) \ ( " ? ' ? ( . * ? ( \ ( . * ? \ ) ) ? [ ^ ( ] * ? ) " ? ' ? \ ) / ,  
  
 	 	 / /   M a t c h :   : e v e n ,   : l a s t - c h l i d ,   # i d ,   . c l a s s  
 	 	 n e w   R e g E x p ( " ^ ( [ : . # ] * ) ( "   +    
 	 	 	 (   j Q u e r y . c h a r s   =   j Q u e r y . b r o w s e r . s a f a r i   & &   j Q u e r y . b r o w s e r . v e r s i o n   <   " 3 . 0 . 0 "   ?   " \ \ w "   :   " ( ? : [ \ \ w \ u 0 1 2 8 - \ u F F F F * _ - ] | \ \ \ \ . ) "   )   +   " + ) " )  
 	 ] ,  
  
 	 m u l t i F i l t e r :   f u n c t i o n (   e x p r ,   e l e m s ,   n o t   )   {  
 	 	 v a r   o l d ,   c u r   =   [ ] ;  
  
 	 	 w h i l e   (   e x p r   & &   e x p r   ! =   o l d   )   {  
 	 	 	 o l d   =   e x p r ;  
 	 	 	 v a r   f   =   j Q u e r y . f i l t e r (   e x p r ,   e l e m s ,   n o t   ) ;  
 	 	 	 e x p r   =   f . t . r e p l a c e ( / ^ \ s * , \ s * / ,   " "   ) ;  
 	 	 	 c u r   =   n o t   ?   e l e m s   =   f . r   :   j Q u e r y . m e r g e (   c u r ,   f . r   ) ;  
 	 	 }  
  
 	 	 r e t u r n   c u r ;  
 	 } ,  
 	 f i n d :   f u n c t i o n (   t ,   c o n t e x t   )   {  
 	 	 / /   Q u i c k l y   h a n d l e   n o n - s t r i n g   e x p r e s s i o n s  
 	 	 i f   (   t y p e o f   t   ! =   " s t r i n g "   )  
 	 	 	 r e t u r n   [   t   ] ;  
  
 	 	 / /   M a k e   s u r e   t h a t   t h e   c o n t e x t   i s   a   D O M   E l e m e n t  
 	 	 i f   (   c o n t e x t   & &   ! c o n t e x t . n o d e T y p e   )  
 	 	 	 c o n t e x t   =   n u l l ;  
  
 	 	 / /   S e t   t h e   c o r r e c t   c o n t e x t   ( i f   n o n e   i s   p r o v i d e d )  
 	 	 c o n t e x t   =   c o n t e x t   | |   d o c u m e n t ;  
  
 	 	 / /   H a n d l e   t h e   c o m m o n   X P a t h   / /   e x p r e s s i o n  
 	 	 i f   (   ! t . i n d e x O f ( " / / " )   )   {  
 	 	 	 c o n t e x t   =   c o n t e x t . d o c u m e n t E l e m e n t ;  
 	 	 	 t   =   t . s u b s t r ( 2 , t . l e n g t h ) ;  
  
 	 	 / /   A n d   t h e   /   r o o t   e x p r e s s i o n  
 	 	 }   e l s e   i f   (   ! t . i n d e x O f ( " / " )   & &   ! c o n t e x t . o w n e r D o c u m e n t   )   {  
 	 	 	 c o n t e x t   =   c o n t e x t . d o c u m e n t E l e m e n t ;  
 	 	 	 t   =   t . s u b s t r ( 1 , t . l e n g t h ) ;  
 	 	 	 i f   (   t . i n d e x O f ( " / " )   > =   1   )  
 	 	 	 	 t   =   t . s u b s t r ( t . i n d e x O f ( " / " ) , t . l e n g t h ) ;  
 	 	 }  
  
 	 	 / /   I n i t i a l i z e   t h e   s e a r c h  
 	 	 v a r   r e t   =   [ c o n t e x t ] ,   d o n e   =   [ ] ,   l a s t ;  
  
 	 	 / /   C o n t i n u e   w h i l e   a   s e l e c t o r   e x p r e s s i o n   e x i s t s ,   a n d   w h i l e  
 	 	 / /   w e ' r e   n o   l o n g e r   l o o p i n g   u p o n   o u r s e l v e s  
 	 	 w h i l e   (   t   & &   l a s t   ! =   t   )   {  
 	 	 	 v a r   r   =   [ ] ;  
 	 	 	 l a s t   =   t ;  
  
 	 	 	 t   =   j Q u e r y . t r i m ( t ) . r e p l a c e (   / ^ \ / \ / / ,   " "   ) ;  
  
 	 	 	 v a r   f o u n d T o k e n   =   f a l s e ;  
  
 	 	 	 / /   A n   a t t e m p t   a t   s p e e d i n g   u p   c h i l d   s e l e c t o r s   t h a t  
 	 	 	 / /   p o i n t   t o   a   s p e c i f i c   e l e m e n t   t a g  
 	 	 	 v a r   r e   =   n e w   R e g E x p ( " ^ [ / > ] \ \ s * ( "   +   j Q u e r y . c h a r s   +   " + ) " ) ;  
 	 	 	 v a r   m   =   r e . e x e c ( t ) ;  
  
 	 	 	 i f   (   m   )   {  
 	 	 	 	 v a r   n o d e N a m e   =   m [ 1 ] . t o U p p e r C a s e ( ) ;  
  
 	 	 	 	 / /   P e r f o r m   o u r   o w n   i t e r a t i o n   a n d   f i l t e r  
 	 	 	 	 f o r   (   v a r   i   =   0 ;   r e t [ i ] ;   i + +   )  
 	 	 	 	 	 f o r   (   v a r   c   =   r e t [ i ] . f i r s t C h i l d ;   c ;   c   =   c . n e x t S i b l i n g   )  
 	 	 	 	 	 	 i f   (   c . n o d e T y p e   = =   1   & &   ( n o d e N a m e   = =   " * "   | |   c . n o d e N a m e . t o U p p e r C a s e ( )   = =   n o d e N a m e . t o U p p e r C a s e ( ) )   )  
 	 	 	 	 	 	 	 r . p u s h (   c   ) ;  
  
 	 	 	 	 r e t   =   r ;  
 	 	 	 	 t   =   t . r e p l a c e (   r e ,   " "   ) ;  
 	 	 	 	 i f   (   t . i n d e x O f ( "   " )   = =   0   )   c o n t i n u e ;  
 	 	 	 	 f o u n d T o k e n   =   t r u e ;  
 	 	 	 }   e l s e   {  
 	 	 	 	 r e   =   / ^ ( ( \ / ? \ . \ . ) | ( [ > \ / + ~ ] ) ) \ s * ( [ a - z ] * ) / i ;  
  
 	 	 	 	 i f   (   ( m   =   r e . e x e c ( t ) )   ! =   n u l l   )   {  
 	 	 	 	 	 r   =   [ ] ;  
  
 	 	 	 	 	 v a r   n o d e N a m e   =   m [ 4 ] ,   m e r g e N u m   =   j Q u e r y . m e r g e N u m + + ;  
 	 	 	 	 	 m   =   m [ 1 ] ;  
  
 	 	 	 	 	 f o r   (   v a r   j   =   0 ,   r l   =   r e t . l e n g t h ;   j   <   r l ;   j + +   )  
 	 	 	 	 	 	 i f   (   m . i n d e x O f ( " . . " )   <   0   )   {  
 	 	 	 	 	 	 	 v a r   n   =   m   = =   " ~ "   | |   m   = =   " + "   ?   r e t [ j ] . n e x t S i b l i n g   :   r e t [ j ] . f i r s t C h i l d ;  
 	 	 	 	 	 	 	 f o r   (   ;   n ;   n   =   n . n e x t S i b l i n g   )  
 	 	 	 	 	 	 	 	 i f   (   n . n o d e T y p e   = =   1   )   {  
 	 	 	 	 	 	 	 	 	 i f   (   m   = =   " ~ "   & &   n . m e r g e N u m   = =   m e r g e N u m   )   b r e a k ;  
 	 	 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	 	 i f   ( ! n o d e N a m e   | |   n . n o d e N a m e . t o U p p e r C a s e ( )   = =   n o d e N a m e . t o U p p e r C a s e ( )   )   {  
 	 	 	 	 	 	 	 	 	 	 i f   (   m   = =   " ~ "   )   n . m e r g e N u m   =   m e r g e N u m ;  
 	 	 	 	 	 	 	 	 	 	 r . p u s h (   n   ) ;  
 	 	 	 	 	 	 	 	 	 }  
 	 	 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	 	 i f   (   m   = =   " + "   )   b r e a k ;  
 	 	 	 	 	 	 	 	 }  
 	 	 	 	 	 	 }   e l s e  
 	 	 	 	 	 	 	 r . p u s h (   r e t [ j ] . p a r e n t N o d e   ) ;  
  
 	 	 	 	 	 r e t   =   r ;  
  
 	 	 	 	 	 / /   A n d   r e m o v e   t h e   t o k e n  
 	 	 	 	 	 t   =   j Q u e r y . t r i m (   t . r e p l a c e (   r e ,   " "   )   ) ;  
 	 	 	 	 	 f o u n d T o k e n   =   t r u e ;  
 	 	 	 	 }  
 	 	 	 }  
  
 	 	 	 / /   S e e   i f   t h e r e ' s   s t i l l   a n   e x p r e s s i o n ,   a n d   t h a t   w e   h a v e n ' t   a l r e a d y  
 	 	 	 / /   m a t c h e d   a   t o k e n  
 	 	 	 i f   (   t   & &   ! f o u n d T o k e n   )   {  
 	 	 	 	 / /   H a n d l e   m u l t i p l e   e x p r e s s i o n s  
 	 	 	 	 i f   (   ! t . i n d e x O f ( " , " )   )   {  
 	 	 	 	 	 / /   C l e a n   t h e   r e s u l t   s e t  
 	 	 	 	 	 i f   (   c o n t e x t   = =   r e t [ 0 ]   )   r e t . s h i f t ( ) ;  
  
 	 	 	 	 	 / /   M e r g e   t h e   r e s u l t   s e t s  
 	 	 	 	 	 d o n e   =   j Q u e r y . m e r g e (   d o n e ,   r e t   ) ;  
  
 	 	 	 	 	 / /   R e s e t   t h e   c o n t e x t  
 	 	 	 	 	 r   =   r e t   =   [ c o n t e x t ] ;  
  
 	 	 	 	 	 / /   T o u c h   u p   t h e   s e l e c t o r   s t r i n g  
 	 	 	 	 	 t   =   "   "   +   t . s u b s t r ( 1 , t . l e n g t h ) ;  
  
 	 	 	 	 }   e l s e   {  
 	 	 	 	 	 / /   O p t o m i z e   f o r   t h e   c a s e   n o d e N a m e # i d N a m e  
 	 	 	 	 	 v a r   r e 2   =   n e w   R e g E x p ( " ^ ( "   +   j Q u e r y . c h a r s   +   " + ) ( # ) ( "   +   j Q u e r y . c h a r s   +   " + ) " ) ;  
 	 	 	 	 	 v a r   m   =   r e 2 . e x e c ( t ) ;  
 	 	 	 	 	  
 	 	 	 	 	 / /   R e - o r g a n i z e   t h e   r e s u l t s ,   s o   t h a t   t h e y ' r e   c o n s i s t e n t  
 	 	 	 	 	 i f   (   m   )   {  
 	 	 	 	 	       m   =   [   0 ,   m [ 2 ] ,   m [ 3 ] ,   m [ 1 ]   ] ;  
  
 	 	 	 	 	 }   e l s e   {  
 	 	 	 	 	 	 / /   O t h e r w i s e ,   d o   a   t r a d i t i o n a l   f i l t e r   c h e c k   f o r  
 	 	 	 	 	 	 / /   I D ,   c l a s s ,   a n d   e l e m e n t   s e l e c t o r s  
 	 	 	 	 	 	 r e 2   =   n e w   R e g E x p ( " ^ ( [ # . ] ? ) ( "   +   j Q u e r y . c h a r s   +   " * ) " ) ;  
 	 	 	 	 	 	 m   =   r e 2 . e x e c ( t ) ;  
 	 	 	 	 	 }  
  
 	 	 	 	 	 m [ 2 ]   =   m [ 2 ] . r e p l a c e ( / \ \ / g ,   " " ) ;  
  
 	 	 	 	 	 v a r   e l e m   =   r e t [ r e t . l e n g t h - 1 ] ;  
  
 	 	 	 	 	 / /   T r y   t o   d o   a   g l o b a l   s e a r c h   b y   I D ,   w h e r e   w e   c a n  
 	 	 	 	 	 i f   (   m [ 1 ]   = =   " # "   & &   e l e m   & &   e l e m . g e t E l e m e n t B y I d   )   {  
 	 	 	 	 	 	 / /   O p t i m i z a t i o n   f o r   H T M L   d o c u m e n t   c a s e  
 	 	 	 	 	 	 v a r   o i d   =   e l e m . g e t E l e m e n t B y I d ( m [ 2 ] ) ;  
 	 	 	 	 	 	  
 	 	 	 	 	 	 / /   D o   a   q u i c k   c h e c k   f o r   t h e   e x i s t e n c e   o f   t h e   a c t u a l   I D   a t t r i b u t e  
 	 	 	 	 	 	 / /   t o   a v o i d   s e l e c t i n g   b y   t h e   n a m e   a t t r i b u t e   i n   I E  
 	 	 	 	 	 	 / /   a l s o   c h e c k   t o   i n s u r e   i d   i s   a   s t r i n g   t o   a v o i d   s e l e c t i n g   a n   e l e m e n t   w i t h   t h e   n a m e   o f   ' i d '   i n s i d e   a   f o r m  
 	 	 	 	 	 	 i f   (   ( j Q u e r y . b r o w s e r . m s i e | | j Q u e r y . b r o w s e r . o p e r a )   & &   o i d   & &   t y p e o f   o i d . i d   = =   " s t r i n g "   & &   o i d . i d   ! =   m [ 2 ]   )  
 	 	 	 	 	 	 	 o i d   =   j Q u e r y ( ' [ @ i d = " ' + m [ 2 ] + ' " ] ' ,   e l e m ) [ 0 ] ;  
  
 	 	 	 	 	 	 / /   D o   a   q u i c k   c h e c k   f o r   n o d e   n a m e   ( w h e r e   a p p l i c a b l e )   s o  
 	 	 	 	 	 	 / /   t h a t   d i v # f o o   s e a r c h e s   w i l l   b e   r e a l l y   f a s t  
 	 	 	 	 	 	 r e t   =   r   =   o i d   & &   ( ! m [ 3 ]   | |   j Q u e r y . n o d e N a m e ( o i d ,   m [ 3 ] ) )   ?   [ o i d ]   :   [ ] ;  
 	 	 	 	 	 }   e l s e   {  
 	 	 	 	 	 	 / /   W e   n e e d   t o   f i n d   a l l   d e s c e n d a n t   e l e m e n t s  
 	 	 	 	 	 	 f o r   (   v a r   i   =   0 ;   r e t [ i ] ;   i + +   )   {  
 	 	 	 	 	 	 	 / /   G r a b   t h e   t a g   n a m e   b e i n g   s e a r c h e d   f o r  
 	 	 	 	 	 	 	 v a r   t a g   =   m [ 1 ]   ! =   " "   | |   m [ 0 ]   = =   " "   ?   " * "   :   m [ 2 ] ;  
  
 	 	 	 	 	 	 	 / /   H a n d l e   I E 7   b e i n g   r e a l l y   d u m b   a b o u t   < o b j e c t > s  
 	 	 	 	 	 	 	 i f   (   t a g   = =   " * "   & &   r e t [ i ] . n o d e N a m e . t o L o w e r C a s e ( )   = =   " o b j e c t "   )  
 	 	 	 	 	 	 	 	 t a g   =   " p a r a m " ;  
  
 	 	 	 	 	 	 	 r   =   j Q u e r y . m e r g e (   r ,   r e t [ i ] . g e t E l e m e n t s B y T a g N a m e (   t a g   ) ) ;  
 	 	 	 	 	 	 }  
  
 	 	 	 	 	 	 / /   I t ' s   f a s t e r   t o   f i l t e r   b y   c l a s s   a n d   b e   d o n e   w i t h   i t  
 	 	 	 	 	 	 i f   (   m [ 1 ]   = =   " . "   )  
 	 	 	 	 	 	 	 r   =   j Q u e r y . c l a s s F i l t e r (   r ,   m [ 2 ]   ) ;  
  
 	 	 	 	 	 	 / /   S a m e   w i t h   I D   f i l t e r i n g  
 	 	 	 	 	 	 i f   (   m [ 1 ]   = =   " # "   )   {  
 	 	 	 	 	 	 	 v a r   t m p   =   [ ] ;  
  
 	 	 	 	 	 	 	 / /   T r y   t o   f i n d   t h e   e l e m e n t   w i t h   t h e   I D  
 	 	 	 	 	 	 	 f o r   (   v a r   i   =   0 ;   r [ i ] ;   i + +   )  
 	 	 	 	 	 	 	 	 i f   (   r [ i ] . g e t A t t r i b u t e ( " i d " )   = =   m [ 2 ]   )   {  
 	 	 	 	 	 	 	 	 	 t m p   =   [   r [ i ]   ] ;  
 	 	 	 	 	 	 	 	 	 b r e a k ;  
 	 	 	 	 	 	 	 	 }  
  
 	 	 	 	 	 	 	 r   =   t m p ;  
 	 	 	 	 	 	 }  
  
 	 	 	 	 	 	 r e t   =   r ;  
 	 	 	 	 	 }  
  
 	 	 	 	 	 t   =   t . r e p l a c e (   r e 2 ,   " "   ) ;  
 	 	 	 	 }  
  
 	 	 	 }  
  
 	 	 	 / /   I f   a   s e l e c t o r   s t r i n g   s t i l l   e x i s t s  
 	 	 	 i f   (   t   )   {  
 	 	 	 	 / /   A t t e m p t   t o   f i l t e r   i t  
 	 	 	 	 v a r   v a l   =   j Q u e r y . f i l t e r ( t , r ) ;  
 	 	 	 	 r e t   =   r   =   v a l . r ;  
 	 	 	 	 t   =   j Q u e r y . t r i m ( v a l . t ) ;  
 	 	 	 }  
 	 	 }  
  
 	 	 / /   A n   e r r o r   o c c u r r e d   w i t h   t h e   s e l e c t o r ;  
 	 	 / /   j u s t   r e t u r n   a n   e m p t y   s e t   i n s t e a d  
 	 	 i f   (   t   )  
 	 	 	 r e t   =   [ ] ;  
  
 	 	 / /   R e m o v e   t h e   r o o t   c o n t e x t  
 	 	 i f   (   r e t   & &   c o n t e x t   = =   r e t [ 0 ]   )  
 	 	 	 r e t . s h i f t ( ) ;  
  
 	 	 / /   A n d   c o m b i n e   t h e   r e s u l t s  
 	 	 d o n e   =   j Q u e r y . m e r g e (   d o n e ,   r e t   ) ;  
  
 	 	 r e t u r n   d o n e ;  
 	 } ,  
  
 	 c l a s s F i l t e r :   f u n c t i o n ( r , m , n o t ) {  
 	 	 m   =   "   "   +   m   +   "   " ;  
 	 	 v a r   t m p   =   [ ] ;  
 	 	 f o r   (   v a r   i   =   0 ;   r [ i ] ;   i + +   )   {  
 	 	 	 v a r   p a s s   =   ( "   "   +   r [ i ] . c l a s s N a m e   +   "   " ) . i n d e x O f (   m   )   > =   0 ;  
 	 	 	 i f   (   ! n o t   & &   p a s s   | |   n o t   & &   ! p a s s   )  
 	 	 	 	 t m p . p u s h (   r [ i ]   ) ;  
 	 	 }  
 	 	 r e t u r n   t m p ;  
 	 } ,  
  
 	 f i l t e r :   f u n c t i o n ( t , r , n o t )   {  
 	 	 v a r   l a s t ;  
  
 	 	 / /   L o o k   f o r   c o m m o n   f i l t e r   e x p r e s s i o n s  
 	 	 w h i l e   (   t     & &   t   ! =   l a s t   )   {  
 	 	 	 l a s t   =   t ;  
  
 	 	 	 v a r   p   =   j Q u e r y . p a r s e ,   m ;  
  
 	 	 	 f o r   (   v a r   i   =   0 ;   p [ i ] ;   i + +   )   {  
 	 	 	 	 m   =   p [ i ] . e x e c (   t   ) ;  
  
 	 	 	 	 i f   (   m   )   {  
 	 	 	 	 	 / /   R e m o v e   w h a t   w e   j u s t   m a t c h e d  
 	 	 	 	 	 t   =   t . s u b s t r i n g (   m [ 0 ] . l e n g t h   ) ;  
  
 	 	 	 	 	 m [ 2 ]   =   m [ 2 ] . r e p l a c e ( / \ \ / g ,   " " ) ;  
 	 	 	 	 	 b r e a k ;  
 	 	 	 	 }  
 	 	 	 }  
  
 	 	 	 i f   (   ! m   )  
 	 	 	 	 b r e a k ;  
  
 	 	 	 / /   : n o t ( )   i s   a   s p e c i a l   c a s e   t h a t   c a n   b e   o p t i m i z e d   b y  
 	 	 	 / /   k e e p i n g   i t   o u t   o f   t h e   e x p r e s s i o n   l i s t  
 	 	 	 i f   (   m [ 1 ]   = =   " : "   & &   m [ 2 ]   = =   " n o t "   )  
 	 	 	 	 r   =   j Q u e r y . f i l t e r ( m [ 3 ] ,   r ,   t r u e ) . r ;  
  
 	 	 	 / /   W e   c a n   g e t   a   b i g   s p e e d   b o o s t   b y   f i l t e r i n g   b y   c l a s s   h e r e  
 	 	 	 e l s e   i f   (   m [ 1 ]   = =   " . "   )  
 	 	 	 	 r   =   j Q u e r y . c l a s s F i l t e r ( r ,   m [ 2 ] ,   n o t ) ;  
  
 	 	 	 e l s e   i f   (   m [ 1 ]   = =   " @ "   )   {  
 	 	 	 	 v a r   t m p   =   [ ] ,   t y p e   =   m [ 3 ] ;  
 	 	 	 	  
 	 	 	 	 f o r   (   v a r   i   =   0 ,   r l   =   r . l e n g t h ;   i   <   r l ;   i + +   )   {  
 	 	 	 	 	 v a r   a   =   r [ i ] ,   z   =   a [   j Q u e r y . p r o p s [ m [ 2 ] ]   | |   m [ 2 ]   ] ;  
 	 	 	 	 	  
 	 	 	 	 	 i f   (   z   = =   n u l l   | |   / h r e f | s r c / . t e s t ( m [ 2 ] )   )  
 	 	 	 	 	 	 z   =   j Q u e r y . a t t r ( a , m [ 2 ] )   | |   ' ' ;  
  
 	 	 	 	 	 i f   (   ( t y p e   = =   " "   & &   ! ! z   | |  
 	 	 	 	 	 	   t y p e   = =   " = "   & &   z   = =   m [ 5 ]   | |  
 	 	 	 	 	 	   t y p e   = =   " ! = "   & &   z   ! =   m [ 5 ]   | |  
 	 	 	 	 	 	   t y p e   = =   " ^ = "   & &   z   & &   ! z . i n d e x O f ( m [ 5 ] )   | |  
 	 	 	 	 	 	   t y p e   = =   " $ = "   & &   z . s u b s t r ( z . l e n g t h   -   m [ 5 ] . l e n g t h )   = =   m [ 5 ]   | |  
 	 	 	 	 	 	   ( t y p e   = =   " * = "   | |   t y p e   = =   " ~ = " )   & &   z . i n d e x O f ( m [ 5 ] )   > =   0 )   ^   n o t   )  
 	 	 	 	 	 	 	 t m p . p u s h (   a   ) ;  
 	 	 	 	 }  
 	 	 	 	  
 	 	 	 	 r   =   t m p ;  
  
 	 	 	 / /   W e   c a n   g e t   a   s p e e d   b o o s t   b y   h a n d l i n g   n t h - c h i l d   h e r e  
 	 	 	 }   e l s e   i f   (   m [ 1 ]   = =   " : "   & &   m [ 2 ]   = =   " n t h - c h i l d "   )   {  
 	 	 	 	 v a r   n u m   =   j Q u e r y . m e r g e N u m + + ,   t m p   =   [ ] ,  
 	 	 	 	 	 t e s t   =   / ( \ d * ) n \ + ? ( \ d * ) / . e x e c (  
 	 	 	 	 	 	 m [ 3 ]   = =   " e v e n "   & &   " 2 n "   | |   m [ 3 ]   = =   " o d d "   & &   " 2 n + 1 "   | |  
 	 	 	 	 	 	 ! / \ D / . t e s t ( m [ 3 ] )   & &   " n + "   +   m [ 3 ]   | |   m [ 3 ] ) ,  
 	 	 	 	 	 f i r s t   =   ( t e s t [ 1 ]   | |   1 )   -   0 ,   l a s t   =   t e s t [ 2 ]   -   0 ;  
  
 	 	 	 	 f o r   (   v a r   i   =   0 ,   r l   =   r . l e n g t h ;   i   <   r l ;   i + +   )   {  
 	 	 	 	 	 v a r   n o d e   =   r [ i ] ,   p a r e n t N o d e   =   n o d e . p a r e n t N o d e ;  
  
 	 	 	 	 	 i f   (   n u m   ! =   p a r e n t N o d e . m e r g e N u m   )   {  
 	 	 	 	 	 	 v a r   c   =   1 ;  
  
 	 	 	 	 	 	 f o r   (   v a r   n   =   p a r e n t N o d e . f i r s t C h i l d ;   n ;   n   =   n . n e x t S i b l i n g   )  
 	 	 	 	 	 	 	 i f   (   n . n o d e T y p e   = =   1   )  
 	 	 	 	 	 	 	 	 n . n o d e I n d e x   =   c + + ;  
  
 	 	 	 	 	 	 p a r e n t N o d e . m e r g e N u m   =   n u m ;  
 	 	 	 	 	 }  
  
 	 	 	 	 	 v a r   a d d   =   f a l s e ;  
  
 	 	 	 	 	 i f   (   f i r s t   = =   1   )   {  
 	 	 	 	 	 	 i f   (   l a s t   = =   0   | |   n o d e . n o d e I n d e x   = =   l a s t   )  
 	 	 	 	 	 	 	 a d d   =   t r u e ;  
 	 	 	 	 	 }   e l s e   i f   (   ( n o d e . n o d e I n d e x   +   l a s t )   %   f i r s t   = =   0   )  
 	 	 	 	 	 	 a d d   =   t r u e ;  
  
 	 	 	 	 	 i f   (   a d d   ^   n o t   )  
 	 	 	 	 	 	 t m p . p u s h (   n o d e   ) ;  
 	 	 	 	 }  
  
 	 	 	 	 r   =   t m p ;  
  
 	 	 	 / /   O t h e r w i s e ,   f i n d   t h e   e x p r e s s i o n   t o   e x e c u t e  
 	 	 	 }   e l s e   {  
 	 	 	 	 v a r   f   =   j Q u e r y . e x p r [ m [ 1 ] ] ;  
 	 	 	 	 i f   (   t y p e o f   f   ! =   " s t r i n g "   )  
 	 	 	 	 	 f   =   j Q u e r y . e x p r [ m [ 1 ] ] [ m [ 2 ] ] ;  
  
 	 	 	 	 / /   B u i l d   a   c u s t o m   m a c r o   t o   e n c l o s e   i t  
 	 	 	 	 e v a l ( " f   =   f u n c t i o n ( a , i ) { r e t u r n   "   +   f   +   " } " ) ;  
  
 	 	 	 	 / /   E x e c u t e   i t   a g a i n s t   t h e   c u r r e n t   f i l t e r  
 	 	 	 	 r   =   j Q u e r y . g r e p (   r ,   f ,   n o t   ) ;  
 	 	 	 }  
 	 	 }  
  
 	 	 / /   R e t u r n   a n   a r r a y   o f   f i l t e r e d   e l e m e n t s   ( r )  
 	 	 / /   a n d   t h e   m o d i f i e d   e x p r e s s i o n   s t r i n g   ( t )  
 	 	 r e t u r n   {   r :   r ,   t :   t   } ;  
 	 } ,  
 	 p a r e n t s :   f u n c t i o n (   e l e m   ) {  
 	 	 v a r   m a t c h e d   =   [ ] ;  
 	 	 v a r   c u r   =   e l e m . p a r e n t N o d e ;  
 	 	 w h i l e   (   c u r   & &   c u r   ! =   d o c u m e n t   )   {  
 	 	 	 m a t c h e d . p u s h (   c u r   ) ;  
 	 	 	 c u r   =   c u r . p a r e n t N o d e ;  
 	 	 }  
 	 	 r e t u r n   m a t c h e d ;  
 	 } ,  
 	 n t h :   f u n c t i o n ( c u r , r e s u l t , d i r , e l e m ) {  
 	 	 r e s u l t   =   r e s u l t   | |   1 ;  
 	 	 v a r   n u m   =   0 ;  
  
 	 	 f o r   (   ;   c u r ;   c u r   =   c u r [ d i r ]   )  
 	 	 	 i f   (   c u r . n o d e T y p e   = =   1   & &   + + n u m   = =   r e s u l t   )  
 	 	 	 	 b r e a k ;  
  
 	 	 r e t u r n   c u r ;  
 	 } ,  
 	 s i b l i n g :   f u n c t i o n (   n ,   e l e m   )   {  
 	 	 v a r   r   =   [ ] ;  
  
 	 	 f o r   (   ;   n ;   n   =   n . n e x t S i b l i n g   )   {  
 	 	 	 i f   (   n . n o d e T y p e   = =   1   & &   ( ! e l e m   | |   n   ! =   e l e m )   )  
 	 	 	 	 r . p u s h (   n   ) ;  
 	 	 }  
  
 	 	 r e t u r n   r ;  
 	 }  
 } ) ;  
 / *  
   *   A   n u m b e r   o f   h e l p e r   f u n c t i o n s   u s e d   f o r   m a n a g i n g   e v e n t s .  
   *   M a n y   o f   t h e   i d e a s   b e h i n d   t h i s   c o d e   o r i g n a t e d   f r o m    
   *   D e a n   E d w a r d s '   a d d E v e n t   l i b r a r y .  
   * /  
 j Q u e r y . e v e n t   =   {  
  
 	 / /   B i n d   a n   e v e n t   t o   a n   e l e m e n t  
 	 / /   O r i g i n a l   b y   D e a n   E d w a r d s  
 	 a d d :   f u n c t i o n ( e l e m e n t ,   t y p e ,   h a n d l e r ,   d a t a )   {  
 	 	 / /   F o r   w h a t e v e r   r e a s o n ,   I E   h a s   t r o u b l e   p a s s i n g   t h e   w i n d o w   o b j e c t  
 	 	 / /   a r o u n d ,   c a u s i n g   i t   t o   b e   c l o n e d   i n   t h e   p r o c e s s  
 	 	 i f   (   j Q u e r y . b r o w s e r . m s i e   & &   e l e m e n t . s e t I n t e r v a l   ! =   u n d e f i n e d   )  
 	 	 	 e l e m e n t   =   w i n d o w ;  
 	 	  
 	 	 / /   M a k e   s u r e   t h a t   t h e   f u n c t i o n   b e i n g   e x e c u t e d   h a s   a   u n i q u e   I D  
 	 	 i f   (   ! h a n d l e r . g u i d   )  
 	 	 	 h a n d l e r . g u i d   =   t h i s . g u i d + + ;  
 	 	 	  
 	 	 / /   i f   d a t a   i s   p a s s e d ,   b i n d   t o   h a n d l e r    
 	 	 i f (   d a t a   ! =   u n d e f i n e d   )   {    
                 	 / /   C r e a t e   t e m p o r a r y   f u n c t i o n   p o i n t e r   t o   o r i g i n a l   h a n d l e r    
 	 	 	 v a r   f n   =   h a n d l e r ;    
  
 	 	 	 / /   C r e a t e   u n i q u e   h a n d l e r   f u n c t i o n ,   w r a p p e d   a r o u n d   o r i g i n a l   h a n d l e r    
 	 	 	 h a n d l e r   =   f u n c t i o n ( )   {    
 	 	 	 	 / /   P a s s   a r g u m e n t s   a n d   c o n t e x t   t o   o r i g i n a l   h a n d l e r    
 	 	 	 	 r e t u r n   f n . a p p l y ( t h i s ,   a r g u m e n t s ) ;    
 	 	 	 } ;  
  
 	 	 	 / /   S t o r e   d a t a   i n   u n i q u e   h a n d l e r    
 	 	 	 h a n d l e r . d a t a   =   d a t a ;  
  
 	 	 	 / /   S e t   t h e   g u i d   o f   u n i q u e   h a n d l e r   t o   t h e   s a m e   o f   o r i g i n a l   h a n d l e r ,   s o   i t   c a n   b e   r e m o v e d    
 	 	 	 h a n d l e r . g u i d   =   f n . g u i d ;  
 	 	 }  
  
 	 	 / /   I n i t   t h e   e l e m e n t ' s   e v e n t   s t r u c t u r e  
 	 	 i f   ( ! e l e m e n t . $ e v e n t s )  
 	 	 	 e l e m e n t . $ e v e n t s   =   { } ;  
 	 	  
 	 	 i f   ( ! e l e m e n t . $ h a n d l e )  
 	 	 	 e l e m e n t . $ h a n d l e   =   f u n c t i o n ( )   {  
 	 	 	 	 / /   r e t u r n e d   u n d e f i n e d   o r   f a l s e  
 	 	 	 	 v a r   v a l ;  
  
 	 	 	 	 / /   H a n d l e   t h e   s e c o n d   e v e n t   o f   a   t r i g g e r   a n d   w h e n  
 	 	 	 	 / /   a n   e v e n t   i s   c a l l e d   a f t e r   a   p a g e   h a s   u n l o a d e d  
 	 	 	 	 i f   (   t y p e o f   j Q u e r y   = =   " u n d e f i n e d "   | |   j Q u e r y . e v e n t . t r i g g e r e d   )  
 	 	 	 	     r e t u r n   v a l ;  
 	 	 	 	  
 	 	 	 	 v a l   =   j Q u e r y . e v e n t . h a n d l e . a p p l y ( e l e m e n t ,   a r g u m e n t s ) ;  
 	 	 	 	  
 	 	 	 	 r e t u r n   v a l ;  
 	 	 	 } ;  
  
 	 	 / /   G e t   t h e   c u r r e n t   l i s t   o f   f u n c t i o n s   b o u n d   t o   t h i s   e v e n t  
 	 	 v a r   h a n d l e r s   =   e l e m e n t . $ e v e n t s [ t y p e ] ;  
  
 	 	 / /   I n i t   t h e   e v e n t   h a n d l e r   q u e u e  
 	 	 i f   ( ! h a n d l e r s )   {  
 	 	 	 h a n d l e r s   =   e l e m e n t . $ e v e n t s [ t y p e ]   =   { } ; 	  
 	 	 	  
 	 	 	 / /   A n d   b i n d   t h e   g l o b a l   e v e n t   h a n d l e r   t o   t h e   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 ( t y p e ,   e l e m e n t . $ h a n d l e ,   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 "   +   t y p e ,   e l e m e n t . $ h a n d l e ) ;  
 	 	 }  
  
 	 	 / /   A d d   t h e   f u n c t i o n   t o   t h e   e l e m e n t ' s   h a n d l e r   l i s t  
 	 	 h a n d l e r s [ h a n d l e r . g u i d ]   =   h a n d l e r ;  
  
 	 	 / /   R e m e m b e r   t h e   f u n c t i o n   i n   a   g l o b a l   l i s t   ( f o r   t r i g g e r i n g )  
 	 	 i f   ( ! t h i s . g l o b a l [ t y p e ] )  
 	 	 	 t h i s . g l o b a l [ t y p e ]   =   [ ] ;  
 	 	 / /   O n l y   a d d   t h e   e l e m e n t   t o   t h e   g l o b a l   l i s t   o n c e  
 	 	 i f   ( j Q u e r y . i n A r r a y ( e l e m e n t ,   t h i s . g l o b a l [ t y p e ] )   = =   - 1 )  
 	 	 	 t h i s . g l o b a l [ t y p e ] . p u s h (   e l e m e n t   ) ;  
 	 } ,  
  
 	 g u i d :   1 ,  
 	 g l o b a l :   { } ,  
  
 	 / /   D e t a c h   a n   e v e n t   o r   s e t   o f   e v e n t s   f r o m   a 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 ,   t y p e ,   h a n d l e r )   {  
 	 	 v a r   e v e n t s   =   e l e m e n t . $ e v e n t s ,   r e t ,   i n d e x ;  
  
 	 	 i f   (   e v e n t s   )   {  
 	 	 	 / /   t y p e   i s   a c t u a l l y   a n   e v e n t   o b j e c t   h e r e  
 	 	 	 i f   (   t y p e   & &   t y p e . t y p e   )   {  
 	 	 	 	 h a n d l e r   =   t y p e . h a n d l e r ;  
 	 	 	 	 t y p e   =   t y p e . t y p e ;  
 	 	 	 }  
 	 	 	  
 	 	 	 i f   (   ! t y p e   )   {  
 	 	 	 	 f o r   (   t y p e   i n   e v e n t s   )  
 	 	 	 	 	 t h i s . r e m o v e (   e l e m e n t ,   t y p e   ) ;  
  
 	 	 	 }   e l s e   i f   (   e v e n t s [ t y p e ]   )   {  
 	 	 	 	 / /   r e m o v e   t h e   g i v e n   h a n d l e r   f o r   t h e   g i v e n   t y p e  
 	 	 	 	 i f   (   h a n d l e r   )  
 	 	 	 	 	 d e l e t e   e v e n t s [ t y p e ] [ h a n d l e r . g u i d ] ;  
 	 	 	 	  
 	 	 	 	 / /   r e m o v e   a l l   h a n d l e r s   f o r   t h e   g i v e n   t y p e  
 	 	 	 	 e l s e  
 	 	 	 	 	 f o r   (   h a n d l e r   i n   e l e m e n t . $ e v e n t s [ t y p e ]   )  
 	 	 	 	 	 	 d e l e t e   e v e n t s [ t y p e ] [ h a n d l e r ] ;  
  
 	 	 	 	 / /   r e m o v e   g e n e r i c   e v e n t   h a n d l e r   i f   n o   m o r e   h a n d l e r s   e x i s t  
 	 	 	 	 f o r   (   r e t   i n   e v e n t s [ t y p e ]   )   b r e a k ;  
 	 	 	 	 i f   (   ! r e 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 ( t y p e ,   e l e m e n t . $ h a n d l e ,   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 "   +   t y p e ,   e l e m e n t . $ h a n d l e ) ;  
 	 	 	 	 	 r e t   =   n u l l ;  
 	 	 	 	 	 d e l e t e   e v e n t s [ t y p e ] ;  
 	 	 	 	 	  
 	 	 	 	 	 / /   R e m o v e   e l e m e n t   f r o m   t h e   g l o b a l   e v e n t   t y p e   c a c h e  
 	 	 	 	 	 w h i l e   (   t h i s . g l o b a l [ t y p e ]   & &   (   ( i n d e x   =   j Q u e r y . i n A r r a y ( e l e m e n t ,   t h i s . g l o b a l [ t y p e ] ) )   > =   0   )   )  
 	 	 	 	 	 	 d e l e t e   t h i s . g l o b a l [ t y p e ] [ i n d e x ] ;  
 	 	 	 	 }  
 	 	 	 }  
  
 	 	 	 / /   R e m o v e   t h e   e x p a n d o   i f   i t ' s   n o   l o n g e r   u s e d  
 	 	 	 f o r   (   r e t   i n   e v e n t s   )   b r e a k ;  
 	 	 	 i f   (   ! r e t   )  
 	 	 	 	 e l e m e n t . $ h a n d l e   =   e l e m e n t . $ e v e n t s   =   n u l l ;  
 	 	 }  
 	 } ,  
  
 	 t r i g g e r :   f u n c t i o n ( t y p e ,   d a t a ,   e l e m e n t )   {  
 	 	 / /   C l o n e   t h e   i n c o m i n g   d a t a ,   i f   a n y  
 	 	 d a t a   =   j Q u e r y . m a k e A r r a y ( d a t a   | |   [ ] ) ;  
  
 	 	 / /   H a n d l e   a   g l o b a l   t r i g g e r  
 	 	 i f   (   ! e l e m e n t   )  
 	 	 	 j Q u e r y . e a c h (   t h i s . g l o b a l [ t y p e ]   | |   [ ] ,   f u n c t i o n ( ) {  
 	 	 	 	 j Q u e r y . e v e n t . t r i g g e r (   t y p e ,   d a t a ,   t h i s   ) ;  
 	 	 	 } ) ;  
  
 	 	 / /   H a n d l e   t r i g g e r i n g   a   s i n g l e   e l e m e n t  
 	 	 e l s e   {  
 	 	 	 v a r   v a l ,   r e t ,   f n   =   j Q u e r y . i s F u n c t i o n (   e l e m e n t [   t y p e   ]   | |   n u l l   ) ;  
 	 	 	  
 	 	 	 / /   P a s s   a l o n g   a   f a k e   e v e n t  
 	 	 	 d a t a . u n s h i f t (   t h i s . f i x ( {   t y p e :   t y p e ,   t a r g e t :   e l e m e n t   } )   ) ;  
  
 	 	 	 / /   T r i g g e r   t h e   e v e n t  
 	 	 	 i f   (   j Q u e r y . i s F u n c t i o n ( e l e m e n t . $ h a n d l e )   & &   ( v a l   =   e l e m e n t . $ h a n d l e . a p p l y (   e l e m e n t ,   d a t a   ) )   ! = =   f a l s e   )  
 	 	 	 	 t h i s . t r i g g e r e d   =   t r u e ;  
  
 	 	 	 i f   (   f n   & &   v a l   ! = =   f a l s e   & &   ! j Q u e r y . n o d e N a m e ( e l e m e n t ,   ' a ' )   )  
 	 	 	 	 e l e m e n t [   t y p e   ] ( ) ;  
  
 	 	 	 t h i s . t r i g g e r e d   =   f a l s e ;  
 	 	 }  
 	 } ,  
  
 	 h a n d l e :   f u n c t i o n ( e v e n t )   {  
 	 	 / /   r e t u r n e d   u n d e f i n e d   o r   f a l s e  
 	 	 v a r   v a l ;  
  
 	 	 / /   E m p t y   o b j e c t   i s   f o r   t r i g g e r e d   e v e n t s   w i t h   n o   d a t a  
 	 	 e v e n t   =   j Q u e r y . e v e n t . f i x (   e v e n t   | |   w i n d o w . e v e n t   | |   { }   ) ;    
  
 	 	 v a r   c   =   t h i s . $ e v e n t s   & &   t h i s . $ e v e n t s [ e v e n t . t y p e ] ,   a r g s   =   [ ] . s l i c e . c a l l (   a r g u m e n t s ,   1   ) ;  
 	 	 a r g s . u n s h i f t (   e v e n t   ) ;  
  
 	 	 f o r   (   v a r   j   i n   c   )   {  
 	 	 	 / /   P a s s   i n   a   r e f e r e n c e   t o   t h e   h a n d l e r   f u n c t i o n   i t s e l f  
 	 	 	 / /   S o   t h a t   w e   c a n   l a t e r   r e m o v e   i t  
 	 	 	 a r g s [ 0 ] . h a n d l e r   =   c [ j ] ;  
 	 	 	 a r g s [ 0 ] . d a t a   =   c [ j ] . d a t a ;  
  
 	 	 	 i f   (   c [ j ] . a p p l y (   t h i s ,   a r g s   )   = = =   f a l s e   )   {  
 	 	 	 	 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 ( ) ;  
 	 	 	 	 v a l   =   f a l s e ;  
 	 	 	 }  
 	 	 }  
  
 	 	 / /   C l e a n   u p   a d d e d   p r o p e r t i e s   i n   I E   t o   p r e v e n t   m e m o r y   l e a k  
 	 	 i f   ( j Q u e r y . b r o w s e r . m s i e )  
 	 	 	 e v e n t . t a r g e 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 . h a n d l e r   =   e v e n t . d a t a   =   n u l l ;  
  
 	 	 r e t u r n   v a l ;  
 	 } ,  
  
 	 f i x :   f u n c t i o n ( e v e n t )   {  
 	 	 / /   s t o r e   a   c o p y   o f   t h e   o r i g i n a l   e v e n t   o b j e c t    
 	 	 / /   a n d   c l o n e   t o   s e t   r e a d - o n l y   p r o p e r t i e s  
 	 	 v a r   o r i g i n a l E v e n t   =   e v e n t ;  
 	 	 e v e n t   =   j Q u e r y . e x t e n d ( { } ,   o r i g i n a l E v e n t ) ;  
 	 	  
 	 	 / /   a d d   p r e v e n t D e f a u l t   a n d   s t o p P r o p a g a t i o n   s i n c e    
 	 	 / /   t h e y   w i l l   n o t   w o r k   o n   t h e   c l o n e  
 	 	 e v e n t . p r e v e n t D e f a u l t   =   f u n c t i o n ( )   {  
 	 	 	 / /   i f   p r e v e n t D e f a u l t   e x i s t s   r u n   i t   o n   t h e   o r i g i n a l   e v e n t  
 	 	 	 i f   ( o r i g i n a l E v e n t . p r e v e n t D e f a u l t )  
 	 	 	 	 r e t u r n   o r i g i n a l E v e n t . p r e v e n t D e f a u l t ( ) ;  
 	 	 	 / /   o t h e r w i s e   s e t   t h e   r e t u r n V a l u e   p r o p e r t y   o f   t h e   o r i g i n a l   e v e n t   t o   f a l s e   ( I E )  
 	 	 	 o r i g i n a l E v e n t . r e t u r n V a l u e   =   f a l s e ;  
 	 	 } ;  
 	 	 e v e n t . s t o p P r o p a g a t i o n   =   f u n c t i o n ( )   {  
 	 	 	 / /   i f   s t o p P r o p a g a t i o n   e x i s t s   r u n   i t   o n   t h e   o r i g i n a l   e v e n t  
 	 	 	 i f   ( o r i g i n a l E v e n t . s t o p P r o p a g a t i o n )  
 	 	 	 	 r e t u r n   o r i g i n a l E v e n t . s t o p P r o p a g a t i o n ( ) ;  
 	 	 	 / /   o t h e r w i s e   s e t   t h e   c a n c e l B u b b l e   p r o p e r t y   o f   t h e   o r i g i n a l   e v e n t   t o   t r u e   ( I E )  
 	 	 	 o r i g i n a l E v e n t . c a n c e l B u b b l e   =   t r u e ;  
 	 	 } ;  
 	 	  
 	 	 / /   F i x   t a r g e t   p r o p e r t y ,   i f   n e c e s s a r y  
 	 	 i f   (   ! 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   )  
 	 	 	 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 ;  
 	 	 	 	  
 	 	 / /   c h e c k   i f   t a r g e t   i s   a   t e x t n o d e   ( s a f a r i )  
 	 	 i f   ( j Q u e r y . b r o w s e r . s a f a r i   & &   e v e n t . t a r g e t . n o d e T y p e   = =   3 )  
 	 	 	 e v e n t . t a r g e t   =   o r i g i n a l E v e n t . t a r g e t . p a r e n t N o d e ;  
  
 	 	 / /   A d d   r e l a t e d T a r g e t ,   i f   n e c e s s a r y  
 	 	 i f   (   ! e v e n t . r e l a t e d T a r g e t   & &   e v e n t . f r o m E l e m e n t   )  
 	 	 	 e v e n t . r e l a t e d T a r g e t   =   e v e n t . f r o m E l e m e n t   = =   e v e n t . t a r g e t   ?   e v e n t . t o E l e m e n t   :   e v e n t . f r o m E l e m e n t ;  
  
 	 	 / /   C a l c u l a t e   p a g e X / Y   i f   m i s s i n g   a n d   c l i e n t X / Y   a v a i l a b l e  
 	 	 i f   (   e v e n t . p a g e X   = =   n u l l   & &   e v e n t . c l i e n t X   ! =   n u l l   )   {  
 	 	 	 v a r   e   =   d o c u m e n t . d o c u m e n t E l e m e n t ,   b   =   d o c u m e n t . b o d y ;  
 	 	 	 e v e n t . p a g e X   =   e v e n t . c l i e n t X   +   ( e   & &   e . s c r o l l L e f t   | |   b . s c r o l l L e f t ) ;  
 	 	 	 e v e n t . p a g e Y   =   e v e n t . c l i e n t Y   +   ( e   & &   e . s c r o l l T o p   | |   b . s c r o l l T o p ) ;  
 	 	 }  
 	 	 	  
 	 	 / /   A d d   w h i c h   f o r   k e y   e v e n t s  
 	 	 i f   (   ! e v e n t . w h i c h   & &   ( e v e n t . c h a r C o d e   | |   e v e n t . k e y C o d e )   )  
 	 	 	 e v e n t . w h i c h   =   e v e n t . c h a r C o d e   | |   e v e n t . k e y C o d e ;  
 	 	  
 	 	 / /   A d d   m e t a K e y   t o   n o n - M a c   b r o w s e r s   ( u s e   c t r l   f o r   P C ' s   a n d   M e t a   f o r   M a c s )  
 	 	 i f   (   ! e v e n t . m e t a K e y   & &   e v e n t . c t r l K e y   )  
 	 	 	 e v e n t . m e t a K e y   =   e v e n t . c t r l K e y ;  
  
 	 	 / /   A d d   w h i c h   f o r   c l i c k :   1   = =   l e f t ;   2   = =   m i d d l e ;   3   = =   r i g h t  
 	 	 / /   N o t e :   b u t t o n   i s   n o t   n o r m a l i z e d ,   s o   d o n ' t   u s e   i t  
 	 	 i f   (   ! e v e n t . w h i c h   & &   e v e n t . b u t t o n   )  
 	 	 	 e v e n t . w h i c h   =   ( e v e n t . b u t t o n   &   1   ?   1   :   (   e v e n t . b u t t o n   &   2   ?   3   :   (   e v e n t . b u t t o n   &   4   ?   2   :   0   )   ) ) ;  
 	 	 	  
 	 	 r e t u r n   e v e n t ;  
 	 }  
 } ;  
  
 j Q u e r y . f n . e x t e n d ( {  
 	 b i n d :   f u n c t i o n (   t y p e ,   d a t a ,   f n   )   {  
 	 	 r e t u r n   t y p e   = =   " u n l o a d "   ?   t h i s . o n e ( t y p e ,   d a t a ,   f n )   :   t h i s . e a c h ( f u n c t i o n ( ) {  
 	 	 	 j Q u e r y . e v e n t . a d d (   t h i s ,   t y p e ,   f n   | |   d a t a ,   f n   & &   d a t a   ) ;  
 	 	 } ) ;  
 	 } ,  
 	 o n e :   f u n c t i o n (   t y p e ,   d a t a ,   f n   )   {  
 	 	 r e t u r n   t h i s . e a c h ( f u n c t i o n ( ) {  
 	 	 	 j Q u e r y . e v e n t . a d d (   t h i s ,   t y p e ,   f u n c t i o n ( e v e n t )   {  
 	 	 	 	 j Q u e r y ( t h i s ) . u n b i n d ( e v e n t ) ;  
 	 	 	 	 r e t u r n   ( f n   | |   d a t a ) . a p p l y (   t h i s ,   a r g u m e n t s ) ;  
 	 	 	 } ,   f n   & &   d a t a ) ;  
 	 	 } ) ;  
 	 } ,  
 	 u n b i n d :   f u n c t i o n (   t y p e ,   f n   )   {  
 	 	 r e t u r n   t h i s . e a c h ( f u n c t i o n ( ) {  
 	 	 	 j Q u e r y . e v e n t . r e m o v e (   t h i s ,   t y p e ,   f n   ) ;  
 	 	 } ) ;  
 	 } ,  
 	 t r i g g e r :   f u n c t i o n (   t y p e ,   d a t a   )   {  
 	 	 r e t u r n   t h i s . e a c h ( f u n c t i o n ( ) {  
 	 	 	 j Q u e r y . e v e n t . t r i g g e r (   t y p e ,   d a t a ,   t h i s   ) ;  
 	 	 } ) ;  
 	 } ,  
 	 t o g g l e :   f u n c t i o n ( )   {  
 	 	 / /   S a v e   r e f e r e n c e   t o   a r g u m e n t s   f o r   a c c e s s   i n   c l o s u r e  
 	 	 v a r   a   =   a r g u m e n t s ;  
  
 	 	 r e t u r n   t h i s . c l i c k ( f u n c t i o n ( e )   {  
 	 	 	 / /   F i g u r e   o u t   w h i c h   f u n c t i o n   t o   e x e c u t e  
 	 	 	 t h i s . l a s t T o g g l e   =   0   = =   t h i s . l a s t T o g g l e   ?   1   :   0 ;  
 	 	 	  
 	 	 	 / /   M a k e   s u r e   t h a t   c l i c k s   s t o p  
 	 	 	 e . p r e v e n t D e f a u l t ( ) ;  
 	 	 	  
 	 	 	 / /   a n d   e x e c u t e   t h e   f u n c t i o n  
 	 	 	 r e t u r n   a [ t h i s . l a s t T o g g l e ] . a p p l y (   t h i s ,   [ e ]   )   | |   f a l s e ;  
 	 	 } ) ;  
 	 } ,  
 	 h o v e r :   f u n c t i o n ( f , g )   {  
 	 	  
 	 	 / /   A   p r i v a t e   f u n c t i o n   f o r   h a n d l i n g   m o u s e   ' h o v e r i n g '  
 	 	 f u n c t i o n   h a n d l e H o v e r ( e )   {  
 	 	 	 / /   C h e c k   i f   m o u s e ( o v e r | o u t )   a r e   s t i l l   w i t h i n   t h e   s a m e   p a r e n t   e l e m e n t  
 	 	 	 v a r   p   =   e . r e l a t e d T a r g e t ;  
 	  
 	 	 	 / /   T r a v e r s e   u p   t h e   t r e e  
 	 	 	 w h i l e   (   p   & &   p   ! =   t h i s   )   t r y   {   p   =   p . p a r e n t N o d e   }   c a t c h ( e )   {   p   =   t h i s ;   } ;  
 	 	 	  
 	 	 	 / /   I f   w e   a c t u a l l y   j u s t   m o u s e d   o n   t o   a   s u b - e l e m e n t ,   i g n o r e   i t  
 	 	 	 i f   (   p   = =   t h i s   )   r e t u r n   f a l s e ;  
 	 	 	  
 	 	 	 / /   E x e c u t e   t h e   r i g h t   f u n c t i o n  
 	 	 	 r e t u r n   ( e . t y p e   = =   " m o u s e o v e r "   ?   f   :   g ) . a p p l y ( t h i s ,   [ e ] ) ;  
 	 	 }  
 	 	  
 	 	 / /   B i n d   t h e   f u n c t i o n   t o   t h e   t w o   e v e n t   l i s t e n e r s  
 	 	 r e t u r n   t h i s . m o u s e o v e r ( h a n d l e H o v e r ) . m o u s e o u t ( h a n d l e H o v e r ) ;  
 	 } ,  
 	 r e a d y :   f u n c t i o n ( f )   {  
 	 	 / /   I f   t h e   D O M   i s   a l r e a d y   r e a d y  
 	 	 i f   (   j Q u e r y . i s R e a d y   )  
 	 	 	 / /   E x e c u t e   t h e   f u n c t i o n   i m m e d i a t e l y  
 	 	 	 f . a p p l y (   d o c u m e n t ,   [ j Q u e r y ]   ) ;  
 	 	 	  
 	 	 / /   O t h e r w i s e ,   r e m e m b e r   t h e   f u n c t i o n   f o r   l a t e r  
 	 	 e l s e  
 	 	 	 / /   A d d   t h e   f u n c t i o n   t o   t h e   w a i t   l i s t  
 	 	 	 j Q u e r y . r e a d y L i s t . p u s h (   f u n c t i o n ( )   {   r e t u r n   f . a p p l y ( t h i s ,   [ j Q u e r y ] )   }   ) ;  
 	  
 	 	 r e t u r n   t h i s ;  
 	 }  
 } ) ;  
  
 j Q u e r y . e x t e n d ( {  
 	 / *  
 	   *   A l l   t h e   c o d e   t h a t   m a k e s   D O M   R e a d y   w o r k   n i c e l y .  
 	   * /  
 	 i s R e a d y :   f a l s e ,  
 	 r e a d y L i s t :   [ ] ,  
 	  
 	 / /   H a n d l e   w h e n   t h e   D O M   i s   r e a d y  
 	 r e a d y :   f u n c t i o n ( )   {  
 	 	 / /   M a k e   s u r e   t h a t   t h e   D O M   i s   n o t   a l r e a d y   l o a d e d  
 	 	 i f   (   ! j Q u e r y . i s R e a d y   )   {  
 	 	 	 / /   R e m e m b e r   t h a t   t h e   D O M   i s   r e a d y  
 	 	 	 j Q u e r y . i s R e a d y   =   t r u e ;  
 	 	 	  
 	 	 	 / /   I f   t h e r e   a r e   f u n c t i o n s   b o u n d ,   t o   e x e c u t e  
 	 	 	 i f   (   j Q u e r y . r e a d y L i s t   )   {  
 	 	 	 	 / /   E x e c u t e   a l l   o f   t h e m  
 	 	 	 	 j Q u e r y . e a c h (   j Q u e r y . r e a d y L i s t ,   f u n c t i o n ( ) {  
 	 	 	 	 	 t h i s . a p p l y (   d o c u m e n t   ) ;  
 	 	 	 	 } ) ;  
 	 	 	 	  
 	 	 	 	 / /   R e s e t   t h e   l i s t   o f   f u n c t i o n s  
 	 	 	 	 j Q u e r y . r e a d y L i s t   =   n u l l ;  
 	 	 	 }  
 	 	 	 / /   R e m o v e   e v e n t   l i s t e n e r   t o   a v o i d   m e m o r y   l e a k  
 	 	 	 i f   (   j Q u e r y . b r o w s e r . m o z i l l a   | |   j Q u e r y . b r o w s e r . o p e r a   )  
 	 	 	 	 d o c u m e n t . r e m o v e 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 " ,   j Q u e r y . r e a d y ,   f a l s e   ) ;  
 	 	 	  
 	 	 	 / /   R e m o v e   s c r i p t   e l e m e n t   u s e d   b y   I E   h a c k  
 	 	 	 i f (   ! w i n d o w . f r a m e s . l e n g t h   )   / /   d o n ' t   r e m o v e   i f   f r a m e s   a r e   p r e s e n t   ( # 1 1 8 7 )  
 	 	 	 	 j Q u e r y ( w i n d o w ) . l o a d ( f u n c t i o n ( ) {   j Q u e r y ( " # _ _ i e _ i n i t " ) . r e m o v e ( ) ;   } ) ;  
 	 	 }  
 	 }  
 } ) ;  
  
 n e w   f u n c t i o n ( ) {  
  
 	 j Q u e r y . e a c h (   ( " b l u r , f o c u s , l o a d , r e s i z e , s c r o l l , u n l o a d , c l i c k , d b l c l i c k , "   +  
 	 	 " m o u s e d o w n , m o u s e u p , m o u s e m o v e , m o u s e o v e r , m o u s e o u t , c h a n g e , s e l e c t , "   +    
 	 	 " s u b m i t , k e y d o w n , k e y p r e s s , k e y u p , e r r o r " ) . s p l i t ( " , " ) ,   f u n c t i o n ( i , o ) {  
 	 	  
 	 	 / /   H a n d l e   e v e n t   b i n d i n g  
 	 	 j Q u e r y . f n [ o ]   =   f u n c t i o n ( f ) {  
 	 	 	 r e t u r n   f   ?   t h i s . b i n d ( o ,   f )   :   t h i s . t r i g g e r ( o ) ;  
 	 	 } ;  
 	 	 	  
 	 } ) ;  
 	  
 	 / /   I f   M o z i l l a   i s   u s e d  
 	 i f   (   j Q u e r y . b r o w s e r . m o z i l l a   | |   j Q u e r y . b r o w s e r . o p e r a   )  
 	 	 / /   U s e   t h e   h a n d y   e v e n t   c a l l b a c k  
 	 	 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 " ,   j Q u e r y . r e a d y ,   f a l s e   ) ;  
 	  
 	 / /   I f   I E   i s   u s e d ,   u s e   t h e   e x c e l l e n t   h a c k   b y   M a t t h i a s   M i l l e r  
 	 / /   h t t p : / / w w w . o u t o f h a n w e l l . c o m / b l o g / i n d e x . p h p ? t i t l e = t h e _ w i n d o w _ o n l o a d _ p r o b l e m _ r e v i s i t e d  
 	 e l s e   i f   (   j Q u e r y . b r o w s e r . m s i e   )   {  
 	  
 	 	 / /   O n l y   w o r k s   i f   y o u   d o c u m e n t . w r i t e ( )   i t  
 	 	 d o c u m e n t . w r i t e ( " < s c r "   +   " i p t   i d = _ _ i e _ i n i t   d e f e r = t r u e   "   +    
 	 	 	 " s r c = / / : > < \ / s c r i p t > " ) ;  
 	  
 	 	 / /   U s e   t h e   d e f e r   s c r i p t   h a c k  
 	 	 v a r   s c r i p t   =   d o c u m e n t . g e t E l e m e n t B y I d ( " _ _ i e _ i n i t " ) ;  
 	 	  
 	 	 / /   s c r i p t   d o e s   n o t   e x i s t   i f   j Q u e r y   i s   l o a d e d   d y n a m i c a l l y  
 	 	 i f   (   s c r i p t   )    
 	 	 	 s c r i p t . 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 "   )   r e t u r n ;  
 	 	 	 	 j Q u e r y . r e a d y ( ) ;  
 	 	 	 } ;  
 	  
 	 	 / /   C l e a r   f r o m   m e m o r y  
 	 	 s c r i p t   =   n u l l ;  
 	  
 	 / /   I f   S a f a r i     i s   u s e d  
 	 }   e l s e   i f   (   j Q u e r y . b r o w s e r . s a f a r i   )  
 	 	 / /   C o n t i n u a l l y   c h e c k   t o   s e e   i f   t h e   d o c u m e n t . r e a d y S t a t e   i s   v a l i d  
 	 	 j Q u e r y . s a f a r i T i m e r   =   s e t I n t e r v a l ( f u n c t i o n ( ) {  
 	 	 	 / /   l o a d e d   a n d   c o m p l e t e   a r e   b o t h   v a l i d   s t a t e s  
 	 	 	 i f   (   d o c u m e n t . r e a d y S t a t e   = =   " l o a d e d "   | |    
 	 	 	 	 d o c u m e n t . r e a d y S t a t e   = =   " c o m p l e t e "   )   {  
 	  
 	 	 	 	 / /   I f   e i t h e r   o n e   a r e   f o u n d ,   r e m o v e   t h e   t i m e r  
 	 	 	 	 c l e a r I n t e r v a l (   j Q u e r y . s a f a r i T i m e r   ) ;  
 	 	 	 	 j Q u e r y . s a f a r i T i m e r   =   n u l l ;  
 	  
 	 	 	 	 / /   a n d   e x e c u t e   a n y   w a i t i n g   f u n c t i o n s  
 	 	 	 	 j Q u e r y . r e a d y ( ) ;  
 	 	 	 }  
 	 	 } ,   1 0 ) ;    
  
 	 / /   A   f a l l b a c k   t o   w i n d o w . o n l o a d ,   t h a t   w i l l   a l w a y s   w o r k  
 	 j Q u e r y . e v e n t . a d d (   w i n d o w ,   " l o a d " ,   j Q u e r y . r e a d y   ) ;  
 	  
 } ;  
  
 / /   C l e a n   u p   a f t e r   I E   t o   a v o i d   m e m o r y   l e a k s  
 i f   ( j Q u e r y . b r o w s e r . m s i e )  
 	 j Q u e r y ( w i n d o w ) . o n e ( " u n l o a d " ,   f u n c t i o n ( )   {  
 	 	 v a r   g l o b a l   =   j Q u e r y . e v e n t . g l o b a l ;  
 	 	 f o r   (   v a r   t y p e   i n   g l o b a l   )   {  
 	 	 	 v a r   e l s   =   g l o b a l [ t y p e ] ,   i   =   e l s . l e n g t h ;  
 	 	 	 i f   (   i   & &   t y p e   ! =   ' u n l o a d '   )  
 	 	 	 	 d o  
 	 	 	 	 	 e l s [ i - 1 ]   & &   j Q u e r y . e v e n t . r e m o v e ( e l s [ i - 1 ] ,   t y p e ) ;  
 	 	 	 	 w h i l e   ( - - i ) ;  
 	 	 }  
 	 } ) ;  
 j Q u e r y . f n . e x t e n d ( {  
 	 l o a d I f M o d i f i e d :   f u n c t i o n (   u r l ,   p a r a m s ,   c a l l b a c k   )   {  
 	 	 t h i s . l o a d (   u r l ,   p a r a m s ,   c a l l b a c k ,   1   ) ;  
 	 } ,  
 	 l o a d :   f u n c t i o n (   u r l ,   p a r a m s ,   c a l l b a c k ,   i f M o d i f i e d   )   {  
 	 	 i f   (   j Q u e r y . i s F u n c t i o n (   u r l   )   )  
 	 	 	 r e t u r n   t h i s . b i n d ( " l o a d " ,   u r l ) ;  
  
 	 	 c a l l b a c k   =   c a l l b a c k   | |   f u n c t i o n ( ) { } ;  
  
 	 	 / /   D e f a u l t   t o   a   G E T   r e q u e s t  
 	 	 v a r   t y p e   =   " G E T " ;  
  
 	 	 / /   I f   t h e   s e c o n d   p a r a m e t e r   w a s   p r o v i d e d  
 	 	 i f   (   p a r a m s   )  
 	 	 	 / /   I f   i t ' s   a   f u n c t i o n  
 	 	 	 i f   (   j Q u e r y . i s F u n c t i o n (   p a r a m s   )   )   {  
 	 	 	 	 / /   W e   a s s u m e   t h a t   i t ' s   t h e   c a l l b a c k  
 	 	 	 	 c a l l b a c k   =   p a r a m s ;  
 	 	 	 	 p a r a m s   =   n u l l ;  
  
 	 	 	 / /   O t h e r w i s e ,   b u i l d   a   p a r a m   s t r i n g  
 	 	 	 }   e l s e   {  
 	 	 	 	 p a r a m s   =   j Q u e r y . p a r a m (   p a r a m s   ) ;  
 	 	 	 	 t y p e   =   " P O S T " ;  
 	 	 	 }  
  
 	 	 v a r   s e l f   =   t h i s ;  
  
 	 	 / /   R e q u e s t   t h e   r e m o t e   d o c u m e n t  
 	 	 j Q u e r y . a j a x ( {  
 	 	 	 u r l :   u r l ,  
 	 	 	 t y p e :   t y p e ,  
 	 	 	 d a t a :   p a r a m s ,  
 	 	 	 i f M o d i f i e d :   i f M o d i f i e d ,  
 	 	 	 c o m p l e t e :   f u n c t i o n ( r e s ,   s t a t u s ) {  
 	 	 	 	 i f   (   s t a t u s   = =   " s u c c e s s "   | |   ! i f M o d i f i e d   & &   s t a t u s   = =   " n o t m o d i f i e d "   )  
 	 	 	 	 	 / /   I n j e c t   t h e   H T M L   i n t o   a l l   t h e   m a t c h e d   e l e m e n t s  
 	 	 	 	 	 s e l f . a t t r ( " i n n e r H T M L " ,   r e s . r e s p o n s e T e x t )  
 	 	 	 	 	     / /   E x e c u t e   a l l   t h e   s c r i p t s   i n s i d e   o f   t h e   n e w l y - i n j e c t e d   H T M L  
 	 	 	 	 	     . e v a l S c r i p t s ( )  
 	 	 	 	 	     / /   E x e c u t e   c a l l b a c k  
 	 	 	 	 	     . e a c h (   c a l l b a c k ,   [ r e s . r e s p o n s e T e x t ,   s t a t u s ,   r e s ]   ) ;  
 	 	 	 	 e l s e  
 	 	 	 	 	 c a l l b a c k . a p p l y (   s e l f ,   [ r e s . r e s p o n s e T e x t ,   s t a t u s ,   r e s ]   ) ;  
 	 	 	 }  
 	 	 } ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
 	 s e r i a l i z e :   f u n c t i o n ( )   {  
 	 	 r e t u r n   j Q u e r y . p a r a m (   t h i s   ) ;  
 	 } ,  
 	 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 . f i n d ( " s c r i p t " ) . e a c h ( f u n c t i o n ( ) {  
 	 	 	 i f   (   t h i s . s r c   )  
 	 	 	 	 j Q u e r y . g e t S c r i p t (   t h i s . s r c   ) ;  
 	 	 	 e l s e  
 	 	 	 	 j Q u e r y . g l o b a l E v a l (   t h i s . t e x t   | |   t h i s . t e x t C o n t e n t   | |   t h i s . i n n e r H T M L   | |   " "   ) ;  
 	 	 } ) . e n d ( ) ;  
 	 }  
  
 } ) ;  
  
 / /   A t t a c h   a   b u n c h   o f   f u n c t i o n s   f o r   h a n d l i n g   c o m m o n   A J A X   e v e n t s  
  
 j Q u e r y . e a c h (   " a j a x S t a r t , a j a x S t o p , a j a x C o m p l e t e , a j a x E r r o r , a j a x S u c c e s s , a j a x S e n d " . s p l i t ( " , " ) ,   f u n c t i o n ( i , o ) {  
 	 j Q u e r y . f n [ o ]   =   f u n c t i o n ( f ) {  
 	 	 r e t u r n   t h i s . b i n d ( o ,   f ) ;  
 	 } ;  
 } ) ;  
  
 j Q u e r y . e x t e n d ( {  
 	 g e t :   f u n c t i o n (   u r l ,   d a t a ,   c a l l b a c k ,   t y p e ,   i f M o d i f i e d   )   {  
 	 	 / /   s h i f t   a r g u m e n t s   i f   d a t a   a r g u m e n t   w a s   o m m i t e d  
 	 	 i f   (   j Q u e r y . i s F u n c t i o n (   d a t a   )   )   {  
 	 	 	 c a l l b a c k   =   d a t a ;  
 	 	 	 d a t a   =   n u l l ;  
 	 	 }  
 	 	  
 	 	 r e t u r n   j Q u e r y . a j a x ( {  
 	 	 	 t y p e :   " G E T " ,  
 	 	 	 u r l :   u r l ,  
 	 	 	 d a t a :   d a t a ,  
 	 	 	 s u c c e s s :   c a l l b a c k ,  
 	 	 	 d a t a T y p e :   t y p e ,  
 	 	 	 i f M o d i f i e d :   i f M o d i f i e d  
 	 	 } ) ;  
 	 } ,  
 	 g e t I f M o d i f i e d :   f u n c t i o n (   u r l ,   d a t a ,   c a l l b a c k ,   t y p e   )   {  
 	 	 r e t u r n   j Q u e r y . g e t ( u r l ,   d a t a ,   c a l l b a c k ,   t y p e ,   1 ) ;  
 	 } ,  
 	 g e t S c r i p t :   f u n c t i o n (   u r l ,   c a l l b a c k   )   {  
 	 	 r e t u r n   j Q u e r y . g e t ( u r l ,   n u l l ,   c a l l b a c k ,   " s c r i p t " ) ;  
 	 } ,  
 	 g e t J S O N :   f u n c t i o n (   u r l ,   d a t a ,   c a l l b a c k   )   {  
 	 	 r e t u r n   j Q u e r y . g e t ( u r l ,   d a t a ,   c a l l b a c k ,   " j s o n " ) ;  
 	 } ,  
 	 p o s t :   f u n c t i o n (   u r l ,   d a t a ,   c a l l b a c k ,   t y p e   )   {  
 	 	 i f   (   j Q u e r y . i s F u n c t i o n (   d a t a   )   )   {  
 	 	 	 c a l l b a c k   =   d a t a ;  
 	 	 	 d a t a   =   { } ;  
 	 	 }  
  
 	 	 r e t u r n   j Q u e r y . a j a x ( {  
 	 	 	 t y p e :   " P O S T " ,  
 	 	 	 u r l :   u r l ,  
 	 	 	 d a t a :   d a t a ,  
 	 	 	 s u c c e s s :   c a l l b a c k ,  
 	 	 	 d a t a T y p e :   t y p e  
 	 	 } ) ;  
 	 } ,  
 	 a j a x T i m e o u t :   f u n c t i o n (   t i m e o u t   )   {  
 	 	 j Q u e r y . a j a x S e t t i n g s . t i m e o u t   =   t i m e o u t ;  
 	 } ,  
 	 a j a x S e t u p :   f u n c t i o n (   s e t t i n g s   )   {  
 	 	 j Q u e r y . e x t e n d (   j Q u e r y . a j a x S e t t i n g s ,   s e t t i n g s   ) ;  
 	 } ,  
  
 	 a j a x S e t t i n g s :   {  
 	 	 g l o b a l :   t r u e ,  
 	 	 t y p e :   " G E T " ,  
 	 	 t i m e o u t :   0 ,  
 	 	 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 " ,  
 	 	 p r o c e s s D a t a :   t r u e ,  
 	 	 a s y n c :   t r u e ,  
 	 	 d a t a :   n u l l  
 	 } ,  
 	  
 	 / /   L a s t - M o d i f i e d   h e a d e r   c a c h e   f o r   n e x t   r e q u e s t  
 	 l a s t M o d i f i e d :   { } ,  
 	 a j a x :   f u n c t i o n (   s   )   {  
 	 	 / /   T O D O   i n t r o d u c e   g l o b a l   s e t t i n g s ,   a l l o w i n g   t h e   c l i e n t   t o   m o d i f y   t h e m   f o r   a l l   r e q u e s t s ,   n o t   o n l y   t i m e o u t  
 	 	 s   =   j Q u e r y . e x t e n d ( { } ,   j Q u e r y . a j a x S e t t i n g s ,   s ) ;  
  
 	 	 / /   i f   d a t a   a v a i l a b l e  
 	 	 i f   (   s . d a t a   )   {  
 	 	 	 / /   c o n v e r t   d a t a   i f   n o t   a l r e a d y   a   s t r i n g  
 	 	 	 i f   ( s . p r o c e s s D a t a   & &   t y p e o f   s . d a t a   ! =   " s t r i n g " )  
         	 	 	 s . d a t a   =   j Q u e r y . p a r a m ( s . d a t a ) ;  
 	 	 	 / /   a p p e n d   d a t a   t o   u r l   f o r   g e t   r e q u e s t s  
 	 	 	 i f (   s . t y p e . t o L o w e r C a s e ( )   = =   " g e t "   )   {  
 	 	 	 	 / /   " ? "   +   d a t a   o r   " & "   +   d a t a   ( i n   c a s e   t h e r e   a r e   a l r e a d y   p a r a m s )  
 	 	 	 	 s . u r l   + =   ( ( s . u r l . i n d e x O f ( " ? " )   >   - 1 )   ?   " & "   :   " ? " )   +   s . d a t a ;  
 	 	 	 	 / /   I E   l i k e s   t o   s e n d   b o t h   g e t   a n d   p o s t   d a t a ,   p r e v e n t   t h i s  
 	 	 	 	 s . d a t a   =   n u l l ;  
 	 	 	 }  
 	 	 }  
  
 	 	 / /   W a t c h   f o r   a   n e w   s e t   o f   r e q u e s t s  
 	 	 i f   (   s . g l o b a l   & &   !   j Q u e r y . a c t i v e + +   )  
 	 	 	 j Q u e r y . e v e n t . t r i g g e r (   " a j a x S t a r t "   ) ;  
  
 	 	 v a r   r e q u e s t D o n e   =   f a l s e ;  
  
 	 	 / /   C r e a t e   t h e   r e q u e s t   o b j e c t ;   M i c r o s o f t   f a i l e d   t o   p r o p e r l y  
 	 	 / /   i m p l e m e n t   t h e   X M L H t t p R e q u e s t   i n   I E 7 ,   s o   w e   u s e   t h e   A c t i v e X O b j e c t   w h e n   i t   i s   a v a i l a b l e  
 	 	 v a r   x m l   =   w i n d o w . A c t i v e X O b j e c t   ?   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 " )   :   n e w   X M L H t t p R e q u e s t ( ) ;  
  
 	 	 / /   O p e n   t h e   s o c k e t  
 	 	 x m l . o p e n ( s . t y p e ,   s . u r l ,   s . a s y n c ) ;  
  
 	 	 / /   S e t   t h e   c o r r e c t   h e a d e r ,   i f   d a t a   i s   b e i n g   s e n t  
 	 	 i f   (   s . d a t a   )  
 	 	 	 x m l . s e t R e q u e s t H e a d e r ( " C o n t e n t - T y p e " ,   s . c o n t e n t T y p e ) ;  
  
 	 	 / /   S e t   t h e   I f - M o d i f i e d - S i n c e   h e a d e r ,   i f   i f M o d i f i e d   m o d e .  
 	 	 i f   (   s . i f M o d i f i e d   )  
 	 	 	 x m l . s e t R e q u e s t H e a d e r ( " I f - M o d i f i e d - S i n c e " ,  
 	 	 	 	 j Q u e r y . l a s t M o d i f i e d [ s . u r l ]   | |   " T h u ,   0 1   J a n   1 9 7 0   0 0 : 0 0 : 0 0   G M T "   ) ;  
  
 	 	 / /   S e t   h e a d e r   s o   t h e   c a l l e d   s c r i p t   k n o w s   t h a t   i t ' s   a n   X M L H t t p R e q u e s t  
 	 	 x m l . s e t R e q u e s t H e a d e r ( " 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 " ) ;  
  
 	 	 / /   A l l o w   c u s t o m   h e a d e r s / m i m e t y p e s  
 	 	 i f (   s . b e f o r e S e n d   )  
 	 	 	 s . b e f o r e S e n d ( x m l ) ;  
 	 	 	  
 	 	 i f   (   s . g l o b a l   )  
 	 	         j Q u e r y . e v e n t . t r i g g e r ( " a j a x S e n d " ,   [ x m l ,   s ] ) ;  
  
 	 	 / /   W a i t   f o r   a   r e s p o n s e   t o   c o m e   b a c k  
 	 	 v a r   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 s T i m e o u t ) {  
 	 	 	 / /   T h e   t r a n s f e r   i s   c o m p l e t e   a n d   t h e   d a t a   i s   a v a i l a b l e ,   o r   t h e   r e q u e s t   t i m e d   o u t  
 	 	 	 i f   (   x m l   & &   ( x m l . r e a d y S t a t e   = =   4   | |   i s T i m e o u t   = =   " t i m e o u t " )   )   {  
 	 	 	 	 r e q u e s t D o n e   =   t r u e ;  
 	 	 	 	  
 	 	 	 	 / /   c l e a r   p o l l   i n t e r v a l  
 	 	 	 	 i f   ( i v a l )   {  
 	 	 	 	 	 c l e a r I n t e r v a l ( i v a l ) ;  
 	 	 	 	 	 i v a l   =   n u l l ;  
 	 	 	 	 }  
 	 	 	 	  
 	 	 	 	 v a r   s t a t u s ;  
 	 	 	 	 t r y   {  
 	 	 	 	 	 s t a t u s   =   j Q u e r y . h t t p S u c c e s s (   x m l   )   & &   i s T i m e o u t   ! =   " t i m e o u t "   ?  
 	 	 	 	 	 	 s . i f M o d i f i e d   & &   j Q u e r y . h t t p N o t M o d i f i e d (   x m l ,   s . u r l   )   ?   " n o t m o d i f i e d "   :   " s u c c e s s "   :   " e r r o r " ;  
 	 	 	 	 	 / /   M a k e   s u r e   t h a t   t h e   r e q u e s t   w a s   s u c c e s s f u l   o r   n o t m o d i f i e d  
 	 	 	 	 	 i f   (   s t a t u s   ! =   " e r r o r "   )   {  
 	 	 	 	 	 	 / /   C a c h e   L a s t - M o d i f i e d   h e a d e r ,   i f   i f M o d i f i e d   m o d e .  
 	 	 	 	 	 	 v a r   m o d R e s ;  
 	 	 	 	 	 	 t r y   {  
 	 	 	 	 	 	 	 m o d R e s   =   x m l . g e t R e s p o n s e H e a d e r ( " L a s t - M o d i f i e d " ) ;  
 	 	 	 	 	 	 }   c a t c h ( e )   { }   / /   s w a l l o w   e x c e p t i o n   t h r o w n   b y   F F   i f   h e a d e r   i s   n o t   a v a i l a b l e  
 	  
 	 	 	 	 	 	 i f   (   s . i f M o d i f i e d   & &   m o d R e s   )  
 	 	 	 	 	 	 	 j Q u e r y . l a s t M o d i f i e d [ s . u r l ]   =   m o d R e s ;  
 	  
 	 	 	 	 	 	 / /   p r o c e s s   t h e   d a t a   ( r u n s   t h e   x m l   t h r o u g h   h t t p D a t a   r e g a r d l e s s   o f   c a l l b a c k )  
 	 	 	 	 	 	 v a r   d a t a   =   j Q u e r y . h t t p D a t a (   x m l ,   s . d a t a T y p e   ) ;  
 	  
 	 	 	 	 	 	 / /   I f   a   l o c a l   c a l l b a c k   w a s   s p e c i f i e d ,   f i r e   i t   a n d   p a s s   i t   t h e   d a t a  
 	 	 	 	 	 	 i f   (   s . s u c c e s s   )  
 	 	 	 	 	 	 	 s . s u c c e s s (   d a t a ,   s t a t u s   ) ;  
 	  
 	 	 	 	 	 	 / /   F i r e   t h e   g l o b a l   c a l l b a c k  
 	 	 	 	 	 	 i f (   s . g l o b a l   )  
 	 	 	 	 	 	 	 j Q u e r y . e v e n t . t r i g g e r (   " a j a x S u c c e s s " ,   [ x m l ,   s ]   ) ;  
 	 	 	 	 	 }   e l s e  
 	 	 	 	 	 	 j Q u e r y . h a n d l e E r r o r ( s ,   x m l ,   s t a t u s ) ;  
 	 	 	 	 }   c a t c h ( e )   {  
 	 	 	 	 	 s t a t u s   =   " e r r o r " ;  
 	 	 	 	 	 j Q u e r y . h a n d l e E r r o r ( s ,   x m l ,   s t a t u s ,   e ) ;  
 	 	 	 	 }  
  
 	 	 	 	 / /   T h e   r e q u e s t   w a s   c o m p l e t e d  
 	 	 	 	 i f (   s . g l o b a l   )  
 	 	 	 	 	 j Q u e r y . e v e n t . t r i g g e r (   " a j a x C o m p l e t e " ,   [ x m l ,   s ]   ) ;  
  
 	 	 	 	 / /   H a n d l e   t h e   g l o b a l   A J A X   c o u n t e r  
 	 	 	 	 i f   (   s . g l o b a l   & &   !   - - j Q u e r y . a c t i v e   )  
 	 	 	 	 	 j Q u e r y . e v e n t . t r i g g e r (   " a j a x S t o p "   ) ;  
  
 	 	 	 	 / /   P r o c e s s   r e s u l t  
 	 	 	 	 i f   (   s . c o m p l e t e   )  
 	 	 	 	 	 s . c o m p l e t e ( x m l ,   s t a t u s ) ;  
  
 	 	 	 	 / /   S t o p   m e m o r y   l e a k s  
 	 	 	 	 i f ( s . a s y n c )  
 	 	 	 	 	 x m l   =   n u l l ;  
 	 	 	 }  
 	 	 } ;  
 	 	  
 	 	 / /   d o n ' t   a t t a c h   t h e   h a n d l e r   t o   t h e   r e q u e s t ,   j u s t   p o l l   i t   i n s t e a d  
 	 	 v a r   i v a l   =   s e t I n t e r v a l ( o n r e a d y s t a t e c h a n g e ,   1 3 ) ;    
  
 	 	 / /   T i m e o u t   c h e c k e r  
 	 	 i f   (   s . t i m e o u t   >   0   )  
 	 	 	 s e t T i m e o u t ( f u n c t i o n ( ) {  
 	 	 	 	 / /   C h e c k   t o   s e e   i f   t h e   r e q u e s t   i s   s t i l l   h a p p e n i n g  
 	 	 	 	 i f   (   x m l   )   {  
 	 	 	 	 	 / /   C a n c e l   t h e   r e q u e s t  
 	 	 	 	 	 x m l . a b o r t ( ) ;  
  
 	 	 	 	 	 i f (   ! r e q u e s t D o n e   )  
 	 	 	 	 	 	 o n r e a d y s t a t e c h a n g e (   " t i m e o u t "   ) ;  
 	 	 	 	 }  
 	 	 	 } ,   s . t i m e o u t ) ;  
 	 	 	  
 	 	 / /   S e n d   t h e   d a t a  
 	 	 t r y   {  
 	 	 	 x m l . s e n d ( s . d a t a ) ;  
 	 	 }   c a t c h ( e )   {  
 	 	 	 j Q u e r y . h a n d l e E r r o r ( s ,   x m l ,   n u l l ,   e ) ;  
 	 	 }  
 	 	  
 	 	 / /   f i r e f o x   1 . 5   d o e s n ' t   f i r e   s t a t e c h a n g e   f o r   s y n c   r e q u e s t s  
 	 	 i f   (   ! s . a s y n c   )  
 	 	 	 o n r e a d y s t a t e c h a n g e ( ) ;  
 	 	  
 	 	 / /   r e t u r n   X M L H t t p R e q u e s t   t o   a l l o w   a b o r t i n g   t h e   r e q u e s t   e t c .  
 	 	 r e t u r n   x m l ;  
 	 } ,  
  
 	 h a n d l e E r r o r :   f u n c t i o n (   s ,   x m l ,   s t a t u s ,   e   )   {  
 	 	 / /   I f   a   l o c a l   c a l l b a c k   w a s   s p e c i f i e d ,   f i r e   i t  
 	 	 i f   (   s . e r r o r   )   s . e r r o r (   x m l ,   s t a t u s ,   e   ) ;  
  
 	 	 / /   F i r e   t h e   g l o b a l   c a l l b a c k  
 	 	 i f   (   s . g l o b a l   )  
 	 	 	 j Q u e r y . e v e n t . t r i g g e r (   " a j a x E r r o r " ,   [ x m l ,   s ,   e ]   ) ;  
 	 } ,  
  
 	 / /   C o u n t e r   f o r   h o l d i n g   t h e   n u m b e r   o f   a c t i v e   q u e r i e s  
 	 a c t i v e :   0 ,  
  
 	 / /   D e t e r m i n e s   i f   a n   X M L H t t p R e q u e s t   w a s   s u c c e s s f u l   o r   n o t  
 	 h t t p S u c c e s s :   f u n c t i o n (   r   )   {  
 	 	 t r y   {  
 	 	 	 r e t u r n   ! r . s t a t u s   & &   l o c a t i o n . p r o t o c o l   = =   " f i l e : "   | |  
 	 	 	 	 (   r . s t a t u s   > =   2 0 0   & &   r . s t a t u s   <   3 0 0   )   | |   r . s t a t u s   = =   3 0 4   | |  
 	 	 	 	 j Q u e r y . b r o w s e r . s a f a r i   & &   r . s t a t u s   = =   u n d e f i n e d ;  
 	 	 }   c a t c h ( e ) { }  
 	 	 r e t u r n   f a l s e ;  
 	 } ,  
  
 	 / /   D e t e r m i n e s   i f   a n   X M L H t t p R e q u e s t   r e t u r n s   N o t M o d i f i e d  
 	 h t t p N o t M o d i f i e d :   f u n c t i o n (   x m l ,   u r l   )   {  
 	 	 t r y   {  
 	 	 	 v a r   x m l R e s   =   x m l . g e t R e s p o n s e H e a d e r ( " L a s t - M o d i f i e d " ) ;  
  
 	 	 	 / /   F i r e f o x   a l w a y s   r e t u r n s   2 0 0 .   c h e c k   L a s t - M o d i f i e d   d a t e  
 	 	 	 r e t u r n   x m l . s t a t u s   = =   3 0 4   | |   x m l R e s   = =   j Q u e r y . l a s t M o d i f i e d [ u r l ]   | |  
 	 	 	 	 j Q u e r y . b r o w s e r . s a f a r i   & &   x m l . s t a t u s   = =   u n d e f i n e d ;  
 	 	 }   c a t c h ( e ) { }  
 	 	 r e t u r n   f a l s e ;  
 	 } ,  
  
 	 / *   G e t   t h e   d a t a   o u t   o f   a n   X M L H t t p R e q u e s t .  
 	   *   R e t u r n   p a r s e d   X M L   i f   c o n t e n t - t y p e   h e a d e r   i s   " x m l "   a n d   t y p e   i s   " x m l "   o r   o m i t t e d ,  
 	   *   o t h e r w i s e   r e t u r n   p l a i n   t e x t .  
 	   *   ( S t r i n g )   d a t a   -   T h e   t y p e   o f   d a t a   t h a t   y o u ' r e   e x p e c t i n g   b a c k ,  
 	   *   ( e . g .   " x m l " ,   " h t m l " ,   " s c r i p t " )  
 	   * /  
 	 h t t p D a t a :   f u n c t i o n (   r ,   t y p e   )   {  
 	 	 v a r   c t   =   r . g e t R e s p o n s e H e a d e r ( " c o n t e n t - t y p e " ) ;  
 	 	 v a r   d a t a   =   ! t y p e   & &   c t   & &   c t . i n d e x O f ( " x m l " )   > =   0 ;  
 	 	 d a t a   =   t y p e   = =   " x m l "   | |   d a t a   ?   r . r e s p o n s e X M L   :   r . r e s p o n s e T e x t ;  
  
 	 	 / /   I f   t h e   t y p e   i s   " s c r i p t " ,   e v a l   i t   i n   g l o b a l   c o n t e x t  
 	 	 i f   (   t y p e   = =   " s c r i p t "   )  
 	 	 	 j Q u e r y . g l o b a l E v a l (   d a t a   ) ;  
  
 	 	 / /   G e t   t h e   J a v a S c r i p t   o b j e c t ,   i f   J S O N   i s   u s e d .  
 	 	 i f   (   t y p e   = =   " j s o n "   )  
 	 	 	 d a t a   =   e v a l ( " ( "   +   d a t a   +   " ) " ) ;  
  
 	 	 / /   e v a l u a t e   s c r i p t s   w i t h i n   h t m l  
 	 	 i f   (   t y p e   = =   " h t m l "   )  
 	 	 	 j Q u e r y ( " < d i v > " ) . h t m l ( d a t a ) . e v a l S c r i p t s ( ) ;  
  
 	 	 r e t u r n   d a t a ;  
 	 } ,  
  
 	 / /   S e r i a l i z e   a n   a r r a y   o f   f o r m   e l e m e n t s   o r   a   s e t   o f  
 	 / /   k e y / v a l u e s   i n t o   a   q u e r y   s t r i n g  
 	 p a r a m :   f u n c t i o n (   a   )   {  
 	 	 v a r   s   =   [ ] ;  
  
 	 	 / /   I f   a n   a r r a y   w a s   p a s s e d   i n ,   a s s u m e   t h a t   i t   i s   a n   a r r a y  
 	 	 / /   o f   f o r m   e l e m e n t s  
 	 	 i f   (   a . c o n s t r u c t o r   = =   A r r a y   | |   a . j q u e r y   )  
 	 	 	 / /   S e r i a l i z e   t h e   f o r m   e l e m e n t s  
 	 	 	 j Q u e r y . e a c h (   a ,   f u n c t i o n ( ) {  
 	 	 	 	 s . p u s h (   e n c o d e U R I C o m p o n e n t ( t h i s . n a m e )   +   " = "   +   e n c o d e U R I C o m p o n e n t (   t h i s . v a l u e   )   ) ;  
 	 	 	 } ) ;  
  
 	 	 / /   O t h e r w i s e ,   a s s u m e   t h a t   i t ' s   a n   o b j e c t   o f   k e y / v a l u e   p a i r s  
 	 	 e l s e  
 	 	 	 / /   S e r i a l i z e   t h e   k e y / v a l u e s  
 	 	 	 f o r   (   v a r   j   i n   a   )  
 	 	 	 	 / /   I f   t h e   v a l u e   i s   a n   a r r a y   t h e n   t h e   k e y   n a m e s   n e e d   t o   b e   r e p e a t e d  
 	 	 	 	 i f   (   a [ j ]   & &   a [ j ] . c o n s t r u c t o r   = =   A r r a y   )  
 	 	 	 	 	 j Q u e r y . e a c h (   a [ j ] ,   f u n c t i o n ( ) {  
 	 	 	 	 	 	 s . p u s h (   e n c o d e U R I C o m p o n e n t ( j )   +   " = "   +   e n c o d e U R I C o m p o n e n t (   t h i s   )   ) ;  
 	 	 	 	 	 } ) ;  
 	 	 	 	 e l s e  
 	 	 	 	 	 s . p u s h (   e n c o d e U R I C o m p o n e n t ( j )   +   " = "   +   e n c o d e U R I C o m p o n e n t (   a [ j ]   )   ) ;  
  
 	 	 / /   R e t u r n   t h e   r e s u l t i n g   s e r i a l i z a t i o n  
 	 	 r e t u r n   s . j o i n ( " & " ) ;  
 	 } ,  
 	  
 	 / /   e v a l u l a t e s   a   s c r i p t   i n   g l o b a l   c o n t e x t  
 	 / /   n o t   r e l i a b l e   f o r   s a f a r i  
 	 g l o b a l E v a l :   f u n c t i o n (   d a t a   )   {  
 	 	 i f   (   w i n d o w . e x e c S c r i p t   )  
 	 	 	 w i n d o w . e x e c S c r i p t (   d a t a   ) ;  
 	 	 e l s e   i f   (   j Q u e r y . b r o w s e r . s a f a r i   )  
 	 	 	 / /   s a f a r i   d o e s n ' t   p r o v i d e   a   s y n c h r o n o u s   g l o b a l   e v a l  
 	 	 	 w i n d o w . s e t T i m e o u t (   d a t a ,   0   ) ;  
 	 	 e l s e  
 	 	 	 e v a l . c a l l (   w i n d o w ,   d a t a   ) ;  
 	 }  
  
 } ) ;  
 j Q u e r y . f n . e x t e n d ( {  
  
 	 s h o w :   f u n c t i o n ( s p e e d , c a l l b a c k ) {  
 	 	 r e t u r n   s p e e d   ?  
 	 	 	 t h i s . a n i m a t e ( {  
 	 	 	 	 h e i g h t :   " s h o w " ,   w i d t h :   " s h o w " ,   o p a c i t y :   " s h o w "  
 	 	 	 } ,   s p e e d ,   c a l l b a c k )   :  
 	 	 	  
 	 	 	 t h i s . f i l t e r ( " : h i d d e n " ) . e a c h ( f u n c t i o n ( ) {  
 	 	 	 	 t h i s . s t y l e . d i s p l a y   =   t h i s . o l d b l o c k   ?   t h i s . o l d b l o c k   :   " " ;  
 	 	 	 	 i f   (   j Q u e r y . c s s ( t h i s , " d i s p l a y " )   = =   " n o n e "   )  
 	 	 	 	 	 t h i s . s t y l e . d i s p l a y   =   " b l o c k " ;  
 	 	 	 } ) . e n d ( ) ;  
 	 } ,  
  
 	 h i d e :   f u n c t i o n ( s p e e d , c a l l b a c k ) {  
 	 	 r e t u r n   s p e e d   ?  
 	 	 	 t h i s . a n i m a t e ( {  
 	 	 	 	 h e i g h t :   " h i d e " ,   w i d t h :   " h i d e " ,   o p a c i t y :   " h i d e "  
 	 	 	 } ,   s p e e d ,   c a l l b a c k )   :  
 	 	 	  
 	 	 	 t h i s . f i l t e r ( " : v i s i b l e " ) . e a c h ( f u n c t i o n ( ) {  
 	 	 	 	 t h i s . o l d b l o c k   =   t h i s . o l d b l o c k   | |   j Q u e r y . c s s ( t h i s , " d i s p l a y " ) ;  
 	 	 	 	 i f   (   t h i s . o l d b l o c k   = =   " n o n e "   )  
 	 	 	 	 	 t h i s . o l d b l o c k   =   " b l o c k " ;  
 	 	 	 	 t h i s . s t y l e . d i s p l a y   =   " n o n e " ;  
 	 	 	 } ) . e n d ( ) ;  
 	 } ,  
  
 	 / /   S a v e   t h e   o l d   t o g g l e   f u n c t i o n  
 	 _ t o g g l e :   j Q u e r y . f n . t o g g l e ,  
 	 t o g g l e :   f u n c t i o n (   f n ,   f n 2   ) {  
 	 	 r e t u r n   j Q u e r y . i s F u n c t i o n ( f n )   & &   j Q u e r y . i s F u n c t i o n ( f n 2 )   ?  
 	 	 	 t h i s . _ t o g g l e (   f n ,   f n 2   )   :  
 	 	 	 f n   ?  
 	 	 	 	 t h i s . a n i m a t e ( {  
 	 	 	 	 	 h e i g h t :   " t o g g l e " ,   w i d t h :   " t o g g l e " ,   o p a c i t y :   " t o g g l e "  
 	 	 	 	 } ,   f n ,   f n 2 )   :  
 	 	 	 	 t h i s . e a c h ( f u n c t i o n ( ) {  
 	 	 	 	 	 j Q u e r y ( t h i s ) [   j Q u e r y ( t h i s ) . i s ( " : h i d d e n " )   ?   " s h o w "   :   " h i d e "   ] ( ) ;  
 	 	 	 	 } ) ;  
 	 } ,  
 	 s l i d e D o w n :   f u n c t i o n ( s p e e d , c a l l b a c k ) {  
 	 	 r e t u r n   t h i s . a n i m a t e ( { h e i g h t :   " s h o w " } ,   s p e e d ,   c a l l b a c k ) ;  
 	 } ,  
 	 s l i d e U p :   f u n c t i o n ( s p e e d , c a l l b a c k ) {  
 	 	 r e t u r n   t h i s . a n i m a t e ( { h e i g h t :   " h i d e " } ,   s p e e d ,   c a l l b a c k ) ;  
 	 } ,  
 	 s l i d e T o g g l e :   f u n c t i o n ( s p e e d ,   c a l l b a c k ) {  
 	 	 r e t u r n   t h i s . a n i m a t e ( { h e i g h t :   " t o g g l e " } ,   s p e e d ,   c a l l b a c k ) ;  
 	 } ,  
 	 f a d e I n :   f u n c t i o n ( s p e e d ,   c a l l b a c k ) {  
 	 	 r e t u r n   t h i s . a n i m a t e ( { o p a c i t y :   " s h o w " } ,   s p e e d ,   c a l l b a c k ) ;  
 	 } ,  
 	 f a d e O u t :   f u n c t i o n ( s p e e d ,   c a l l b a c k ) {  
 	 	 r e t u r n   t h i s . a n i m a t e ( { o p a c i t y :   " h i d e " } ,   s p e e d ,   c a l l b a c k ) ;  
 	 } ,  
 	 f a d e T o :   f u n c t i o n ( s p e e d , t o , c a l l b a c k ) {  
 	 	 r e t u r n   t h i s . a n i m a t e ( { o p a c i t y :   t o } ,   s p e e d ,   c a l l b a c k ) ;  
 	 } ,  
 	 a n i m a t e :   f u n c t i o n (   p r o p ,   s p e e d ,   e a s i n g ,   c a l l b a c k   )   {  
 	 	 r e t u r n   t h i s . q u e u e ( f u n c t i o n ( ) {  
 	 	 	 v a r   h i d d e n   =   j Q u e r y ( t h i s ) . i s ( " : h i d d e n " ) ,  
 	 	 	 	 o p t   =   j Q u e r y . s p e e d ( s p e e d ,   e a s i n g ,   c a l l b a c k ) ,  
 	 	 	 	 s e l f   =   t h i s ;  
 	 	 	  
 	 	 	 f o r   (   v a r   p   i n   p r o p   )   {  
 	 	 	 	 i f   (   p r o p [ p ]   = =   " h i d e "   & &   h i d d e n   | |   p r o p [ p ]   = =   " s h o w "   & &   ! h i d d e n   )  
 	 	 	 	 	 r e t u r n   j Q u e r y . i s F u n c t i o n ( o p t . c o m p l e t e )   & &   o p t . c o m p l e t e . a p p l y ( t h i s ) ;  
  
 	 	 	 	 i f   (   p   = =   " h e i g h t "   | |   p   = =   " w i d t h "   )   {  
 	 	 	 	 	 / /   S t o r e   d i s p l a y   p r o p e r t y  
 	 	 	 	 	 o p t . d i s p l a y   =   j Q u e r y . c s s ( t h i s ,   " d i s p l a y " ) ;  
  
 	 	 	 	 	 / /   M a k e   s u r e   t h a t   n o t h i n g   s n e a k s   o u t  
 	 	 	 	 	 o p t . o v e r f l o w   =   t h i s . s t y l e . o v e r f l o w ;  
 	 	 	 	 }  
 	 	 	 }  
  
 	 	 	 i f   (   o p t . o v e r f l o w   ! =   n u l l   )  
 	 	 	 	 t h i s . s t y l e . o v e r f l o w   =   " h i d d e n " ;  
  
 	 	 	 t h i s . c u r A n i m   =   j Q u e r y . e x t e n d ( { } ,   p r o p ) ;  
 	 	 	  
 	 	 	 j Q u e r y . e a c h (   p r o p ,   f u n c t i o n ( n a m e ,   v a l ) {  
 	 	 	 	 v a r   e   =   n e w   j Q u e r y . f x (   s e l f ,   o p t ,   n a m e   ) ;  
 	 	 	 	 i f   (   v a l . c o n s t r u c t o r   = =   N u m b e r   )  
 	 	 	 	 	 e . c u s t o m (   e . c u r ( ) ,   v a l   ) ;  
 	 	 	 	 e l s e  
 	 	 	 	 	 e [   v a l   = =   " t o g g l e "   ?   h i d d e n   ?   " s h o w "   :   " h i d e "   :   v a l   ] (   p r o p   ) ;  
 	 	 	 } ) ;  
 	 	 } ) ;  
 	 } ,  
 	 q u e u e :   f u n c t i o n ( t y p e , f n ) {  
 	 	 i f   (   ! f n   )   {  
 	 	 	 f n   =   t y p e ;  
 	 	 	 t y p e   =   " f x " ;  
 	 	 }  
 	  
 	 	 r e t u r n   t h i s . e a c h ( f u n c t i o n ( ) {  
 	 	 	 i f   (   ! t h i s . q u e u e   )  
 	 	 	 	 t h i s . q u e u e   =   { } ;  
 	  
 	 	 	 i f   (   ! t h i s . q u e u e [ t y p e ]   )  
 	 	 	 	 t h i s . q u e u e [ t y p e ]   =   [ ] ;  
 	  
 	 	 	 t h i s . q u e u e [ t y p e ] . p u s h (   f n   ) ;  
 	 	  
 	 	 	 i f   (   t h i s . q u e u e [ t y p e ] . l e n g t h   = =   1   )  
 	 	 	 	 f n . a p p l y ( t h i s ) ;  
 	 	 } ) ;  
 	 }  
  
 } ) ;  
  
 j Q u e r y . e x t e n d ( {  
 	  
 	 s p e e d :   f u n c t i o n ( s p e e d ,   e a s i n g ,   f n )   {  
 	 	 v a r   o p t   =   s p e e d   & &   s p e e d . c o n s t r u c t o r   = =   O b j e c t   ?   s p e e d   :   {  
 	 	 	 c o m p l e t e :   f n   | |   ! f n   & &   e a s i n g   | |    
 	 	 	 	 j Q u e r y . i s F u n c t i o n (   s p e e d   )   & &   s p e e d ,  
 	 	 	 d u r a t i o n :   s p e e d ,  
 	 	 	 e a s i n g :   f n   & &   e a s i n g   | |   e a s i n g   & &   e a s i n g . c o n s t r u c t o r   ! =   F u n c t i o n   & &   e a s i n g   | |   ( j Q u e r y . e a s i n g . s w i n g   ?   " s w i n g "   :   " l i n e a r " )  
 	 	 } ;  
  
 	 	 o p t . d u r a t i o n   =   ( o p t . d u r a t i o n   & &   o p t . d u r a t i o n . c o n s t r u c t o r   = =   N u m b e r   ?    
 	 	 	 o p t . d u r a t i o n   :    
 	 	 	 {   s l o w :   6 0 0 ,   f a s t :   2 0 0   } [ o p t . d u r a t i o n ] )   | |   4 0 0 ;  
 	  
 	 	 / /   Q u e u e i n g  
 	 	 o p t . o l d   =   o p t . c o m p l e t e ;  
 	 	 o p t . c o m p l e t e   =   f u n c t i o n ( ) {  
 	 	 	 j Q u e r y . d e q u e u e ( t h i s ,   " f x " ) ;  
 	 	 	 i f   (   j Q u e r y . i s F u n c t i o n (   o p t . o l d   )   )  
 	 	 	 	 o p t . o l d . a p p l y (   t h i s   ) ;  
 	 	 } ;  
 	  
 	 	 r e t u r n   o p t ;  
 	 } ,  
 	  
 	 e a s i n g :   {  
 	 	 l i n e a r :   f u n c t i o n (   p ,   n ,   f i r s t N u m ,   d i f f   )   {  
 	 	 	 r e t u r n   f i r s t N u m   +   d i f f   *   p ;  
 	 	 } ,  
 	 	 s w i n g :   f u n c t i o n (   p ,   n ,   f i r s t N u m ,   d i f f   )   {  
 	 	 	 r e t u r n   ( ( - M a t h . c o s ( p * M a t h . P I ) / 2 )   +   0 . 5 )   *   d i f f   +   f i r s t N u m ;  
 	 	 }  
 	 } ,  
 	  
 	 q u e u e :   { } ,  
 	  
 	 d e q u e u e :   f u n c t i o n ( e l e m , t y p e ) {  
 	 	 t y p e   =   t y p e   | |   " f x " ;  
 	  
 	 	 i f   (   e l e m . q u e u e   & &   e l e m . q u e u e [ t y p e ]   )   {  
 	 	 	 / /   R e m o v e   s e l f  
 	 	 	 e l e m . q u e u e [ t y p e ] . s h i f t ( ) ;  
 	  
 	 	 	 / /   G e t   n e x t   f u n c t i o n  
 	 	 	 v a r   f   =   e l e m . q u e u e [ t y p e ] [ 0 ] ;  
 	 	  
 	 	 	 i f   (   f   )   f . a p p l y (   e l e m   ) ;  
 	 	 }  
 	 } ,  
  
 	 t i m e r s :   [ ] ,  
  
 	 / *  
 	   *   I   o r i g i n a l l y   w r o t e   f x ( )   a s   a   c l o n e   o f   m o o . f x   a n d   i n   t h e   p r o c e s s  
 	   *   o f   m a k i n g   i t   s m a l l   i n   s i z e   t h e   c o d e   b e c a m e   i l l e g i b l e   t o   s a n e  
 	   *   p e o p l e .   Y o u ' v e   b e e n   w a r n e d .  
 	   * /  
 	  
 	 f x :   f u n c t i o n (   e l e m ,   o p t i o n s ,   p r o p   ) {  
  
 	 	 v a r   z   =   t h i s ;  
  
 	 	 / /   T h e   s t y l e s  
 	 	 v a r   y   =   e l e m . s t y l e ;  
 	 	  
 	 	 / /   S i m p l e   f u n c t i o n   f o r   s e t t i n g   a   s t y l e   v a l u e  
 	 	 z . a   =   f u n c t i o n ( ) {  
 	 	 	 i f   (   o p t i o n s . s t e p   )  
 	 	 	 	 o p t i o n s . s t e p . a p p l y (   e l e m ,   [   z . n o w   ]   ) ;  
  
 	 	 	 i f   (   p r o p   = =   " o p a c i t y "   )  
 	 	 	 	 j Q u e r y . a t t r ( y ,   " o p a c i t y " ,   z . n o w ) ;   / /   L e t   a t t r   h a n d l e   o p a c i t y  
 	 	 	 e l s e   {  
 	 	 	 	 y [ p r o p ]   =   p a r s e I n t ( z . n o w )   +   " p x " ;  
 	 	 	 	 y . d i s p l a y   =   " b l o c k " ;   / /   S e t   d i s p l a y   p r o p e r t y   t o   b l o c k   f o r   a n i m a t i o n  
 	 	 	 }  
 	 	 } ;  
  
 	 	 / /   F i g u r e   o u t   t h e   m a x i m u m   n u m b e r   t o   r u n   t o  
 	 	 z . m a x   =   f u n c t i o n ( ) {  
 	 	 	 r e t u r n   p a r s e F l o a t (   j Q u e r y . c s s ( e l e m , p r o p )   ) ;  
 	 	 } ;  
  
 	 	 / /   G e t   t h e   c u r r e n t   s i z e  
 	 	 z . c u r   =   f u n c t i o n ( ) {  
 	 	 	 v a r   r   =   p a r s e F l o a t (   j Q u e r y . c u r C S S ( e l e m ,   p r o p )   ) ;  
 	 	 	 r e t u r n   r   & &   r   >   - 1 0 0 0 0   ?   r   :   z . m a x ( ) ;  
 	 	 } ;  
  
 	 	 / /   S t a r t   a n   a n i m a t i o n   f r o m   o n e   n u m b e r   t o   a n o t h e r  
 	 	 z . c u s t o m   =   f u n c t i o n ( f r o m , t o ) {  
 	 	 	 z . s t a r t T i m e   =   ( n e w   D a t e ( ) ) . g e t T i m e ( ) ;  
 	 	 	 z . n o w   =   f r o m ;  
 	 	 	 z . a ( ) ;  
  
 	 	 	 j Q u e r y . t i m e r s . p u s h ( f u n c t i o n ( ) {  
 	 	 	 	 r e t u r n   z . s t e p ( f r o m ,   t o ) ;  
 	 	 	 } ) ;  
  
 	 	 	 i f   (   j Q u e r y . t i m e r s . l e n g t h   = =   1   )   {  
 	 	 	 	 v a r   t i m e r   =   s e t I n t e r v a l ( f u n c t i o n ( ) {  
 	 	 	 	 	 v a r   t i m e r s   =   j Q u e r y . t i m e r s ;  
 	 	 	 	 	  
 	 	 	 	 	 f o r   (   v a r   i   =   0 ;   i   <   t i m e r s . l e n g t h ;   i + +   )  
 	 	 	 	 	 	 i f   (   ! t i m e r s [ i ] ( )   )  
 	 	 	 	 	 	 	 t i m e r s . s p l i c e ( i - - ,   1 ) ;  
  
 	 	 	 	 	 i f   (   ! t i m e r s . l e n g t h   )  
 	 	 	 	 	 	 c l e a r I n t e r v a l (   t i m e r   ) ;  
 	 	 	 	 } ,   1 3 ) ;  
 	 	 	 }  
 	 	 } ;  
  
 	 	 / /   S i m p l e   ' s h o w '   f u n c t i o n  
 	 	 z . s h o w   =   f u n c t i o n ( ) {  
 	 	 	 i f   (   ! e l e m . o r i g   )   e l e m . o r i g   =   { } ;  
  
 	 	 	 / /   R e m e m b e r   w h e r e   w e   s t a r t e d ,   s o   t h a t   w e   c a n   g o   b a c k   t o   i t   l a t e r  
 	 	 	 e l e m . o r i g [ p r o p ]   =   j Q u e r y . a t t r (   e l e m . s t y l e ,   p r o p   ) ;  
  
 	 	 	 o p t i o n s . s h o w   =   t r u e ;  
  
 	 	 	 / /   B e g i n   t h e   a n i m a t i o n  
 	 	 	 z . c u s t o m ( 0 ,   t h i s . c u r ( ) ) ;  
  
 	 	 	 / /   M a k e   s u r e   t h a t   w e   s t a r t   a t   a   s m a l l   w i d t h / h e i g h t   t o   a v o i d   a n y  
 	 	 	 / /   f l a s h   o f   c o n t e n t  
 	 	 	 i f   (   p r o p   ! =   " o p a c i t y "   )  
 	 	 	 	 y [ p r o p ]   =   " 1 p x " ;  
 	 	 	  
 	 	 	 / /   S t a r t   b y   s h o w i n g   t h e   e l e m e n t  
 	 	 	 j Q u e r y ( e l e m ) . s h o w ( ) ;  
 	 	 } ;  
  
 	 	 / /   S i m p l e   ' h i d e '   f u n c t i o n  
 	 	 z . h i d e   =   f u n c t i o n ( ) {  
 	 	 	 i f   (   ! e l e m . o r i g   )   e l e m . o r i g   =   { } ;  
  
 	 	 	 / /   R e m e m b e r   w h e r e   w e   s t a r t e d ,   s o   t h a t   w e   c a n   g o   b a c k   t o   i t   l a t e r  
 	 	 	 e l e m . o r i g [ p r o p ]   =   j Q u e r y . a t t r (   e l e m . s t y l e ,   p r o p   ) ;  
  
 	 	 	 o p t i o n s . h i d e   =   t r u e ;  
  
 	 	 	 / /   B e g i n   t h e   a n i m a t i o n  
 	 	 	 z . c u s t o m ( t h i s . c u r ( ) ,   0 ) ;  
 	 	 } ;  
  
 	 	 / /   E a c h   s t e p   o f   a n   a n i m a t i o n  
 	 	 z . s t e p   =   f u n c t i o n ( f i r s t N u m ,   l a s t N u m ) {  
 	 	 	 v a r   t   =   ( n e w   D a t e ( ) ) . g e t T i m e ( ) ;  
  
 	 	 	 i f   ( t   >   o p t i o n s . d u r a t i o n   +   z . s t a r t T i m e )   {  
 	 	 	 	 z . n o w   =   l a s t N u m ;  
 	 	 	 	 z . a ( ) ;  
  
 	 	 	 	 i f   ( e l e m . c u r A n i m )   e l e m . c u r A n i m [   p r o p   ]   =   t r u e ;  
  
 	 	 	 	 v a r   d o n e   =   t r u e ;  
 	 	 	 	 f o r   (   v a r   i   i n   e l e m . c u r A n i m   )  
 	 	 	 	 	 i f   (   e l e m . c u r A n i m [ i ]   ! = =   t r u e   )  
 	 	 	 	 	 	 d o n e   =   f a l s e ;  
  
 	 	 	 	 i f   (   d o n e   )   {  
 	 	 	 	 	 i f   (   o p t i o n s . d i s p l a y   ! =   n u l l   )   {  
 	 	 	 	 	 	 / /   R e s e t   t h e   o v e r f l o w  
 	 	 	 	 	 	 y . o v e r f l o w   =   o p t i o n s . o v e r f l o w ;  
 	 	 	 	 	  
 	 	 	 	 	 	 / /   R e s e t   t h e   d i s p l a y  
 	 	 	 	 	 	 y . d i s p l a y   =   o p t i o n s . d i s p l a y ;  
 	 	 	 	 	 	 i f   (   j Q u e r y . c s s ( e l e m ,   " d i s p l a y " )   = =   " n o n e "   )  
 	 	 	 	 	 	 	 y . d i s p l a y   =   " b l o c k " ;  
 	 	 	 	 	 }  
  
 	 	 	 	 	 / /   H i d e   t h e   e l e m e n t   i f   t h e   " h i d e "   o p e r a t i o n   w a s   d o n e  
 	 	 	 	 	 i f   (   o p t i o n s . h i d e   )  
 	 	 	 	 	 	 y . d i s p l a y   =   " n o n e " ;  
  
 	 	 	 	 	 / /   R e s e t   t h e   p r o p e r t i e s ,   i f   t h e   i t e m   h a s   b e e n   h i d d e n   o r   s h o w n  
 	 	 	 	 	 i f   (   o p t i o n s . h i d e   | |   o p t i o n s . s h o w   )  
 	 	 	 	 	 	 f o r   (   v a r   p   i n   e l e m . c u r A n i m   )  
 	 	 	 	 	 	 	 j Q u e r y . a t t r ( y ,   p ,   e l e m . o r i g [ p ] ) ;  
 	 	 	 	 }  
  
 	 	 	 	 / /   I f   a   c a l l b a c k   w a s   p r o v i d e d ,   e x e c u t e   i t  
 	 	 	 	 i f   (   d o n e   & &   j Q u e r y . i s F u n c t i o n (   o p t i o n s . c o m p l e t e   )   )  
 	 	 	 	 	 / /   E x e c u t e   t h e   c o m p l e t e   f u n c t i o n  
 	 	 	 	 	 o p t i o n s . c o m p l e t e . a p p l y (   e l e m   ) ;  
  
 	 	 	 	 r e t u r n   f a l s e ;  
 	 	 	 }   e l s e   {  
 	 	 	 	 v a r   n   =   t   -   t h i s . s t a r t T i m e ;  
 	 	 	 	 / /   F i g u r e   o u t   w h e r e   i n   t h e   a n i m a t i o n   w e   a r e   a n d   s e t   t h e   n u m b e r  
 	 	 	 	 v a r   p   =   n   /   o p t i o n s . d u r a t i o n ;  
 	 	 	 	  
 	 	 	 	 / /   P e r f o r m   t h e   e a s i n g   f u n c t i o n ,   d e f a u l t s   t o   s w i n g  
 	 	 	 	 z . n o w   =   j Q u e r y . e a s i n g [ o p t i o n s . e a s i n g ] ( p ,   n ,   f i r s t N u m ,   ( l a s t N u m - f i r s t N u m ) ,   o p t i o n s . d u r a t i o n ) ;  
  
 	 	 	 	 / /   P e r f o r m   t h e   n e x t   s t e p   o f   t h e   a n i m a t i o n  
 	 	 	 	 z . a ( ) ;  
 	 	 	 }  
  
 	 	 	 r e t u r n   t r u e ;  
 	 	 } ;  
 	  
 	 }  
 } ) ;  
 }  
 
