ÿþÿþ/ *  
 S c r i p t :   C o r e . j s  
 	 M o o t o o l s   -   M y   O b j e c t   O r i e n t e d   j a v a s c r i p t .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
  
 M o o T o o l s   C o p y r i g h t :  
 	 c o p y r i g h t   ( c )   2 0 0 7   V a l e r i o   P r o i e t t i ,   < h t t p : / / m a d 4 m i l k . n e t >  
  
 M o o T o o l s   C r e d i t s :  
 	 -   C l a s s   i s   s l i g h t l y   b a s e d   o n   B a s e . j s   < h t t p : / / d e a n . e d w a r d s . n a m e / w e b l o g / 2 0 0 6 / 0 3 / b a s e / >   ( c )   2 0 0 6   D e a n   E d w a r d s ,   L i c e n s e   < h t t p : / / c r e a t i v e c o m m o n s . o r g / l i c e n s e s / L G P L / 2 . 1 / >  
 	 -   S o m e   f u n c t i o n s   a r e   i n s p i r e d   b y   t h o s e   f o u n d   i n   p r o t o t y p e . j s   < h t t p : / / p r o t o t y p e . c o n i o . n e t / >   ( c )   2 0 0 5   S a m   S t e p h e n s o n   s a m   [ a t ]   c o n i o   [ d o t ]   n e t ,   M I T - s t y l e   l i c e n s e  
 	 -   D o c u m e n t a t i o n   b y   A a r o n   N e w t o n   ( a a r o n . n e w t o n   [ a t ]   c n e t   [ d o t ]   c o m )   a n d   V a l e r i o   P r o i e t t i .  
 * /  
  
 v a r   M o o T o o l s   =   {  
 	 v e r s i o n :   ' 1 . 1 1 '    
 } ;  
  
 / *   S e c t i o n :   C o r e   F u n c t i o n s   * /  
  
 / *  
 F u n c t i o n :   $ d e f i n e d  
 	 R e t u r n s   t r u e   i f   t h e   p a s s e d   i n   v a l u e / o b j e c t   i s   d e f i n e d ,   t h a t   m e a n s   i s   n o t   n u l l   o r   u n d e f i n e d .  
  
 A r g u m e n t s :  
 	 o b j   -   o b j e c t   t o   i n s p e c t  
 * /  
  
 f u n c t i o n   $ d e f i n e d ( o b j ) {  
 	 r e t u r n   ( o b j   ! =   u n d e f i n e d ) ;  
 } ;  
  
 / *  
 F u n c t i o n :   $ t y p e  
 	 R e t u r n s   t h e   t y p e   o f   o b j e c t   t h a t   m a t c h e s   t h e   e l e m e n t   p a s s e d   i n .  
  
 A r g u m e n t s :  
 	 o b j   -   t h e   o b j e c t   t o   i n s p e c t .  
  
 E x a m p l e :  
 	 > v a r   m y S t r i n g   =   ' h e l l o ' ;  
 	 > $ t y p e ( m y S t r i n g ) ;   / / r e t u r n s   " s t r i n g "  
  
 R e t u r n s :  
 	 ' e l e m e n t '   -   i f   o b j   i s   a   D O M   e l e m e n t   n o d e  
 	 ' t e x t n o d e '   -   i f   o b j   i s   a   D O M   t e x t   n o d e  
 	 ' w h i t e s p a c e '   -   i f   o b j   i s   a   D O M   w h i t e s p a c e   n o d e  
 	 ' a r g u m e n t s '   -   i f   o b j   i s   a n   a r g u m e n t s   o b j e c t  
 	 ' o b j e c t '   -   i f   o b j   i s   a n   o b j e c t  
 	 ' s t r i n g '   -   i f   o b j   i s   a   s t r i n g  
 	 ' n u m b e r '   -   i f   o b j   i s   a   n u m b e r  
 	 ' b o o l e a n '   -   i f   o b j   i s   a   b o o l e a n  
 	 ' f u n c t i o n '   -   i f   o b j   i s   a   f u n c t i o n  
 	 ' r e g e x p '   -   i f   o b j   i s   a   r e g u l a r   e x p r e s s i o n  
 	 ' c l a s s '   -   i f   o b j   i s   a   C l a s s .   ( c r e a t e d   w i t h   n e w   C l a s s ,   o r   t h e   e x t e n d   o f   a n o t h e r   c l a s s ) .  
 	 ' c o l l e c t i o n '   -   i f   o b j   i s   a   n a t i v e   h t m l e l e m e n t s   c o l l e c t i o n ,   s u c h   a s   c h i l d N o d e s ,   g e t E l e m e n t s B y T a g N a m e   . .   e t c .  
 	 f a l s e   -   ( b o o l e a n )   i f   t h e   o b j e c t   i s   n o t   d e f i n e d   o r   n o n e   o f   t h e   a b o v e .  
 * /  
  
 f u n c t i o n   $ t y p e ( o b j ) {  
 	 i f   ( ! $ d e f i n e d ( o b j ) )   r e t u r n   f a l s e ;  
 	 i f   ( o b j . h t m l E l e m e n t )   r e t u r n   ' e l e m e n t ' ;  
 	 v a r   t y p e   =   t y p e o f   o b j ;  
 	 i f   ( t y p e   = =   ' o b j e c t '   & &   o b j . n o d e N a m e ) {  
 	 	 s w i t c h ( o b j . n o d e T y p e ) {  
 	 	 	 c a s e   1 :   r e t u r n   ' e l e m e n t ' ;  
 	 	 	 c a s e   3 :   r e t u r n   ( / \ S / ) . t e s t ( o b j . n o d e V a l u e )   ?   ' t e x t n o d e '   :   ' w h i t e s p a c e ' ;  
 	 	 }  
 	 }  
 	 i f   ( t y p e   = =   ' o b j e c t '   | |   t y p e   = =   ' f u n c t i o n ' ) {  
 	 	 s w i t c h ( o b j . c o n s t r u c t o r ) {  
 	 	 	 c a s e   A r r a y :   r e t u r n   ' a r r a y ' ;  
 	 	 	 c a s e   R e g E x p :   r e t u r n   ' r e g e x p ' ;  
 	 	 	 c a s e   C l a s s :   r e t u r n   ' c l a s s ' ;  
 	 	 }  
 	 	 i f   ( t y p e o f   o b j . l e n g t h   = =   ' n u m b e r ' ) {  
 	 	 	 i f   ( o b j . i t e m )   r e t u r n   ' c o l l e c t i o n ' ;  
 	 	 	 i f   ( o b j . c a l l e e )   r e t u r n   ' a r g u m e n t s ' ;  
 	 	 }  
 	 }  
 	 r e t u r n   t y p e ;  
 } ;  
  
 / *  
 F u n c t i o n :   $ m e r g e  
 	 m e r g e s   a   n u m b e r   o f   o b j e c t s   r e c u r s i v e l y   w i t h o u t   r e f e r e n c i n g   t h e m   o r   t h e i r   s u b - o b j e c t s .  
  
 A r g u m e n t s :  
 	 a n y   n u m b e r   o f   o b j e c t s .  
  
 E x a m p l e :  
 	 > v a r   m e r g e d O b j   =   $ m e r g e ( o b j 1 ,   o b j 2 ,   o b j 3 ) ;  
 	 > / / o b j 1 ,   o b j 2 ,   a n d   o b j 3   a r e   u n a l t e r e d  
 * /  
  
 f u n c t i o n   $ m e r g e ( ) {  
 	 v a r   m i x   =   { } ;  
 	 f o r   ( v a r   i   =   0 ;   i   <   a r g u m e n t s . l e n g t h ;   i + + ) {  
 	 	 f o r   ( v a r   p r o p e r t y   i n   a r g u m e n t s [ i ] ) {  
 	 	 	 v a r   a p   =   a r g u m e n t s [ i ] [ p r o p e r t y ] ;  
 	 	 	 v a r   m p   =   m i x [ p r o p e r t y ] ;  
 	 	 	 i f   ( m p   & &   $ t y p e ( a p )   = =   ' o b j e c t '   & &   $ t y p e ( m p )   = =   ' o b j e c t ' )   m i x [ p r o p e r t y ]   =   $ m e r g e ( m p ,   a p ) ;  
 	 	 	 e l s e   m i x [ p r o p e r t y ]   =   a p ;  
 	 	 }  
 	 }  
 	 r e t u r n   m i x ;  
 } ;  
  
 / *  
 F u n c t i o n :   $ e x t e n d  
 	 C o p i e s   a l l   t h e   p r o p e r t i e s   f r o m   t h e   s e c o n d   p a s s e d   o b j e c t   t o   t h e   f i r s t   p a s s e d   O b j e c t .  
 	 I f   y o u   d o   m y W h a t e v e r . e x t e n d   =   $ e x t e n d   t h e   f i r s t   p a r a m e t e r   w i l l   b e c o m e   m y W h a t e v e r ,   a n d   y o u r   e x t e n d   f u n c t i o n   w i l l   o n l y   n e e d   o n e   p a r a m e t e r .  
  
 E x a m p l e :  
 	 ( s t a r t   c o d e )  
 	 v a r   f i r s t O b   =   {  
 	 	 ' n a m e ' :   ' J o h n ' ,  
 	 	 ' l a s t N a m e ' :   ' D o e '  
 	 } ;  
 	 v a r   s e c o n d O b   =   {  
 	 	 ' a g e ' :   ' 2 0 ' ,  
 	 	 ' s e x ' :   ' m a l e ' ,  
 	 	 ' l a s t N a m e ' :   ' D o r i a n '  
 	 } ;  
 	 $ e x t e n d ( f i r s t O b ,   s e c o n d O b ) ;  
 	 / / f i r s t O b   w i l l   b e c o m e :  
 	 {  
 	 	 ' n a m e ' :   ' J o h n ' ,  
 	 	 ' l a s t N a m e ' :   ' D o r i a n ' ,  
 	 	 ' a g e ' :   ' 2 0 ' ,  
 	 	 ' s e x ' :   ' m a l e '  
 	 } ;  
 	 ( e n d )  
  
 R e t u r n s :  
 	 T h e   f i r s t   o b j e c t ,   e x t e n d e d .  
 * /  
  
 v a r   $ e x t e n d   =   f u n c t i o n ( ) {  
 	 v a r   a r g s   =   a r g u m e n t s ;  
 	 i f   ( ! a r g s [ 1 ] )   a r g s   =   [ t h i s ,   a r g s [ 0 ] ] ;  
 	 f o r   ( v a r   p r o p e r t y   i n   a r g s [ 1 ] )   a r g s [ 0 ] [ p r o p e r t y ]   =   a r g s [ 1 ] [ p r o p e r t y ] ;  
 	 r e t u r n   a r g s [ 0 ] ;  
 } ;  
  
 / *  
 F u n c t i o n :   $ n a t i v e  
 	 W i l l   a d d   a   . e x t e n d   m e t h o d   t o   t h e   o b j e c t s   p a s s e d   a s   a   p a r a m e t e r ,   b u t   t h e   p r o p e r t y   p a s s e d   i n   w i l l   b e   c o p i e d   t o   t h e   o b j e c t ' s   p r o t o t y p e   o n l y   i f   n o n   p r e v i o u s l y   e x i s t e n t .  
 	 I t s   h a n d y   i f   y o u   d o n t   w a n t   t h e   . e x t e n d   m e t h o d   o f   a n   o b j e c t   t o   o v e r w r i t e   e x i s t i n g   m e t h o d s .  
 	 U s e d   a u t o m a t i c a l l y   i n   M o o T o o l s   t o   i m p l e m e n t   A r r a y / S t r i n g / F u n c t i o n / N u m b e r   m e t h o d s   t o   b r o w s e r   t h a t   d o n t   s u p p o r t   t h e m   w h i t o u t   m a n u a l   c h e c k i n g .  
  
 A r g u m e n t s :  
 	 a   n u m b e r   o f   c l a s s e s / n a t i v e   j a v a s c r i p t   o b j e c t s  
  
 * /  
  
 v a r   $ n a t i v e   =   f u n c t i o n ( ) {  
 	 f o r   ( v a r   i   =   0 ,   l   =   a r g u m e n t s . l e n g t h ;   i   <   l ;   i + + ) {  
 	 	 a r g u m e n t s [ i ] . e x t e n d   =   f u n c t i o n ( p r o p s ) {  
 	 	 	 f o r   ( v a r   p r o p   i n   p r o p s ) {  
 	 	 	 	 i f   ( ! t h i s . p r o t o t y p e [ p r o p ] )   t h i s . p r o t o t y p e [ p r o p ]   =   p r o p s [ p r o p ] ;  
 	 	 	 	 i f   ( ! t h i s [ p r o p ] )   t h i s [ p r o p ]   =   $ n a t i v e . g e n e r i c ( p r o p ) ;  
 	 	 	 }  
 	 	 } ;  
 	 }  
 } ;  
  
 $ n a t i v e . g e n e r i c   =   f u n c t i o n ( p r o p ) {  
 	 r e t u r n   f u n c t i o n ( b i n d ) {  
 	 	 r e t u r n   t h i s . p r o t o t y p e [ p r o p ] . a p p l y ( b i n d ,   A r r a y . p r o t o t y p e . s l i c e . c a l l ( a r g u m e n t s ,   1 ) ) ;  
 	 } ;  
 } ;  
  
 $ n a t i v e ( F u n c t i o n ,   A r r a y ,   S t r i n g ,   N u m b e r ) ;  
  
 / *  
 F u n c t i o n :   $ c h k  
 	 R e t u r n s   t r u e   i f   t h e   p a s s e d   i n   v a l u e / o b j e c t   e x i s t s   o r   i s   0 ,   o t h e r w i s e   r e t u r n s   f a l s e .  
 	 U s e f u l   t o   a c c e p t   z e r o e s .  
  
 A r g u m e n t s :  
 	 o b j   -   o b j e c t   t o   i n s p e c t  
 * /  
  
 f u n c t i o n   $ c h k ( o b j ) {  
 	 r e t u r n   ! ! ( o b j   | |   o b j   = = =   0 ) ;  
 } ;  
  
 / *  
 F u n c t i o n :   $ p i c k  
 	 R e t u r n s   t h e   f i r s t   o b j e c t   i f   d e f i n e d ,   o t h e r w i s e   r e t u r n s   t h e   s e c o n d .  
  
 A r g u m e n t s :  
 	 o b j   -   o b j e c t   t o   t e s t  
 	 p i c k e d   -   t h e   d e f a u l t   t o   r e t u r n  
  
 E x a m p l e :  
 	 ( s t a r t   c o d e )  
 	 	 f u n c t i o n   s a y ( m s g ) {  
 	 	 	 a l e r t ( $ p i c k ( m s g ,   ' n o   m e e s s a g e   s u p p l i e d ' ) ) ;  
 	 	 }  
 	 ( e n d )  
 * /  
  
 f u n c t i o n   $ p i c k ( o b j ,   p i c k e d ) {  
 	 r e t u r n   $ d e f i n e d ( o b j )   ?   o b j   :   p i c k e d ;  
 } ;  
  
 / *  
 F u n c t i o n :   $ r a n d o m  
 	 R e t u r n s   a   r a n d o m   i n t e g e r   n u m b e r   b e t w e e n   t h e   t w o   p a s s e d   i n   v a l u e s .  
  
 A r g u m e n t s :  
 	 m i n   -   i n t e g e r ,   t h e   m i n i m u m   v a l u e   ( i n c l u s i v e ) .  
 	 m a x   -   i n t e g e r ,   t h e   m a x i m u m   v a l u e   ( i n c l u s i v e ) .  
  
 R e t u r n s :  
 	 a   r a n d o m   i n t e g e r   b e t w e e n   m i n   a n d   m a x .  
 * /  
  
 f u n c t i o n   $ r a n d o m ( m i n ,   m a x ) {  
 	 r e t u r n   M a t h . f l o o r ( M a t h . r a n d o m ( )   *   ( m a x   -   m i n   +   1 )   +   m i n ) ;  
 } ;  
  
 / *  
 F u n c t i o n :   $ t i m e  
 	 R e t u r n s   t h e   c u r r e n t   t i m e s t a m p  
  
 R e t u r n s :  
 	 a   t i m e s t a m p   i n t e g e r .  
 * /  
  
 f u n c t i o n   $ t i m e ( ) {  
 	 r e t u r n   n e w   D a t e ( ) . g e t T i m e ( ) ;  
 } ;  
  
 / *  
 F u n c t i o n :   $ c l e a r  
 	 c l e a r s   a   t i m e o u t   o r   a n   I n t e r v a l .  
  
 R e t u r n s :  
 	 n u l l  
  
 A r g u m e n t s :  
 	 t i m e r   -   t h e   s e t I n t e r v a l   o r   s e t T i m e o u t   t o   c l e a r .  
  
 E x a m p l e :  
 	 > v a r   m y T i m e r   =   m y F u n c t i o n . d e l a y ( 5 0 0 0 ) ;   / / w a i t   5   s e c o n d s   a n d   e x e c u t e   m y   f u n c t i o n .  
 	 > m y T i m e r   =   $ c l e a r ( m y T i m e r ) ;   / / n e v e r m i n d  
  
 S e e   a l s o :  
 	 < F u n c t i o n . d e l a y > ,   < F u n c t i o n . p e r i o d i c a l >  
 * /  
  
 f u n c t i o n   $ c l e a r ( t i m e r ) {  
 	 c l e a r T i m e o u t ( t i m e r ) ;  
 	 c l e a r I n t e r v a l ( t i m e r ) ;  
 	 r e t u r n   n u l l ;  
 } ;  
  
 / *  
 C l a s s :   A b s t r a c t  
 	 A b s t r a c t   c l a s s ,   t o   b e   u s e d   a s   s i n g l e t o n .   W i l l   a d d   . e x t e n d   t o   a n y   o b j e c t  
  
 A r g u m e n t s :  
 	 a n   o b j e c t  
  
 R e t u r n s :  
 	 t h e   o b j e c t   w i t h   a n   . e x t e n d   p r o p e r t y ,   e q u i v a l e n t   t o   < $ e x t e n d > .  
 * /  
  
 v a r   A b s t r a c t   =   f u n c t i o n ( o b j ) {  
 	 o b j   =   o b j   | |   { } ;  
 	 o b j . e x t e n d   =   $ e x t e n d ;  
 	 r e t u r n   o b j ;  
 } ;  
  
 / / w i n d o w ,   d o c u m e n t  
  
 v a r   W i n d o w   =   n e w   A b s t r a c t ( w i n d o w ) ;  
 v a r   D o c u m e n t   =   n e w   A b s t r a c t ( d o c u m e n t ) ;  
 d o c u m e n t . h e a d   =   d o c u m e n t . g e t E l e m e n t s B y T a g N a m e ( ' h e a d ' ) [ 0 ] ;  
  
 / *  
 C l a s s :   w i n d o w  
 	 S o m e   p r o p e r t i e s   a r e   a t t a c h e d   t o   t h e   w i n d o w   o b j e c t   b y   t h e   b r o w s e r   d e t e c t i o n .  
 	  
 N o t e :  
 	 b r o w s e r   d e t e c t i o n   i s   e n t i r e l y   o b j e c t - b a s e d .   W e   d o n t   s n i f f .  
  
 P r o p e r t i e s :  
 	 w i n d o w . i e   -   w i l l   b e   s e t   t o   t r u e   i f   t h e   c u r r e n t   b r o w s e r   i s   i n t e r n e t   e x p l o r e r   ( a n y ) .  
 	 w i n d o w . i e 6   -   w i l l   b e   s e t   t o   t r u e   i f   t h e   c u r r e n t   b r o w s e r   i s   i n t e r n e t   e x p l o r e r   6 .  
 	 w i n d o w . i e 7   -   w i l l   b e   s e t   t o   t r u e   i f   t h e   c u r r e n t   b r o w s e r   i s   i n t e r n e t   e x p l o r e r   7 .  
 	 w i n d o w . g e c k o   -   w i l l   b e   s e t   t o   t r u e   i f   t h e   c u r r e n t   b r o w s e r   i s   M o z i l l a / G e c k o .  
 	 w i n d o w . w e b k i t   -   w i l l   b e   s e t   t o   t r u e   i f   t h e   c u r r e n t   b r o w s e r   i s   S a f a r i / K o n q u e r o r .  
 	 w i n d o w . w e b k i t 4 1 9   -   w i l l   b e   s e t   t o   t r u e   i f   t h e   c u r r e n t   b r o w s e r   i s   S a f a r i 2   /   w e b k i t   t i l l   v e r s i o n   4 1 9 .  
 	 w i n d o w . w e b k i t 4 2 0   -   w i l l   b e   s e t   t o   t r u e   i f   t h e   c u r r e n t   b r o w s e r   i s   S a f a r i 3   ( W e b k i t   S V N   B u i l d )   /   w e b k i t   o v e r   v e r s i o n   4 1 9 .  
 	 w i n d o w . o p e r a   -   i s   s e t   t o   t r u e   b y   o p e r a   i t s e l f .  
 * /  
  
 w i n d o w . x p a t h   =   ! ! ( d o c u m e n t . e v a l u a t e ) ;  
 i f   ( w i n d o w . A c t i v e X O b j e c t )   w i n d o w . i e   =   w i n d o w [ w i n d o w . X M L H t t p R e q u e s t   ?   ' i e 7 '   :   ' i e 6 ' ]   =   t r u e ;  
 e l s e   i f   ( d o c u m e n t . c h i l d N o d e s   & &   ! d o c u m e n t . a l l   & &   ! n a v i g a t o r . t a i n t E n a b l e d )   w i n d o w . w e b k i t   =   w i n d o w [ w i n d o w . x p a t h   ?   ' w e b k i t 4 2 0 '   :   ' w e b k i t 4 1 9 ' ]   =   t r u e ;  
 e l s e   i f   ( d o c u m e n t . g e t B o x O b j e c t F o r   ! =   n u l l )   w i n d o w . g e c k o   =   t r u e ;  
  
 / * c o m p a t i b i l i t y * /  
  
 w i n d o w . k h t m l   =   w i n d o w . w e b k i t ;  
  
 O b j e c t . e x t e n d   =   $ e x t e n d ;  
  
 / * e n d   c o m p a t i b i l i t y * /  
  
 / / h t m l e l e m e n t  
  
 i f   ( t y p e o f   H T M L E l e m e n t   = =   ' u n d e f i n e d ' ) {  
 	 v a r   H T M L E l e m e n t   =   f u n c t i o n ( ) { } ;  
 	 i f   ( w i n d o w . w e b k i t )   d o c u m e n t . c r e a t e E l e m e n t ( " i f r a m e " ) ;   / / f i x e s   s a f a r i  
 	 H T M L E l e m e n t . p r o t o t y p e   =   ( w i n d o w . w e b k i t )   ?   w i n d o w [ " [ [ D O M E l e m e n t . p r o t o t y p e ] ] " ]   :   { } ;  
 }  
 H T M L E l e m e n t . p r o t o t y p e . h t m l E l e m e n t   =   f u n c t i o n ( ) { } ;  
  
 / / e n a b l e s   b a c k g r o u n d   i m a g e   c a c h e   f o r   i n t e r n e t   e x p l o r e r   6  
  
 i f   ( w i n d o w . i e 6 )   t r y   { d o c u m e n t . e x e c C o m m a n d ( " B a c k g r o u n d I m a g e C a c h e " ,   f a l s e ,   t r u e ) ; }   c a t c h ( e ) { } ;  
  
 / *  
 S c r i p t :   C l a s s . j s  
 	 C o n t a i n s   t h e   C l a s s   F u n c t i o n ,   a i m s   t o   e a s e   t h e   c r e a t i o n   o f   r e u s a b l e   C l a s s e s .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   C l a s s  
 	 T h e   b a s e   c l a s s   o b j e c t   o f   t h e   < h t t p : / / m o o t o o l s . n e t >   f r a m e w o r k .  
 	 C r e a t e s   a   n e w   c l a s s ,   i t s   i n i t i a l i z e   m e t h o d   w i l l   f i r e   u p o n   c l a s s   i n s t a n t i a t i o n .  
 	 I n i t i a l i z e   w o n t   f i r e   o n   i n s t a n t i a t i o n   w h e n   y o u   p a s s   * n u l l * .  
  
 A r g u m e n t s :  
 	 p r o p e r t i e s   -   t h e   c o l l e c t i o n   o f   p r o p e r t i e s   t h a t   a p p l y   t o   t h e   c l a s s .  
  
 E x a m p l e :  
 	 ( s t a r t   c o d e )  
 	 v a r   C a t   =   n e w   C l a s s ( {  
 	 	 i n i t i a l i z e :   f u n c t i o n ( n a m e ) {  
 	 	 	 t h i s . n a m e   =   n a m e ;  
 	 	 }  
 	 } ) ;  
 	 v a r   m y C a t   =   n e w   C a t ( ' M i c i a ' ) ;  
 	 a l e r t ( m y C a t . n a m e ) ;   / / a l e r t s   ' M i c i a '  
 	 ( e n d )  
 * /  
  
 v a r   C l a s s   =   f u n c t i o n ( p r o p e r t i e s ) {  
 	 v a r   k l a s s   =   f u n c t i o n ( ) {  
 	 	 r e t u r n   ( a r g u m e n t s [ 0 ]   ! = =   n u l l   & &   t h i s . i n i t i a l i z e   & &   $ t y p e ( t h i s . i n i t i a l i z e )   = =   ' f u n c t i o n ' )   ?   t h i s . i n i t i a l i z e . a p p l y ( t h i s ,   a r g u m e n t s )   :   t h i s ;  
 	 } ;  
 	 $ e x t e n d ( k l a s s ,   t h i s ) ;  
 	 k l a s s . p r o t o t y p e   =   p r o p e r t i e s ;  
 	 k l a s s . c o n s t r u c t o r   =   C l a s s ;  
 	 r e t u r n   k l a s s ;  
 } ;  
  
 / *  
 P r o p e r t y :   e m p t y  
 	 R e t u r n s   a n   e m p t y   f u n c t i o n  
 * /  
  
 C l a s s . e m p t y   =   f u n c t i o n ( ) { } ;  
  
 C l a s s . p r o t o t y p e   =   {  
  
 	 / *  
 	 P r o p e r t y :   e x t e n d  
 	 	 R e t u r n s   t h e   c o p y   o f   t h e   C l a s s   e x t e n d e d   w i t h   t h e   p a s s e d   i n   p r o p e r t i e s .  
  
 	 A r g u m e n t s :  
 	 	 p r o p e r t i e s   -   t h e   p r o p e r t i e s   t o   a d d   t o   t h e   b a s e   c l a s s   i n   t h i s   n e w   C l a s s .  
  
 	 E x a m p l e :  
 	 	 ( s t a r t   c o d e )  
 	 	 v a r   A n i m a l   =   n e w   C l a s s ( {  
 	 	 	 i n i t i a l i z e :   f u n c t i o n ( a g e ) {  
 	 	 	 	 t h i s . a g e   =   a g e ;  
 	 	 	 }  
 	 	 } ) ;  
 	 	 v a r   C a t   =   A n i m a l . e x t e n d ( {  
 	 	 	 i n i t i a l i z e :   f u n c t i o n ( n a m e ,   a g e ) {  
 	 	 	 	 t h i s . p a r e n t ( a g e ) ;   / / w i l l   c a l l   t h e   p r e v i o u s   i n i t i a l i z e ;  
 	 	 	 	 t h i s . n a m e   =   n a m e ;  
 	 	 	 }  
 	 	 } ) ;  
 	 	 v a r   m y C a t   =   n e w   C a t ( ' M i c i a ' ,   2 0 ) ;  
 	 	 a l e r t ( m y C a t . n a m e ) ;   / / a l e r t s   ' M i c i a '  
 	 	 a l e r t ( m y C a t . a g e ) ;   / / a l e r t s   2 0  
 	 	 ( e n d )  
 	 * /  
  
 	 e x t e n d :   f u n c t i o n ( p r o p e r t i e s ) {  
 	 	 v a r   p r o t o   =   n e w   t h i s ( n u l l ) ;  
 	 	 f o r   ( v a r   p r o p e r t y   i n   p r o p e r t i e s ) {  
 	 	 	 v a r   p p   =   p r o t o [ p r o p e r t y ] ;  
 	 	 	 p r o t o [ p r o p e r t y ]   =   C l a s s . M e r g e ( p p ,   p r o p e r t i e s [ p r o p e r t y ] ) ;  
 	 	 }  
 	 	 r e t u r n   n e w   C l a s s ( p r o t o ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   i m p l e m e n t  
 	 	 I m p l e m e n t s   t h e   p a s s e d   i n   p r o p e r t i e s   t o   t h e   b a s e   C l a s s   p r o t o t y p e s ,   a l t e r i n g   t h e   b a s e   c l a s s ,   u n l i k e   < C l a s s . e x t e n d > .  
  
 	 A r g u m e n t s :  
 	 	 p r o p e r t i e s   -   t h e   p r o p e r t i e s   t o   a d d   t o   t h e   b a s e   c l a s s .  
  
 	 E x a m p l e :  
 	 	 ( s t a r t   c o d e )  
 	 	 v a r   A n i m a l   =   n e w   C l a s s ( {  
 	 	 	 i n i t i a l i z e :   f u n c t i o n ( a g e ) {  
 	 	 	 	 t h i s . a g e   =   a g e ;  
 	 	 	 }  
 	 	 } ) ;  
 	 	 A n i m a l . i m p l e m e n t ( {  
 	 	 	 s e t N a m e :   f u n c t i o n ( n a m e ) {  
 	 	 	 	 t h i s . n a m e   =   n a m e  
 	 	 	 }  
 	 	 } ) ;  
 	 	 v a r   m y A n i m a l   =   n e w   A n i m a l ( 2 0 ) ;  
 	 	 m y A n i m a l . s e t N a m e ( ' M i c i a ' ) ;  
 	 	 a l e r t ( m y A n i m a l . n a m e ) ;   / / a l e r t s   ' M i c i a '  
 	 	 ( e n d )  
 	 * /  
  
 	 i m p l e m e n t :   f u n c t i o n ( ) {  
 	 	 f o r   ( v a r   i   =   0 ,   l   =   a r g u m e n t s . l e n g t h ;   i   <   l ;   i + + )   $ e x t e n d ( t h i s . p r o t o t y p e ,   a r g u m e n t s [ i ] ) ;  
 	 }  
  
 } ;  
  
 / / i n t e r n a l  
  
 C l a s s . M e r g e   =   f u n c t i o n ( p r e v i o u s ,   c u r r e n t ) {  
 	 i f   ( p r e v i o u s   & &   p r e v i o u s   ! =   c u r r e n t ) {  
 	 	 v a r   t y p e   =   $ t y p e ( c u r r e n t ) ;  
 	 	 i f   ( t y p e   ! =   $ t y p e ( p r e v i o u s ) )   r e t u r n   c u r r e n t ;  
 	 	 s w i t c h ( t y p e ) {  
 	 	 	 c a s e   ' f u n c t i o n ' :  
 	 	 	 	 v a r   m e r g e d   =   f u n c t i o n ( ) {  
 	 	 	 	 	 t h i s . p a r e n t   =   a r g u m e n t s . c a l l e e . p a r e n t ;  
 	 	 	 	 	 r e t u r n   c u r r e n t . a p p l y ( t h i s ,   a r g u m e n t s ) ;  
 	 	 	 	 } ;  
 	 	 	 	 m e r g e d . p a r e n t   =   p r e v i o u s ;  
 	 	 	 	 r e t u r n   m e r g e d ;  
 	 	 	 c a s e   ' o b j e c t ' :   r e t u r n   $ m e r g e ( p r e v i o u s ,   c u r r e n t ) ;  
 	 	 }  
 	 }  
 	 r e t u r n   c u r r e n t ;  
 } ;  
  
 / *  
 S c r i p t :   C l a s s . E x t r a s . j s  
 	 C o n t a i n s   c o m m o n   i m p l e m e n t a t i o n s   f o r   c u s t o m   c l a s s e s .   I n   M o o t o o l s   i s   i m p l e m e n t e d   i n   < A j a x > ,   < X H R >   a n d   < F x . B a s e >   a n d   m a n y   m o r e .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   C h a i n  
 	 A n   " U t i l i t y "   C l a s s .   I t s   m e t h o d s   c a n   b e   i m p l e m e n t e d   w i t h   < C l a s s . i m p l e m e n t >   i n t o   a n y   < C l a s s > .  
 	 C u r r e n t l y   i m p l e m e n t e d   i n   < F x . B a s e > ,   < X H R >   a n d   < A j a x > .   I n   < F x . B a s e >   f o r   e x a m p l e ,   i s   u s e d   t o   e x e c u t e   a   l i s t   o f   f u n c t i o n ,   o n e   a f t e r   a n o t h e r ,   o n c e   t h e   e f f e c t   i s   c o m p l e t e d .  
 	 T h e   f u n c t i o n s   w i l l   n o t   b e   f i r e d   a l l   t o g h e t e r ,   b u t   o n e   e v e r y   c o m p l e t i o n ,   t o   c r e a t e   c u s t o m   c o m p l e x   a n i m a t i o n s .  
  
 E x a m p l e :  
 	 ( s t a r t   c o d e )  
 	 v a r   m y F x   =   n e w   F x . S t y l e ( ' e l e m e n t ' ,   ' o p a c i t y ' ) ;  
  
 	 m y F x . s t a r t ( 1 , 0 ) . c h a i n ( f u n c t i o n ( ) {  
 	 	 m y F x . s t a r t ( 0 , 1 ) ;  
 	 } ) . c h a i n ( f u n c t i o n ( ) {  
 	 	 m y F x . s t a r t ( 1 , 0 ) ;  
 	 } ) . c h a i n ( f u n c t i o n ( ) {  
 	 	 m y F x . s t a r t ( 0 , 1 ) ;  
 	 } ) ;  
 	 / / t h e   e l e m e n t   w i l l   a p p e a r   a n d   d i s a p p e a r   t h r e e   t i m e s  
 	 ( e n d )  
 * /  
  
 v a r   C h a i n   =   n e w   C l a s s ( {  
  
 	 / *  
 	 P r o p e r t y :   c h a i n  
 	 	 a d d s   a   f u n c t i o n   t o   t h e   C h a i n   i n s t a n c e   s t a c k .  
  
 	 A r g u m e n t s :  
 	 	 f n   -   t h e   f u n c t i o n   t o   a p p e n d .  
 	 * /  
  
 	 c h a i n :   f u n c t i o n ( f n ) {  
 	 	 t h i s . c h a i n s   =   t h i s . c h a i n s   | |   [ ] ;  
 	 	 t h i s . c h a i n s . p u s h ( f n ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   c a l l C h a i n  
 	 	 E x e c u t e s   t h e   f i r s t   f u n c t i o n   o f   t h e   C h a i n   i n s t a n c e   s t a c k ,   t h e n   r e m o v e s   i t .   T h e   f i r s t   f u n c t i o n   w i l l   t h e n   b e c o m e   t h e   s e c o n d .  
 	 * /  
  
 	 c a l l C h a i n :   f u n c t i o n ( ) {  
 	 	 i f   ( t h i s . c h a i n s   & &   t h i s . c h a i n s . l e n g t h )   t h i s . c h a i n s . s h i f t ( ) . d e l a y ( 1 0 ,   t h i s ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   c l e a r C h a i n  
 	 	 C l e a r s   t h e   s t a c k   o f   a   C h a i n   i n s t a n c e .  
 	 * /  
  
 	 c l e a r C h a i n :   f u n c t i o n ( ) {  
 	 	 t h i s . c h a i n s   =   [ ] ;  
 	 }  
  
 } ) ;  
  
 / *  
 C l a s s :   E v e n t s  
 	 A n   " U t i l i t y "   C l a s s .   I t s   m e t h o d s   c a n   b e   i m p l e m e n t e d   w i t h   < C l a s s . i m p l e m e n t >   i n t o   a n y   < C l a s s > .  
 	 I n   < F x . B a s e >   C l a s s ,   f o r   e x a m p l e ,   i s   u s e d   t o   g i v e   t h e   p o s s i b i l i t y   a d d   a n y   n u m b e r   o f   f u n c t i o n s   t o   t h e   E f f e c t s   e v e n t s ,   l i k e   o n C o m p l e t e ,   o n S t a r t ,   o n C a n c e l .  
 	 E v e n t s   i n   a   C l a s s   t h a t   i m p l e m e n t s   < E v e n t s >   c a n   b e   e i t h e r   a d d e d   a s   a n   o p t i o n ,   o r   w i t h   a d d E v e n t .   N e v e r   w i t h   . o p t i o n s . o n E v e n t N a m e .  
  
 E x a m p l e :  
 	 ( s t a r t   c o d e )  
 	 v a r   m y F x   =   n e w   F x . S t y l e ( ' e l e m e n t ' ,   ' o p a c i t y ' ) . a d d E v e n t ( ' o n C o m p l e t e ' ,   f u n c t i o n ( ) {  
 	 	 a l e r t ( ' t h e   e f f e c t   i s   c o m p l e t e d ' ) ;  
 	 } ) . a d d E v e n t ( ' o n C o m p l e t e ' ,   f u n c t i o n ( ) {  
 	 	 a l e r t ( ' I   t o l d   y o u   t h e   e f f e c t   i s   c o m p l e t e d ' ) ;  
 	 } ) ;  
  
 	 m y F x . s t a r t ( 0 , 1 ) ;  
 	 / / u p o n   c o m p l e t i o n   i t   w i l l   d i s p l a y   t h e   2   a l e r t s ,   i n   o r d e r .  
 	 ( e n d )  
  
 I m p l e m e n t i n g :  
 	 T h i s   c l a s s   c a n   b e   i m p l e m e n t e d   i n t o   o t h e r   c l a s s e s   t o   a d d   t h e   f u n c t i o n a l i t y   t o   t h e m .  
 	 G o e s   w e l l   w i t h   t h e   < O p t i o n s >   c l a s s .  
  
 E x a m p l e :  
 	 ( s t a r t   c o d e )  
 	 v a r   W i d g e t   =   n e w   C l a s s ( {  
 	 	 i n i t i a l i z e :   f u n c t i o n ( ) { } ,  
 	 	 f i n i s h :   f u n c t i o n ( ) {  
 	 	 	 t h i s . f i r e E v e n t ( ' o n C o m p l e t e ' ) ;  
 	 	 }  
 	 } ) ;  
 	 W i d g e t . i m p l e m e n t ( n e w   E v e n t s ) ;  
 	 / / l a t e r . . .  
 	 v a r   m y W i d g e t   =   n e w   W i d g e t ( ) ;  
 	 m y W i d g e t . a d d E v e n t ( ' o n C o m p l e t e ' ,   m y f u n c t i o n ) ;  
 	 ( e n d )  
 * /  
  
 v a r   E v e n t s   =   n e w   C l a s s ( {  
  
 	 / *  
 	 P r o p e r t y :   a d d E v e n t  
 	 	 a d d s   a n   e v e n t   t o   t h e   s t a c k   o f   e v e n t s   o f   t h e   C l a s s   i n s t a n c e .  
  
 	 A r g u m e n t s :  
 	 	 t y p e   -   s t r i n g ;   t h e   e v e n t   n a m e   ( e . g .   ' o n C o m p l e t e ' )  
 	 	 f n   -   f u n c t i o n   t o   e x e c u t e  
 	 * /  
  
 	 a d d E v e n t :   f u n c t i o n ( t y p e ,   f n ) {  
 	 	 i f   ( f n   ! =   C l a s s . e m p t y ) {  
 	 	 	 t h i s . $ e v e n t s   =   t h i s . $ e v e n t s   | |   { } ;  
 	 	 	 t h i s . $ e v e n t s [ t y p e ]   =   t h i s . $ e v e n t s [ t y p e ]   | |   [ ] ;  
 	 	 	 t h i s . $ e v e n t s [ t y p e ] . i n c l u d e ( f n ) ;  
 	 	 }  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   f i r e E v e n t  
 	 	 f i r e s   a l l   e v e n t s   o f   t h e   s p e c i f i e d   t y p e   i n   t h e   C l a s s   i n s t a n c e .  
  
 	 A r g u m e n t s :  
 	 	 t y p e   -   s t r i n g ;   t h e   e v e n t   n a m e   ( e . g .   ' o n C o m p l e t e ' )  
 	 	 a r g s   -   a r r a y   o r   s i n g l e   o b j e c t ;   a r g u m e n t s   t o   p a s s   t o   t h e   f u n c t i o n ;   i f   m o r e   t h a n   o n e   a r g u m e n t ,   m u s t   b e   a n   a r r a y  
 	 	 d e l a y   -   ( i n t e g e r )   d e l a y   ( i n   m s )   t o   w a i t   t o   e x e c u t e   t h e   e v e n t  
  
 	 E x a m p l e :  
 	 ( s t a r t   c o d e )  
 	 v a r   W i d g e t   =   n e w   C l a s s ( {  
 	 	 i n i t i a l i z e :   f u n c t i o n ( a r g 1 ,   a r g 2 ) {  
 	 	 	 . . .  
 	 	 	 t h i s . f i r e E v e n t ( " o n I n i t i a l i z e " ,   [ a r g 1 ,   a r g 2 ] ,   5 0 ) ;  
 	 	 }  
 	 } ) ;  
 	 W i d g e t . i m p l e m e n t ( n e w   E v e n t s ) ;  
 	 ( e n d )  
 	 * /  
  
 	 f i r e E v e n t :   f u n c t i o n ( t y p e ,   a r g s ,   d e l a y ) {  
 	 	 i f   ( t h i s . $ e v e n t s   & &   t h i s . $ e v e n t s [ t y p e ] ) {  
 	 	 	 t h i s . $ e v e n t s [ t y p e ] . e a c h ( f u n c t i o n ( f n ) {  
 	 	 	 	 f n . c r e a t e ( { ' b i n d ' :   t h i s ,   ' d e l a y ' :   d e l a y ,   ' a r g u m e n t s ' :   a r g s } ) ( ) ;  
 	 	 	 } ,   t h i s ) ;  
 	 	 }  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   r e m o v e E v e n t  
 	 	 r e m o v e s   a n   e v e n t   f r o m   t h e   s t a c k   o f   e v e n t s   o f   t h e   C l a s s   i n s t a n c e .  
  
 	 A r g u m e n t s :  
 	 	 t y p e   -   s t r i n g ;   t h e   e v e n t   n a m e   ( e . g .   ' o n C o m p l e t e ' )  
 	 	 f n   -   f u n c t i o n   t h a t   w a s   a d d e d  
 	 * /  
  
 	 r e m o v e E v e n t :   f u n c t i o n ( t y p e ,   f n ) {  
 	 	 i f   ( t h i s . $ e v e n t s   & &   t h i s . $ e v e n t s [ t y p e ] )   t h i s . $ e v e n t s [ t y p e ] . r e m o v e ( f n ) ;  
 	 	 r e t u r n   t h i s ;  
 	 }  
  
 } ) ;  
  
 / *  
 C l a s s :   O p t i o n s  
 	 A n   " U t i l i t y "   C l a s s .   I t s   m e t h o d s   c a n   b e   i m p l e m e n t e d   w i t h   < C l a s s . i m p l e m e n t >   i n t o   a n y   < C l a s s > .  
 	 U s e d   t o   a u t o m a t e   t h e   o p t i o n s   s e t t i n g s ,   a l s o   a d d i n g   C l a s s   < E v e n t s >   w h e n   t h e   o p t i o n   b e g i n s   w i t h   o n .  
  
 	 E x a m p l e :  
 	 	 ( s t a r t   c o d e )  
 	 	 v a r   W i d g e t   =   n e w   C l a s s ( {  
 	 	 	 o p t i o n s :   {  
 	 	 	 	 c o l o r :   ' # f f f ' ,  
 	 	 	 	 s i z e :   {  
 	 	 	 	 	 w i d t h :   1 0 0  
 	 	 	 	 	 h e i g h t :   1 0 0  
 	 	 	 	 }  
 	 	 	 } ,  
 	 	 	 i n i t i a l i z e :   f u n c t i o n ( o p t i o n s ) {  
 	 	 	 	 t h i s . s e t O p t i o n s ( o p t i o n s ) ;  
 	 	 	 }  
 	 	 } ) ;  
 	 	 W i d g e t . i m p l e m e n t ( n e w   O p t i o n s ) ;  
 	 	 / / l a t e r . . .  
 	 	 v a r   m y W i d g e t   =   n e w   W i d g e t ( {  
 	 	 	 c o l o r :   ' # f 0 0 ' ,  
 	 	 	 s i z e :   {  
 	 	 	 	 w i d t h :   2 0 0  
 	 	 	 }  
 	 	 } ) ;  
 	 	 / / m y W i d g e t . o p t i o n s   =   { c o l o r :   # f 0 0 ,   s i z e :   { w i d t h :   2 0 0 ,   h e i g h t :   1 0 0 } }  
 	 	 ( e n d )  
 * /  
  
 v a r   O p t i o n s   =   n e w   C l a s s ( {  
  
 	 / *  
 	 P r o p e r t y :   s e t O p t i o n s  
 	 	 s e t s   t h i s . o p t i o n s  
  
 	 A r g u m e n t s :  
 	 	 d e f a u l t s   -   o b j e c t ;   t h e   d e f a u l t   s e t   o f   o p t i o n s  
 	 	 o p t i o n s   -   o b j e c t ;   t h e   u s e r   e n t e r e d   o p t i o n s .   c a n   b e   e m p t y   t o o .  
  
 	 N o t e :  
 	 	 i f   y o u r   C l a s s   h a s   < E v e n t s >   i m p l e m e n t e d ,   e v e r y   o p t i o n   b e g i n n i n g   w i t h   o n ,   f o l l o w e d   b y   a   c a p i t a l   l e t t e r   ( o n C o m p l e t e )   b e c o m e s   a n   C l a s s   i n s t a n c e   e v e n t .  
 	 * /  
  
 	 s e t O p t i o n s :   f u n c t i o n ( ) {  
 	 	 t h i s . o p t i o n s   =   $ m e r g e . a p p l y ( n u l l ,   [ t h i s . o p t i o n s ] . e x t e n d ( a r g u m e n t s ) ) ;  
 	 	 i f   ( t h i s . a d d E v e n t ) {  
 	 	 	 f o r   ( v a r   o p t i o n   i n   t h i s . o p t i o n s ) {  
 	 	 	 	 i f   ( $ t y p e ( t h i s . o p t i o n s [ o p t i o n ]   = =   ' f u n c t i o n ' )   & &   ( / ^ o n [ A - Z ] / ) . t e s t ( o p t i o n ) )   t h i s . a d d E v e n t ( o p t i o n ,   t h i s . o p t i o n s [ o p t i o n ] ) ;  
 	 	 	 }  
 	 	 }  
 	 	 r e t u r n   t h i s ;  
 	 }  
  
 } ) ;  
  
 / *  
 S c r i p t :   A r r a y . j s  
 	 C o n t a i n s   A r r a y   p r o t o t y p e s ,   < $ A > ,   < $ e a c h >  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   A r r a y  
 	 A   c o l l e c t i o n   o f   T h e   A r r a y   O b j e c t   p r o t o t y p e   m e t h o d s .  
 * /  
  
 / / c u s t o m   m e t h o d s  
  
 A r r a y . e x t e n d ( {  
  
 	 / *  
 	 P r o p e r t y :   f o r E a c h  
 	 	 I t e r a t e s   t h r o u g h   a n   a r r a y ;   T h i s   m e t h o d   i s   o n l y   a v a i l a b l e   f o r   b r o w s e r s   w i t h o u t   n a t i v e   * f o r E a c h *   s u p p o r t .  
 	 	 F o r   m o r e   i n f o   s e e   < h t t p : / / d e v e l o p e r . m o z i l l a . o r g / e n / d o c s / C o r e _ J a v a S c r i p t _ 1 . 5 _ R e f e r e n c e : G l o b a l _ O b j e c t s : A r r a y : f o r E a c h >  
  
 	 	 * f o r E a c h *   e x e c u t e s   t h e   p r o v i d e d   f u n c t i o n   ( c a l l b a c k )   o n c e   f o r   e a c h   e l e m e n t   p r e s e n t   i n   t h e   a r r a y .   c a l l b a c k   i s   i n v o k e d   o n l y   f o r   i n d e x e s   o f   t h e   a r r a y   w h i c h   h a v e   a s s i g n e d   v a l u e s ;   i t   i s   n o t   i n v o k e d   f o r   i n d e x e s   w h i c h   h a v e   b e e n   d e l e t e d   o r   w h i c h   h a v e   n e v e r   b e e n   a s s i g n e d   v a l u e s .  
  
 	 A r g u m e n t s :  
 	 	 f n   -   f u n c t i o n   t o   e x e c u t e   w i t h   e a c h   i t e m   i n   t h e   a r r a y ;   p a s s e d   t h e   i t e m   a n d   t h e   i n d e x   o f   t h a t   i t e m   i n   t h e   a r r a y  
 	 	 b i n d   -   t h e   o b j e c t   t o   b i n d   " t h i s "   t o   ( s e e   < F u n c t i o n . b i n d > )  
  
 	 E x a m p l e :  
 	 	 > [ ' a p p l e ' , ' b a n a n a ' , ' l e m o n ' ] . e a c h ( f u n c t i o n ( i t e m ,   i n d e x ) {  
 	 	 > 	 a l e r t ( i n d e x   +   "   =   "   +   i t e m ) ;   / / a l e r t s   " 0   =   a p p l e "   e t c .  
 	 	 > } ,   b i n d O b j ) ;   / / o p t i o n a l   s e c o n d   a r g   f o r   b i n d i n g ,   n o t   u s e d   h e r e  
 	 * /  
  
 	 f o r E a c h :   f u n c t i o n ( f n ,   b i n d ) {  
 	 	 f o r   ( v a r   i   =   0 ,   j   =   t h i s . l e n g t h ;   i   <   j ;   i + + )   f n . c a l l ( b i n d ,   t h i s [ i ] ,   i ,   t h i s ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   f i l t e r  
 	 	 T h i s   m e t h o d   i s   p r o v i d e d   o n l y   f o r   b r o w s e r s   w i t h o u t   n a t i v e   * f i l t e r *   s u p p o r t .  
 	 	 F o r   m o r e   i n f o   s e e   < h t t p : / / d e v e l o p e r . m o z i l l a . o r g / e n / d o c s / C o r e _ J a v a S c r i p t _ 1 . 5 _ R e f e r e n c e : O b j e c t s : A r r a y : f i l t e r >  
  
 	 	 * f i l t e r *   c a l l s   a   p r o v i d e d   c a l l b a c k   f u n c t i o n   o n c e   f o r   e a c h   e l e m e n t   i n   a n   a r r a y ,   a n d   c o n s t r u c t s   a   n e w   a r r a y   o f   a l l   t h e   v a l u e s   f o r   w h i c h   c a l l b a c k   r e t u r n s   a   t r u e   v a l u e .   c a l l b a c k   i s   i n v o k e d   o n l y   f o r   i n d e x e s   o f   t h e   a r r a y   w h i c h   h a v e   a s s i g n e d   v a l u e s ;   i t   i s   n o t   i n v o k e d   f o r   i n d e x e s   w h i c h   h a v e   b e e n   d e l e t e d   o r   w h i c h   h a v e   n e v e r   b e e n   a s s i g n e d   v a l u e s .   A r r a y   e l e m e n t s   w h i c h   d o   n o t   p a s s   t h e   c a l l b a c k   t e s t   a r e   s i m p l y   s k i p p e d ,   a n d   a r e   n o t   i n c l u d e d   i n   t h e   n e w   a r r a y .  
  
 	 A r g u m e n t s :  
 	 	 f n   -   f u n c t i o n   t o   e x e c u t e   w i t h   e a c h   i t e m   i n   t h e   a r r a y ;   p a s s e d   t h e   i t e m   a n d   t h e   i n d e x   o f   t h a t   i t e m   i n   t h e   a r r a y  
 	 	 b i n d   -   t h e   o b j e c t   t o   b i n d   " t h i s "   t o   ( s e e   < F u n c t i o n . b i n d > )  
  
 	 E x a m p l e :  
 	 	 > v a r   b i g g e r T h a n T w e n t y   =   [ 1 0 , 3 , 2 5 , 1 0 0 ] . f i l t e r ( f u n c t i o n ( i t e m ,   i n d e x ) {  
 	 	 >   r e t u r n   i t e m   >   2 0 ;  
 	 	 > } ) ;  
 	 	 > / / b i g g e r T h a n T w e n t y   =   [ 2 5 , 1 0 0 ]  
 	 * /  
  
 	 f i l t e r :   f u n c t i o n ( f n ,   b i n d ) {  
 	 	 v a r   r e s u l t s   =   [ ] ;  
 	 	 f o r   ( v a r   i   =   0 ,   j   =   t h i s . l e n g t h ;   i   <   j ;   i + + ) {  
 	 	 	 i f   ( f n . c a l l ( b i n d ,   t h i s [ i ] ,   i ,   t h i s ) )   r e s u l t s . p u s h ( t h i s [ i ] ) ;  
 	 	 }  
 	 	 r e t u r n   r e s u l t s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   m a p  
 	 	 T h i s   m e t h o d   i s   p r o v i d e d   o n l y   f o r   b r o w s e r s   w i t h o u t   n a t i v e   * m a p *   s u p p o r t .  
 	 	 F o r   m o r e   i n f o   s e e   < h t t p : / / d e v e l o p e r . m o z i l l a . o r g / e n / d o c s / C o r e _ J a v a S c r i p t _ 1 . 5 _ R e f e r e n c e : G l o b a l _ O b j e c t s : A r r a y : m a p >  
  
 	 	 * m a p *   c a l l s   a   p r o v i d e d   c a l l b a c k   f u n c t i o n   o n c e   f o r   e a c h   e l e m e n t   i n   a n   a r r a y ,   i n   o r d e r ,   a n d   c o n s t r u c t s   a   n e w   a r r a y   f r o m   t h e   r e s u l t s .   c a l l b a c k   i s   i n v o k e d   o n l y   f o r   i n d e x e s   o f   t h e   a r r a y   w h i c h   h a v e   a s s i g n e d   v a l u e s ;   i t   i s   n o t   i n v o k e d   f o r   i n d e x e s   w h i c h   h a v e   b e e n   d e l e t e d   o r   w h i c h   h a v e   n e v e r   b e e n   a s s i g n e d   v a l u e s .  
  
 	 A r g u m e n t s :  
 	 	 f n   -   f u n c t i o n   t o   e x e c u t e   w i t h   e a c h   i t e m   i n   t h e   a r r a y ;   p a s s e d   t h e   i t e m   a n d   t h e   i n d e x   o f   t h a t   i t e m   i n   t h e   a r r a y  
 	 	 b i n d   -   t h e   o b j e c t   t o   b i n d   " t h i s "   t o   ( s e e   < F u n c t i o n . b i n d > )  
  
 	 E x a m p l e :  
 	 	 > v a r   t i m e s T w o   =   [ 1 , 2 , 3 ] . m a p ( f u n c t i o n ( i t e m ,   i n d e x ) {  
 	 	 >   r e t u r n   i t e m * 2 ;  
 	 	 > } ) ;  
 	 	 > / / t i m e s T w o   =   [ 2 , 4 , 6 ] ;  
 	 * /  
  
 	 m a p :   f u n c t i o n ( f n ,   b i n d ) {  
 	 	 v a r   r e s u l t s   =   [ ] ;  
 	 	 f o r   ( v a r   i   =   0 ,   j   =   t h i s . l e n g t h ;   i   <   j ;   i + + )   r e s u l t s [ i ]   =   f n . c a l l ( b i n d ,   t h i s [ i ] ,   i ,   t h i s ) ;  
 	 	 r e t u r n   r e s u l t s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   e v e r y  
 	 	 T h i s   m e t h o d   i s   p r o v i d e d   o n l y   f o r   b r o w s e r s   w i t h o u t   n a t i v e   * e v e r y *   s u p p o r t .  
 	 	 F o r   m o r e   i n f o   s e e   < h t t p : / / d e v e l o p e r . m o z i l l a . o r g / e n / d o c s / C o r e _ J a v a S c r i p t _ 1 . 5 _ R e f e r e n c e : G l o b a l _ O b j e c t s : A r r a y : e v e r y >  
  
 	 	 * e v e r y *   e x e c u t e s   t h e   p r o v i d e d   c a l l b a c k   f u n c t i o n   o n c e   f o r   e a c h   e l e m e n t   p r e s e n t   i n   t h e   a r r a y   u n t i l   i t   f i n d s   o n e   w h e r e   c a l l b a c k   r e t u r n s   a   f a l s e   v a l u e .   I f   s u c h   a n   e l e m e n t   i s   f o u n d ,   t h e   e v e r y   m e t h o d   i m m e d i a t e l y   r e t u r n s   f a l s e .   O t h e r w i s e ,   i f   c a l l b a c k   r e t u r n e d   a   t r u e   v a l u e   f o r   a l l   e l e m e n t s ,   e v e r y   w i l l   r e t u r n   t r u e .   c a l l b a c k   i s   i n v o k e d   o n l y   f o r   i n d e x e s   o f   t h e   a r r a y   w h i c h   h a v e   a s s i g n e d   v a l u e s ;   i t   i s   n o t   i n v o k e d   f o r   i n d e x e s   w h i c h   h a v e   b e e n   d e l e t e d   o r   w h i c h   h a v e   n e v e r   b e e n   a s s i g n e d   v a l u e s .  
  
 	 A r g u m e n t s :  
 	 	 f n   -   f u n c t i o n   t o   e x e c u t e   w i t h   e a c h   i t e m   i n   t h e   a r r a y ;   p a s s e d   t h e   i t e m   a n d   t h e   i n d e x   o f   t h a t   i t e m   i n   t h e   a r r a y  
 	 	 b i n d   -   t h e   o b j e c t   t o   b i n d   " t h i s "   t o   ( s e e   < F u n c t i o n . b i n d > )  
  
 	 E x a m p l e :  
 	 	 > v a r   a r e A l l B i g E n o u g h   =   [ 1 0 , 4 , 2 5 , 1 0 0 ] . e v e r y ( f u n c t i o n ( i t e m ,   i n d e x ) {  
 	 	 >   r e t u r n   i t e m   >   2 0 ;  
 	 	 > } ) ;  
 	 	 > / / a r e A l l B i g E n o u g h   =   f a l s e  
 	 * /  
  
 	 e v e r y :   f u n c t i o n ( f n ,   b i n d ) {  
 	 	 f o r   ( v a r   i   =   0 ,   j   =   t h i s . l e n g t h ;   i   <   j ;   i + + ) {  
 	 	 	 i f   ( ! f n . c a l l ( b i n d ,   t h i s [ i ] ,   i ,   t h i s ) )   r e t u r n   f a l s e ;  
 	 	 }  
 	 	 r e t u r n   t r u e ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s o m e  
 	 	 T h i s   m e t h o d   i s   p r o v i d e d   o n l y   f o r   b r o w s e r s   w i t h o u t   n a t i v e   * s o m e *   s u p p o r t .  
 	 	 F o r   m o r e   i n f o   s e e   < h t t p : / / d e v e l o p e r . m o z i l l a . o r g / e n / d o c s / C o r e _ J a v a S c r i p t _ 1 . 5 _ R e f e r e n c e : G l o b a l _ O b j e c t s : A r r a y : s o m e >  
  
 	 	 * s o m e *   e x e c u t e s   t h e   c a l l b a c k   f u n c t i o n   o n c e   f o r   e a c h   e l e m e n t   p r e s e n t   i n   t h e   a r r a y   u n t i l   i t   f i n d s   o n e   w h e r e   c a l l b a c k   r e t u r n s   a   t r u e   v a l u e .   I f   s u c h   a n   e l e m e n t   i s   f o u n d ,   s o m e   i m m e d i a t e l y   r e t u r n s   t r u e .   O t h e r w i s e ,   s o m e   r e t u r n s   f a l s e .   c a l l b a c k   i s   i n v o k e d   o n l y   f o r   i n d e x e s   o f   t h e   a r r a y   w h i c h   h a v e   a s s i g n e d   v a l u e s ;   i t   i s   n o t   i n v o k e d   f o r   i n d e x e s   w h i c h   h a v e   b e e n   d e l e t e d   o r   w h i c h   h a v e   n e v e r   b e e n   a s s i g n e d   v a l u e s .  
  
 	 A r g u m e n t s :  
 	 	 f n   -   f u n c t i o n   t o   e x e c u t e   w i t h   e a c h   i t e m   i n   t h e   a r r a y ;   p a s s e d   t h e   i t e m   a n d   t h e   i n d e x   o f   t h a t   i t e m   i n   t h e   a r r a y  
 	 	 b i n d   -   t h e   o b j e c t   t o   b i n d   " t h i s "   t o   ( s e e   < F u n c t i o n . b i n d > )  
  
 	 E x a m p l e :  
 	 	 > v a r   i s A n y B i g E n o u g h   =   [ 1 0 , 4 , 2 5 , 1 0 0 ] . s o m e ( f u n c t i o n ( i t e m ,   i n d e x ) {  
 	 	 >   r e t u r n   i t e m   >   2 0 ;  
 	 	 > } ) ;  
 	 	 > / / i s A n y B i g E n o u g h   =   t r u e  
 	 * /  
  
 	 s o m e :   f u n c t i o n ( f n ,   b i n d ) {  
 	 	 f o r   ( v a r   i   =   0 ,   j   =   t h i s . l e n g t h ;   i   <   j ;   i + + ) {  
 	 	 	 i f   ( f n . c a l l ( b i n d ,   t h i s [ i ] ,   i ,   t h i s ) )   r e t u r n   t r u e ;  
 	 	 }  
 	 	 r e t u r n   f a l s e ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   i n d e x O f  
 	 	 T h i s   m e t h o d   i s   p r o v i d e d   o n l y   f o r   b r o w s e r s   w i t h o u t   n a t i v e   * i n d e x O f *   s u p p o r t .  
 	 	 F o r   m o r e   i n f o   s e e   < h t t p : / / d e v e l o p e r . m o z i l l a . o r g / e n / d o c s / C o r e _ J a v a S c r i p t _ 1 . 5 _ R e f e r e n c e : G l o b a l _ O b j e c t s : A r r a y : i n d e x O f >  
  
 	 	 * i n d e x O f *   c o m p a r e s   a   s e a r c h   e l e m e n t   t o   e l e m e n t s   o f   t h e   A r r a y   u s i n g   s t r i c t   e q u a l i t y   ( t h e   s a m e   m e t h o d   u s e d   b y   t h e   = = = ,   o r   t r i p l e - e q u a l s ,   o p e r a t o r ) .  
  
 	 A r g u m e n t s :  
 	 	 i t e m   -   a n y   t y p e   o f   o b j e c t ;   e l e m e n t   t o   l o c a t e   i n   t h e   a r r a y  
 	 	 f r o m   -   i n t e g e r ;   o p t i o n a l ;   t h e   i n d e x   o f   t h e   a r r a y   a t   w h i c h   t o   b e g i n   t h e   s e a r c h   ( d e f a u l t s   t o   0 )  
  
 	 E x a m p l e :  
 	 	 > [ ' a p p l e ' , ' l e m o n ' , ' b a n a n a ' ] . i n d e x O f ( ' l e m o n ' ) ;   / / r e t u r n s   1  
 	 	 > [ ' a p p l e ' , ' l e m o n ' ] . i n d e x O f ( ' b a n a n a ' ) ;   / / r e t u r n s   - 1  
 	 * /  
  
 	 i n d e x O f :   f u n c t i o n ( i t e m ,   f r o m ) {  
 	 	 v a r   l e n   =   t h i s . l e n g t h ;  
 	 	 f o r   ( v a r   i   =   ( f r o m   <   0 )   ?   M a t h . m a x ( 0 ,   l e n   +   f r o m )   :   f r o m   | |   0 ;   i   <   l e n ;   i + + ) {  
 	 	 	 i f   ( t h i s [ i ]   = = =   i t e m )   r e t u r n   i ;  
 	 	 }  
 	 	 r e t u r n   - 1 ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   e a c h  
 	 	 S a m e   a s   < A r r a y . f o r E a c h > .  
  
 	 A r g u m e n t s :  
 	 	 f n   -   f u n c t i o n   t o   e x e c u t e   w i t h   e a c h   i t e m   i n   t h e   a r r a y ;   p a s s e d   t h e   i t e m   a n d   t h e   i n d e x   o f   t h a t   i t e m   i n   t h e   a r r a y  
 	 	 b i n d   -   o p t i o n a l ,   t h e   o b j e c t   t h a t   t h e   " t h i s "   o f   t h e   f u n c t i o n   w i l l   r e f e r   t o .  
  
 	 E x a m p l e :  
 	 	 > v a r   A n i m a l s   =   [ ' C a t ' ,   ' D o g ' ,   ' C o a l a ' ] ;  
 	 	 > A n i m a l s . e a c h ( f u n c t i o n ( a n i m a l ) {  
 	 	 > 	 d o c u m e n t . w r i t e ( a n i m a l )  
 	 	 > } ) ;  
 	 * /  
  
 	 / *  
 	 P r o p e r t y :   c o p y  
 	 	 r e t u r n s   a   c o p y   o f   t h e   a r r a y .  
  
 	 R e t u r n s :  
 	 	 a   n e w   a r r a y   w h i c h   i s   a   c o p y   o f   t h e   c u r r e n t   o n e .  
  
 	 A r g u m e n t s :  
 	 	 s t a r t   -   i n t e g e r ;   o p t i o n a l ;   t h e   i n d e x   w h e r e   t o   s t a r t   t h e   c o p y ,   d e f a u l t   i s   0 .   I f   n e g a t i v e ,   i t   i s   t a k e n   a s   t h e   o f f s e t   f r o m   t h e   e n d   o f   t h e   a r r a y .  
 	 	 l e n g t h   -   i n t e g e r ;   o p t i o n a l ;   t h e   n u m b e r   o f   e l e m e n t s   t o   c o p y .   B y   d e f a u l t ,   c o p i e s   a l l   e l e m e n t s   f r o m   s t a r t   t o   t h e   e n d   o f   t h e   a r r a y .  
  
 	 E x a m p l e :  
 	 	 > v a r   l e t t e r s   =   [ " a " , " b " , " c " ] ;  
 	 	 > v a r   c o p y   =   l e t t e r s . c o p y ( ) ; 	 	 / /   [ " a " , " b " , " c " ]   ( n e w   i n s t a n c e )  
 	 * /  
  
 	 c o p y :   f u n c t i o n ( s t a r t ,   l e n g t h ) {  
 	 	 s t a r t   =   s t a r t   | |   0 ;  
 	 	 i f   ( s t a r t   <   0 )   s t a r t   =   t h i s . l e n g t h   +   s t a r t ;  
 	 	 l e n g t h   =   l e n g t h   | |   ( t h i s . l e n g t h   -   s t a r t ) ;  
 	 	 v a r   n e w A r r a y   =   [ ] ;  
 	 	 f o r   ( v a r   i   =   0 ;   i   <   l e n g t h ;   i + + )   n e w A r r a y [ i ]   =   t h i s [ s t a r t + + ] ;  
 	 	 r e t u r n   n e w A r r a y ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   r e m o v e  
 	 	 R e m o v e s   a l l   o c c u r r e n c e s   o f   a n   i t e m   f r o m   t h e   a r r a y .  
  
 	 A r g u m e n t s :  
 	 	 i t e m   -   t h e   i t e m   t o   r e m o v e  
  
 	 R e t u r n s :  
 	 	 t h e   A r r a y   w i t h   a l l   o c c u r r e n c e s   o f   t h e   i t e m   r e m o v e d .  
  
 	 E x a m p l e :  
 	 	 > [ " 1 " , " 2 " , " 3 " , " 2 " ] . r e m o v e ( " 2 " )   / /   [ " 1 " , " 3 " ] ;  
 	 * /  
  
 	 r e m o v e :   f u n c t i o n ( i t e m ) {  
 	 	 v a r   i   =   0 ;  
 	 	 v a r   l e n   =   t h i s . l e n g t h ;  
 	 	 w h i l e   ( i   <   l e n ) {  
 	 	 	 i f   ( t h i s [ i ]   = = =   i t e m ) {  
 	 	 	 	 t h i s . s p l i c e ( i ,   1 ) ;  
 	 	 	 	 l e n - - ;  
 	 	 	 }   e l s e   {  
 	 	 	 	 i + + ;  
 	 	 	 }  
 	 	 }  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   c o n t a i n s  
 	 	 T e s t s   a n   a r r a y   f o r   t h e   p r e s e n c e   o f   a n   i t e m .  
  
 	 A r g u m e n t s :  
 	 	 i t e m   -   t h e   i t e m   t o   s e a r c h   f o r   i n   t h e   a r r a y .  
 	 	 f r o m   -   i n t e g e r ;   o p t i o n a l ;   t h e   i n d e x   a t   w h i c h   t o   b e g i n   t h e   s e a r c h ,   d e f a u l t   i s   0 .   I f   n e g a t i v e ,   i t   i s   t a k e n   a s   t h e   o f f s e t   f r o m   t h e   e n d   o f   t h e   a r r a y .  
  
 	 R e t u r n s :  
 	 	 t r u e   -   t h e   i t e m   w a s   f o u n d  
 	 	 f a l s e   -   i t   w a s n ' t  
  
 	 E x a m p l e :  
 	 	 > [ " a " , " b " , " c " ] . c o n t a i n s ( " a " ) ;   / /   t r u e  
 	 	 > [ " a " , " b " , " c " ] . c o n t a i n s ( " d " ) ;   / /   f a l s e  
 	 * /  
  
 	 c o n t a i n s :   f u n c t i o n ( i t e m ,   f r o m ) {  
 	 	 r e t u r n   t h i s . i n d e x O f ( i t e m ,   f r o m )   ! =   - 1 ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   a s s o c i a t e  
 	 	 C r e a t e s   a n   o b j e c t   w i t h   k e y - v a l u e   p a i r s   b a s e d   o n   t h e   a r r a y   o f   k e y w o r d s   p a s s e d   i n  
 	 	 a n d   t h e   c u r r e n t   c o n t e n t   o f   t h e   a r r a y .  
  
 	 A r g u m e n t s :  
 	 	 k e y s   -   t h e   a r r a y   o f   k e y w o r d s .  
  
 	 E x a m p l e :  
 	 	 ( s t a r t   c o d e )  
 	 	 v a r   A n i m a l s   =   [ ' C a t ' ,   ' D o g ' ,   ' C o a l a ' ,   ' L i z a r d ' ] ;  
 	 	 v a r   S p e e c h   =   [ ' M i a o ' ,   ' B a u ' ,   ' F r u u u ' ,   ' M u t e ' ] ;  
 	 	 v a r   S p e e c h e s   =   A n i m a l s . a s s o c i a t e ( S p e e c h ) ;  
 	 	 / / S p e e c h e s [ ' M i a o ' ]   i s   n o w   C a t .  
 	 	 / / S p e e c h e s [ ' B a u ' ]   i s   n o w   D o g .  
 	 	 / / . . .  
 	 	 ( e n d )  
 	 * /  
  
 	 a s s o c i a t e :   f u n c t i o n ( k e y s ) {  
 	 	 v a r   o b j   =   { } ,   l e n g t h   =   M a t h . m i n ( t h i s . l e n g t h ,   k e y s . l e n g t h ) ;  
 	 	 f o r   ( v a r   i   =   0 ;   i   <   l e n g t h ;   i + + )   o b j [ k e y s [ i ] ]   =   t h i s [ i ] ;  
 	 	 r e t u r n   o b j ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   e x t e n d  
 	 	 E x t e n d s   a n   a r r a y   w i t h   a n o t h e r   o n e .  
  
 	 A r g u m e n t s :  
 	 	 a r r a y   -   t h e   a r r a y   t o   e x t e n d   o u r s   w i t h  
  
 	 E x a m p l e :  
 	 	 > v a r   A n i m a l s   =   [ ' C a t ' ,   ' D o g ' ,   ' C o a l a ' ] ;  
 	 	 > A n i m a l s . e x t e n d ( [ ' L i z a r d ' ] ) ;  
 	 	 > / / A n i m a l s   i s   n o w :   [ ' C a t ' ,   ' D o g ' ,   ' C o a l a ' ,   ' L i z a r d ' ] ;  
 	 * /  
  
 	 e x t e n d :   f u n c t i o n ( a r r a y ) {  
 	 	 f o r   ( v a r   i   =   0 ,   j   =   a r r a y . l e n g t h ;   i   <   j ;   i + + )   t h i s . p u s h ( a r r a y [ i ] ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   m e r g e  
 	 	 m e r g e s   a n   a r r a y   i n   a n o t h e r   a r r a y ,   w i t h o u t   d u p l i c a t e s .   ( c a s e -   a n d   t y p e - s e n s i t i v e )  
  
 	 A r g u m e n t s :  
 	 	 a r r a y   -   t h e   a r r a y   t o   m e r g e   f r o m .  
  
 	 E x a m p l e :  
 	 	 > [ ' C a t ' , ' D o g ' ] . m e r g e ( [ ' D o g ' , ' C o a l a ' ] ) ;   / / r e t u r n s   [ ' C a t ' , ' D o g ' , ' C o a l a ' ]  
 	 * /  
  
 	 m e r g e :   f u n c t i o n ( a r r a y ) {  
 	 	 f o r   ( v a r   i   =   0 ,   l   =   a r r a y . l e n g t h ;   i   <   l ;   i + + )   t h i s . i n c l u d e ( a r r a y [ i ] ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   i n c l u d e  
 	 	 i n c l u d e s   t h e   p a s s e d   i n   e l e m e n t   i n   t h e   a r r a y ,   o n l y   i f   i t s   n o t   a l r e a d y   p r e s e n t .   ( c a s e -   a n d   t y p e - s e n s i t i v e )  
  
 	 A r g u m e n t s :  
 	 	 i t e m   -   i t e m   t o   a d d   t o   t h e   a r r a y   ( i f   n o t   p r e s e n t )  
  
 	 E x a m p l e :  
 	 	 > [ ' C a t ' , ' D o g ' ] . i n c l u d e ( ' D o g ' ) ;   / / r e t u r n s   [ ' C a t ' , ' D o g ' ]  
 	 	 > [ ' C a t ' , ' D o g ' ] . i n c l u d e ( ' C o a l a ' ) ;   / / r e t u r n s   [ ' C a t ' , ' D o g ' , ' C o a l a ' ]  
 	 * /  
  
 	 i n c l u d e :   f u n c t i o n ( i t e m ) {  
 	 	 i f   ( ! t h i s . c o n t a i n s ( i t e m ) )   t h i s . p u s h ( i t e m ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t R a n d o m  
 	 	 r e t u r n s   a   r a n d o m   i t e m   i n   t h e   A r r a y  
 	 * /  
  
 	 g e t R a n d o m :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s [ $ r a n d o m ( 0 ,   t h i s . l e n g t h   -   1 ) ]   | |   n u l l ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t L a s t  
 	 	 r e t u r n s   t h e   l a s t   i t e m   i n   t h e   A r r a y  
 	 * /  
  
 	 g e t L a s t :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s [ t h i s . l e n g t h   -   1 ]   | |   n u l l ;  
 	 }  
  
 } ) ;  
  
 / / c o p i e s  
  
 A r r a y . p r o t o t y p e . e a c h   =   A r r a y . p r o t o t y p e . f o r E a c h ;  
 A r r a y . e a c h   =   A r r a y . f o r E a c h ;  
  
 / *   S e c t i o n :   U t i l i t y   F u n c t i o n s   * /  
  
 / *  
 F u n c t i o n :   $ A ( )  
 	 S a m e   a s   < A r r a y . c o p y > ,   b u t   a s   f u n c t i o n .  
 	 U s e f u l   t o   a p p l y   A r r a y   p r o t o t y p e s   t o   i t e r a b l e   o b j e c t s ,   a s   a   c o l l e c t i o n   o f   D O M   e l e m e n t s   o r   t h e   a r g u m e n t s   o b j e c t .  
  
 E x a m p l e :  
 	 ( s t a r t   c o d e )  
 	 f u n c t i o n   m y F u n c t i o n ( ) {  
 	 	 $ A ( a r g u m e n t s ) . e a c h ( a r g u m e n t ,   f u n c t i o n ( ) {  
 	 	 	 a l e r t ( a r g u m e n t ) ;  
 	 	 } ) ;  
 	 } ;  
 	 / / t h e   a b o v e   w i l l   a l e r t   a l l   t h e   a r g u m e n t s   p a s s e d   t o   t h e   f u n c t i o n   m y F u n c t i o n .  
 	 ( e n d )  
 * /  
  
 f u n c t i o n   $ A ( a r r a y ) {  
 	 r e t u r n   A r r a y . c o p y ( a r r a y ) ;  
 } ;  
  
 / *  
 F u n c t i o n :   $ e a c h  
 	 U s e   t o   i t e r a t e   t h r o u g h   i t e r a b l e s   t h a t   a r e   n o t   r e g u l a r   a r r a y s ,   s u c h   a s   b u i l t i n   g e t E l e m e n t s B y T a g N a m e   c a l l s ,   a r g u m e n t s   o f   a   f u n c t i o n ,   o r   a n   o b j e c t .  
  
 A r g u m e n t s :  
 	 i t e r a b l e   -   a n   i t e r a b l e   e l e m e n t   o r   a n   o b j c t .  
 	 f u n c t i o n   -   f u n c t i o n   t o   a p p l y   t o   t h e   i t e r a b l e .  
 	 b i n d   -   o p t i o n a l ,   t h e   ' t h i s '   o f   t h e   f u n c t i o n   w i l l   r e f e r   t o   t h i s   o b j e c t .  
  
 F u n c t i o n   a r g u m e n t :  
 	 T h e   f u n c t i o n   a r g u m e n t   w i l l   b e   p a s s e d   t h e   f o l l o w i n g   a r g u m e n t s .  
  
 	 i t e m   -   t h e   c u r r e n t   i t e m   i n   t h e   i t e r a t o r   b e i n g   p r o c e s e d  
 	 i n d e x   -   i n t e g e r ;   t h e   i n d e x   o f   t h e   i t e m ,   o r   k e y   i n   c a s e   o f   a n   o b j e c t .  
  
 E x a m p l e s :  
 	 ( s t a r t   c o d e )  
 	 $ e a c h ( [ ' S u n ' , ' M o n ' , ' T u e ' ] ,   f u n c t i o n ( d a y ,   i n d e x ) {  
 	 	 a l e r t ( ' n a m e : '   +   d a y   +   ' ,   i n d e x :   '   +   i n d e x ) ;  
 	 } ) ;  
 	 / / a l e r t s   " n a m e :   S u n ,   i n d e x :   0 " ,   " n a m e :   M o n ,   i n d e x :   1 " ,   e t c .  
 	 / / o v e r   a n   o b j e c t  
 	 $ e a c h ( { f i r s t :   " S u n d a y " ,   s e c o n d :   " M o n d a y " ,   t h i r d :   " T u e s d a y " } ,   f u n c t i o n ( v a l u e ,   k e y ) {  
 	 	 a l e r t ( " t h e   "   +   k e y   +   "   d a y   o f   t h e   w e e k   i s   "   +   v a l u e ) ;  
 	 } ) ;  
 	 / / a l e r t s   " t h e   f i r s t   d a y   o f   t h e   w e e k   i s   S u n d a y " ,  
 	 / / " t h e   s e c o n d   d a y   o f   t h e   w e e k   i s   M o n d a y " ,   e t c .  
 	 ( e n d )  
 * /  
  
 f u n c t i o n   $ e a c h ( i t e r a b l e ,   f n ,   b i n d ) {  
 	 i f   ( i t e r a b l e   & &   t y p e o f   i t e r a b l e . l e n g t h   = =   ' n u m b e r '   & &   $ t y p e ( i t e r a b l e )   ! =   ' o b j e c t ' ) {  
 	 	 A r r a y . f o r E a c h ( i t e r a b l e ,   f n ,   b i n d ) ;  
 	 }   e l s e   {  
 	 	   f o r   ( v a r   n a m e   i n   i t e r a b l e )   f n . c a l l ( b i n d   | |   i t e r a b l e ,   i t e r a b l e [ n a m e ] ,   n a m e ) ;  
 	 }  
 } ;  
  
 / * c o m p a t i b i l i t y * /  
  
 A r r a y . p r o t o t y p e . t e s t   =   A r r a y . p r o t o t y p e . c o n t a i n s ;  
  
 / * e n d   c o m p a t i b i l i t y * /  
  
 / *  
 S c r i p t :   S t r i n g . j s  
 	 C o n t a i n s   S t r i n g   p r o t o t y p e s .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   S t r i n g  
 	 A   c o l l e c t i o n   o f   T h e   S t r i n g   O b j e c t   p r o t o t y p e   m e t h o d s .  
 * /  
  
 S t r i n g . e x t e n d ( {  
  
 	 / *  
 	 P r o p e r t y :   t e s t  
 	 	 T e s t s   a   s t r i n g   w i t h   a   r e g u l a r   e x p r e s s i o n .  
  
 	 A r g u m e n t s :  
 	 	 r e g e x   -   a   s t r i n g   o r   r e g u l a r   e x p r e s s i o n   o b j e c t ,   t h e   r e g u l a r   e x p r e s s i o n   y o u   w a n t   t o   m a t c h   t h e   s t r i n g   w i t h  
 	 	 p a r a m s   -   o p t i o n a l ,   i f   f i r s t   p a r a m e t e r   i s   a   s t r i n g ,   a n y   p a r a m e t e r s   y o u   w a n t   t o   p a s s   t o   t h e   r e g e x   ( ' g '   h a s   n o   e f f e c t )  
  
 	 R e t u r n s :  
 	 	 t r u e   i f   a   m a t c h   f o r   t h e   r e g u l a r   e x p r e s s i o n   i s   f o u n d   i n   t h e   s t r i n g ,   f a l s e   i f   n o t .  
 	 	 S e e   < h t t p : / / d e v e l o p e r . m o z i l l a . o r g / e n / d o c s / C o r e _ J a v a S c r i p t _ 1 . 5 _ R e f e r e n c e : O b j e c t s : R e g E x p : t e s t >  
  
 	 E x a m p l e :  
 	 	 > " I   l i k e   c o o k i e s " . t e s t ( " c o o k i e " ) ;   / /   r e t u r n s   t r u e  
 	 	 > " I   l i k e   c o o k i e s " . t e s t ( " C O O K I E " ,   " i " )   / /   i g n o r e   c a s e ,   r e t u r n s   t r u e  
 	 	 > " I   l i k e   c o o k i e s " . t e s t ( " c a k e " ) ;   / /   r e t u r n s   f a l s e  
 	 * /  
  
 	 t e s t :   f u n c t i o n ( r e g e x ,   p a r a m s ) {  
 	 	 r e t u r n   ( ( $ t y p e ( r e g e x )   = =   ' s t r i n g ' )   ?   n e w   R e g E x p ( r e g e x ,   p a r a m s )   :   r e g e x ) . t e s t ( t h i s ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   t o I n t  
 	 	 p a r s e s   a   s t r i n g   t o   a n   i n t e g e r .  
  
 	 R e t u r n s :  
 	 	 e i t h e r   a n   i n t   o r   " N a N "   i f   t h e   s t r i n g   i s   n o t   a   n u m b e r .  
  
 	 E x a m p l e :  
 	 	 > v a r   v a l u e   =   " 1 0 p x " . t o I n t ( ) ;   / /   v a l u e   i s   1 0  
 	 * /  
  
 	 t o I n t :   f u n c t i o n ( ) {  
 	 	 r e t u r n   p a r s e I n t ( t h i s ,   1 0 ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   t o F l o a t  
 	 	 p a r s e s   a   s t r i n g   t o   a n   f l o a t .  
  
 	 R e t u r n s :  
 	 	 e i t h e r   a   f l o a t   o r   " N a N "   i f   t h e   s t r i n g   i s   n o t   a   n u m b e r .  
  
 	 E x a m p l e :  
 	 	 > v a r   v a l u e   =   " 1 0 . 8 4 8 " . t o F l o a t ( ) ;   / /   v a l u e   i s   1 0 . 8 4 8  
 	 * /  
  
 	 t o F l o a t :   f u n c t i o n ( ) {  
 	 	 r e t u r n   p a r s e F l o a t ( t h i s ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   c a m e l C a s e  
 	 	 C o n v e r t s   a   h i p h e n a t e d   s t r i n g   t o   a   c a m e l c a s e   s t r i n g .  
  
 	 E x a m p l e :  
 	 	 > " I - l i k e - c o o k i e s " . c a m e l C a s e ( ) ;   / / " I L i k e C o o k i e s "  
  
 	 R e t u r n s :  
 	 	 t h e   c a m e l   c a s e d   s t r i n g  
 	 * /  
  
 	 c a m e l C a s e :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s . r e p l a c e ( / - \ D / g ,   f u n c t i o n ( m a t c h ) {  
 	 	 	 r e t u r n   m a t c h . c h a r A t ( 1 ) . t o U p p e r C a s e ( ) ;  
 	 	 } ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   h y p h e n a t e  
 	 	 C o n v e r t s   a   c a m e l C a s e d   s t r i n g   t o   a   h y p h e n - a t e d   s t r i n g .  
  
 	 E x a m p l e :  
 	 	 > " I L i k e C o o k i e s " . h y p h e n a t e ( ) ;   / / " I - l i k e - c o o k i e s "  
 	 * /  
  
 	 h y p h e n a t e :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s . r e p l a c e ( / \ w [ A - Z ] / g ,   f u n c t i o n ( m a t c h ) {  
 	 	 	 r e t u r n   ( m a t c h . c h a r A t ( 0 )   +   ' - '   +   m a t c h . c h a r A t ( 1 ) . t o L o w e r C a s e ( ) ) ;  
 	 	 } ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   c a p i t a l i z e  
 	 	 C o n v e r t s   t h e   f i r s t   l e t t e r   i n   e a c h   w o r d   o f   a   s t r i n g   t o   U p p e r c a s e .  
  
 	 E x a m p l e :  
 	 	 > " i   l i k e   c o o k i e s " . c a p i t a l i z e ( ) ;   / / " I   L i k e   C o o k i e s "  
  
 	 R e t u r n s :  
 	 	 t h e   c a p i t a l i z e d   s t r i n g  
 	 * /  
  
 	 c a p i t a l i z e :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s . r e p l a c e ( / \ b [ a - z ] / g ,   f u n c t i o n ( m a t c h ) {  
 	 	 	 r e t u r n   m a t c h . t o U p p e r C a s e ( ) ;  
 	 	 } ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   t r i m  
 	 	 T r i m s   t h e   l e a d i n g   a n d   t r a i l i n g   s p a c e s   o f f   a   s t r i n g .  
  
 	 E x a m p l e :  
 	 	 > "         i   l i k e   c o o k i e s           " . t r i m ( )   / / " i   l i k e   c o o k i e s "  
  
 	 R e t u r n s :  
 	 	 t h e   t r i m m e d   s t r i n g  
 	 * /  
  
 	 t r i m :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s . r e p l a c e ( / ^ \ s + | \ s + $ / g ,   ' ' ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   c l e a n  
 	 	 t r i m s   ( < S t r i n g . t r i m > )   a   s t r i n g   A N D   r e m o v e s   a l l   t h e   d o u b l e   s p a c e s   i n   a   s t r i n g .  
  
 	 R e t u r n s :  
 	 	 t h e   c l e a n e d   s t r i n g  
  
 	 E x a m p l e :  
 	 	 > "   i             l i k e           c o o k i e s             \ n \ n " . c l e a n ( )   / / " i   l i k e   c o o k i e s "  
 	 * /  
  
 	 c l e a n :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s . r e p l a c e ( / \ s { 2 , } / g ,   '   ' ) . t r i m ( ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   r g b T o H e x  
 	 	 C o n v e r t s   a n   R G B   v a l u e   t o   h e x i d e c i m a l .   T h e   s t r i n g   m u s t   b e   i n   t h e   f o r m a t   o f   " r g b ( 2 5 5 , 2 5 5 , 2 5 5 ) "   o r   " r g b a ( 2 5 5 , 2 5 5 , 2 5 5 , 1 ) " ;  
  
 	 A r g u m e n t s :  
 	 	 a r r a y   -   b o o l e a n   v a l u e ,   d e f a u l t s   t o   f a l s e .   U s e   t r u e   i f   y o u   w a n t   t h e   a r r a y   [ ' F F ' , ' 3 3 ' , ' 0 0 ' ]   a s   o u t p u t   i n s t e a d   o f   " # F F 3 3 0 0 "  
  
 	 R e t u r n s :  
 	 	 h e x   s t r i n g   o r   a r r a y .   r e t u r n s   " t r a n s p a r e n t "   i f   t h e   o u t p u t   i s   s e t   a s   s t r i n g   a n d   t h e   f o u r t h   v a l u e   o f   r g b a   i n   i n p u t   s t r i n g   i s   0 .  
  
 	 E x a m p l e :  
 	 	 > " r g b ( 1 7 , 3 4 , 5 1 ) " . r g b T o H e x ( ) ;   / / " # 1 1 2 2 3 3 "  
 	 	 > " r g b a ( 1 7 , 3 4 , 5 1 , 0 ) " . r g b T o H e x ( ) ;   / / " t r a n s p a r e n t "  
 	 	 > " r g b ( 1 7 , 3 4 , 5 1 ) " . r g b T o H e x ( t r u e ) ;   / / [ ' 1 1 ' , ' 2 2 ' , ' 3 3 ' ]  
 	 * /  
  
 	 r g b T o H e x :   f u n c t i o n ( a r r a y ) {  
 	 	 v a r   r g b   =   t h i s . m a t c h ( / \ d { 1 , 3 } / g ) ;  
 	 	 r e t u r n   ( r g b )   ?   r g b . r g b T o H e x ( a r r a y )   :   f a l s e ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   h e x T o R g b  
 	 	 C o n v e r t s   a   h e x i d e c i m a l   c o l o r   v a l u e   t o   R G B .   I n p u t   s t r i n g   m u s t   b e   t h e   h e x   c o l o r   v a l u e   ( w i t h   o r   w i t h o u t   t h e   h a s h ) .   A l s o   a c c e p t s   t r i p l e t s   ( ' 3 3 3 ' ) ;  
  
 	 A r g u m e n t s :  
 	 	 a r r a y   -   b o o l e a n   v a l u e ,   d e f a u l t s   t o   f a l s e .   U s e   t r u e   i f   y o u   w a n t   t h e   a r r a y   [ 2 5 5 , 2 5 5 , 2 5 5 ]   a s   o u t p u t   i n s t e a d   o f   " r g b ( 2 5 5 , 2 5 5 , 2 5 5 ) " ;  
  
 	 R e t u r n s :  
 	 	 r g b   s t r i n g   o r   a r r a y .  
  
 	 E x a m p l e :  
 	 	 > " # 1 1 2 2 3 3 " . h e x T o R g b ( ) ;   / / " r g b ( 1 7 , 3 4 , 5 1 ) "  
 	 	 > " # 1 1 2 2 3 3 " . h e x T o R g b ( t r u e ) ;   / / [ 1 7 , 3 4 , 5 1 ]  
 	 * /  
  
 	 h e x T o R g b :   f u n c t i o n ( a r r a y ) {  
 	 	 v a r   h e x   =   t h i s . m a t c h ( / ^ # ? ( \ w { 1 , 2 } ) ( \ w { 1 , 2 } ) ( \ w { 1 , 2 } ) $ / ) ;  
 	 	 r e t u r n   ( h e x )   ?   h e x . s l i c e ( 1 ) . h e x T o R g b ( a r r a y )   :   f a l s e ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   c o n t a i n s  
 	 	 c h e c k s   i f   t h e   p a s s e d   i n   s t r i n g   i s   c o n t a i n e d   i n   t h e   S t r i n g .   a l s o   a c c e p t s   a n   o p t i o n a l   s e c o n d   p a r a m e t e r ,   t o   c h e c k   i f   t h e   s t r i n g   i s   c o n t a i n e d   i n   a   l i s t   o f   s e p a r a t e d   v a l u e s .  
  
 	 E x a m p l e :  
 	 	 > ' a   b   c ' . c o n t a i n s ( ' c ' ,   '   ' ) ;   / / t r u e  
 	 	 > ' a   b c ' . c o n t a i n s ( ' b c ' ) ;   / / t r u e  
 	 	 > ' a   b c ' . c o n t a i n s ( ' b ' ,   '   ' ) ;   / / f a l s e  
 	 * /  
  
 	 c o n t a i n s :   f u n c t i o n ( s t r i n g ,   s ) {  
 	 	 r e t u r n   ( s )   ?   ( s   +   t h i s   +   s ) . i n d e x O f ( s   +   s t r i n g   +   s )   >   - 1   :   t h i s . i n d e x O f ( s t r i n g )   >   - 1 ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   e s c a p e R e g E x p  
 	 	 R e t u r n s   s t r i n g   w i t h   e s c a p e d   r e g u l a r   e x p r e s s i o n   c h a r a c t e r s  
  
 	 E x a m p l e :  
 	 	 > v a r   s e a r c h   =   ' a n i m a l s . s h e e p s [ 1 ] ' . e s c a p e R e g E x p ( ) ;   / /   s e a r c h   i s   n o w   ' a n i m a l s \ . s h e e p s \ [ 1 \ ] '  
  
 	 R e t u r n s :  
 	 	 E s c a p e d   s t r i n g  
 	 * /  
  
 	 e s c a p e R e g E x p :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s . r e p l a c e ( / ( [ . * + ? ^ $ { } ( ) | [ \ ] \ / \ \ ] ) / g ,   ' \ \ $ 1 ' ) ;  
 	 }  
  
 } ) ;  
  
 A r r a y . e x t e n d ( {  
  
 	 / *  
 	 P r o p e r t y :   r g b T o H e x  
 	 	 s e e   < S t r i n g . r g b T o H e x > ,   b u t   a s   a n   a r r a y   m e t h o d .  
 	 * /  
  
 	 r g b T o H e x :   f u n c t i o n ( a r r a y ) {  
 	 	 i f   ( t h i s . l e n g t h   <   3 )   r e t u r n   f a l s e ;  
 	 	 i f   ( t h i s . l e n g t h   = =   4   & &   t h i s [ 3 ]   = =   0   & &   ! a r r a y )   r e t u r n   ' t r a n s p a r e n t ' ;  
 	 	 v a r   h e x   =   [ ] ;  
 	 	 f o r   ( v a r   i   =   0 ;   i   <   3 ;   i + + ) {  
 	 	 	 v a r   b i t   =   ( t h i s [ i ]   -   0 ) . t o S t r i n g ( 1 6 ) ;  
 	 	 	 h e x . p u s h ( ( b i t . l e n g t h   = =   1 )   ?   ' 0 '   +   b i t   :   b i t ) ;  
 	 	 }  
 	 	 r e t u r n   a r r a y   ?   h e x   :   ' # '   +   h e x . j o i n ( ' ' ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   h e x T o R g b  
 	 	 s a m e   a s   < S t r i n g . h e x T o R g b > ,   b u t   a s   a n   a r r a y   m e t h o d .  
 	 * /  
  
 	 h e x T o R g b :   f u n c t i o n ( a r r a y ) {  
 	 	 i f   ( t h i s . l e n g t h   ! =   3 )   r e t u r n   f a l s e ;  
 	 	 v a r   r g b   =   [ ] ;  
 	 	 f o r   ( v a r   i   =   0 ;   i   <   3 ;   i + + ) {  
 	 	 	 r g b . p u s h ( p a r s e I n t ( ( t h i s [ i ] . l e n g t h   = =   1 )   ?   t h i s [ i ]   +   t h i s [ i ]   :   t h i s [ i ] ,   1 6 ) ) ;  
 	 	 }  
 	 	 r e t u r n   a r r a y   ?   r g b   :   ' r g b ( '   +   r g b . j o i n ( ' , ' )   +   ' ) ' ;  
 	 }  
  
 } ) ;  
  
 / *    
 S c r i p t :   F u n c t i o n . j s  
 	 C o n t a i n s   F u n c t i o n   p r o t o t y p e s   a n d   u t i l i t y   f u n c t i o n s   .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
  
 C r e d i t s :  
 	 -   S o m e   f u n c t i o n s   a r e   i n s p i r e d   b y   t h o s e   f o u n d   i n   p r o t o t y p e . j s   < h t t p : / / p r o t o t y p e . c o n i o . n e t / >   ( c )   2 0 0 5   S a m   S t e p h e n s o n   s a m   [ a t ]   c o n i o   [ d o t ]   n e t ,   M I T - s t y l e   l i c e n s e  
 * /  
  
 / *  
 C l a s s :   F u n c t i o n  
 	 A   c o l l e c t i o n   o f   T h e   F u n c t i o n   O b j e c t   p r o t o t y p e   m e t h o d s .  
 * /  
  
 F u n c t i o n . e x t e n d ( {  
  
 	 / *  
 	 P r o p e r t y :   c r e a t e  
 	 	 M a i n   f u n c t i o n   t o   c r e a t e   c l o s u r e s .  
  
 	 R e t u r n s :  
 	 	 a   f u n c t i o n .  
  
 	 A r g u m e n t s :  
 	 	 o p t i o n s   -   A n   O p t i o n s   o b j e c t .  
  
 	 O p t i o n s :  
 	 	 b i n d   -   T h e   o b j e c t   t h a t   t h e   " t h i s "   o f   t h e   f u n c t i o n   w i l l   r e f e r   t o .   D e f a u l t   i s   t h e   c u r r e n t   f u n c t i o n .  
 	 	 e v e n t   -   I f   s e t   t o   t r u e ,   t h e   f u n c t i o n   w i l l   a c t   a s   a n   e v e n t   l i s t e n e r   a n d   r e c e i v e   a n   e v e n t   a s   f i r s t   a r g u m e n t .  
 	 	 	 	 I f   s e t   t o   a   c l a s s   n a m e ,   t h e   f u n c t i o n   w i l l   r e c e i v e   a   n e w   i n s t a n c e   o f   t h i s   c l a s s   ( w i t h   t h e   e v e n t   p a s s e d   a s   a r g u m e n t ' s   c o n s t r u c t o r )   a s   f i r s t   a r g u m e n t .  
 	 	 	 	 D e f a u l t   i s   f a l s e .  
 	 	 a r g u m e n t s   -   A   s i n g l e   a r g u m e n t   o r   a r r a y   o f   a r g u m e n t s   t h a t   w i l l   b e   p a s s e d   t o   t h e   f u n c t i o n   w h e n   c a l l e d .  
 	 	  
 	 	 	 	 	 I f   b o t h   t h e   e v e n t   a n d   a r g u m e n t s   o p t i o n s   a r e   s e t ,   t h e   e v e n t   i s   p a s s e d   a s   f i r s t   a r g u m e n t   a n d   t h e   a r g u m e n t s   a r r a y   w i l l   f o l l o w .  
 	 	 	 	 	  
 	 	 	 	 	 D e f a u l t   i s   n o   c u s t o m   a r g u m e n t s ,   t h e   f u n c t i o n   w i l l   r e c e i v e   t h e   s t a n d a r d   a r g u m e n t s   w h e n   c a l l e d .  
 	 	 	 	 	  
 	 	 d e l a y   -   N u m e r i c   v a l u e :   i f   s e t ,   t h e   r e t u r n e d   f u n c t i o n   w i l l   d e l a y   t h e   a c t u a l   e x e c u t i o n   b y   t h i s   a m o u n t   o f   m i l l i s e c o n d s   a n d   r e t u r n   a   t i m e r   h a n d l e   w h e n   c a l l e d .  
 	 	 	 	 D e f a u l t   i s   n o   d e l a y .  
 	 	 p e r i o d i c a l   -   N u m e r i c   v a l u e :   i f   s e t ,   t h e   r e t u r n e d   f u n c t i o n   w i l l   p e r i o d i c a l l y   p e r f o r m   t h e   a c t u a l   e x e c u t i o n   w i t h   t h i s   s p e c i f i e d   i n t e r v a l   a n d   r e t u r n   a   t i m e r   h a n d l e   w h e n   c a l l e d .  
 	 	 	 	 D e f a u l t   i s   n o   p e r i o d i c a l   e x e c u t i o n .  
 	 	 a t t e m p t   -   I f   s e t   t o   t r u e ,   t h e   r e t u r n e d   f u n c t i o n   w i l l   t r y   t o   e x e c u t e   a n d   r e t u r n   e i t h e r   t h e   r e s u l t s   o r   f a l s e   o n   e r r o r .   D e f a u l t   i s   f a l s e .  
 	 * /  
  
 	 c r e a t e :   f u n c t i o n ( o p t i o n s ) {  
 	 	 v a r   f n   =   t h i s ;  
 	 	 o p t i o n s   =   $ m e r g e ( {  
 	 	 	 ' b i n d ' :   f n ,  
 	 	 	 ' e v e n t ' :   f a l s e ,  
 	 	 	 ' a r g u m e n t s ' :   n u l l ,  
 	 	 	 ' d e l a y ' :   f a l s e ,  
 	 	 	 ' p e r i o d i c a l ' :   f a l s e ,  
 	 	 	 ' a t t e m p t ' :   f a l s e  
 	 	 } ,   o p t i o n s ) ;  
 	 	 i f   ( $ c h k ( o p t i o n s . a r g u m e n t s )   & &   $ t y p e ( o p t i o n s . a r g u m e n t s )   ! =   ' a r r a y ' )   o p t i o n s . a r g u m e n t s   =   [ o p t i o n s . a r g u m e n t s ] ;  
 	 	 r e t u r n   f u n c t i o n ( e v e n t ) {  
 	 	 	 v a r   a r g s ;  
 	 	 	 i f   ( o p t i o n s . e v e n t ) {  
 	 	 	 	 e v e n t   =   e v e n t   | |   w i n d o w . e v e n t ;  
 	 	 	 	 a r g s   =   [ ( o p t i o n s . e v e n t   = = =   t r u e )   ?   e v e n t   :   n e w   o p t i o n s . e v e n t ( e v e n t ) ] ;  
 	 	 	 	 i f   ( o p t i o n s . a r g u m e n t s )   a r g s . e x t e n d ( o p t i o n s . a r g u m e n t s ) ;  
 	 	 	 }  
 	 	 	 e l s e   a r g s   =   o p t i o n s . a r g u m e n t s   | |   a r g u m e n t s ;  
 	 	 	 v a r   r e t u r n s   =   f u n c t i o n ( ) {  
 	 	 	 	 r e t u r n   f n . a p p l y ( $ p i c k ( o p t i o n s . b i n d ,   f n ) ,   a r g s ) ;  
 	 	 	 } ;  
 	 	 	 i f   ( o p t i o n s . d e l a y )   r e t u r n   s e t T i m e o u t ( r e t u r n s ,   o p t i o n s . d e l a y ) ;  
 	 	 	 i f   ( o p t i o n s . p e r i o d i c a l )   r e t u r n   s e t I n t e r v a l ( r e t u r n s ,   o p t i o n s . p e r i o d i c a l ) ;  
 	 	 	 i f   ( o p t i o n s . a t t e m p t )   t r y   { r e t u r n   r e t u r n s ( ) ; }   c a t c h ( e r r ) { r e t u r n   f a l s e ; } ;  
 	 	 	 r e t u r n   r e t u r n s ( ) ;  
 	 	 } ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   p a s s  
 	 	 S h o r t c u t   t o   c r e a t e   c l o s u r e s   w i t h   a r g u m e n t s   a n d   b i n d .  
  
 	 R e t u r n s :  
 	 	 a   f u n c t i o n .  
  
 	 A r g u m e n t s :  
 	 	 a r g s   -   t h e   a r g u m e n t s   p a s s e d .   m u s t   b e   a n   a r r a y   i f   a r g u m e n t s   >   1  
 	 	 b i n d   -   o p t i o n a l ,   t h e   o b j e c t   t h a t   t h e   " t h i s "   o f   t h e   f u n c t i o n   w i l l   r e f e r   t o .  
  
 	 E x a m p l e :  
 	 	 > m y F u n c t i o n . p a s s ( [ a r g 1 ,   a r g 2 ] ,   m y E l e m e n t ) ;  
 	 * /  
  
 	 p a s s :   f u n c t i o n ( a r g s ,   b i n d ) {  
 	 	 r e t u r n   t h i s . c r e a t e ( { ' a r g u m e n t s ' :   a r g s ,   ' b i n d ' :   b i n d } ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   a t t e m p t  
 	 	 T r i e s   t o   e x e c u t e   t h e   f u n c t i o n ,   r e t u r n s   e i t h e r   t h e   r e s u l t   o f   t h e   f u n c t i o n   o r   f a l s e   o n   e r r o r .  
  
 	 A r g u m e n t s :  
 	 	 a r g s   -   t h e   a r g u m e n t s   p a s s e d .   m u s t   b e   a n   a r r a y   i f   a r g u m e n t s   >   1  
 	 	 b i n d   -   o p t i o n a l ,   t h e   o b j e c t   t h a t   t h e   " t h i s "   o f   t h e   f u n c t i o n   w i l l   r e f e r   t o .  
  
 	 E x a m p l e :  
 	 	 > m y F u n c t i o n . a t t e m p t ( [ a r g 1 ,   a r g 2 ] ,   m y E l e m e n t ) ;  
 	 * /  
  
 	 a t t e m p t :   f u n c t i o n ( a r g s ,   b i n d ) {  
 	 	 r e t u r n   t h i s . c r e a t e ( { ' a r g u m e n t s ' :   a r g s ,   ' b i n d ' :   b i n d ,   ' a t t e m p t ' :   t r u e } ) ( ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   b i n d  
 	 	 m e t h o d   t o   e a s i l y   c r e a t e   c l o s u r e s   w i t h   " t h i s "   a l t e r e d .  
  
 	 A r g u m e n t s :  
 	 	 b i n d   -   o p t i o n a l ,   t h e   o b j e c t   t h a t   t h e   " t h i s "   o f   t h e   f u n c t i o n   w i l l   r e f e r   t o .  
 	 	 a r g s   -   o p t i o n a l ,   t h e   a r g u m e n t s   p a s s e d .   m u s t   b e   a n   a r r a y   i f   a r g u m e n t s   >   1  
  
 	 R e t u r n s :  
 	 	 a   f u n c t i o n .  
  
 	 E x a m p l e :  
 	 	 > f u n c t i o n   m y F u n c t i o n ( ) {  
 	 	 > 	 t h i s . s e t S t y l e ( ' c o l o r ' ,   ' r e d ' ) ;  
 	 	 > 	 / /   n o t e   t h a t   ' t h i s '   h e r e   r e f e r s   t o   m y F u n c t i o n ,   n o t   a n   e l e m e n t  
 	 	 > 	 / /   w e ' l l   n e e d   t o   b i n d   t h i s   f u n c t i o n   t o   t h e   e l e m e n t   w e   w a n t   t o   a l t e r  
 	 	 > } ;  
 	 	 > v a r   m y B o u n d F u n c t i o n   =   m y F u n c t i o n . b i n d ( m y E l e m e n t ) ;  
 	 	 > m y B o u n d F u n c t i o n ( ) ;   / /   t h i s   w i l l   m a k e   t h e   e l e m e n t   m y E l e m e n t   r e d .  
 	 * /  
  
 	 b i n d :   f u n c t i o n ( b i n d ,   a r g s ) {  
 	 	 r e t u r n   t h i s . c r e a t e ( { ' b i n d ' :   b i n d ,   ' a r g u m e n t s ' :   a r g s } ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   b i n d A s E v e n t L i s t e n e r  
 	 	 c r o s s   b r o w s e r   m e t h o d   t o   p a s s   e v e n t   f i r e r  
  
 	 A r g u m e n t s :  
 	 	 b i n d   -   o p t i o n a l ,   t h e   o b j e c t   t h a t   t h e   " t h i s "   o f   t h e   f u n c t i o n   w i l l   r e f e r   t o .  
 	 	 a r g s   -   o p t i o n a l ,   t h e   a r g u m e n t s   p a s s e d .   m u s t   b e   a n   a r r a y   i f   a r g u m e n t s   >   1  
  
 	 R e t u r n s :  
 	 	 a   f u n c t i o n   w i t h   t h e   p a r a m e t e r   b i n d   a s   i t s   " t h i s "   a n d   a s   a   p r e - p a s s e d   a r g u m e n t   e v e n t   o r   w i n d o w . e v e n t ,   d e p e n d i n g   o n   t h e   b r o w s e r .  
  
 	 E x a m p l e :  
 	 	 > f u n c t i o n   m y F u n c t i o n ( e v e n t ) {  
 	 	 > 	 a l e r t ( e v e n t . c l i e n t x )   / / r e t u r n s   t h e   c o o r d i n a t e s   o f   t h e   m o u s e . .  
 	 	 > } ;  
 	 	 > m y E l e m e n t . o n c l i c k   =   m y F u n c t i o n . b i n d A s E v e n t L i s t e n e r ( m y E l e m e n t ) ;  
 	 * /  
  
 	 b i n d A s E v e n t L i s t e n e r :   f u n c t i o n ( b i n d ,   a r g s ) {  
 	 	 r e t u r n   t h i s . c r e a t e ( { ' b i n d ' :   b i n d ,   ' e v e n t ' :   t r u e ,   ' a r g u m e n t s ' :   a r g s } ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   d e l a y  
 	 	 D e l a y s   t h e   e x e c u t i o n   o f   a   f u n c t i o n   b y   a   s p e c i f i e d   d u r a t i o n .  
  
 	 A r g u m e n t s :  
 	 	 d e l a y   -   t h e   d u r a t i o n   t o   w a i t   i n   m i l l i s e c o n d s .  
 	 	 b i n d   -   o p t i o n a l ,   t h e   o b j e c t   t h a t   t h e   " t h i s "   o f   t h e   f u n c t i o n   w i l l   r e f e r   t o .  
 	 	 a r g s   -   o p t i o n a l ,   t h e   a r g u m e n t s   p a s s e d .   m u s t   b e   a n   a r r a y   i f   a r g u m e n t s   >   1  
  
 	 E x a m p l e :  
 	 	 > m y F u n c t i o n . d e l a y ( 5 0 ,   m y E l e m e n t )   / / w a i t   5 0   m i l l i s e c o n d s ,   t h e n   c a l l   m y F u n c t i o n   a n d   b i n d   m y E l e m e n t   t o   i t  
 	 	 > ( f u n c t i o n ( ) { a l e r t ( ' o n e   s e c o n d   l a t e r . . . ' ) } ) . d e l a y ( 1 0 0 0 ) ;   / / w a i t   a   s e c o n d   a n d   a l e r t  
 	 * /  
  
 	 d e l a y :   f u n c t i o n ( d e l a y ,   b i n d ,   a r g s ) {  
 	 	 r e t u r n   t h i s . c r e a t e ( { ' d e l a y ' :   d e l a y ,   ' b i n d ' :   b i n d ,   ' a r g u m e n t s ' :   a r g s } ) ( ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   p e r i o d i c a l  
 	 	 E x e c u t e s   a   f u n c t i o n   i n   t h e   s p e c i f i e d   i n t e r v a l s   o f   t i m e  
  
 	 A r g u m e n t s :  
 	 	 i n t e r v a l   -   t h e   d u r a t i o n   o f   t h e   i n t e r v a l s   b e t w e e n   e x e c u t i o n s .  
 	 	 b i n d   -   o p t i o n a l ,   t h e   o b j e c t   t h a t   t h e   " t h i s "   o f   t h e   f u n c t i o n   w i l l   r e f e r   t o .  
 	 	 a r g s   -   o p t i o n a l ,   t h e   a r g u m e n t s   p a s s e d .   m u s t   b e   a n   a r r a y   i f   a r g u m e n t s   >   1  
 	 * /  
  
 	 p e r i o d i c a l :   f u n c t i o n ( i n t e r v a l ,   b i n d ,   a r g s ) {  
 	 	 r e t u r n   t h i s . c r e a t e ( { ' p e r i o d i c a l ' :   i n t e r v a l ,   ' b i n d ' :   b i n d ,   ' a r g u m e n t s ' :   a r g s } ) ( ) ;  
 	 }  
  
 } ) ;  
  
 / *  
 S c r i p t :   N u m b e r . j s  
 	 C o n t a i n s   t h e   N u m b e r   p r o t o t y p e s .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   N u m b e r  
 	 A   c o l l e c t i o n   o f   T h e   N u m b e r   O b j e c t   p r o t o t y p e   m e t h o d s .  
 * /  
  
 N u m b e r . e x t e n d ( {  
  
 	 / *  
 	 P r o p e r t y :   t o I n t  
 	 	 R e t u r n s   t h i s   n u m b e r ;   u s e f u l   b e c a u s e   t o I n t   m u s t   w o r k   o n   b o t h   S t r i n g s   a n d   N u m b e r s .  
 	 * /  
  
 	 t o I n t :   f u n c t i o n ( ) {  
 	 	 r e t u r n   p a r s e I n t ( t h i s ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   t o F l o a t  
 	 	 R e t u r n s   t h i s   n u m b e r   a s   a   f l o a t ;   u s e f u l   b e c a u s e   t o F l o a t   m u s t   w o r k   o n   b o t h   S t r i n g s   a n d   N u m b e r s .  
 	 * /  
  
 	 t o F l o a t :   f u n c t i o n ( ) {  
 	 	 r e t u r n   p a r s e F l o a t ( t h i s ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   l i m i t  
 	 	 L i m i t s   t h e   n u m b e r .  
  
 	 A r g u m e n t s :  
 	 	 m i n   -   n u m b e r ,   m i n i m u m   v a l u e  
 	 	 m a x   -   n u m b e r ,   m a x i m u m   v a l u e  
  
 	 R e t u r n s :  
 	 	 t h e   n u m b e r   i n   t h e   g i v e n   l i m i t s .  
  
 	 E x a m p l e :  
 	 	 > ( 1 2 ) . l i m i t ( 2 ,   6 . 5 )     / /   r e t u r n s   6 . 5  
 	 	 > ( - 4 ) . l i m i t ( 2 ,   6 . 5 )     / /   r e t u r n s   2  
 	 	 > ( 4 . 3 ) . l i m i t ( 2 ,   6 . 5 )   / /   r e t u r n s   4 . 3  
 	 * /  
  
 	 l i m i t :   f u n c t i o n ( m i n ,   m a x ) {  
 	 	 r e t u r n   M a t h . m i n ( m a x ,   M a t h . m a x ( m i n ,   t h i s ) ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   r o u n d  
 	 	 R e t u r n s   t h e   n u m b e r   r o u n d e d   t o   s p e c i f i e d   p r e c i s i o n .  
  
 	 A r g u m e n t s :  
 	 	 p r e c i s i o n   -   i n t e g e r ,   n u m b e r   o f   d i g i t s   a f t e r   t h e   d e c i m a l   p o i n t .   C a n   a l s o   b e   n e g a t i v e   o r   z e r o   ( d e f a u l t ) .  
  
 	 E x a m p l e :  
 	 	 > 1 2 . 4 5 . r o u n d ( )   / /   r e t u r n s   1 2  
 	 	 > 1 2 . 4 5 . r o u n d ( 1 )   / /   r e t u r n s   1 2 . 5  
 	 	 > 1 2 . 4 5 . r o u n d ( - 1 )   / /   r e t u r n s   1 0  
  
 	 R e t u r n s :  
 	 	 T h e   r o u n d e d   n u m b e r .  
 	 * /  
  
 	 r o u n d :   f u n c t i o n ( p r e c i s i o n ) {  
 	 	 p r e c i s i o n   =   M a t h . p o w ( 1 0 ,   p r e c i s i o n   | |   0 ) ;  
 	 	 r e t u r n   M a t h . r o u n d ( t h i s   *   p r e c i s i o n )   /   p r e c i s i o n ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   t i m e s  
 	 	 E x e c u t e s   a   p a s s e d   i n   f u n c t i o n   t h e   s p e c i f i e d   n u m b e r   o f   t i m e s  
  
 	 A r g u m e n t s :  
 	 	 f u n c t i o n   -   t h e   f u n c t i o n   t o   b e   e x e c u t e d   o n   e a c h   i t e r a t i o n   o f   t h e   l o o p  
  
 	 E x a m p l e :  
 	 	 > ( 4 ) . t i m e s ( a l e r t ) ;  
 	 * /  
  
 	 t i m e s :   f u n c t i o n ( f n ) {  
 	 	 f o r   ( v a r   i   =   0 ;   i   <   t h i s ;   i + + )   f n ( i ) ;  
 	 }  
  
 } ) ;  
  
 / *  
 S c r i p t :   E l e m e n t . j s  
 	 C o n t a i n s   u s e f u l   E l e m e n t   p r o t o t y p e s ,   t o   b e   u s e d   w i t h   t h e   d o l l a r   f u n c t i o n   < $ > .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
  
 C r e d i t s :  
 	 -   S o m e   f u n c t i o n s   a r e   i n s p i r e d   b y   t h o s e   f o u n d   i n   p r o t o t y p e . j s   < h t t p : / / p r o t o t y p e . c o n i o . n e t / >   ( c )   2 0 0 5   S a m   S t e p h e n s o n   s a m   [ a t ]   c o n i o   [ d o t ]   n e t ,   M I T - s t y l e   l i c e n s e  
 * /  
  
 / *  
 C l a s s :   E l e m e n t  
 	 C u s t o m   c l a s s   t o   a l l o w   a l l   o f   i t s   m e t h o d s   t o   b e   u s e d   w i t h   a n y   D O M   e l e m e n t   v i a   t h e   d o l l a r   f u n c t i o n   < $ > .  
 * /  
  
 v a r   E l e m e n t   =   n e w   C l a s s ( {  
  
 	 / *  
 	 P r o p e r t y :   i n i t i a l i z e  
 	 	 C r e a t e s   a   n e w   e l e m e n t   o f   t h e   t y p e   p a s s e d   i n .  
  
 	 A r g u m e n t s :  
 	 	 e l   -   s t r i n g ;   t h e   t a g   n a m e   f o r   t h e   e l e m e n t   y o u   w i s h   t o   c r e a t e .   y o u   c a n   a l s o   p a s s   i n   a n   e l e m e n t   r e f e r e n c e ,   i n   w h i c h   c a s e   i t   w i l l   b e   e x t e n d e d .  
 	 	 p r o p s   -   o b j e c t ;   t h e   p r o p e r t i e s   y o u   w a n t   t o   a d d   t o   y o u r   e l e m e n t .  
 	 	 A c c e p t s   t h e   s a m e   k e y s   a s   < E l e m e n t . s e t P r o p e r t i e s > ,   b u t   a l s o   a l l o w s   e v e n t s   a n d   s t y l e s  
  
 	 P r o p s :  
 	 	 t h e   k e y   s t y l e s   w i l l   b e   u s e d   a s   s e t S t y l e s ,   t h e   k e y   e v e n t s   w i l l   b e   u s e d   a s   a d d E v e n t s .   a n y   o t h e r   k e y   i s   u s e d   a s   s e t P r o p e r t y .  
  
 	 E x a m p l e :  
 	 	 ( s t a r t   c o d e )  
 	 	 n e w   E l e m e n t ( ' a ' ,   {  
 	 	 	 ' s t y l e s ' :   {  
 	 	 	 	 ' d i s p l a y ' :   ' b l o c k ' ,  
 	 	 	 	 ' b o r d e r ' :   ' 1 p x   s o l i d   b l a c k '  
 	 	 	 } ,  
 	 	 	 ' e v e n t s ' :   {  
 	 	 	 	 ' c l i c k ' :   f u n c t i o n ( ) {  
 	 	 	 	 	 / / a a a  
 	 	 	 	 } ,  
 	 	 	 	 ' m o u s e d o w n ' :   f u n c t i o n ( ) {  
 	 	 	 	 	 / / a a a  
 	 	 	 	 }  
 	 	 	 } ,  
 	 	 	 ' c l a s s ' :   ' m y C l a s s S u p e r C l a s s ' ,  
 	 	 	 ' h r e f ' :   ' h t t p : / / m a d 4 m i l k . n e t '  
 	 	 } ) ;  
  
 	 	 ( e n d )  
 	 * /  
  
 	 i n i t i a l i z e :   f u n c t i o n ( e l ,   p r o p s ) {  
 	 	 i f   ( $ t y p e ( e l )   = =   ' s t r i n g ' ) {  
 	 	 	 i f   ( w i n d o w . i e   & &   p r o p s   & &   ( p r o p s . n a m e   | |   p r o p s . t y p e ) ) {  
 	 	 	 	 v a r   n a m e   =   ( p r o p s . n a m e )   ?   '   n a m e = " '   +   p r o p s . n a m e   +   ' " '   :   ' ' ;  
 	 	 	 	 v a r   t y p e   =   ( p r o p s . t y p e )   ?   '   t y p e = " '   +   p r o p s . t y p e   +   ' " '   :   ' ' ;  
 	 	 	 	 d e l e t e   p r o p s . n a m e ;  
 	 	 	 	 d e l e t e   p r o p s . t y p e ;  
 	 	 	 	 e l   =   ' < '   +   e l   +   n a m e   +   t y p e   +   ' > ' ;  
 	 	 	 }  
 	 	 	 e l   =   d o c u m e n t . c r e a t e E l e m e n t ( e l ) ;  
 	 	 }  
 	 	 e l   =   $ ( e l ) ;  
 	 	 r e t u r n   ( ! p r o p s   | |   ! e l )   ?   e l   :   e l . s e t ( p r o p s ) ;  
 	 }  
  
 } ) ;  
  
 / *  
 C l a s s :   E l e m e n t s  
 	 -   E v e r y   d o m   f u n c t i o n   s u c h   a s   < $ $ > ,   o r   i n   g e n e r a l   e v e r y   f u n c t i o n   t h a t   r e t u r n s   a   c o l l e c t i o n   o f   n o d e s   i n   m o o t o o l s ,   r e t u r n s   t h e m   a s   a n   E l e m e n t s   c l a s s .  
 	 -   T h e   p u r p o s e   o f   t h e   E l e m e n t s   c l a s s   i s   t o   a l l o w   < E l e m e n t >   m e t h o d s   t o   w o r k   a l s o   o n   < E l e m e n t s >   a r r a y .  
 	 -   E l e m e n t s   i s   a l s o   a n   A r r a y ,   s o   i t   a c c e p t s   a l l   t h e   < A r r a y >   m e t h o d s .  
 	 -   E v e r y   n o d e   o f   t h e   E l e m e n t s   i n s t a n c e   i s   a l r e a d y   e x t e n d e d   w i t h   < $ > .  
  
 E x a m p l e :  
 	 > $ $ ( ' m y s e l e c t o r ' ) . e a c h ( f u n c t i o n ( e l ) {  
 	 >   / / . . .  
 	 > } ) ;  
  
 	 s o m e   i t e r a t i o n s   h e r e ,   $ $ ( ' m y s e l e c t o r ' )   i s   a l s o   a n   a r r a y .  
  
 	 > $ $ ( ' m y s e l e c t o r ' ) . s e t S t y l e ( ' c o l o r ' ,   ' r e d ' ) ;  
 	 e v e r y   e l e m e n t   r e t u r n e d   b y   $ $ ( ' m y s e l e c t o r ' )   a l s o   a c c e p t s   < E l e m e n t >   m e t h o d s ,   i n   t h i s   e x a m p l e   e v e r y   e l e m e n t   w i l l   b e   m a d e   r e d .  
 * /  
  
 v a r   E l e m e n t s   =   n e w   C l a s s ( {  
  
 	 i n i t i a l i z e :   f u n c t i o n ( e l e m e n t s ) {  
 	 	 r e t u r n   ( e l e m e n t s )   ?   $ e x t e n d ( e l e m e n t s ,   t h i s )   :   t h i s ;  
 	 }  
  
 } ) ;  
  
 E l e m e n t s . e x t e n d   =   f u n c t i o n ( p r o p s ) {  
 	 f o r   ( v a r   p r o p   i n   p r o p s ) {  
 	 	 t h i s . p r o t o t y p e [ p r o p ]   =   p r o p s [ p r o p ] ;  
 	 	 t h i s [ p r o p ]   =   $ n a t i v e . g e n e r i c ( p r o p ) ;  
 	 }  
 } ;  
  
 / *  
 S e c t i o n :   U t i l i t y   F u n c t i o n s  
  
 F u n c t i o n :   $  
 	 r e t u r n s   t h e   e l e m e n t   p a s s e d   i n   w i t h   a l l   t h e   E l e m e n t   p r o t o t y p e s   a p p l i e d .  
  
 A r g u m e n t s :  
 	 e l   -   a   r e f e r e n c e   t o   a n   a c t u a l   e l e m e n t   o r   a   s t r i n g   r e p r e s e n t i n g   t h e   i d   o f   a n   e l e m e n t  
  
 E x a m p l e :  
 	 > $ ( ' m y E l e m e n t ' )   / /   g e t s   a   D O M   e l e m e n t   b y   i d   w i t h   a l l   t h e   E l e m e n t   p r o t o t y p e s   a p p l i e d .  
 	 > v a r   d i v   =   d o c u m e n t . g e t E l e m e n t B y I d ( ' m y E l e m e n t ' ) ;  
 	 > $ ( d i v )   / / r e t u r n s   a n   E l e m e n t   a l s o   w i t h   a l l   t h e   m o o t o o l s   e x t e n t i o n s   a p p l i e d .  
  
 	 Y o u ' l l   u s e   t h i s   w h e n   y o u   a r e n ' t   s u r e   i f   a   v a r i a b l e   i s   a n   a c t u a l   e l e m e n t   o r   a n   i d ,   a s  
 	 w e l l   a s   j u s t   s h o r t h a n d   f o r   d o c u m e n t . g e t E l e m e n t B y I d ( ) .  
  
 R e t u r n s :  
 	 a   D O M   e l e m e n t   o r   f a l s e   ( i f   n o   i d   w a s   f o u n d ) .  
  
 N o t e :  
 	 y o u   n e e d   t o   c a l l   $   o n   a n   e l e m e n t   o n l y   o n c e   t o   g e t   a l l   t h e   p r o t o t y p e s .  
 	 B u t   i t s   n o   h a r m   t o   c a l l   i t   m u l t i p l e   t i m e s ,   a s   i t   w i l l   d e t e c t   i f   i t   h a s   b e e n   a l r e a d y   e x t e n d e d .  
 * /  
  
 f u n c t i o n   $ ( e l ) {  
 	 i f   ( ! e l )   r e t u r n   n u l l ;  
 	 i f   ( e l . h t m l E l e m e n t )   r e t u r n   G a r b a g e . c o l l e c t ( e l ) ;  
 	 i f   ( [ w i n d o w ,   d o c u m e n t ] . c o n t a i n s ( e l ) )   r e t u r n   e l ;  
 	 v a r   t y p e   =   $ t y p e ( e l ) ;  
 	 i f   ( t y p e   = =   ' s t r i n g ' ) {  
 	 	 e l   =   d o c u m e n t . g e t E l e m e n t B y I d ( e l ) ;  
 	 	 t y p e   =   ( e l )   ?   ' e l e m e n t '   :   f a l s e ;  
 	 }  
 	 i f   ( t y p e   ! =   ' e l e m e n t ' )   r e t u r n   n u l l ;  
 	 i f   ( e l . h t m l E l e m e n t )   r e t u r n   G a r b a g e . c o l l e c t ( e l ) ;  
 	 i f   ( [ ' o b j e c t ' ,   ' e m b e d ' ] . c o n t a i n s ( e l . t a g N a m e . t o L o w e r C a s e ( ) ) )   r e t u r n   e l ;  
 	 $ e x t e n d ( e l ,   E l e m e n t . p r o t o t y p e ) ;  
 	 e l . h t m l E l e m e n t   =   f u n c t i o n ( ) { } ;  
 	 r e t u r n   G a r b a g e . c o l l e c t ( e l ) ;  
 } ;  
  
 / *  
 F u n c t i o n :   $ $  
 	 S e l e c t s ,   a n d   e x t e n d s   D O M   e l e m e n t s .   E l e m e n t s   a r r a y s   r e t u r n e d   w i t h   $ $   w i l l   a l s o   a c c e p t   a l l   t h e   < E l e m e n t >   m e t h o d s .  
 	 T h e   r e t u r n   t y p e   o f   e l e m e n t   m e t h o d s   r u n   t h r o u g h   $ $   i s   a l w a y s   a n   a r r a y .   I f   t h e   r e t u r n   a r r a y   i s   o n l y   m a d e   b y   e l e m e n t s ,  
 	 $ $   w i l l   b e   a p p l i e d   a u t o m a t i c a l l y .  
  
 A r g u m e n t s :  
 	 H T M L   C o l l e c t i o n s ,   a r r a y s   o f   e l e m e n t s ,   a r r a y s   o f   s t r i n g s   a s   e l e m e n t   i d s ,   e l e m e n t s ,   s t r i n g s   a s   s e l e c t o r s .  
 	 A n y   n u m b e r   o f   t h e   a b o v e   a s   a r g u m e n t s   a r e   a c c e p t e d .  
  
 N o t e :  
 	 i f   y o u   l o a d   < E l e m e n t . S e l e c t o r s . j s > ,   $ $   w i l l   a l s o   a c c e p t   C S S   S e l e c t o r s ,   o t h e r w i s e   t h e   o n l y   s e l e c t o r s   s u p p o r t e d   a r e   t a g   n a m e s .  
  
 E x a m p l e :  
 	 > $ $ ( ' a ' )   / / a n   a r r a y   o f   a l l   a n c h o r   t a g s   o n   t h e   p a g e  
 	 > $ $ ( ' a ' ,   ' b ' )   / / a n   a r r a y   o f   a l l   a n c h o r   a n d   b o l d   t a g s   o n   t h e   p a g e  
 	 > $ $ ( ' # m y E l e m e n t ' )   / / a r r a y   c o n t a i n i n g   o n l y   t h e   e l e m e n t   w i t h   i d   =   m y E l e m e n t .   ( o n l y   w i t h   < E l e m e n t . S e l e c t o r s . j s > )  
 	 > $ $ ( ' # m y E l e m e n t   a . m y C l a s s ' )   / / a n   a r r a y   o f   a l l   a n c h o r   t a g s   w i t h   t h e   c l a s s   " m y C l a s s "  
 	 > / / w i t h i n   t h e   D O M   e l e m e n t   w i t h   i d   " m y E l e m e n t "   ( o n l y   w i t h   < E l e m e n t . S e l e c t o r s . j s > )  
 	 > $ $ ( m y e l e m e n t ,   m y e l e m e n t 2 ,   ' a ' ,   [ ' m y i d ' ,   m y i d 2 ,   ' m y i d 3 ' ] ,   d o c u m e n t . g e t E l e m e n t s B y T a g N a m e ( ' d i v ' ) )   / / a n   a r r a y   c o n t a i n i n g :  
 	 > / /   t h e   e l e m e n t   r e f e r e n c e d   a s   m y e l e m e n t   i f   e x i s t i n g ,  
 	 > / /   t h e   e l e m e n t   r e f e r e n c e d   a s   m y e l e m e n t 2   i f   e x i s t i n g ,  
 	 > / /   a l l   t h e   e l e m e n t s   w i t h   a   a s   t a g   i n   t h e   p a g e ,  
 	 > / /   t h e   e l e m e n t   w i t h   i d   =   m y i d   i f   e x i s t i n g  
 	 > / /   t h e   e l e m e n t   w i t h   i d   =   m y i d 2   i f   e x i s t i n g  
 	 > / /   t h e   e l e m e n t   w i t h   i d   =   m y i d 3   i f   e x i s t i n g  
 	 > / /   a l l   t h e   e l e m e n t s   w i t h   d i v   a s   t a g   i n   t h e   p a g e  
  
 R e t u r n s :  
 	 a r r a y   -   a r r a y   o f   a l l   t h e   d o m   e l e m e n t s   m a t c h e d ,   e x t e n d e d   w i t h   < $ > .     R e t u r n s   a s   < E l e m e n t s > .  
 * /  
  
 d o c u m e n t . g e t E l e m e n t s B y S e l e c t o r   =   d o c u m e n t . g e t E l e m e n t s B y T a g N a m e ;  
  
 f u n c t i o n   $ $ ( ) {  
 	 v a r   e l e m e n t s   =   [ ] ;  
 	 f o r   ( v a r   i   =   0 ,   j   =   a r g u m e n t s . l e n g t h ;   i   <   j ;   i + + ) {  
 	 	 v a r   s e l e c t o r   =   a r g u m e n t s [ i ] ;  
 	 	 s w i t c h ( $ t y p e ( s e l e c t o r ) ) {  
 	 	 	 c a s e   ' e l e m e n t ' :   e l e m e n t s . p u s h ( s e l e c t o r ) ;  
 	 	 	 c a s e   ' b o o l e a n ' :   b r e a k ;  
 	 	 	 c a s e   f a l s e :   b r e a k ;  
 	 	 	 c a s e   ' s t r i n g ' :   s e l e c t o r   =   d o c u m e n t . g e t E l e m e n t s B y S e l e c t o r ( s e l e c t o r ,   t r u e ) ;  
 	 	 	 d e f a u l t :   e l e m e n t s . e x t e n d ( s e l e c t o r ) ;  
 	 	 }  
 	 }  
 	 r e t u r n   $ $ . u n i q u e ( e l e m e n t s ) ;  
 } ;  
  
 $ $ . u n i q u e   =   f u n c t i o n ( a r r a y ) {  
 	 v a r   e l e m e n t s   =   [ ] ;  
 	 f o r   ( v a r   i   =   0 ,   l   =   a r r a y . l e n g t h ;   i   <   l ;   i + + ) {  
 	 	 i f   ( a r r a y [ i ] . $ i n c l u d e d )   c o n t i n u e ;  
 	 	 v a r   e l e m e n t   =   $ ( a r r a y [ i ] ) ;  
 	 	 i f   ( e l e m e n t   & &   ! e l e m e n t . $ i n c l u d e d ) {  
 	 	 	 e l e m e n t . $ i n c l u d e d   =   t r u e ;  
 	 	 	 e l e m e n t s . p u s h ( e l e m e n t ) ;  
 	 	 }  
 	 }  
 	 f o r   ( v a r   n   =   0 ,   d   =   e l e m e n t s . l e n g t h ;   n   <   d ;   n + + )   e l e m e n t s [ n ] . $ i n c l u d e d   =   n u l l ;  
 	 r e t u r n   n e w   E l e m e n t s ( e l e m e n t s ) ;  
 } ;  
  
 E l e m e n t s . M u l t i   =   f u n c t i o n ( p r o p e r t y ) {  
 	 r e t u r n   f u n c t i o n ( ) {  
 	 	 v a r   a r g s   =   a r g u m e n t s ;  
 	 	 v a r   i t e m s   =   [ ] ;  
 	 	 v a r   e l e m e n t s   =   t r u e ;  
 	 	 f o r   ( v a r   i   =   0 ,   j   =   t h i s . l e n g t h ,   r e t u r n s ;   i   <   j ;   i + + ) {  
 	 	 	 r e t u r n s   =   t h i s [ i ] [ p r o p e r t y ] . a p p l y ( t h i s [ i ] ,   a r g s ) ;  
 	 	 	 i f   ( $ t y p e ( r e t u r n s )   ! =   ' e l e m e n t ' )   e l e m e n t s   =   f a l s e ;  
 	 	 	 i t e m s . p u s h ( r e t u r n s ) ;  
 	 	 } ;  
 	 	 r e t u r n   ( e l e m e n t s )   ?   $ $ . u n i q u e ( i t e m s )   :   i t e m s ;  
 	 } ;  
 } ;  
  
 E l e m e n t . e x t e n d   =   f u n c t i o n ( p r o p e r t i e s ) {  
 	 f o r   ( v a r   p r o p e r t y   i n   p r o p e r t i e s ) {  
 	 	 H T M L E l e m e n t . p r o t o t y p e [ p r o p e r t y ]   =   p r o p e r t i e s [ p r o p e r t y ] ;  
 	 	 E l e m e n t . p r o t o t y p e [ p r o p e r t y ]   =   p r o p e r t i e s [ p r o p e r t y ] ;  
 	 	 E l e m e n t [ p r o p e r t y ]   =   $ n a t i v e . g e n e r i c ( p r o p e r t y ) ;  
 	 	 v a r   e l e m e n t s P r o p e r t y   =   ( A r r a y . p r o t o t y p e [ p r o p e r t y ] )   ?   p r o p e r t y   +   ' E l e m e n t s '   :   p r o p e r t y ;  
 	 	 E l e m e n t s . p r o t o t y p e [ e l e m e n t s P r o p e r t y ]   =   E l e m e n t s . M u l t i ( p r o p e r t y ) ;  
 	 }  
 } ;  
  
 / *  
 C l a s s :   E l e m e n t  
 	 C u s t o m   c l a s s   t o   a l l o w   a l l   o f   i t s   m e t h o d s   t o   b e   u s e d   w i t h   a n y   D O M   e l e m e n t   v i a   t h e   d o l l a r   f u n c t i o n   < $ > .  
 * /  
  
 E l e m e n t . e x t e n d ( {  
  
 	 / *  
 	 P r o p e r t y :   s e t  
 	 	 y o u   c a n   s e t   e v e n t s ,   s t y l e s   a n d   p r o p e r t i e s   w i t h   t h i s   s h o r t c u t .   s a m e   a s   c a l l i n g   n e w   E l e m e n t .  
 	 * /  
  
 	 s e t :   f u n c t i o n ( p r o p s ) {  
 	 	 f o r   ( v a r   p r o p   i n   p r o p s ) {  
 	 	 	 v a r   v a l   =   p r o p s [ p r o p ] ;  
 	 	 	 s w i t c h ( p r o p ) {  
 	 	 	 	 c a s e   ' s t y l e s ' :   t h i s . s e t S t y l e s ( v a l ) ;   b r e a k ;  
 	 	 	 	 c a s e   ' e v e n t s ' :   i f   ( t h i s . a d d E v e n t s )   t h i s . a d d E v e n t s ( v a l ) ;   b r e a k ;  
 	 	 	 	 c a s e   ' p r o p e r t i e s ' :   t h i s . s e t P r o p e r t i e s ( v a l ) ;   b r e a k ;  
 	 	 	 	 d e f a u l t :   t h i s . s e t P r o p e r t y ( p r o p ,   v a l ) ;  
 	 	 	 }  
 	 	 }  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 i n j e c t :   f u n c t i o n ( e l ,   w h e r e ) {  
 	 	 e l   =   $ ( e l ) ;  
 	 	 s w i t c h ( w h e r e ) {  
 	 	 	 c a s e   ' b e f o r e ' :   e l . p a r e n t N o d e . i n s e r t B e f o r e ( t h i s ,   e l ) ;   b r e a k ;  
 	 	 	 c a s e   ' a f t e r ' :  
 	 	 	 	 v a r   n e x t   =   e l . g e t N e x t ( ) ;  
 	 	 	 	 i f   ( ! n e x t )   e l . p a r e n t N o d e . a p p e n d C h i l d ( t h i s ) ;  
 	 	 	 	 e l s e   e l . p a r e n t N o d e . i n s e r t B e f o r e ( t h i s ,   n e x t ) ;  
 	 	 	 	 b r e a k ;  
 	 	 	 c a s e   ' t o p ' :  
 	 	 	 	 v a r   f i r s t   =   e l . f i r s t C h i l d ;  
 	 	 	 	 i f   ( f i r s t ) {  
 	 	 	 	 	 e l . i n s e r t B e f o r e ( t h i s ,   f i r s t ) ;  
 	 	 	 	 	 b r e a k ;  
 	 	 	 	 }  
 	 	 	 d e f a u l t :   e l . a p p e n d C h i l d ( t h i s ) ;  
 	 	 }  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   i n j e c t B e f o r e  
 	 	 I n s e r t s   t h e   E l e m e n t   b e f o r e   t h e   p a s s e d   e l e m e n t .  
  
 	 A r g u m e n t s :  
 	 	 e l   -   a n   e l e m e n t   r e f e r e n c e   o r   t h e   i d   o f   t h e   e l e m e n t   t o   b e   i n j e c t e d   i n .  
  
 	 E x a m p l e :  
 	 	 > h t m l :  
 	 	 > < d i v   i d = " m y E l e m e n t " > < / d i v >  
 	 	 > < d i v   i d = " m y S e c o n d E l e m e n t " > < / d i v >  
 	 	 > j s :  
 	 	 > $ ( ' m y S e c o n d E l e m e n t ' ) . i n j e c t B e f o r e ( ' m y E l e m e n t ' ) ;  
 	 	 > r e s u l t i n g   h t m l :  
 	 	 > < d i v   i d = " m y S e c o n d E l e m e n t " > < / d i v >  
 	 	 > < d i v   i d = " m y E l e m e n t " > < / d i v >  
 	 * /  
  
 	 i n j e c t B e f o r e :   f u n c t i o n ( e l ) {  
 	 	 r e t u r n   t h i s . i n j e c t ( e l ,   ' b e f o r e ' ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   i n j e c t A f t e r  
 	 	 S a m e   a s   < E l e m e n t . i n j e c t B e f o r e > ,   b u t   i n s e r t s   t h e   e l e m e n t   a f t e r .  
 	 * /  
  
 	 i n j e c t A f t e r :   f u n c t i o n ( e l ) {  
 	 	 r e t u r n   t h i s . i n j e c t ( e l ,   ' a f t e r ' ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   i n j e c t I n s i d e  
 	 	 S a m e   a s   < E l e m e n t . i n j e c t B e f o r e > ,   b u t   i n s e r t s   t h e   e l e m e n t   i n s i d e .  
 	 * /  
  
 	 i n j e c t I n s i d e :   f u n c t i o n ( e l ) {  
 	 	 r e t u r n   t h i s . i n j e c t ( e l ,   ' b o t t o m ' ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   i n j e c t T o p  
 	 	 S a m e   a s   < E l e m e n t . i n j e c t I n s i d e > ,   b u t   i n s e r t s   t h e   e l e m e n t   i n s i d e ,   a t   t h e   t o p .  
 	 * /  
  
 	 i n j e c t T o p :   f u n c t i o n ( e l ) {  
 	 	 r e t u r n   t h i s . i n j e c t ( e l ,   ' t o p ' ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   a d o p t  
 	 	 I n s e r t s   t h e   p a s s e d   e l e m e n t s   i n s i d e   t h e   E l e m e n t .  
  
 	 A r g u m e n t s :  
 	 	 a c c e p t s   e l e m e n t s   r e f e r e n c e s ,   e l e m e n t   i d s   a s   s t r i n g ,   s e l e c t o r s   ( $ $ ( ' s t u f f ' ) )   /   a r r a y   o f   e l e m e n t s ,   a r r a y   o f   i d s   a s   s t r i n g s   a n d   c o l l e c t i o n s .  
 	 * /  
  
 	 a d o p t :   f u n c t i o n ( ) {  
 	 	 v a r   e l e m e n t s   =   [ ] ;  
 	 	 $ e a c h ( a r g u m e n t s ,   f u n c t i o n ( a r g u m e n t ) {  
 	 	 	 e l e m e n t s   =   e l e m e n t s . c o n c a t ( a r g u m e n t ) ;  
 	 	 } ) ;  
 	 	 $ $ ( e l e m e n t s ) . i n j e c t ( t h i s ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   r e m o v e  
 	 	 R e m o v e s   t h e   E l e m e n t   f r o m   t h e   D O M .  
  
 	 E x a m p l e :  
 	 	 > $ ( ' m y E l e m e n t ' ) . r e m o v e ( )   / / b y e   b y e  
 	 * /  
  
 	 r e m o v e :   f u n c t i o n ( ) {  
 	 	 r e t u r n   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 ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   c l o n e  
 	 	 C l o n e s   t h e   E l e m e n t   a n d   r e t u r n s   t h e   c l o n e d   o n e .  
  
 	 A r g u m e n t s :  
 	 	 c o n t e n t s   -   b o o l e a n ,   w h e n   t r u e   t h e   E l e m e n t   i s   c l o n e d   w i t h   c h i l d N o d e s ,   d e f a u l t   t r u e  
  
 	 R e t u r n s :  
 	 	 t h e   c l o n e d   e l e m e n t  
  
 	 E x a m p l e :  
 	 	 > v a r   c l o n e   =   $ ( ' m y E l e m e n t ' ) . c l o n e ( ) . i n j e c t A f t e r ( ' m y E l e m e n t ' ) ;  
 	 	 > / / c l o n e s   t h e   E l e m e n t   a n d   a p p e n d   t h e   c l o n e   a f t e r   t h e   E l e m e n t .  
 	 * /  
  
 	 c l o n e :   f u n c t i o n ( c o n t e n t s ) {  
 	 	 v a r   e l   =   $ ( t h i s . c l o n e N o d e ( c o n t e n t s   ! = =   f a l s e ) ) ;  
 	 	 i f   ( ! e l . $ e v e n t s )   r e t u r n   e l ;  
 	 	 e l . $ 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 )   e l . $ e v e n t s [ t y p e ]   =   {  
 	 	 	 ' k e y s ' :   $ A ( t h i s . $ e v e n t s [ t y p e ] . k e y s ) ,  
 	 	 	 ' v a l u e s ' :   $ A ( t h i s . $ e v e n t s [ t y p e ] . v a l u e s )  
 	 	 } ;  
 	 	 r e t u r n   e l . r e m o v e E v e n t s ( ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   r e p l a c e W i t h  
 	 	 R e p l a c e s   t h e   E l e m e n t   w i t h   a n   e l e m e n t   p a s s e d .  
  
 	 A r g u m e n t s :  
 	 	 e l   -   a   s t r i n g   r e p r e s e n t i n g   t h e   e l e m e n t   t o   b e   i n j e c t e d   i n   ( m y E l e m e n t I d ,   o r   d i v ) ,   o r   a n   e l e m e n t   r e f e r e n c e .  
 	 	 I f   y o u   p a s s   d i v   o r   a n o t h e r   t a g ,   t h e   e l e m e n t   w i l l   b e   c r e a t e d .  
  
 	 R e t u r n s :  
 	 	 t h e   p a s s e d   i n   e l e m e n t  
  
 	 E x a m p l e :  
 	 	 > $ ( ' m y O l d E l e m e n t ' ) . r e p l a c e W i t h ( $ ( ' m y N e w E l e m e n t ' ) ) ;   / / $ ( ' m y O l d E l e m e n t ' )   i s   g o n e ,   a n d   $ ( ' m y N e w E l e m e n t ' )   i s   i n   i t s   p l a c e .  
 	 * /  
  
 	 r e p l a c e W i t h :   f u n c t i o n ( e l ) {  
 	 	 e l   =   $ ( e l ) ;  
 	 	 t h i s . p a r e n t N o d e . r e p l a c e C h i l d ( e l ,   t h i s ) ;  
 	 	 r e t u r n   e l ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   a p p e n d T e x t  
 	 	 A p p e n d s   t e x t   n o d e   t o   a   D O M   e l e m e n t .  
  
 	 A r g u m e n t s :  
 	 	 t e x t   -   t h e   t e x t   t o   a p p e n d .  
  
 	 E x a m p l e :  
 	 	 > < d i v   i d = " m y E l e m e n t " > h e y < / d i v >  
 	 	 > $ ( ' m y E l e m e n t ' ) . a p p e n d T e x t ( '   h o w d y ' ) ;   / / m y E l e m e n t   i n n e r H T M L   i s   n o w   " h e y   h o w d y "  
 	 * /  
  
 	 a p p e n d T e x t :   f u n c t i o n ( t e x t ) {  
 	 	 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 T e x t N o d e ( t e x t ) ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   h a s C l a s s  
 	 	 T e s t s   t h e   E l e m e n t   t o   s e e   i f   i t   h a s   t h e   p a s s e d   i n   c l a s s N a m e .  
  
 	 R e t u r n s :  
 	 	 t r u e   -   t h e   E l e m e n t   h a s   t h e   c l a s s  
 	 	 f a l s e   -   i t   d o e s n ' t  
  
 	 A r g u m e n t s :  
 	 	 c l a s s N a m e   -   s t r i n g ;   t h e   c l a s s   n a m e   t o   t e s t .  
  
 	 E x a m p l e :  
 	 	 > < d i v   i d = " m y E l e m e n t "   c l a s s = " t e s t C l a s s " > < / d i v >  
 	 	 > $ ( ' m y E l e m e n t ' ) . h a s C l a s s ( ' t e s t C l a s s ' ) ;   / / r e t u r n s   t r u e  
 	 * /  
  
 	 h a s C l a s s :   f u n c t i o n ( c l a s s N a m e ) {  
 	 	 r e t u r n   t h i s . c l a s s N a m e . c o n t a i n s ( c l a s s N a m e ,   '   ' ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   a d d C l a s s  
 	 	 A d d s   t h e   p a s s e d   i n   c l a s s   t o   t h e   E l e m e n t ,   i f   t h e   e l e m e n t   d o e s n t   a l r e a d y   h a v e   i t .  
  
 	 A r g u m e n t s :  
 	 	 c l a s s N a m e   -   s t r i n g ;   t h e   c l a s s   n a m e   t o   a d d  
  
 	 E x a m p l e :  
 	 	 > < d i v   i d = " m y E l e m e n t "   c l a s s = " t e s t C l a s s " > < / d i v >  
 	 	 > $ ( ' m y E l e m e n t ' ) . a d d C l a s s ( ' n e w C l a s s ' ) ;   / / < d i v   i d = " m y E l e m e n t "   c l a s s = " t e s t C l a s s   n e w C l a s s " > < / d i v >  
 	 * /  
  
 	 a d d C l a s s :   f u n c t i o n ( c l a s s N a m e ) {  
 	 	 i f   ( ! t h i s . h a s C l a s s ( c l a s s N a m e ) )   t h i s . c l a s s N a m e   =   ( t h i s . c l a s s N a m e   +   '   '   +   c l a s s N a m e ) . c l e a n ( ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   r e m o v e C l a s s  
 	 	 W o r k s   l i k e   < E l e m e n t . a d d C l a s s > ,   b u t   r e m o v e s   t h e   c l a s s   f r o m   t h e   e l e m e n t .  
 	 * /  
  
 	 r e m o v e C l a s s :   f u n c t i o n ( c l a s s N a m e ) {  
 	 	 t h i s . c l a s s N a m e   =   t h i s . c l a s s N a m e . r e p l a c e ( n e w   R e g E x p ( ' ( ^ | \ \ s ) '   +   c l a s s N a m e   +   ' ( ? : \ \ s | $ ) ' ) ,   ' $ 1 ' ) . c l e a n ( ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   t o g g l e C l a s s  
 	 	 A d d s   o r   r e m o v e s   t h e   p a s s e d   i n   c l a s s   n a m e   t o   t h e   e l e m e n t ,   d e p e n d i n g   o n   i f   i t ' s   p r e s e n t   o r   n o t .  
  
 	 A r g u m e n t s :  
 	 	 c l a s s N a m e   -   t h e   c l a s s   t o   a d d   o r   r e m o v e  
  
 	 E x a m p l e :  
 	 	 > < d i v   i d = " m y E l e m e n t "   c l a s s = " m y C l a s s " > < / d i v >  
 	 	 > $ ( ' m y E l e m e n t ' ) . t o g g l e C l a s s ( ' m y C l a s s ' ) ;  
 	 	 > < d i v   i d = " m y E l e m e n t "   c l a s s = " " > < / d i v >  
 	 	 > $ ( ' m y E l e m e n t ' ) . t o g g l e C l a s s ( ' m y C l a s s ' ) ;  
 	 	 > < d i v   i d = " m y E l e m e n t "   c l a s s = " m y C l a s s " > < / d i v >  
 	 * /  
  
 	 t o g g l e C l a s s :   f u n c t i o n ( c l a s s N a m e ) {  
 	 	 r e t u r n   t h i s . h a s C l a s s ( c l a s s N a m e )   ?   t h i s . r e m o v e C l a s s ( c l a s s N a m e )   :   t h i s . a d d C l a s s ( c l a s s N a m e ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s e t S t y l e  
 	 	 S e t s   a   c s s   p r o p e r t y   t o   t h e   E l e m e n t .  
  
 	 	 A r g u m e n t s :  
 	 	 	 p r o p e r t y   -   t h e   p r o p e r t y   t o   s e t  
 	 	 	 v a l u e   -   t h e   v a l u e   t o   w h i c h   t o   s e t   i t ;   f o r   n u m e r i c   v a l u e s   t h a t   r e q u i r e   " p x "   y o u   c a n   p a s s   a n   i n t e g e r  
  
 	 	 E x a m p l e :  
 	 	 	 > $ ( ' m y E l e m e n t ' ) . s e t S t y l e ( ' w i d t h ' ,   ' 3 0 0 p x ' ) ;   / / t h e   w i d t h   i s   n o w   3 0 0 p x  
 	 	 	 > $ ( ' m y E l e m e n t ' ) . s e t S t y l e ( ' w i d t h ' ,   3 0 0 ) ;   / / t h e   w i d t h   i s   n o w   3 0 0 p x  
 	 * /  
  
 	 s e t S t y l e :   f u n c t i o n ( p r o p e r t y ,   v a l u e ) {  
 	 	 s w i t c h ( p r o p e r t y ) {  
 	 	 	 c a s e   ' o p a c i t y ' :   r e t u r n   t h i s . s e t O p a c i t y ( p a r s e F l o a t ( v a l u e ) ) ;  
 	 	 	 c a s e   ' f l o a t ' :   p r o p e r t y   =   ( w i n d o w . i e )   ?   ' s t y l e F l o a t '   :   ' c s s F l o a t ' ;  
 	 	 }  
 	 	 p r o p e r t y   =   p r o p e r t y . c a m e l C a s e ( ) ;  
 	 	 s w i t c h ( $ t y p e ( v a l u e ) ) {  
 	 	 	 c a s e   ' n u m b e r ' :   i f   ( ! [ ' z I n d e x ' ,   ' z o o m ' ] . c o n t a i n s ( p r o p e r t y ) )   v a l u e   + =   ' p x ' ;   b r e a k ;  
 	 	 	 c a s e   ' a r r a y ' :   v a l u e   =   ' r g b ( '   +   v a l u e . j o i n ( ' , ' )   +   ' ) ' ;  
 	 	 }  
 	 	 t h i s . s t y l e [ p r o p e r t y ]   =   v a l u e ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s e t S t y l e s  
 	 	 A p p l i e s   a   c o l l e c t i o n   o f   s t y l e s   t o   t h e   E l e m e n t .  
  
 	 A r g u m e n t s :  
 	 	 s o u r c e   -   a n   o b j e c t   o r   s t r i n g   c o n t a i n i n g   a l l   t h e   s t y l e s   t o   a p p l y .   W h e n   i t s   a   s t r i n g   i t   o v e r r i d e s   o l d   s t y l e .  
  
 	 E x a m p l e s :  
 	 	 > $ ( ' m y E l e m e n t ' ) . s e t S t y l e s ( {  
 	 	 > 	 b o r d e r :   ' 1 p x   s o l i d   # 0 0 0 ' ,  
 	 	 > 	 w i d t h :   3 0 0 ,  
 	 	 > 	 h e i g h t :   4 0 0  
 	 	 > } ) ;  
  
 	 	 O R  
  
 	 	 > $ ( ' m y E l e m e n t ' ) . s e t S t y l e s ( ' b o r d e r :   1 p x   s o l i d   # 0 0 0 ;   w i d t h :   3 0 0 p x ;   h e i g h t :   4 0 0 p x ; ' ) ;  
 	 * /  
  
 	 s e t S t y l e s :   f u n c t i o n ( s o u r c e ) {  
 	 	 s w i t c h ( $ t y p e ( s o u r c e ) ) {  
 	 	 	 c a s e   ' o b j e c t ' :   E l e m e n t . s e t M a n y ( t h i s ,   ' s e t S t y l e ' ,   s o u r c e ) ;   b r e a k ;  
 	 	 	 c a s e   ' s t r i n g ' :   t h i s . s t y l e . c s s T e x t   =   s o u r c e ;  
 	 	 }  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s e t O p a c i t y  
 	 	 S e t s   t h e   o p a c i t y   o f   t h e   E l e m e n t ,   a n d   s e t s   a l s o   v i s i b i l i t y   = =   " h i d d e n "   i f   o p a c i t y   = =   0 ,   a n d   v i s i b i l i t y   =   " v i s i b l e "   i f   o p a c i t y   >   0 .  
  
 	 A r g u m e n t s :  
 	 	 o p a c i t y   -   f l o a t ;   A c c e p t s   v a l u e s   f r o m   0   t o   1 .  
  
 	 E x a m p l e :  
 	 	 > $ ( ' m y E l e m e n t ' ) . s e t O p a c i t y ( 0 . 5 )   / / m a k e   i t   5 0 %   t r a n s p a r e n t  
 	 * /  
  
 	 s e t O p a c i t y :   f u n c t i o n ( o p a c i t y ) {  
 	 	 i f   ( o p a c i t y   = =   0 ) {  
 	 	 	 i f   ( t h i s . s t y l e . v i s i b i l i t y   ! =   " h i d d e n " )   t h i s . s t y l e . v i s i b i l i t y   =   " h i d d e n " ;  
 	 	 }   e l s e   {  
 	 	 	 i f   ( t h i s . s t y l e . v i s i b i l i t y   ! =   " v i s i b l e " )   t h i s . s t y l e . v i s i b i l i t y   =   " v i s i b l e " ;  
 	 	 }  
 	 	 i f   ( ! t h i s . c u r r e n t S t y l e   | |   ! t h i s . c u r r e n t S t y l e . h a s L a y o u t )   t h i s . s t y l e . z o o m   =   1 ;  
 	 	 i f   ( w i n d o w . i e )   t h i s . s t y l e . f i l t e r   =   ( o p a c i t y   = =   1 )   ?   ' '   :   " a l p h a ( o p a c i t y = "   +   o p a c i t y   *   1 0 0   +   " ) " ;  
 	 	 t h i s . s t y l e . o p a c i t y   =   t h i s . $ t m p . o p a c i t y   =   o p a c i t y ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t S t y l e  
 	 	 R e t u r n s   t h e   s t y l e   o f   t h e   E l e m e n t   g i v e n   t h e   p r o p e r t y   p a s s e d   i n .  
  
 	 A r g u m e n t s :  
 	 	 p r o p e r t y   -   t h e   c s s   s t y l e   p r o p e r t y   y o u   w a n t   t o   r e t r i e v e  
  
 	 E x a m p l e :  
 	 	 > $ ( ' m y E l e m e n t ' ) . g e t S t y l e ( ' w i d t h ' ) ;   / / r e t u r n s   " 4 0 0 p x "  
 	 	 > / / b u t   y o u   c a n   a l s o   u s e  
 	 	 > $ ( ' m y E l e m e n t ' ) . g e t S t y l e ( ' w i d t h ' ) . t o I n t ( ) ;   / / r e t u r n s   4 0 0  
  
 	 R e t u r n s :  
 	 	 t h e   s t y l e   a s   a   s t r i n g  
 	 * /  
  
 	 g e t S t y l e :   f u n c t i o n ( p r o p e r t y ) {  
 	 	 p r o p e r t y   =   p r o p e r t y . c a m e l C a s e ( ) ;  
 	 	 v a r   r e s u l t   =   t h i s . s t y l e [ p r o p e r t y ] ;  
 	 	 i f   ( ! $ c h k ( r e s u l t ) ) {  
 	 	 	 i f   ( p r o p e r t y   = =   ' o p a c i t y ' )   r e t u r n   t h i s . $ t m p . o p a c i t y ;  
 	 	 	 r e s u l t   =   [ ] ;  
 	 	 	 f o r   ( v a r   s t y l e   i n   E l e m e n t . S t y l e s ) {  
 	 	 	 	 i f   ( p r o p e r t y   = =   s t y l e ) {  
 	 	 	 	 	 E l e m e n t . S t y l e s [ s t y l e ] . e a c h ( f u n c t i o n ( s ) {  
 	 	 	 	 	 	 v a r   s t y l e   =   t h i s . g e t S t y l e ( s ) ;  
 	 	 	 	 	 	 r e s u l t . p u s h ( p a r s e I n t ( s t y l e )   ?   s t y l e   :   ' 0 p x ' ) ;  
 	 	 	 	 	 } ,   t h i s ) ;  
 	 	 	 	 	 i f   ( p r o p e r t y   = =   ' b o r d e r ' ) {  
 	 	 	 	 	 	 v a r   e v e r y   =   r e s u l t . e v e r y ( f u n c t i o n ( b i t ) {  
 	 	 	 	 	 	 	 r e t u r n   ( b i t   = =   r e s u l t [ 0 ] ) ;  
 	 	 	 	 	 	 } ) ;  
 	 	 	 	 	 	 r e t u r n   ( e v e r y )   ?   r e s u l t [ 0 ]   :   f a l s e ;  
 	 	 	 	 	 }  
 	 	 	 	 	 r e t u r n   r e s u l t . j o i n ( '   ' ) ;  
 	 	 	 	 }  
 	 	 	 }  
 	 	 	 i f   ( p r o p e r t y . c o n t a i n s ( ' b o r d e r ' ) ) {  
 	 	 	 	 i f   ( E l e m e n t . S t y l e s . b o r d e r . c o n t a i n s ( p r o p e r t y ) ) {  
 	 	 	 	 	 r e t u r n   [ ' W i d t h ' ,   ' S t y l e ' ,   ' C o l o r ' ] . m a p ( f u n c t i o n ( p ) {  
 	 	 	 	 	 	 r e t u r n   t h i s . g e t S t y l e ( p r o p e r t y   +   p ) ;  
 	 	 	 	 	 } ,   t h i s ) . j o i n ( '   ' ) ;  
 	 	 	 	 }   e l s e   i f   ( E l e m e n t . b o r d e r S h o r t . c o n t a i n s ( p r o p e r t y ) ) {  
 	 	 	 	 	 r e t u r n   [ ' T o p ' ,   ' R i g h t ' ,   ' B o t t o m ' ,   ' L e f t ' ] . m a p ( f u n c t i o n ( p ) {  
 	 	 	 	 	 	 r e t u r n   t h i s . g e t S t y l e ( ' b o r d e r '   +   p   +   p r o p e r t y . r e p l a c e ( ' b o r d e r ' ,   ' ' ) ) ;  
 	 	 	 	 	 } ,   t h i s ) . j o i n ( '   ' ) ;  
 	 	 	 	 }  
 	 	 	 }  
 	 	 	 i f   ( d o c u m e n t . d e f a u l t V i e w )   r e s u l t   =   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 ,   n u l l ) . g e t P r o p e r t y V a l u e ( p r o p e r t y . h y p h e n a t e ( ) ) ;  
 	 	 	 e l s e   i f   ( t h i s . c u r r e n t S t y l e )   r e s u l t   =   t h i s . c u r r e n t S t y l e [ p r o p e r t y ] ;  
 	 	 }  
 	 	 i f   ( w i n d o w . i e )   r e s u l t   =   E l e m e n t . f i x S t y l e ( p r o p e r t y ,   r e s u l t ,   t h i s ) ;  
 	 	 i f   ( r e s u l t   & &   p r o p e r t y . t e s t ( / c o l o r / i )   & &   r e s u l t . c o n t a i n s ( ' r g b ' ) ) {  
 	 	 	 r e t u r n   r e s u l t . s p l i t ( ' r g b ' ) . s p l i c e ( 1 , 4 ) . m a p ( f u n c t i o n ( c o l o r ) {  
 	 	 	 	 r e t u r n   c o l o r . r g b T o H e x ( ) ;  
 	 	 	 } ) . j o i n ( '   ' ) ;  
 	 	 }  
 	 	 r e t u r n   r e s u l t ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t S t y l e s  
 	 	 R e t u r n s   a n   o b j e c t   o f   s t y l e s   o f   t h e   E l e m e n t   f o r   e a c h   a r g u m e n t   p a s s e d   i n .  
 	 	 A r g u m e n t s :  
 	 	 p r o p e r t i e s   -   s t r i n g s ;   a n y   n u m b e r   o f   s t y l e   p r o p e r t i e s  
 	 E x a m p l e :  
 	 	 > $ ( ' m y E l e m e n t ' ) . g e t S t y l e s ( ' w i d t h ' , ' h e i g h t ' , ' p a d d i n g ' ) ;  
 	 	 > / / r e t u r n s   a n   o b j e c t   l i k e :  
 	 	 > { w i d t h :   " 1 0 p x " ,   h e i g h t :   " 1 0 p x " ,   p a d d i n g :   " 1 0 p x   0 p x   1 0 p x   0 p x " }  
 	 * /  
  
 	 g e t S t y l e s :   f u n c t i o n ( ) {  
 	 	 r e t u r n   E l e m e n t . g e t M a n y ( t h i s ,   ' g e t S t y l e ' ,   a r g u m e n t s ) ;  
 	 } ,  
  
 	 w a l k :   f u n c t i o n ( b r o t h e r ,   s t a r t ) {  
 	 	 b r o t h e r   + =   ' S i b l i n g ' ;  
 	 	 v a r   e l   =   ( s t a r t )   ?   t h i s [ s t a r t ]   :   t h i s [ b r o t h e r ] ;  
 	 	 w h i l e   ( e l   & &   $ t y p e ( e l )   ! =   ' e l e m e n t ' )   e l   =   e l [ b r o t h e r ] ;  
 	 	 r e t u r n   $ ( e l ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t P r e v i o u s  
 	 	 R e t u r n s   t h e   p r e v i o u s S i b l i n g   o f   t h e   E l e m e n t ,   e x c l u d i n g   t e x t   n o d e s .  
  
 	 E x a m p l e :  
 	 	 > $ ( ' m y E l e m e n t ' ) . g e t P r e v i o u s ( ) ;   / / g e t   t h e   p r e v i o u s   D O M   e l e m e n t   f r o m   m y E l e m e n t  
  
 	 R e t u r n s :  
 	 	 t h e   s i b l i n g   e l e m e n t   o r   u n d e f i n e d   i f   n o n e   f o u n d .  
 	 * /  
  
 	 g e t P r e v i o u s :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s . w a l k ( ' p r e v i o u s ' ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t N e x t  
 	 	 W o r k s   a s   E l e m e n t . g e t P r e v i o u s ,   b u t   t r i e s   t o   f i n d   t h e   n e x t S i b l i n g .  
 	 * /  
  
 	 g e t N e x t :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s . w a l k ( ' n e x t ' ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t F i r s t  
 	 	 W o r k s   a s   < E l e m e n t . g e t P r e v i o u s > ,   b u t   t r i e s   t o   f i n d   t h e   f i r s t C h i l d .  
 	 * /  
  
 	 g e t F i r s t :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s . w a l k ( ' n e x t ' ,   ' f i r s t C h i l d ' ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t L a s t  
 	 	 W o r k s   a s   < E l e m e n t . g e t P r e v i o u s > ,   b u t   t r i e s   t o   f i n d   t h e   l a s t C h i l d .  
 	 * /  
  
 	 g e t L a s t :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s . w a l k ( ' p r e v i o u s ' ,   ' l a s t C h i l d ' ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t P a r e n t  
 	 	 r e t u r n s   t h e   $ ( e l e m e n t . p a r e n t N o d e )  
 	 * /  
  
 	 g e t P a r e n t :   f u n c t i o n ( ) {  
 	 	 r e t u r n   $ ( t h i s . p a r e n t N o d e ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t C h i l d r e n  
 	 	 r e t u r n s   a l l   t h e   $ ( e l e m e n t . c h i l d N o d e s ) ,   e x c l u d i n g   t e x t   n o d e s .   R e t u r n s   a s   < E l e m e n t s > .  
 	 * /  
  
 	 g e t C h i l d r e n :   f u n c t i o n ( ) {  
 	 	 r e t u r n   $ $ ( t h i s . c h i l d N o d e s ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   h a s C h i l d  
 	 	 r e t u r n s   t r u e   i f   t h e   p a s s e d   i n   e l e m e n t   i s   a   c h i l d   o f   t h e   $ ( e l e m e n t ) .  
 	 * /  
  
 	 h a s C h i l d :   f u n c t i o n ( e l ) {  
 	 	 r e t u r n   ! ! $ A ( t h i s . g e t E l e m e n t s B y T a g N a m e ( ' * ' ) ) . c o n t a i n s ( e l ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t P r o p e r t y  
 	 	 G e t s   t h e   a n   a t t r i b u t e   o f   t h e   E l e m e n t .  
  
 	 A r g u m e n t s :  
 	 	 p r o p e r t y   -   s t r i n g ;   t h e   a t t r i b u t e   t o   r e t r i e v e  
  
 	 E x a m p l e :  
 	 	 > $ ( ' m y I m a g e ' ) . g e t P r o p e r t y ( ' s r c ' )   / /   r e t u r n s   w h a t e v e r . g i f  
  
 	 R e t u r n s :  
 	 	 t h e   v a l u e ,   o r   a n   e m p t y   s t r i n g  
 	 * /  
  
 	 g e t P r o p e r t y :   f u n c t i o n ( p r o p e r t y ) {  
 	 	 v a r   i n d e x   =   E l e m e n t . P r o p e r t i e s [ p r o p e r t y ] ;  
 	 	 i f   ( i n d e x )   r e t u r n   t h i s [ i n d e x ] ;  
 	 	 v a r   f l a g   =   E l e m e n t . P r o p e r t i e s I F l a g [ p r o p e r t y ]   | |   0 ;  
 	 	 i f   ( ! w i n d o w . i e   | |   f l a g )   r e t u r n   t h i s . g e t A t t r i b u t e ( p r o p e r t y ,   f l a g ) ;  
 	 	 v a r   n o d e   =   t h i s . a t t r i b u t e s [ p r o p e r t y ] ;  
 	 	 r e t u r n   ( n o d e )   ?   n o d e . n o d e V a l u e   :   n u l l ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   r e m o v e P r o p e r t y  
 	 	 R e m o v e s   a n   a t t r i b u t e   f r o m   t h e   E l e m e n t  
  
 	 A r g u m e n t s :  
 	 	 p r o p e r t y   -   s t r i n g ;   t h e   a t t r i b u t e   t o   r e m o v e  
 	 * /  
  
 	 r e m o v e P r o p e r t y :   f u n c t i o n ( p r o p e r t y ) {  
 	 	 v a r   i n d e x   =   E l e m e n t . P r o p e r t i e s [ p r o p e r t y ] ;  
 	 	 i f   ( i n d e x )   t h i s [ i n d e x ]   =   ' ' ;  
 	 	 e l s e   t h i s . r e m o v e A t t r i b u t e ( p r o p e r t y ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t P r o p e r t i e s  
 	 	 s a m e   a s   < E l e m e n t . g e t S t y l e s > ,   b u t   f o r   p r o p e r t i e s  
 	 * /  
  
 	 g e t P r o p e r t i e s :   f u n c t i o n ( ) {  
 	 	 r e t u r n   E l e m e n t . g e t M a n y ( t h i s ,   ' g e t P r o p e r t y ' ,   a r g u m e n t s ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s e t P r o p e r t y  
 	 	 S e t s   a n   a t t r i b u t e   f o r   t h e   E l e m e n t .  
  
 	 A r g u m e n t s :  
 	 	 p r o p e r t y   -   s t r i n g ;   t h e   p r o p e r t y   t o   a s s i g n   t h e   v a l u e   p a s s e d   i n  
 	 	 v a l u e   -   t h e   v a l u e   t o   a s s i g n   t o   t h e   p r o p e r t y   p a s s e d   i n  
  
 	 E x a m p l e :  
 	 	 > $ ( ' m y I m a g e ' ) . s e t P r o p e r t y ( ' s r c ' ,   ' w h a t e v e r . g i f ' ) ;   / / m y I m a g e   n o w   p o i n t s   t o   w h a t e v e r . g i f   f o r   i t s   s o u r c e  
 	 * /  
  
 	 s e t P r o p e r t y :   f u n c t i o n ( p r o p e r t y ,   v a l u e ) {  
 	 	 v a r   i n d e x   =   E l e m e n t . P r o p e r t i e s [ p r o p e r t y ] ;  
 	 	 i f   ( i n d e x )   t h i s [ i n d e x ]   =   v a l u e ;  
 	 	 e l s e   t h i s . s e t A t t r i b u t e ( p r o p e r t y ,   v a l u e ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s e t P r o p e r t i e s  
 	 	 S e t s   n u m e r o u s   a t t r i b u t e s   f o r   t h e   E l e m e n t .  
  
 	 A r g u m e n t s :  
 	 	 s o u r c e   -   a n   o b j e c t   w i t h   k e y / v a l u e   p a i r s .  
  
 	 E x a m p l e :  
 	 	 ( s t a r t   c o d e )  
 	 	 $ ( ' m y E l e m e n t ' ) . s e t P r o p e r t i e s ( {  
 	 	 	 s r c :   ' w h a t e v e r . g i f ' ,  
 	 	 	 a l t :   ' w h a t e v e r   d u d e '  
 	 	 } ) ;  
 	 	 < i m g   s r c = " w h a t e v e r . g i f "   a l t = " w h a t e v e r   d u d e " >  
 	 	 ( e n d )  
 	 * /  
  
 	 s e t P r o p e r t i e s :   f u n c t i o n ( s o u r c e ) {  
 	 	 r e t u r n   E l e m e n t . s e t M a n y ( t h i s ,   ' s e t P r o p e r t y ' ,   s o u r c e ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s e t H T M L  
 	 	 S e t s   t h e   i n n e r H T M L   o f   t h e   E l e m e n t .  
  
 	 A r g u m e n t s :  
 	 	 h t m l   -   s t r i n g ;   t h e   n e w   i n n e r H T M L   f o r   t h e   e l e m e n t .  
  
 	 E x a m p l e :  
 	 	 > $ ( ' m y E l e m e n t ' ) . s e t H T M L ( n e w H T M L )   / / t h e   i n n e r H T M L   o f   m y E l e m e n t   i s   n o w   =   n e w H T M L  
 	 * /  
  
 	 s e t H T M L :   f u n c t i o n ( ) {  
 	 	 t h i s . i n n e r H T M L   =   $ A ( a r g u m e n t s ) . j o i n ( ' ' ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s e t T e x t  
 	 	 S e t s   t h e   i n n e r   t e x t   o f   t h e   E l e m e n t .  
  
 	 A r g u m e n t s :  
 	 	 t e x t   -   s t r i n g ;   t h e   n e w   t e x t   c o n t e n t   f o r   t h e   e l e m e n t .  
  
 	 E x a m p l e :  
 	 	 > $ ( ' m y E l e m e n t ' ) . s e t T e x t ( ' s o m e   t e x t ' )   / / t h e   t e x t   o f   m y E l e m e n t   i s   n o w   =   ' s o m e   t e x t '  
 	 * /  
  
 	 s e t T e x t :   f u n c t i o n ( t e x t ) {  
 	 	 v a r   t a g   =   t h i s . g e t T a g ( ) ;  
 	 	 i f   ( [ ' s t y l e ' ,   ' s c r i p t ' ] . c o n t a i n s ( t a g ) ) {  
 	 	 	 i f   ( w i n d o w . i e ) {  
 	 	 	 	 i f   ( t a g   = =   ' s t y l e ' )   t h i s . s t y l e S h e e t . c s s T e x t   =   t e x t ;  
 	 	 	 	 e l s e   i f   ( t a g   = =     ' s c r i p t ' )   t h i s . s e t P r o p e r t y ( ' t e x t ' ,   t e x t ) ;  
 	 	 	 	 r e t u r n   t h i s ;  
 	 	 	 }   e l s e   {  
 	 	 	 	 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 ) ;  
 	 	 	 	 r e t u r n   t h i s . a p p e n d T e x t ( t e x t ) ;  
 	 	 	 }  
 	 	 }  
 	 	 t h i s [ $ d e f i n e d ( t h i s . i n n e r T e x t )   ?   ' i n n e r T e x t '   :   ' t e x t C o n t e n t ' ]   =   t e x t ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t T e x t  
 	 	 G e t s   t h e   i n n e r   t e x t   o f   t h e   E l e m e n t .  
 	 * /  
  
 	 g e t T e x t :   f u n c t i o n ( ) {  
 	 	 v a r   t a g   =   t h i s . g e t T a g ( ) ;  
 	 	 i f   ( [ ' s t y l e ' ,   ' s c r i p t ' ] . c o n t a i n s ( t a g ) ) {  
 	 	 	 i f   ( w i n d o w . i e ) {  
 	 	 	 	 i f   ( t a g   = =   ' s t y l e ' )   r e t u r n   t h i s . s t y l e S h e e t . c s s T e x t ;  
 	 	 	 	 e l s e   i f   ( t a g   = =     ' s c r i p t ' )   r e t u r n   t h i s . g e t P r o p e r t y ( ' t e x t ' ) ;  
 	 	 	 }   e l s e   {  
 	 	 	 	 r e t u r n   t h i s . i n n e r H T M L ;  
 	 	 	 }  
 	 	 }  
 	 	 r e t u r n   ( $ p i c k ( t h i s . i n n e r T e x t ,   t h i s . t e x t C o n t e n t ) ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t T a g  
 	 	 R e t u r n s   t h e   t a g N a m e   o f   t h e   e l e m e n t   i n   l o w e r   c a s e .  
  
 	 E x a m p l e :  
 	 	 > $ ( ' m y I m a g e ' ) . g e t T a g ( )   / /   r e t u r n s   ' i m g '  
  
 	 R e t u r n s :  
 	 	 T h e   t a g   n a m e   i n   l o w e r   c a s e  
 	 * /  
  
 	 g e t T a g :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s . t a g N a m e . t o L o w e r C a s e ( ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   e m p t y  
 	 	 E m p t i e s   a n   e l e m e n t   o f   a l l   i t s   c h i l d r e n .  
  
 	 E x a m p l e :  
 	 	 > $ ( ' m y D i v ' ) . e m p t y ( )   / /   e m p t i e s   t h e   D i v   a n d   r e t u r n s   i t  
  
 	 R e t u r n s :  
 	 	 T h e   e l e m e n t .  
 	 * /  
  
 	 e m p t y :   f u n c t i o n ( ) {  
 	 	 G a r b a g e . t r a s h ( t h i s . g e t E l e m e n t s B y T a g N a m e ( ' * ' ) ) ;  
 	 	 r e t u r n   t h i s . s e t H T M L ( ' ' ) ;  
 	 }  
  
 } ) ;  
  
 E l e m e n t . f i x S t y l e   =   f u n c t i o n ( p r o p e r t y ,   r e s u l t ,   e l e m e n t ) {  
 	 i f   ( $ c h k ( p a r s e I n t ( r e s u l t ) ) )   r e t u r n   r e s u l t ;  
 	 i f   ( [ ' h e i g h t ' ,   ' w i d t h ' ] . c o n t a i n s ( p r o p e r t y ) ) {  
 	 	 v a r   v a l u e s   =   ( p r o p e r t y   = =   ' w i d t h ' )   ?   [ ' l e f t ' ,   ' r i g h t ' ]   :   [ ' t o p ' ,   ' b o t t o m ' ] ;  
 	 	 v a r   s i z e   =   0 ;  
 	 	 v a l u e s . e a c h ( f u n c t i o n ( v a l u e ) {  
 	 	 	 s i z e   + =   e l e m e n t . g e t S t y l e ( ' b o r d e r - '   +   v a l u e   +   ' - w i d t h ' ) . t o I n t ( )   +   e l e m e n t . g e t S t y l e ( ' p a d d i n g - '   +   v a l u e ) . t o I n t ( ) ;  
 	 	 } ) ;  
 	 	 r e t u r n   e l e m e n t [ ' o f f s e t '   +   p r o p e r t y . c a p i t a l i z e ( ) ]   -   s i z e   +   ' p x ' ;  
 	 }   e l s e   i f   ( p r o p e r t y . t e s t ( / b o r d e r ( . + ) W i d t h | m a r g i n | p a d d i n g / ) ) {  
 	 	 r e t u r n   ' 0 p x ' ;  
 	 }  
 	 r e t u r n   r e s u l t ;  
 } ;  
  
 E l e m e n t . S t y l e s   =   { ' b o r d e r ' :   [ ] ,   ' p a d d i n g ' :   [ ] ,   ' m a r g i n ' :   [ ] } ;  
 [ ' T o p ' ,   ' R i g h t ' ,   ' B o t t o m ' ,   ' L e f t ' ] . e a c h ( f u n c t i o n ( d i r e c t i o n ) {  
 	 f o r   ( v a r   s t y l e   i n   E l e m e n t . S t y l e s )   E l e m e n t . S t y l e s [ s t y l e ] . p u s h ( s t y l e   +   d i r e c t i o n ) ;  
 } ) ;  
  
 E l e m e n t . b o r d e r S h o r t   =   [ ' b o r d e r W i d t h ' ,   ' b o r d e r S t y l e ' ,   ' b o r d e r C o l o r ' ] ;  
  
 E l e m e n t . g e t M a n y   =   f u n c t i o n ( e l ,   m e t h o d ,   k e y s ) {  
 	 v a r   r e s u l t   =   { } ;  
 	 $ e a c h ( k e y s ,   f u n c t i o n ( k e y ) {  
 	 	 r e s u l t [ k e y ]   =   e l [ m e t h o d ] ( k e y ) ;  
 	 } ) ;  
 	 r e t u r n   r e s u l t ;  
 } ;  
  
 E l e m e n t . s e t M a n y   =   f u n c t i o n ( e l ,   m e t h o d ,   p a i r s ) {  
 	 f o r   ( v a r   k e y   i n   p a i r s )   e l [ m e t h o d ] ( k e y ,   p a i r s [ k e y ] ) ;  
 	 r e t u r n   e l ;  
 } ;  
  
 E l e m e n t . P r o p e r t i e s   =   n e w   A b s t r a c t ( {  
 	 ' c l a s s ' :   ' c l a s s N a m e ' ,   ' f o r ' :   ' h t m l F o r ' ,   ' c o l s p a n ' :   ' c o l S p a n ' ,   ' r o w s p a n ' :   ' r o w S p a n ' ,  
 	 ' a c c e s s k e y ' :   ' a c c e s s K e y ' ,   ' t a b i n d e x ' :   ' t a b I n d e x ' ,   ' m a x l e n g t h ' :   ' m a x L e n g t h ' ,  
 	 ' r e a d o n l y ' :   ' r e a d O n l y ' ,   ' f r a m e b o r d e r ' :   ' f r a m e B o r d e r ' ,   ' 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 ' ,   ' m u l t i p l e ' :   ' m u l t i p l e ' ,   ' s e l e c t e d ' :   ' s e l e c t e d '  
 } ) ;  
 E l e m e n t . P r o p e r t i e s I F l a g   =   {  
 	 ' h r e f ' :   2 ,   ' s r c ' :   2  
 } ;  
  
 E l e m e n t . M e t h o d s   =   {  
 	 L i s t e n e r s :   {  
 	 	 a d d L i s t e n e r :   f u n c t i o n ( t y p e ,   f n ) {  
 	 	 	 i f   ( t h i s . a d d E v e n t L i s t e n e r )   t h i s . a d d E v e n t L i s t e n e r ( t y p e ,   f n ,   f a l s e ) ;  
 	 	 	 e l s e   t h i s . a t t a c h E v e n t ( ' o n '   +   t y p e ,   f n ) ;  
 	 	 	 r e t u r n   t h i s ;  
 	 	 } ,  
  
 	 	 r e m o v e L i s t e n e r :   f u n c t i o n ( t y p e ,   f n ) {  
 	 	 	 i f   ( t h i s . r e m o v e E v e n t L i s t e n e r )   t h i s . r e m o v e E v e n t L i s t e n e r ( t y p e ,   f n ,   f a l s e ) ;  
 	 	 	 e l s e   t h i s . d e t a c h E v e n t ( ' o n '   +   t y p e ,   f n ) ;  
 	 	 	 r e t u r n   t h i s ;  
 	 	 }  
 	 }  
 } ;  
  
 w i n d o w . e x t e n d ( E l e m e n t . M e t h o d s . L i s t e n e r s ) ;  
 d o c u m e n t . e x t e n d ( E l e m e n t . M e t h o d s . L i s t e n e r s ) ;  
 E l e m e n t . e x t e n d ( E l e m e n t . M e t h o d s . L i s t e n e r s ) ;  
  
 v a r   G a r b a g e   =   {  
  
 	 e l e m e n t s :   [ ] ,  
  
 	 c o l l e c t :   f u n c t i o n ( e l ) {  
 	 	 i f   ( ! e l . $ t m p ) {  
 	 	 	 G a r b a g e . e l e m e n t s . p u s h ( e l ) ;  
 	 	 	 e l . $ t m p   =   { ' o p a c i t y ' :   1 } ;  
 	 	 }  
 	 	 r e t u r n   e l ;  
 	 } ,  
  
 	 t r a s h :   f u n c t i o n ( e l e m e n t s ) {  
 	 	 f o r   ( v a r   i   =   0 ,   j   =   e l e m e n t s . l e n g t h ,   e l ;   i   <   j ;   i + + ) {  
 	 	 	 t r y  
 	 	 	 {  
 	 	 	 	 i f   ( ! ( e l   =   e l e m e n t s [ i ] )   | |   ! e l . $ t m p )   c o n t i n u e ;  
 	 	 	 	 i f   ( e l . $ e v e n t s )   e l . f i r e E v e n t ( ' t r a s h ' ) . r e m o v e E v e n t s ( ) ;  
 	 	 	 	 f o r   ( v a r   p   i n   e l . $ t m p )   e l . $ t m p [ p ]   =   n u l l ;  
 	 	 	 	 f o r   ( v a r   d   i n   E l e m e n t . p r o t o t y p e )   e l [ d ]   =   n u l l ;  
 	 	 	 	 G a r b a g e . e l e m e n t s [ G a r b a g e . e l e m e n t s . i n d e x O f ( e l ) ]   =   n u l l ;  
 	 	 	 	 e l . h t m l E l e m e n t   =   e l . $ t m p   =   e l   =   n u l l ;  
 	 	 	 }  
 	 	 	 c a t c h ( e ) { }  
 	 	 }  
 	 	 G a r b a g e . e l e m e n t s . r e m o v e ( n u l l ) ;  
 	 } ,  
  
 	 e m p t y :   f u n c t i o n ( ) {  
 	 	 G a r b a g e . c o l l e c t ( w i n d o w ) ;  
 	 	 G a r b a g e . c o l l e c t ( d o c u m e n t ) ;  
 	 	 G a r b a g e . t r a s h ( G a r b a g e . e l e m e n t s ) ;  
 	 }  
  
 } ;  
  
 w i n d o w . a d d L i s t e n e r ( ' b e f o r e u n l o a d ' ,   f u n c t i o n ( ) {  
 	 w i n d o w . a d d L i s t e n e r ( ' u n l o a d ' ,   G a r b a g e . e m p t y ) ;  
 	 i f   ( w i n d o w . i e )   w i n d o w . a d d L i s t e n e r ( ' u n l o a d ' ,   C o l l e c t G a r b a g e ) ;  
 } ) ;  
  
 / *  
 S c r i p t :   E l e m e n t . E v e n t . j s  
 	 C o n t a i n s   t h e   E v e n t   C l a s s ,   E l e m e n t   m e t h o d s   t o   d e a l   w i t h   E l e m e n t   e v e n t s ,   c u s t o m   E v e n t s ,   a n d   t h e   F u n c t i o n   p r o t o t y p e   b i n d W i t h E v e n t .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   E v e n t  
 	 C r o s s   b r o w s e r   m e t h o d s   t o   m a n a g e   e v e n t s .  
  
 A r g u m e n t s :  
 	 e v e n t   -   t h e   e v e n t  
  
 P r o p e r t i e s :  
 	 s h i f t   -   t r u e   i f   t h e   u s e r   p r e s s e d   t h e   s h i f t  
 	 c o n t r o l   -   t r u e   i f   t h e   u s e r   p r e s s e d   t h e   c o n t r o l  
 	 a l t   -   t r u e   i f   t h e   u s e r   p r e s s e d   t h e   a l t  
 	 m e t a   -   t r u e   i f   t h e   u s e r   p r e s s e d   t h e   m e t a   k e y  
 	 w h e e l   -   t h e   a m o u n t   o f   t h i r d   b u t t o n   s c r o l l i n g  
 	 c o d e   -   t h e   k e y c o d e   o f   t h e   k e y   p r e s s e d  
 	 p a g e . x   -   t h e   x   p o s i t i o n   o f   t h e   m o u s e ,   r e l a t i v e   t o   t h e   f u l l   w i n d o w  
 	 p a g e . y   -   t h e   y   p o s i t i o n   o f   t h e   m o u s e ,   r e l a t i v e   t o   t h e   f u l l   w i n d o w  
 	 c l i e n t . x   -   t h e   x   p o s i t i o n   o f   t h e   m o u s e ,   r e l a t i v e   t o   t h e   v i e w p o r t  
 	 c l i e n t . y   -   t h e   y   p o s i t i o n   o f   t h e   m o u s e ,   r e l a t i v e   t o   t h e   v i e w p o r t  
 	 k e y   -   t h e   k e y   p r e s s e d   a s   a   l o w e r c a s e   s t r i n g .   k e y   a l s o   r e t u r n s   ' e n t e r ' ,   ' u p ' ,   ' d o w n ' ,   ' l e f t ' ,   ' r i g h t ' ,   ' s p a c e ' ,   ' b a c k s p a c e ' ,   ' d e l e t e ' ,   ' e s c ' .   H a n d y   f o r   t h e s e   s p e c i a l   k e y s .  
 	 t a r g e t   -   t h e   e v e n t   t a r g e t  
 	 r e l a t e d T a r g e t   -   t h e   e v e n t   r e l a t e d   t a r g e t  
  
 E x a m p l e :  
 	 ( s t a r t   c o d e )  
 	 $ ( ' m y L i n k ' ) . o n k e y d o w n   =   f u n c t i o n ( e v e n t ) {  
 	 	 v a r   e v e n t   =   n e w   E v e n t ( e v e n t ) ;  
 	 	 / / e v e n t   i s   n o w   t h e   E v e n t   c l a s s .  
 	 	 a l e r t ( e v e n t . k e y ) ;   / / r e t u r n s   t h e   l o w e r c a s e   l e t t e r   p r e s s e d  
 	 	 a l e r t ( e v e n t . s h i f t ) ;   / / r e t u r n s   t r u e   i f   t h e   k e y   p r e s s e d   i s   s h i f t  
 	 	 i f   ( e v e n t . k e y   = =   ' s '   & &   e v e n t . c o n t r o l )   a l e r t ( ' d o c u m e n t   s a v e d ' ) ;  
 	 } ;  
 	 ( e n d )  
 * /  
  
 v a r   E v e n t   =   n e w   C l a s s ( {  
  
 	 i n i t i a l i z e :   f u n c t i o n ( e v e n t ) {  
 	 	 i f   ( e v e n t   & &   e v e n t . $ e x t e n d e d )   r e t u r n   e v e n t ;  
 	 	 t h i s . $ e x t e n d e d   =   t r u e ;  
 	 	 e v e n t   =   e v e n t   | |   w i n d o w . e v e n t ;  
 	 	 t h i s . e v e n t   =   e v e n t ;  
 	 	 t h i s . t y p e   =   e v e n t . t y p e ;  
 	 	 t h i s . t a r g e 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 ;  
 	 	 i f   ( t h i s . t a r g e t . n o d e T y p e   = =   3 )   t h i s . t a r g e t   =   t h i s . t a r g e t . p a r e n t N o d e ;  
 	 	 t h i s . s h i f t   =   e v e n t . s h i f t K e y ;  
 	 	 t h i s . c o n t r o l   =   e v e n t . c t r l K e y ;  
 	 	 t h i s . a l t   =   e v e n t . a l t K e y ;  
 	 	 t h i s . m e t a   =   e v e n t . m e t a K e y ;  
 	 	 i f   ( [ ' D O M M o u s e S c r o l l ' ,   ' m o u s e w h e e l ' ] . c o n t a i n s ( t h i s . t y p e ) ) {  
 	 	 	 t h i s . w h e e l   =   ( e v e n t . w h e e l D e l t a )   ?   e v e n t . w h e e l D e l t a   /   1 2 0   :   - ( e v e n t . d e t a i l   | |   0 )   /   3 ;  
 	 	 }   e l s e   i f   ( t h i s . t y p e . c o n t a i n s ( ' k e y ' ) ) {  
 	 	 	 t h i s . c o d e   =   e v e n t . w h i c h   | |   e v e n t . k e y C o d e ;  
 	 	 	 f o r   ( v a r   n a m e   i n   E v e n t . k e y s ) {  
 	 	 	 	 i f   ( E v e n t . k e y s [ n a m e ]   = =   t h i s . c o d e ) {  
 	 	 	 	 	 t h i s . k e y   =   n a m e ;  
 	 	 	 	 	 b r e a k ;  
 	 	 	 	 }  
 	 	 	 }  
 	 	 	 i f   ( t h i s . t y p e   = =   ' k e y d o w n ' ) {  
 	 	 	 	 v a r   f K e y   =   t h i s . c o d e   -   1 1 1 ;  
 	 	 	 	 i f   ( f K e y   >   0   & &   f K e y   <   1 3 )   t h i s . k e y   =   ' f '   +   f K e y ;  
 	 	 	 }  
 	 	 	 t h i s . k e y   =   t h i s . k e y   | |   S t r i n g . f r o m C h a r C o d e ( t h i s . c o d e ) . t o L o w e r C a s e ( ) ;  
 	 	 }   e l s e   i f   ( t h i s . t y p e . t e s t ( / ( c l i c k | m o u s e | m e n u ) / ) ) {  
 	 	 	 t h i s . p a g e   =   {  
 	 	 	 	 ' x ' :   e v e n t . p a g e X   | |   e v e n t . c l i e n t X   +   d o c u m e n t . d o c u m e n t E l e m e n t . s c r o l l L e f t ,  
 	 	 	 	 ' y ' :   e v e n t . p a g e Y   | |   e v e n t . c l i e n t Y   +   d o c u m e n t . d o c u m e n t E l e m e n t . s c r o l l T o p  
 	 	 	 } ;  
 	 	 	 t h i s . c l i e n t   =   {  
 	 	 	 	 ' x ' :   e v e n t . p a g e X   ?   e v e n t . p a g e X   -   w i n d o w . p a g e X O f f s e t   :   e v e n t . c l i e n t X ,  
 	 	 	 	 ' y ' :   e v e n t . p a g e Y   ?   e v e n t . p a g e Y   -   w i n d o w . p a g e Y O f f s e t   :   e v e n t . c l i e n t Y  
 	 	 	 } ;  
 	 	 	 t h i s . r i g h t C l i c k   =   ( e v e n t . w h i c h   = =   3 )   | |   ( e v e n t . b u t t o n   = =   2 ) ;  
 	 	 	 s w i t c h ( t h i s . t y p e ) {  
 	 	 	 	 c a s e   ' m o u s e o v e r ' :   t h i s . r e l a t e d T a r g e t   =   e v e n t . r e l a t e d T a r g e t   | |   e v e n t . f r o m E l e m e n t ;   b r e a k ;  
 	 	 	 	 c a s e   ' m o u s e o u t ' :   t h i s . r e l a t e d T a r g e t   =   e v e n t . r e l a t e d T a r g e t   | |   e v e n t . t o E l e m e n t ;  
 	 	 	 }  
 	 	 	 t h i s . f i x R e l a t e d T a r g e t ( ) ;  
 	 	 }  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s t o p  
 	 	 c r o s s   b r o w s e r   m e t h o d   t o   s t o p   a n   e v e n t  
 	 * /  
  
 	 s t o p :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s . s t o p P r o p a g a t i o n ( ) . p r e v e n t D e f a u l t ( ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s t o p P r o p a g a t i o n  
 	 	 c r o s s   b r o w s e r   m e t h o d   t o   s t o p   t h e   p r o p a g a t i o n   o f   a n   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   ( t h i s . e v e n t . s t o p P r o p a g a t i o n )   t h i s . e v e n t . s t o p P r o p a g a t i o n ( ) ;  
 	 	 e l s e   t h i s . e v e n t . c a n c e l B u b b l e   =   t r u e ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   p r e v e n t D e f a u l t  
 	 	 c r o s s   b r o w s e r   m e t h o d   t o   p r e v e n t   t h e   d e f a u l t   a c t i o n   o f   t h 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   ( t h i s . e v e n t . p r e v e n t D e f a u l t )   t h i s . e v e n t . p r e v e n t D e f a u l t ( ) ;  
 	 	 e l s e   t h i s . e v e n t . r e t u r n V a l u e   =   f a l s e ;  
 	 	 r e t u r n   t h i s ;  
 	 }  
  
 } ) ;  
  
 E v e n t . f i x   =   {  
  
 	 r e l a t e d T a r g e t :   f u n c t i o n ( ) {  
 	 	 i f   ( t h i s . r e l a t e d T a r g e t   & &   t h i s . r e l a t e d T a r g e t . n o d e T y p e   = =   3 )   t h i s . r e l a t e d T a r g e t   =   t h i s . r e l a t e d T a r g e t . p a r e n t N o d e ;  
 	 } ,  
  
 	 r e l a t e d T a r g e t G e c k o :   f u n c t i o n ( ) {  
 	 	 t r y   { E v e n t . f i x . r e l a t e d T a r g e t . c a l l ( t h i s ) ; }   c a t c h ( e ) { t h i s . r e l a t e d T a r g e t   =   t h i s . t a r g e t ; }  
 	 }  
  
 } ;  
  
 E v e n t . p r o t o t y p e . f i x R e l a t e d T a r g e t   =   ( w i n d o w . g e c k o )   ?   E v e n t . f i x . r e l a t e d T a r g e t G e c k o   :   E v e n t . f i x . r e l a t e d T a r g e t ;  
  
 / *  
 P r o p e r t y :   k e y s  
 	 y o u   c a n   a d d   a d d i t i o n a l   E v e n t   k e y s   c o d e s   t h i s   w a y :  
  
 E x a m p l e :  
 	 ( s t a r t   c o d e )  
 	 E v e n t . k e y s . w h a t e v e r   =   8 0 ;  
 	 $ ( m y e l e m e n t ) . a d d E v e n t ( k e y d o w n ,   f u n c t i o n ( e v e n t ) {  
 	 	 e v e n t   =   n e w   E v e n t ( e v e n t ) ;  
 	 	 i f   ( e v e n t . k e y   = =   ' w h a t e v e r ' )   c o n s o l e . l o g ( w h a t e v e r   k e y   c l i c k e d ) .  
 	 } ) ;  
 	 ( e n d )  
 * /  
  
 E v e n t . k e y s   =   n e w   A b s t r a c t ( {  
 	 ' e n t e r ' :   1 3 ,  
 	 ' u p ' :   3 8 ,  
 	 ' d o w n ' :   4 0 ,  
 	 ' l e f t ' :   3 7 ,  
 	 ' r i g h t ' :   3 9 ,  
 	 ' e s c ' :   2 7 ,  
 	 ' s p a c e ' :   3 2 ,  
 	 ' b a c k s p a c e ' :   8 ,  
 	 ' t a b ' :   9 ,  
 	 ' d e l e t e ' :   4 6  
 } ) ;  
  
 / *  
 C l a s s :   E l e m e n t  
 	 C u s t o m   c l a s s   t o   a l l o w   a l l   o f   i t s   m e t h o d s   t o   b e   u s e d   w i t h   a n y   D O M   e l e m e n t   v i a   t h e   d o l l a r   f u n c t i o n   < $ > .  
 * /  
  
 E l e m e n t . M e t h o d s . E v e n t s   =   {  
  
 	 / *  
 	 P r o p e r t y :   a d d E v e n t  
 	 	 A t t a c h e s   a n   e v e n t   l i s t e n e r   t o   a   D O M   e l e m e n t .  
  
 	 A r g u m e n t s :  
 	 	 t y p e   -   t h e   e v e n t   t o   m o n i t o r   ( ' c l i c k ' ,   ' l o a d ' ,   e t c )   w i t h o u t   t h e   p r e f i x   ' o n ' .  
 	 	 f n   -   t h e   f u n c t i o n   t o   e x e c u t e  
  
 	 E x a m p l e :  
 	 	 > $ ( ' m y E l e m e n t ' ) . a d d E v e n t ( ' c l i c k ' ,   f u n c t i o n ( ) { a l e r t ( ' c l i c k e d ! ' ) } ) ;  
 	 * /  
  
 	 a d d E v e n t :   f u n c t i o n ( t y p e ,   f n ) {  
 	 	 t h i s . $ e v e n t s   =   t h i s . $ e v e n t s   | |   { } ;  
 	 	 t h i s . $ e v e n t s [ t y p e ]   =   t h i s . $ e v e n t s [ t y p e ]   | |   { ' k e y s ' :   [ ] ,   ' v a l u e s ' :   [ ] } ;  
 	 	 i f   ( t h i s . $ e v e n t s [ t y p e ] . k e y s . c o n t a i n s ( f n ) )   r e t u r n   t h i s ;  
 	 	 t h i s . $ e v e n t s [ t y p e ] . k e y s . p u s h ( f n ) ;  
 	 	 v a r   r e a l T y p e   =   t y p e ;  
 	 	 v a r   c u s t o m   =   E l e m e n t . E v e n t s [ t y p e ] ;  
 	 	 i f   ( c u s t o m ) {  
 	 	 	 i f   ( c u s t o m . a d d )   c u s t o m . a d d . c a l l ( t h i s ,   f n ) ;  
 	 	 	 i f   ( c u s t o m . m a p )   f n   =   c u s t o m . m a p ;  
 	 	 	 i f   ( c u s t o m . t y p e )   r e a l T y p e   =   c u s t o m . t y p e ;  
 	 	 }  
 	 	 i f   ( ! t h i s . a d d E v e n t L i s t e n e r )   f n   =   f n . c r e a t e ( { ' b i n d ' :   t h i s ,   ' e v e n t ' :   t r u e } ) ;  
 	 	 t h i s . $ e v e n t s [ t y p e ] . v a l u e s . p u s h ( f n ) ;  
 	 	 r e t u r n   ( E l e m e n t . N a t i v e E v e n t s . c o n t a i n s ( r e a l T y p e ) )   ?   t h i s . a d d L i s t e n e r ( r e a l T y p e ,   f n )   :   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   r e m o v e E v e n t  
 	 	 W o r k s   a s   E l e m e n t . a d d E v e n t ,   b u t   i n s t e a d   r e m o v e s   t h e   p r e v i o u s l y   a d d e d   e v e n t   l i s t e n e r .  
 	 * /  
  
 	 r e m o v e E v e n t :   f u n c t i o n ( t y p e ,   f n ) {  
 	 	 i f   ( ! t h i s . $ e v e n t s   | |   ! t h i s . $ e v e n t s [ t y p e ] )   r e t u r n   t h i s ;  
 	 	 v a r   p o s   =   t h i s . $ e v e n t s [ t y p e ] . k e y s . i n d e x O f ( f n ) ;  
 	 	 i f   ( p o s   = =   - 1 )   r e t u r n   t h i s ;  
 	 	 v a r   k e y   =   t h i s . $ e v e n t s [ t y p e ] . k e y s . s p l i c e ( p o s , 1 ) [ 0 ] ;  
 	 	 v a r   v a l u e   =   t h i s . $ e v e n t s [ t y p e ] . v a l u e s . s p l i c e ( p o s , 1 ) [ 0 ] ;  
 	 	 v a r   c u s t o m   =   E l e m e n t . E v e n t s [ t y p e ] ;  
 	 	 i f   ( c u s t o m ) {  
 	 	 	 i f   ( c u s t o m . r e m o v e )   c u s t o m . r e m o v e . c a l l ( t h i s ,   f n ) ;  
 	 	 	 i f   ( c u s t o m . t y p e )   t y p e   =   c u s t o m . t y p e ;  
 	 	 }  
 	 	 r e t u r n   ( E l e m e n t . N a t i v e E v e n t s . c o n t a i n s ( t y p e ) )   ?   t h i s . r e m o v e L i s t e n e r ( t y p e ,   v a l u e )   :   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   a d d E v e n t s  
 	 	 A s   < a d d E v e n t > ,   b u t   a c c e p t s   a n   o b j e c t   a n d   a d d   m u l t i p l e   e v e n t s   a t   o n c e .  
 	 * /  
  
 	 a d d E v e n t s :   f u n c t i o n ( s o u r c e ) {  
 	 	 r e t u r n   E l e m e n t . s e t M a n y ( t h i s ,   ' a d d E v e n t ' ,   s o u r c e ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   r e m o v e E v e n t s  
 	 	 r e m o v e s   a l l   e v e n t s   o f   a   c e r t a i n   t y p e   f r o m   a n   e l e m e n t .   i f   n o   a r g u m e n t   i s   p a s s e d   i n ,   r e m o v e s   a l l   e v e n t s .  
  
 	 A r g u m e n t s :  
 	 	 t y p e   -   s t r i n g ;   t h e   e v e n t   n a m e   ( e . g .   ' c l i c k ' )  
 	 * /  
  
 	 r e m o v e E v e n t s :   f u n c t i o n ( t y p e ) {  
 	 	 i f   ( ! t h i s . $ e v e n t s )   r e t u r n   t h i s ;  
 	 	 i f   ( ! t y p e ) {  
 	 	 	 f o r   ( v a r   e v T y p e   i n   t h i s . $ e v e n t s )   t h i s . r e m o v e E v e n t s ( e v T y p e ) ;  
 	 	 	 t h i s . $ e v e n t s   =   n u l l ;  
 	 	 }   e l s e   i f   ( t h i s . $ e v e n t s [ t y p e ] ) {  
 	 	 	 t h i s . $ e v e n t s [ t y p e ] . k e y s . e a c h ( f u n c t i o n ( f n ) {  
 	 	 	 	 t h i s . r e m o v e E v e n t ( t y p e ,   f n ) ;  
 	 	 	 } ,   t h i s ) ;  
 	 	 	 t h i s . $ e v e n t s [ t y p e ]   =   n u l l ;  
 	 	 }  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   f i r e E v e n t  
 	 	 e x e c u t e s   a l l   e v e n t s   o f   t h e   s p e c i f i e d   t y p e   p r e s e n t   i n   t h e   e l e m e n t .  
  
 	 A r g u m e n t s :  
 	 	 t y p e   -   s t r i n g ;   t h e   e v e n t   n a m e   ( e . g .   ' c l i c k ' )  
 	 	 a r g s   -   a r r a y   o r   s i n g l e   o b j e c t ;   a r g u m e n t s   t o   p a s s   t o   t h e   f u n c t i o n ;   i f   m o r e   t h a n   o n e   a r g u m e n t ,   m u s t   b e   a n   a r r a y  
 	 	 d e l a y   -   ( i n t e g e r )   d e l a y   ( i n   m s )   t o   w a i t   t o   e x e c u t e   t h e   e v e n t  
 	 * /  
  
 	 f i r e E v e n t :   f u n c t i o n ( t y p e ,   a r g s ,   d e l a y ) {  
 	 	 i f   ( t h i s . $ e v e n t s   & &   t h i s . $ e v e n t s [ t y p e ] ) {  
 	 	 	 t h i s . $ e v e n t s [ t y p e ] . k e y s . e a c h ( f u n c t i o n ( f n ) {  
 	 	 	 	 f n . c r e a t e ( { ' b i n d ' :   t h i s ,   ' d e l a y ' :   d e l a y ,   ' a r g u m e n t s ' :   a r g s } ) ( ) ;  
 	 	 	 } ,   t h i s ) ;  
 	 	 }  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   c l o n e E v e n t s  
 	 	 C l o n e s   a l l   e v e n t s   f r o m   a n   e l e m e n t   t o   t h i s   e l e m e n t .  
  
 	 A r g u m e n t s :  
 	 	 f r o m   -   e l e m e n t ,   c o p y   a l l   e v e n t s   f r o m   t h i s   e l e m e n t  
 	 	 t y p e   -   o p t i o n a l ,   c o p i e s   o n l y   e v e n t s   o f   t h i s   t y p e  
 	 * /  
  
 	 c l o n e E v e n t s :   f u n c t i o n ( f r o m ,   t y p e ) {  
 	 	 i f   ( ! f r o m . $ e v e n t s )   r e t u r n   t h i s ;  
 	 	 i f   ( ! t y p e ) {  
 	 	 	 f o r   ( v a r   e v T y p e   i n   f r o m . $ e v e n t s )   t h i s . c l o n e E v e n t s ( f r o m ,   e v T y p e ) ;  
 	 	 }   e l s e   i f   ( f r o m . $ e v e n t s [ t y p e ] ) {  
 	 	 	 f r o m . $ e v e n t s [ t y p e ] . k e y s . e a c h ( f u n c t i o n ( f n ) {  
 	 	 	 	 t h i s . a d d E v e n t ( t y p e ,   f n ) ;  
 	 	 	 } ,   t h i s ) ;  
 	 	 }  
 	 	 r e t u r n   t h i s ;  
 	 }  
  
 } ;  
  
 w i n d o w . e x t e n d ( E l e m e n t . M e t h o d s . E v e n t s ) ;  
 d o c u m e n t . e x t e n d ( E l e m e n t . M e t h o d s . E v e n t s ) ;  
 E l e m e n t . e x t e n d ( E l e m e n t . M e t h o d s . E v e n t s ) ;  
  
 / *   S e c t i o n :   C u s t o m   E v e n t s   * /  
  
 E l e m e n t . E v e n t s   =   n e w   A b s t r a c t ( {  
  
 	 / *  
 	 E v e n t :   m o u s e e n t e r  
 	 	 I n   a d d i t i o n   t o   t h e   s t a n d a r d   j a v a s c r i p t   e v e n t s   ( l o a d ,   m o u s e o v e r ,   m o u s e o u t ,   c l i c k ,   e t c . )   < E v e n t . j s >   c o n t a i n s   t w o   c u s t o m   e v e n t s  
 	 	 t h i s   e v e n t   f i r e s   w h e n   t h e   m o u s e   e n t e r s   t h e   a r e a   o f   t h e   d o m   e l e m e n t ;   w i l l   n o t   b e   f i r e d   a g a i n   i f   t h e   m o u s e   c r o s s e s   o v e r   c h i l d r e n   o f   t h e   e l e m e n t   ( u n l i k e   m o u s e o v e r )  
  
  
 	 E x a m p l e :  
 	 	 > $ ( m y E l e m e n t ) . a d d E v e n t ( ' m o u s e e n t e r ' ,   m y F u n c t i o n ) ;  
 	 * /  
  
 	 ' m o u s e e n t e r ' :   {  
 	 	 t y p e :   ' m o u s e o v e r ' ,  
 	 	 m a p :   f u n c t i o n ( e v e n t ) {  
 	 	 	 e v e n t   =   n e w   E v e n t ( e v e n t ) ;  
 	 	 	 i f   ( e v e n t . r e l a t e d T a r g e t   ! =   t h i s   & &   ! t h i s . h a s C h i l d ( e v e n t . r e l a t e d T a r g e t ) )   t h i s . f i r e E v e n t ( ' m o u s e e n t e r ' ,   e v e n t ) ;  
 	 	 }  
 	 } ,  
  
 	 / *  
 	 E v e n t :   m o u s e l e a v e  
 	 	 t h i s   e v e n t   f i r e s   w h e n   t h e   m o u s e   e x i t s   t h e   a r e a   o f   t h e   d o m   e l e m e n t ;   w i l l   n o t   b e   f i r e d   a g a i n   i f   t h e   m o u s e   c r o s s e s   o v e r   c h i l d r e n   o f   t h e   e l e m e n t   ( u n l i k e   m o u s e o u t )  
  
  
 	 E x a m p l e :  
 	 	 > $ ( m y E l e m e n t ) . a d d E v e n t ( ' m o u s e l e a v e ' ,   m y F u n c t i o n ) ;  
 	 * /  
  
 	 ' m o u s e l e a v e ' :   {  
 	 	 t y p e :   ' m o u s e o u t ' ,  
 	 	 m a p :   f u n c t i o n ( e v e n t ) {  
 	 	 	 e v e n t   =   n e w   E v e n t ( e v e n t ) ;  
 	 	 	 i f   ( e v e n t . r e l a t e d T a r g e t   ! =   t h i s   & &   ! t h i s . h a s C h i l d ( e v e n t . r e l a t e d T a r g e t ) )   t h i s . f i r e E v e n t ( ' m o u s e l e a v e ' ,   e v e n t ) ;  
 	 	 }  
 	 } ,  
  
 	 ' m o u s e w h e e l ' :   {  
 	 	 t y p e :   ( w i n d o w . g e c k o )   ?   ' D O M M o u s e S c r o l l '   :   ' m o u s e w h e e l '  
 	 }  
  
 } ) ;  
  
 E l e m e n t . N a t i v e E v e n t s   =   [  
 	 ' c l i c k ' ,   ' d b l c l i c k ' ,   ' m o u s e u p ' ,   ' m o u s e d o w n ' ,   / / m o u s e   b u t t o n s  
 	 ' m o u s e w h e e l ' ,   ' D O M M o u s e S c r o l l ' ,   / / m o u s e   w h e e l  
 	 ' m o u s e o v e r ' ,   ' m o u s e o u t ' ,   ' m o u s e m o v e ' ,   / / m o u s e   m o v e m e n t  
 	 ' k e y d o w n ' ,   ' k e y p r e s s ' ,   ' k e y u p ' ,   / / k e y s  
 	 ' l o a d ' ,   ' u n l o a d ' ,   ' b e f o r e u n l o a d ' ,   ' r e s i z e ' ,   ' m o v e ' ,   / / w i n d o w  
 	 ' f o c u s ' ,   ' b l u r ' ,   ' c h a n g e ' ,   ' s u b m i t ' ,   ' r e s e t ' ,   ' s e l e c t ' ,   / / f o r m s   e l e m e n t s  
 	 ' e r r o r ' ,   ' a b o r t ' ,   ' c o n t e x t m e n u ' ,   ' s c r o l l '   / / m i s c  
 ] ;  
  
 / *  
 C l a s s :   F u n c t i o n  
 	 A   c o l l e c t i o n   o f   T h e   F u n c t i o n   O b j e c t   p r o t o t y p e   m e t h o d s .  
 * /  
  
 F u n c t i o n . e x t e n d ( {  
  
 	 / *  
 	 P r o p e r t y :   b i n d W i t h E v e n t  
 	 	 a u t o m a t i c a l l y   p a s s e s   M o o T o o l s   E v e n t   C l a s s .  
  
 	 A r g u m e n t s :  
 	 	 b i n d   -   o p t i o n a l ,   t h e   o b j e c t   t h a t   t h e   " t h i s "   o f   t h e   f u n c t i o n   w i l l   r e f e r   t o .  
 	 	 a r g s   -   o p t i o n a l ,   a n   a r g u m e n t   t o   p a s s   t o   t h e   f u n c t i o n ;   i f   m o r e   t h a n   o n e   a r g u m e n t ,   i t   m u s t   b e   a n   a r r a y   o f   a r g u m e n t s .  
  
 	 R e t u r n s :  
 	 	 a   f u n c t i o n   w i t h   t h e   p a r a m e t e r   b i n d   a s   i t s   " t h i s "   a n d   a s   a   p r e - p a s s e d   a r g u m e n t   e v e n t   o r   w i n d o w . e v e n t ,   d e p e n d i n g   o n   t h e   b r o w s e r .  
  
 	 E x a m p l e :  
 	 	 > f u n c t i o n   m y F u n c t i o n ( e v e n t ) {  
 	 	 > 	 a l e r t ( e v e n t . c l i e n t . x )   / / r e t u r n s   t h e   c o o r d i n a t e s   o f   t h e   m o u s e . .  
 	 	 > } ;  
 	 	 > m y E l e m e n t . a d d E v e n t ( ' c l i c k ' ,   m y F u n c t i o n . b i n d W i t h E v e n t ( m y E l e m e n t ) ) ;  
 	 * /  
  
 	 b i n d W i t h E v e n t :   f u n c t i o n ( b i n d ,   a r g s ) {  
 	 	 r e t u r n   t h i s . c r e a t e ( { ' b i n d ' :   b i n d ,   ' a r g u m e n t s ' :   a r g s ,   ' e v e n t ' :   E v e n t } ) ;  
 	 }  
  
 } ) ;  
  
  
 / *  
 S c r i p t :   E l e m e n t . F i l t e r s . j s  
 	 a d d   F i l t e r s   c a p a b i l i t y   t o   < E l e m e n t s > .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   E l e m e n t s  
 	 A   c o l l e c t i o n   o f   m e t h o d s   t o   b e   u s e d   w i t h   < $ $ >   e l e m e n t s   c o l l e c t i o n s .  
 * /  
  
 E l e m e n t s . e x t e n d ( {  
 	  
 	 / *  
 	 P r o p e r t y :   f i l t e r B y T a g  
 	 	 F i l t e r s   t h e   c o l l e c t i o n   b y   a   s p e c i f i e d   t a g   n a m e .  
 	 	 R e t u r n s   a   n e w   E l e m e n t s   c o l l e c t i o n ,   w h i l e   t h e   o r i g i n a l   r e m a i n s   u n t o u c h e d .  
 	 * /  
 	  
 	 f i l t e r B y T a g :   f u n c t i o n ( t a g ) {  
 	 	 r e t u r n   n e w   E l e m e n t s ( t h i s . f i l t e r ( f u n c t i o n ( e l ) {  
 	 	 	 r e t u r n   ( E l e m e n t . g e t T a g ( e l )   = =   t a g ) ;  
 	 	 } ) ) ;  
 	 } ,  
 	  
 	 / *  
 	 P r o p e r t y :   f i l t e r B y C l a s s  
 	 	 F i l t e r s   t h e   c o l l e c t i o n   b y   a   s p e c i f i e d   c l a s s   n a m e .  
 	 	 R e t u r n s   a   n e w   E l e m e n t s   c o l l e c t i o n ,   w h i l e   t h e   o r i g i n a l   r e m a i n s   u n t o u c h e d .  
 	 * /  
 	  
 	 f i l t e r B y C l a s s :   f u n c t i o n ( c l a s s N a m e ,   n o c a s h ) {  
 	 	 v a r   e l e m e n t s   =   t h i s . f i l t e r ( f u n c t i o n ( e l ) {  
 	 	 	 r e t u r n   ( e l . c l a s s N a m e   & &   e l . c l a s s N a m e . c o n t a i n s ( c l a s s N a m e ,   '   ' ) ) ;  
 	 	 } ) ;  
 	 	 r e t u r n   ( n o c a s h )   ?   e l e m e n t s   :   n e w   E l e m e n t s ( e l e m e n t s ) ;  
 	 } ,  
 	  
 	 / *  
 	 P r o p e r t y :   f i l t e r B y I d  
 	 	 F i l t e r s   t h e   c o l l e c t i o n   b y   a   s p e c i f i e d   I D .  
 	 	 R e t u r n s   a   n e w   E l e m e n t s   c o l l e c t i o n ,   w h i l e   t h e   o r i g i n a l   r e m a i n s   u n t o u c h e d .  
 	 * /  
 	  
 	 f i l t e r B y I d :   f u n c t i o n ( i d ,   n o c a s h ) {  
 	 	 v a r   e l e m e n t s   =   t h i s . f i l t e r ( f u n c t i o n ( e l ) {  
 	 	 	 r e t u r n   ( e l . i d   = =   i d ) ;  
 	 	 } ) ;  
 	 	 r e t u r n   ( n o c a s h )   ?   e l e m e n t s   :   n e w   E l e m e n t s ( e l e m e n t s ) ;  
 	 } ,  
 	  
 	 / *  
 	 P r o p e r t y :   f i l t e r B y A t t r i b u t e  
 	 	 F i l t e r s   t h e   c o l l e c t i o n   b y   a   s p e c i f i e d   a t t r i b u t e .  
 	 	 R e t u r n s   a   n e w   E l e m e n t s   c o l l e c t i o n ,   w h i l e   t h e   o r i g i n a l   r e m a i n s   u n t o u c h e d .  
 	 	  
 	 A r g u m e n t s :  
 	 	 n a m e   -   t h e   a t t r i b u t e   n a m e .  
 	 	 o p e r a t o r   -   o p t i o n a l ,   t h e   a t t r i b u t e   o p e r a t o r .  
 	 	 v a l u e   -   o p t i o n a l ,   t h e   a t t r i b u t e   v a l u e ,   o n l y   v a l i d   i f   t h e   o p e r a t o r   i s   s p e c i f i e d .  
 	 * /  
 	  
 	 f i l t e r B y A t t r i b u t e :   f u n c t i o n ( n a m e ,   o p e r a t o r ,   v a l u e ,   n o c a s h ) {  
 	 	 v a r   e l e m e n t s   =   t h i s . f i l t e r ( f u n c t i o n ( e l ) {  
 	 	 	 v a r   c u r r e n t   =   E l e m e n t . g e t P r o p e r t y ( e l ,   n a m e ) ;  
 	 	 	 i f   ( ! c u r r e n t )   r e t u r n   f a l s e ;  
 	 	 	 i f   ( ! o p e r a t o r )   r e t u r n   t r u e ;  
 	 	 	 s w i t c h ( o p e r a t o r ) {  
 	 	 	 	 c a s e   ' = ' :   r e t u r n   ( c u r r e n t   = =   v a l u e ) ;  
 	 	 	 	 c a s e   ' * = ' :   r e t u r n   ( c u r r e n t . c o n t a i n s ( v a l u e ) ) ;  
 	 	 	 	 c a s e   ' ^ = ' :   r e t u r n   ( c u r r e n t . s u b s t r ( 0 ,   v a l u e . l e n g t h )   = =   v a l u e ) ;  
 	 	 	 	 c a s e   ' $ = ' :   r e t u r n   ( c u r r e n t . s u b s t r ( c u r r e n t . l e n g t h   -   v a l u e . l e n g t h )   = =   v a l u e ) ;  
 	 	 	 	 c a s e   ' ! = ' :   r e t u r n   ( c u r r e n t   ! =   v a l u e ) ;  
 	 	 	 	 c a s e   ' ~ = ' :   r e t u r n   c u r r e n t . c o n t a i n s ( v a l u e ,   '   ' ) ;  
 	 	 	 }  
 	 	 	 r e t u r n   f a l s e ;  
 	 	 } ) ;  
 	 	 r e t u r n   ( n o c a s h )   ?   e l e m e n t s   :   n e w   E l e m e n t s ( e l e m e n t s ) ;  
 	 }  
  
 } ) ;  
  
 / *  
 S c r i p t :   E l e m e n t . S e l e c t o r s . j s  
 	 C s s   Q u e r y   r e l a t e d   f u n c t i o n s   a n d   < E l e m e n t >   e x t e n s i o n s  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *   S e c t i o n :   U t i l i t y   F u n c t i o n s   * /  
  
 / *  
 F u n c t i o n :   $ E  
 	 S e l e c t s   a   s i n g l e   ( i . e .   t h e   f i r s t   f o u n d )   E l e m e n t   b a s e d   o n   t h e   s e l e c t o r   p a s s e d   i n   a n d   a n   o p t i o n a l   f i l t e r   e l e m e n t .  
 	 R e t u r n s   a s   < E l e m e n t > .  
  
 A r g u m e n t s :  
 	 s e l e c t o r   -   s t r i n g ;   t h e   c s s   s e l e c t o r   t o   m a t c h  
 	 f i l t e r   -   o p t i o n a l ;   a   D O M   e l e m e n t   t o   l i m i t   t h e   s c o p e   o f   t h e   s e l e c t o r   m a t c h ;   d e f a u l t s   t o   d o c u m e n t .  
  
 E x a m p l e :  
 	 > $ E ( ' a ' ,   ' m y E l e m e n t ' )   / / f i n d   t h e   f i r s t   a n c h o r   t a g   i n s i d e   t h e   D O M   e l e m e n t   w i t h   i d   ' m y E l e m e n t '  
  
 R e t u r n s :  
 	 a   D O M   e l e m e n t   -   t h e   f i r s t   e l e m e n t   t h a t   m a t c h e s   t h e   s e l e c t o r  
 * /  
  
 f u n c t i o n   $ E ( s e l e c t o r ,   f i l t e r ) {  
 	 r e t u r n   ( $ ( f i l t e r )   | |   d o c u m e n t ) . g e t E l e m e n t ( s e l e c t o r ) ;  
 } ;  
  
 / *  
 F u n c t i o n :   $ E S  
 	 R e t u r n s   a   c o l l e c t i o n   o f   E l e m e n t s   t h a t   m a t c h   t h e   s e l e c t o r   p a s s e d   i n   l i m i t e d   t o   t h e   s c o p e   o f   t h e   o p t i o n a l   f i l t e r .  
 	 S e e   A l s o :   < E l e m e n t . g e t E l e m e n t s >   f o r   a n   a l t e r n a t e   s y n t a x .  
 	 R e t u r n s   a s   < E l e m e n t s > .  
  
 R e t u r n s :  
 	 a n   a r r a y   o f   d o m   e l e m e n t s   t h a t   m a t c h   t h e   s e l e c t o r   w i t h i n   t h e   f i l t e r  
  
 A r g u m e n t s :  
 	 s e l e c t o r   -   s t r i n g ;   c s s   s e l e c t o r   t o   m a t c h  
 	 f i l t e r   -   o p t i o n a l ;   a   D O M   e l e m e n t   t o   l i m i t   t h e   s c o p e   o f   t h e   s e l e c t o r   m a t c h ;   d e f a u l t s   t o   d o c u m e n t .  
  
 E x a m p l e s :  
 	 > $ E S ( " a " )   / / g e t s   a l l   t h e   a n c h o r   t a g s ;   s y n o n y m o u s   w i t h   $ $ ( " a " )  
 	 > $ E S ( ' a ' , ' m y E l e m e n t ' )   / / g e t   a l l   t h e   a n c h o r   t a g s   w i t h i n   $ ( ' m y E l e m e n t ' )  
 * /  
  
 f u n c t i o n   $ E S ( s e l e c t o r ,   f i l t e r ) {  
 	 r e t u r n   ( $ ( f i l t e r )   | |   d o c u m e n t ) . g e t E l e m e n t s B y S e l e c t o r ( s e l e c t o r ) ;  
 } ;  
  
 $ $ . s h a r e d   =   {  
  
 	 ' r e g e x p ' :   / ^ ( \ w * | \ * ) ( ? : # ( [ \ w - ] + ) | \ . ( [ \ w - ] + ) ) ? ( ? : \ [ ( \ w + ) ( ? : ( [ ! * ^ $ ] ? = ) [ " ' ] ? ( [ ^ " ' \ ] ] * ) [ " ' ] ? ) ? ] ) ? $ / ,  
 	  
 	 ' x p a t h ' :   {  
  
 	 	 g e t P a r a m :   f u n c t i o n ( i t e m s ,   c o n t e x t ,   p a r a m ,   i ) {  
 	 	 	 v a r   t e m p   =   [ c o n t e x t . n a m e s p a c e U R I   ?   ' x h t m l : '   :   ' ' ,   p a r a m [ 1 ] ] ;  
 	 	 	 i f   ( p a r a m [ 2 ] )   t e m p . p u s h ( ' [ @ i d = " ' ,   p a r a m [ 2 ] ,   ' " ] ' ) ;  
 	 	 	 i f   ( p a r a m [ 3 ] )   t e m p . p u s h ( ' [ c o n t a i n s ( c o n c a t ( "   " ,   @ c l a s s ,   "   " ) ,   "   ' ,   p a r a m [ 3 ] ,   '   " ) ] ' ) ;  
 	 	 	 i f   ( p a r a m [ 4 ] ) {  
 	 	 	 	 i f   ( p a r a m [ 5 ]   & &   p a r a m [ 6 ] ) {  
 	 	 	 	 	 s w i t c h ( p a r a m [ 5 ] ) {  
 	 	 	 	 	 	 c a s e   ' * = ' :   t e m p . p u s h ( ' [ c o n t a i n s ( @ ' ,   p a r a m [ 4 ] ,   ' ,   " ' ,   p a r a m [ 6 ] ,   ' " ) ] ' ) ;   b r e a k ;  
 	 	 	 	 	 	 c a s e   ' ^ = ' :   t e m p . p u s h ( ' [ s t a r t s - w i t h ( @ ' ,   p a r a m [ 4 ] ,   ' ,   " ' ,   p a r a m [ 6 ] ,   ' " ) ] ' ) ;   b r e a k ;  
 	 	 	 	 	 	 c a s e   ' $ = ' :   t e m p . p u s h ( ' [ s u b s t r i n g ( @ ' ,   p a r a m [ 4 ] ,   ' ,   s t r i n g - l e n g t h ( @ ' ,   p a r a m [ 4 ] ,   ' )   -   ' ,   p a r a m [ 6 ] . l e n g t h ,   '   +   1 )   =   " ' ,   p a r a m [ 6 ] ,   ' " ] ' ) ;   b r e a k ;  
 	 	 	 	 	 	 c a s e   ' = ' :   t e m p . p u s h ( ' [ @ ' ,   p a r a m [ 4 ] ,   ' = " ' ,   p a r a m [ 6 ] ,   ' " ] ' ) ;   b r e a k ;  
 	 	 	 	 	 	 c a s e   ' ! = ' :   t e m p . p u s h ( ' [ @ ' ,   p a r a m [ 4 ] ,   ' ! = " ' ,   p a r a m [ 6 ] ,   ' " ] ' ) ;  
 	 	 	 	 	 }  
 	 	 	 	 }   e l s e   {  
 	 	 	 	 	 t e m p . p u s h ( ' [ @ ' ,   p a r a m [ 4 ] ,   ' ] ' ) ;  
 	 	 	 	 }  
 	 	 	 }  
 	 	 	 i t e m s . p u s h ( t e m p . j o i n ( ' ' ) ) ;  
 	 	 	 r e t u r n   i t e m s ;  
 	 	 } ,  
 	 	  
 	 	 g e t I t e m s :   f u n c t i o n ( i t e m s ,   c o n t e x t ,   n o c a s h ) {  
 	 	 	 v a r   e l e m e n t s   =   [ ] ;  
 	 	 	 v a r   x p a t h   =   d o c u m e n t . e v a l u a t e ( ' . / / '   +   i t e m s . j o i n ( ' / / ' ) ,   c o n t e x t ,   $ $ . s h a r e d . r e s o l v e r ,   X P a t h R e s u l t . U N O R D E R E D _ N O D E _ S N A P S H O T _ T Y P E ,   n u l l ) ;  
 	 	 	 f o r   ( v a r   i   =   0 ,   j   =   x p a t h . s n a p s h o t L e n g t h ;   i   <   j ;   i + + )   e l e m e n t s . p u s h ( x p a t h . s n a p s h o t I t e m ( i ) ) ;  
 	 	 	 r e t u r n   ( n o c a s h )   ?   e l e m e n t s   :   n e w   E l e m e n t s ( e l e m e n t s . m a p ( $ ) ) ;  
 	 	 }  
  
 	 } ,  
 	  
 	 ' n o r m a l ' :   {  
 	 	  
 	 	 g e t P a r a m :   f u n c t i o n ( i t e m s ,   c o n t e x t ,   p a r a m ,   i ) {  
 	 	 	 i f   ( i   = =   0 ) {  
 	 	 	 	 i f   ( p a r a m [ 2 ] ) {  
 	 	 	 	 	 v a r   e l   =   c o n t e x t . g e t E l e m e n t B y I d ( p a r a m [ 2 ] ) ;  
 	 	 	 	 	 i f   ( ! e l   | |   ( ( p a r a m [ 1 ]   ! =   ' * ' )   & &   ( E l e m e n t . g e t T a g ( e l )   ! =   p a r a m [ 1 ] ) ) )   r e t u r n   f a l s e ;  
 	 	 	 	 	 i t e m s   =   [ e l ] ;  
 	 	 	 	 }   e l s e   {  
 	 	 	 	 	 i t e m s   =   $ A ( c o n t e x t . g e t E l e m e n t s B y T a g N a m e ( p a r a m [ 1 ] ) ) ;  
 	 	 	 	 }  
 	 	 	 }   e l s e   {  
 	 	 	 	 i t e m s   =   $ $ . s h a r e d . g e t E l e m e n t s B y T a g N a m e ( i t e m s ,   p a r a m [ 1 ] ) ;  
 	 	 	 	 i f   ( p a r a m [ 2 ] )   i t e m s   =   E l e m e n t s . f i l t e r B y I d ( i t e m s ,   p a r a m [ 2 ] ,   t r u e ) ;  
 	 	 	 }  
 	 	 	 i f   ( p a r a m [ 3 ] )   i t e m s   =   E l e m e n t s . f i l t e r B y C l a s s ( i t e m s ,   p a r a m [ 3 ] ,   t r u e ) ;  
 	 	 	 i f   ( p a r a m [ 4 ] )   i t e m s   =   E l e m e n t s . f i l t e r B y A t t r i b u t e ( i t e m s ,   p a r a m [ 4 ] ,   p a r a m [ 5 ] ,   p a r a m [ 6 ] ,   t r u e ) ;  
 	 	 	 r e t u r n   i t e m s ;  
 	 	 } ,  
  
 	 	 g e t I t e m s :   f u n c t i o n ( i t e m s ,   c o n t e x t ,   n o c a s h ) {  
 	 	 	 r e t u r n   ( n o c a s h )   ?   i t e m s   :   $ $ . u n i q u e ( i t e m s ) ;  
 	 	 }  
  
 	 } ,  
  
 	 r e s o l v e r :   f u n c t i o n ( p r e f i x ) {  
 	 	 r e t u r n   ( p r e f i x   = =   ' x h t m l ' )   ?   ' h t t p : / / w w w . w 3 . o r g / 1 9 9 9 / x h t m l '   :   f a l s e ;  
 	 } ,  
  
 	 g e t E l e m e n t s B y T a g N a m e :   f u n c t i o n ( c o n t e x t ,   t a g N a m e ) {  
 	 	 v a r   f o u n d   =   [ ] ;  
 	 	 f o r   ( v a r   i   =   0 ,   j   =   c o n t e x t . l e n g t h ;   i   <   j ;   i + + )   f o u n d . e x t e n d ( c o n t e x 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 N a m e ) ) ;  
 	 	 r e t u r n   f o u n d ;  
 	 }  
  
 } ;  
  
 $ $ . s h a r e d . m e t h o d   =   ( w i n d o w . x p a t h )   ?   ' x p a t h '   :   ' n o r m a l ' ;  
  
 / *  
 C l a s s :   E l e m e n t  
 	 C u s t o m   c l a s s   t o   a l l o w   a l l   o f   i t s   m e t h o d s   t o   b e   u s e d   w i t h   a n y   D O M   e l e m e n t   v i a   t h e   d o l l a r   f u n c t i o n   < $ > .  
 * /  
  
 E l e m e n t . M e t h o d s . D o m   =   {  
  
 	 / *  
 	 P r o p e r t y :   g e t E l e m e n t s  
 	 	 G e t s   a l l   t h e   e l e m e n t s   w i t h i n   a n   e l e m e n t   t h a t   m a t c h   t h e   g i v e n   ( s i n g l e )   s e l e c t o r .  
 	 	 R e t u r n s   a s   < E l e m e n t s > .  
  
 	 A r g u m e n t s :  
 	 	 s e l e c t o r   -   s t r i n g ;   t h e   c s s   s e l e c t o r   t o   m a t c h  
  
 	 E x a m p l e s :  
 	 	 > $ ( ' m y E l e m e n t ' ) . g e t E l e m e n t s ( ' a ' ) ;   / /   g e t   a l l   a n c h o r s   w i t h i n   m y E l e m e n t  
 	 	 > $ ( ' m y E l e m e n t ' ) . g e t E l e m e n t s ( ' i n p u t [ n a m e = d i a l o g ] ' )   / / g e t   a l l   i n p u t   t a g s   w i t h   n a m e   ' d i a l o g '  
 	 	 > $ ( ' m y E l e m e n t ' ) . g e t E l e m e n t s ( ' i n p u t [ n a m e $ = l o g ] ' )   / / g e t   a l l   i n p u t   t a g s   w i t h   n a m e s   e n d i n g   w i t h   ' l o g '  
  
 	 N o t e s :  
 	 	 S u p p o r t s   t h e s e   o p e r a t o r s   i n   a t t r i b u t e   s e l e c t o r s :  
  
 	 	 -   =   :   i s   e q u a l   t o  
 	 	 -   ^ =   :   s t a r t s - w i t h  
 	 	 -   $ =   :   e n d s - w i t h  
 	 	 -   ! =   :   i s   n o t   e q u a l   t o  
  
 	 	 X p a t h   i s   u s e d   a u t o m a t i c a l l y   f o r   c o m p l i a n t   b r o w s e r s .  
 	 * /  
  
 	 g e t E l e m e n t s :   f u n c t i o n ( s e l e c t o r ,   n o c a s h ) {  
 	 	 v a r   i t e m s   =   [ ] ;  
 	 	 s e l e c t o r   =   s e l e c t o r . t r i m ( ) . s p l i t ( '   ' ) ;  
 	 	 f o r   ( v a r   i   =   0 ,   j   =   s e l e c t o r . l e n g t h ;   i   <   j ;   i + + ) {  
 	 	 	 v a r   s e l   =   s e l e c t o r [ i ] ;  
 	 	 	 v a r   p a r a m   =   s e l . m a t c h ( $ $ . s h a r e d . r e g e x p ) ;  
 	 	 	 i f   ( ! p a r a m )   b r e a k ;  
 	 	 	 p a r a m [ 1 ]   =   p a r a m [ 1 ]   | |   ' * ' ;  
 	 	 	 v a r   t e m p   =   $ $ . s h a r e d [ $ $ . s h a r e d . m e t h o d ] . g e t P a r a m ( i t e m s ,   t h i s ,   p a r a m ,   i ) ;  
 	 	 	 i f   ( ! t e m p )   b r e a k ;  
 	 	 	 i t e m s   =   t e m p ;  
 	 	 }  
 	 	 r e t u r n   $ $ . s h a r e d [ $ $ . s h a r e d . m e t h o d ] . g e t I t e m s ( i t e m s ,   t h i s ,   n o c a s h ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t E l e m e n t  
 	 	 S a m e   a s   < E l e m e n t . g e t E l e m e n t s > ,   b u t   r e t u r n s   o n l y   t h e   f i r s t .   A l t e r n a t e   s y n t a x   f o r   < $ E > ,   w h e r e   f i l t e r   i s   t h e   E l e m e n t .  
 	 	 R e t u r n s   a s   < E l e m e n t > .  
  
 	 A r g u m e n t s :  
 	 	 s e l e c t o r   -   s t r i n g ;   c s s   s e l e c t o r  
 	 * /  
  
 	 g e t E l e m e n t :   f u n c t i o n ( s e l e c t o r ) {  
 	 	 r e t u r n   $ ( t h i s . g e t E l e m e n t s ( s e l e c t o r ,   t r u e ) [ 0 ]   | |   f a l s e ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t E l e m e n t s B y S e l e c t o r  
 	 	 S a m e   a s   < E l e m e n t . g e t E l e m e n t s > ,   b u t   a l l o w s   f o r   c o m m a   s e p a r a t e d   s e l e c t o r s ,   a s   i n   c s s .   A l t e r n a t e   s y n t a x   f o r   < $ $ > ,   w h e r e   f i l t e r   i s   t h e   E l e m e n t .  
 	 	 R e t u r n s   a s   < E l e m e n t s > .  
  
 	 A r g u m e n t s :  
 	 	 s e l e c t o r   -   s t r i n g ;   c s s   s e l e c t o r  
 	 * /  
  
 	 g e t E l e m e n t s B y S e l e c t o r :   f u n c t i o n ( s e l e c t o r ,   n o c a s h ) {  
 	 	 v a r   e l e m e n t s   =   [ ] ;  
 	 	 s e l e c t o r   =   s e l e c t o r . s p l i t ( ' , ' ) ;  
 	 	 f o r   ( v a r   i   =   0 ,   j   =   s e l e c t o r . l e n g t h ;   i   <   j ;   i + + )   e l e m e n t s   =   e l e m e n t s . c o n c a t ( t h i s . g e t E l e m e n t s ( s e l e c t o r [ i ] ,   t r u e ) ) ;  
 	 	 r e t u r n   ( n o c a s h )   ?   e l e m e n t s   :   $ $ . u n i q u e ( e l e m e n t s ) ;  
 	 }  
  
 } ;  
  
 E l e m e n t . e x t e n d ( {  
  
 	 / *  
 	 P r o p e r t y :   g e t E l e m e n t B y I d  
 	 	 T a r g e t s   a n   e l e m e n t   w i t h   t h e   s p e c i f i e d   i d   f o u n d   i n s i d e   t h e   E l e m e n t .   D o e s   n o t   o v e r w r i t e   d o c u m e n t . g e t E l e m e n t B y I d .  
  
 	 A r g u m e n t s :  
 	 	 i d   -   s t r i n g ;   t h e   i d   o f   t h e   e l e m e n t   t o   f i n d .  
 	 * /  
  
 	 g e t E l e m e n t B y I d :   f u n c t i o n ( i d ) {  
 	 	 v a r   e l   =   d o c u m e n t . g e t E l e m e n t B y I d ( i d ) ;  
 	 	 i f   ( ! e l )   r e t u r n   f a l s e ;  
 	 	 f o r   ( v a r   p a r e n t   =   e l . p a r e n t N o d e ;   p a r e n t   ! =   t h i s ;   p a r e n t   =   p a r e n t . p a r e n t N o d e ) {  
 	 	 	 i f   ( ! p a r e n t )   r e t u r n   f a l s e ;  
 	 	 }  
 	 	 r e t u r n   e l ;  
 	 } / * c o m p a t i b i l i t y * / ,  
 	  
 	 g e t E l e m e n t s B y C l a s s N a m e :   f u n c t i o n ( c l a s s N a m e ) {    
 	 	 r e t u r n   t h i s . g e t E l e m e n t s ( ' . '   +   c l a s s N a m e ) ;    
 	 }  
 	  
 	 / * e n d   c o m p a t i b i l i t y * /  
  
 } ) ;  
  
 d o c u m e n t . e x t e n d ( E l e m e n t . M e t h o d s . D o m ) ;  
 E l e m e n t . e x t e n d ( E l e m e n t . M e t h o d s . D o m ) ;  
  
 / *  
 S c r i p t :   E l e m e n t . F o r m . j s  
 	 C o n t a i n s   E l e m e n t   p r o t o t y p e s   t o   d e a l   w i t h   F o r m s   a n d   t h e i r   e l e m e n t s .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   E l e m e n t  
 	 C u s t o m   c l a s s   t o   a l l o w   a l l   o f   i t s   m e t h o d s   t o   b e   u s e d   w i t h   a n y   D O M   e l e m e n t   v i a   t h e   d o l l a r   f u n c t i o n   < $ > .  
 * /  
  
 E l e m e n t . e x t e n d ( {  
  
 	 / *  
 	 P r o p e r t y :   g e t V a l u e  
 	 	 R e t u r n s   t h e   v a l u e   o f   t h e   E l e m e n t ,   i f   i t s   t a g   i s   t e x t a r e a ,   s e l e c t   o r   i n p u t .   g e t V a l u e   c a l l e d   o n   a   m u l t i p l e   s e l e c t   w i l l   r e t u r n   a n   a r r a y .  
 	 * /  
  
 	 g e t V a l u e :   f u n c t i o n ( ) {  
 	 	 s w i t c h ( t h i s . g e t T a g ( ) ) {  
 	 	 	 c a s e   ' s e l e c t ' :  
 	 	 	 	 v a r   v a l u e s   =   [ ] ;  
 	 	 	 	 $ e a c h ( t h i s . o p t i o n s ,   f u n c t i o n ( o p t i o n ) {  
 	 	 	 	 	 i f   ( o p t i o n . s e l e c t e d )   v a l u e s . p u s h ( $ p i c k ( o p t i o n . v a l u e ,   o p t i o n . t e x t ) ) ;  
 	 	 	 	 } ) ;  
 	 	 	 	 r e t u r n   ( t h i s . m u l t i p l e )   ?   v a l u e s   :   v a l u e s [ 0 ] ;  
 	 	 	 c a s e   ' i n p u t ' :   i f   ( ! ( t h i s . c h e c k e d   & &   [ ' c h e c k b o x ' ,   ' r a d i o ' ] . c o n t a i n s ( t h i s . t y p e ) )   & &   ! [ ' h i d d e n ' ,   ' t e x t ' ,   ' p a s s w o r d ' ] . c o n t a i n s ( t h i s . t y p e ) )   b r e a k ;  
 	 	 	 c a s e   ' t e x t a r e a ' :   r e t u r n   t h i s . v a l u e ;  
 	 	 }  
 	 	 r e t u r n   f a l s e ;  
 	 } ,  
  
 	 g e t F o r m E l e m e n t s :   f u n c t i o n ( ) {  
 	 	 r e t u r n   $ $ ( t h i s . g e t E l e m e n t s B y T a g N a m e ( ' i n p u t ' ) ,   t h i s . g e t E l e m e n t s B y T a g N a m e ( ' s e l e c t ' ) ,   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 e x t a r e a ' ) ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   t o Q u e r y S t r i n g  
 	 	 R e a d s   t h e   c h i l d r e n   i n p u t s   o f   t h e   E l e m e n t   a n d   g e n e r a t e s   a   q u e r y   s t r i n g ,   b a s e d   o n   t h e i r   v a l u e s .   U s e d   i n t e r n a l l y   i n   < A j a x >  
  
 	 E x a m p l e :  
 	 	 ( s t a r t   c o d e )  
 	 	 < f o r m   i d = " m y F o r m "   a c t i o n = " s u b m i t . p h p " >  
 	 	 < i n p u t   n a m e = " e m a i l "   v a l u e = " b o b @ b o b . c o m " >  
 	 	 < i n p u t   n a m e = " z i p C o d e "   v a l u e = " 9 0 2 1 0 " >  
 	 	 < / f o r m >  
  
 	 	 < s c r i p t >  
 	 	   $ ( ' m y F o r m ' ) . t o Q u e r y S t r i n g ( )  
 	 	 < / s c r i p t >  
 	 	 ( e n d )  
  
 	 	 R e t u r n s :  
 	 	 	 e m a i l = b o b @ b o b . c o m & z i p C o d e = 9 0 2 1 0  
 	 * /  
  
 	 t o Q u e r y S t r i n g :   f u n c t i o n ( ) {  
 	 	 v a r   q u e r y S t r i n g   =   [ ] ;  
 	 	 t h i s . g e t F o r m E l e m e n t s ( ) . e a c h ( f u n c t i o n ( e l ) {  
 	 	 	 v a r   n a m e   =   e l . n a m e ;  
 	 	 	 v a r   v a l u e   =   e l . g e t V a l u e ( ) ;  
 	 	 	 i f   ( v a l u e   = = =   f a l s e   | |   ! n a m e   | |   e l . d i s a b l e d )   r e t u r n ;  
 	 	 	 v a r   q s   =   f u n c t i o n ( v a l ) {  
 	 	 	 	 q u e r y S t r i n g . p u s h ( n a m e   +   ' = '   +   e n c o d e U R I C o m p o n e n t ( v a l ) ) ;  
 	 	 	 } ;  
 	 	 	 i f   ( $ t y p e ( v a l u e )   = =   ' a r r a y ' )   v a l u e . e a c h ( q s ) ;  
 	 	 	 e l s e   q s ( v a l u e ) ;  
 	 	 } ) ;  
 	 	 r e t u r n   q u e r y S t r i n g . j o i n ( ' & ' ) ;  
 	 }  
  
 } ) ;  
  
 / *  
 S c r i p t :   E l e m e n t . D i m e n s i o n s . j s  
 	 C o n t a i n s   E l e m e n t   p r o t o t y p e s   t o   d e a l   w i t h   E l e m e n t   s i z e   a n d   p o s i t i o n   i n   s p a c e .  
  
 N o t e :  
 	 T h e   f u n c t i o n s   i n   t h i s   s c r i p t   r e q u i r e   n   X H T M L   d o c t y p e .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   E l e m e n t  
 	 C u s t o m   c l a s s   t o   a l l o w   a l l   o f   i t s   m e t h o d s   t o   b e   u s e d   w i t h   a n y   D O M   e l e m e n t   v i a   t h e   d o l l a r   f u n c t i o n   < $ > .  
 * /  
  
 E l e m e n t . e x t e n d ( {  
  
 	 / *  
 	 P r o p e r t y :   s c r o l l T o  
 	 	 S c r o l l s   t h e   e l e m e n t   t o   t h e   s p e c i f i e d   c o o r d i n a t e d   ( i f   t h e   e l e m e n t   h a s   a n   o v e r f l o w )  
  
 	 A r g u m e n t s :  
 	 	 x   -   t h e   x   c o o r d i n a t e  
 	 	 y   -   t h e   y   c o o r d i n a t e  
  
 	 E x a m p l e :  
 	 	 > $ ( ' m y E l e m e n t ' ) . s c r o l l T o ( 0 ,   1 0 0 )  
 	 * /  
  
 	 s c r o l l T o :   f u n c t i o n ( x ,   y ) {  
 	 	 t h i s . s c r o l l L e f t   =   x ;  
 	 	 t h i s . s c r o l l T o p   =   y ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t S i z e  
 	 	 R e t u r n   a n   O b j e c t   r e p r e s e n t i n g   t h e   s i z e / s c r o l l   v a l u e s   o f   t h e   e l e m e n t .  
  
 	 E x a m p l e :  
 	 	 ( s t a r t   c o d e )  
 	 	 $ ( ' m y E l e m e n t ' ) . g e t S i z e ( ) ;  
 	 	 ( e n d )  
  
 	 R e t u r n s :  
 	 	 ( s t a r t   c o d e )  
 	 	 {  
 	 	 	 ' s c r o l l ' :   { ' x ' :   1 0 0 ,   ' y ' :   1 0 0 } ,  
 	 	 	 ' s i z e ' :   { ' x ' :   2 0 0 ,   ' y ' :   4 0 0 } ,  
 	 	 	 ' s c r o l l S i z e ' :   { ' x ' :   3 0 0 ,   ' y ' :   5 0 0 }  
 	 	 }  
 	 	 ( e n d )  
 	 * /  
  
 	 g e t S i z e :   f u n c t i o n ( ) {  
 	 	 r e t u r n   {  
 	 	 	 ' s c r o l l ' :   { ' x ' :   t h i s . s c r o l l L e f t ,   ' y ' :   t h i s . s c r o l l T o p } ,  
 	 	 	 ' s i z e ' :   { ' x ' :   t h i s . o f f s e t W i d t h ,   ' y ' :   t h i s . o f f s e t H e i g h t } ,  
 	 	 	 ' s c r o l l S i z e ' :   { ' x ' :   t h i s . s c r o l l W i d t h ,   ' y ' :   t h i s . s c r o l l H e i g h t }  
 	 	 } ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t P o s i t i o n  
 	 	 R e t u r n s   t h e   r e a l   o f f s e t s   o f   t h e   e l e m e n t .  
  
 	 A r g u m e n t s :  
 	 	 o v e r f l o w n   -   o p t i o n a l ,   a n   a r r a y   o f   n e s t e d   s c r o l l i n g   c o n t a i n e r s   f o r   s c r o l l   o f f s e t   c a l c u l a t i o n ,   u s e   t h i s   i f   y o u r   e l e m e n t   i s   i n s i d e   a n y   e l e m e n t   c o n t a i n i n g   s c r o l l b a r s  
  
 	 E x a m p l e :  
 	 	 > $ ( ' e l e m e n t ' ) . g e t P o s i t i o n ( ) ;  
  
 	 R e t u r n s :  
 	 	 > { x :   1 0 0 ,   y : 5 0 0 } ;  
 	 * /  
  
 	 g e t P o s i t i o n :   f u n c t i o n ( o v e r f l o w n ) {  
 	 	 o v e r f l o w n   =   o v e r f l o w n   | |   [ ] ;  
 	 	 v a r   e l   =   t h i s ,   l e f t   =   0 ,   t o p   =   0 ;  
 	 	 d o   {  
 	 	 	 l e f t   + =   e l . o f f s e t L e f t   | |   0 ;  
 	 	 	 t o p   + =   e l . o f f s e t T o p   | |   0 ;  
 	 	 	 e l   =   e l . o f f s e t P a r e n t ;  
 	 	 }   w h i l e   ( e l ) ;  
 	 	 o v e r f l o w n . e a c h ( f u n c t i o n ( e l e m e n t ) {  
 	 	 	 l e f t   - =   e l e m e n t . s c r o l l L e f t   | |   0 ;  
 	 	 	 t o p   - =   e l e m e n t . s c r o l l T o p   | |   0 ;  
 	 	 } ) ;  
 	 	 r e t u r n   { ' x ' :   l e f t ,   ' y ' :   t o p } ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t T o p  
 	 	 R e t u r n s   t h e   d i s t a n c e   f r o m   t h e   t o p   o f   t h e   w i n d o w   t o   t h e   E l e m e n t .  
  
 	 A r g u m e n t s :  
 	 	 o v e r f l o w n   -   o p t i o n a l ,   a n   a r r a y   o f   n e s t e d   s c r o l l i n g   c o n t a i n e r s ,   s e e   E l e m e n t : : g e t P o s i t i o n  
 	 * /  
  
 	 g e t T o p :   f u n c t i o n ( o v e r f l o w n ) {  
 	 	 r e t u r n   t h i s . g e t P o s i t i o n ( o v e r f l o w n ) . y ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t L e f t  
 	 	 R e t u r n s   t h e   d i s t a n c e   f r o m   t h e   l e f t   o f   t h e   w i n d o w   t o   t h e   E l e m e n t .  
  
 	 A r g u m e n t s :  
 	 	 o v e r f l o w n   -   o p t i o n a l ,   a n   a r r a y   o f   n e s t e d   s c r o l l i n g   c o n t a i n e r s ,   s e e   E l e m e n t : : g e t P o s i t i o n  
 	 * /  
  
 	 g e t L e f t :   f u n c t i o n ( o v e r f l o w n ) {  
 	 	 r e t u r n   t h i s . g e t P o s i t i o n ( o v e r f l o w n ) . x ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t C o o r d i n a t e s  
 	 	 R e t u r n s   a n   o b j e c t   w i t h   w i d t h ,   h e i g h t ,   l e f t ,   r i g h t ,   t o p ,   a n d   b o t t o m ,   r e p r e s e n t i n g   t h e   v a l u e s   o f   t h e   E l e m e n t  
  
 	 A r g u m e n t s :  
 	 	 o v e r f l o w n   -   o p t i o n a l ,   a n   a r r a y   o f   n e s t e d   s c r o l l i n g   c o n t a i n e r s ,   s e e   E l e m e n t : : g e t P o s i t i o n  
  
 	 E x a m p l e :  
 	 	 ( s t a r t   c o d e )  
 	 	 v a r   m y V a l u e s   =   $ ( ' m y E l e m e n t ' ) . g e t C o o r d i n a t e s ( ) ;  
 	 	 ( e n d )  
  
 	 R e t u r n s :  
 	 	 ( s t a r t   c o d e )  
 	 	 {  
 	 	 	 w i d t h :   2 0 0 ,  
 	 	 	 h e i g h t :   3 0 0 ,  
 	 	 	 l e f t :   1 0 0 ,  
 	 	 	 t o p :   5 0 ,  
 	 	 	 r i g h t :   3 0 0 ,  
 	 	 	 b o t t o m :   3 5 0  
 	 	 }  
 	 	 ( e n d )  
 	 * /  
  
 	 g e t C o o r d i n a t e s :   f u n c t i o n ( o v e r f l o w n ) {  
 	 	 v a r   p o s i t i o n   =   t h i s . g e t P o s i t i o n ( o v e r f l o w n ) ;  
 	 	 v a r   o b j   =   {  
 	 	 	 ' w i d t h ' :   t h i s . o f f s e t W i d t h ,  
 	 	 	 ' h e i g h t ' :   t h i s . o f f s e t H e i g h t ,  
 	 	 	 ' l e f t ' :   p o s i t i o n . x ,  
 	 	 	 ' t o p ' :   p o s i t i o n . y  
 	 	 } ;  
 	 	 o b j . r i g h t   =   o b j . l e f t   +   o b j . w i d t h ;  
 	 	 o b j . b o t t o m   =   o b j . t o p   +   o b j . h e i g h t ;  
 	 	 r e t u r n   o b j ;  
 	 }  
  
 } ) ;  
  
 / *  
 S c r i p t :   W i n d o w . D o m R e a d y . j s  
 	 C o n t a i n s   t h e   c u s t o m   e v e n t   d o m r e a d y ,   f o r   w i n d o w .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *   S e c t i o n :   C u s t o m   E v e n t s   * /  
  
 / *  
 E v e n t :   d o m r e a d y  
 	 e x e c u t e s   a   f u n c t i o n   w h e n   t h e   d o m   t r e e   i s   l o a d e d ,   w i t h o u t   w a i t i n g   f o r   i m a g e s .   O n l y   w o r k s   w h e n   c a l l e d   f r o m   w i n d o w .  
  
 C r e d i t s :  
 	 ( c )   D e a n   E d w a r d s / M a t t h i a s   M i l l e r / J o h n   R e s i g ,   r e m a s t e r e d   f o r   M o o T o o l s .  
  
 A r g u m e n t s :  
 	 f n   -   t h e   f u n c t i o n   t o   e x e c u t e   w h e n   t h e   D O M   i s   r e a d y  
  
 E x a m p l e :  
 	 >   w i n d o w . a d d E v e n t ( ' d o m r e a d y ' ,   f u n c t i o n ( ) {  
 	 > 	 a l e r t ( ' t h e   d o m   i s   r e a d y ' ) ;  
 	 >   } ) ;  
 * /  
  
 E l e m e n t . E v e n t s . d o m r e a d y   =   {  
  
 	 a d d :   f u n c t i o n ( f n ) {  
 	 	 i f   ( w i n d o w . l o a d e d ) {  
 	 	 	 f n . c a l l ( t h i s ) ;  
 	 	 	 r e t u r n ;  
 	 	 }  
 	 	 v a r   d o m R e a d y   =   f u n c t i o n ( ) {  
 	 	 	 i f   ( w i n d o w . l o a d e d )   r e t u r n ;  
 	 	 	 w i n d o w . l o a d e d   =   t r u e ;  
 	 	 	 w i n d o w . t i m e r   =   $ c l e a r ( w i n d o w . t i m e r ) ;  
 	 	 	 t h i s . f i r e E v e n t ( ' d o m r e a d y ' ) ;  
 	 	 } . b i n d ( t h i s ) ;  
 	 	 i f   ( d o c u m e n t . r e a d y S t a t e   & &   w i n d o w . w e b k i t ) {  
 	 	 	 w i n d o w . t i m e r   =   f u n c t i o n ( ) {  
 	 	 	 	 i f   ( [ ' l o a d e d ' , ' c o m p l e t e ' ] . c o n t a i n s ( d o c u m e n t . r e a d y S t a t e ) )   d o m R e a d y ( ) ;  
 	 	 	 } . p e r i o d i c a l ( 5 0 ) ;  
 	 	 }   e l s e   i f   ( d o c u m e n t . r e a d y S t a t e   & &   w i n d o w . i e ) {  
 	 	 	 i f   ( ! $ ( ' i e _ r e a d y ' ) ) {  
 	 	 	 	 v a r   s r c   =   ( w i n d o w . l o c a t i o n . p r o t o c o l   = =   ' h t t p s : ' )   ?   ' : / / 0 '   :   ' j a v a s c r i p t : v o i d ( 0 ) ' ;  
 	 	 	 	 d o c u m e n t . w r i t e ( ' < s c r i p t   i d = " i e _ r e a d y "   d e f e r   s r c = " '   +   s r c   +   ' " > < \ / s c r i p t > ' ) ;  
 	 	 	 	 $ ( ' i e _ r e a d y ' ) . 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 ' )   d o m R e a d y ( ) ;  
 	 	 	 	 } ;  
 	 	 	 }  
 	 	 }   e l s e   {  
 	 	 	 w i n d o w . a d d L i s t e n e r ( " l o a d " ,   d o m R e a d y ) ;  
 	 	 	 d o c u m e n t . a d d L i s t e n e r ( " D O M C o n t e n t L o a d e d " ,   d o m R e a d y ) ;  
 	 	 }  
 	 }  
  
 } ;  
  
 / * c o m p a t i b i l i t y * /  
  
 w i n d o w . o n D o m R e a d y   =   f u n c t i o n ( f n ) {    
 	 r e t u r n   t h i s . a d d E v e n t ( ' d o m r e a d y ' ,   f n ) ;    
 } ;  
  
 / * e n d   c o m p a t i b i l i t y * /  
  
 / *  
 S c r i p t :   W i n d o w . S i z e . j s  
 	 W i n d o w   c r o s s - b r o w s e r   d i m e n s i o n s   m e t h o d s .  
 	  
 N o t e :  
 	 T h e   F u n c t i o n s   i n   t h i s   s c r i p t   r e q u i r e   a n   X H T M L   d o c t y p e .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   w i n d o w  
 	 C r o s s   b r o w s e r   m e t h o d s   t o   g e t   v a r i o u s   w i n d o w   d i m e n s i o n s .  
 	 W a r n i n g :   A l l   t h e s e   m e t h o d s   r e q u i r e   t h a t   t h e   b r o w s e r   o p e r a t e s   i n   s t r i c t   m o d e ,   n o t   q u i r k s   m o d e .  
 * /  
  
 w i n d o w . e x t e n d ( {  
  
 	 / *  
 	 P r o p e r t y :   g e t W i d t h  
 	 	 R e t u r n s   a n   i n t e g e r   r e p r e s e n t i n g   t h e   w i d t h   o f   t h e   b r o w s e r   w i n d o w   ( w i t h o u t   t h e   s c r o l l b a r ) .  
 	 * /  
  
 	 g e t W i d t h :   f u n c t i o n ( ) {  
 	 	 i f   ( t h i s . w e b k i t 4 1 9 )   r e t u r n   t h i s . i n n e r W i d t h ;  
 	 	 i f   ( t h i s . o p e r a )   r e t u r n   d o c u m e n t . b o d y . c l i e n t W i d t h ;  
 	 	 r e t u r n   d o c u m e n t . d o c u m e n t E l e m e n t . c l i e n t W i d t h ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t H e i g h t  
 	 	 R e t u r n s   a n   i n t e g e r   r e p r e s e n t i n g   t h e   h e i g h t   o f   t h e   b r o w s e r   w i n d o w   ( w i t h o u t   t h e   s c r o l l b a r ) .  
 	 * /  
  
 	 g e t H e i g h t :   f u n c t i o n ( ) {  
 	 	 i f   ( t h i s . w e b k i t 4 1 9 )   r e t u r n   t h i s . i n n e r H e i g h t ;  
 	 	 i f   ( t h i s . o p e r a )   r e t u r n   d o c u m e n t . b o d y . c l i e n t H e i g h t ;  
 	 	 r e t u r n   d o c u m e n t . d o c u m e n t E l e m e n t . c l i e n t H e i g h t ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t S c r o l l W i d t h  
 	 	 R e t u r n s   a n   i n t e g e r   r e p r e s e n t i n g   t h e   s c r o l l W i d t h   o f   t h e   w i n d o w .  
 	 	 T h i s   v a l u e   i s   e q u a l   t o   o r   b i g g e r   t h a n   < g e t W i d t h > .  
  
 	 S e e   A l s o :  
 	 	 < h t t p : / / d e v e l o p e r . m o z i l l a . o r g / e n / d o c s / D O M : e l e m e n t . s c r o l l W i d t h >  
 	 * /  
  
 	 g e t S c r o l l W i d t h :   f u n c t i o n ( ) {  
 	 	 i f   ( t h i s . i e )   r e t u r n   M a t h . m a x ( d o c u m e n t . d o c u m e n t E l e m e n t . o f f s e t W i d t h ,   d o c u m e n t . d o c u m e n t E l e m e n t . s c r o l l W i d t h ) ;  
 	 	 i f   ( t h i s . w e b k i t )   r e t u r n   d o c u m e n t . b o d y . s c r o l l W i d t h ;  
 	 	 r e t u r n   d o c u m e n t . d o c u m e n t E l e m e n t . s c r o l l W i d t h ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t S c r o l l H e i g h t  
 	 	 R e t u r n s   a n   i n t e g e r   r e p r e s e n t i n g   t h e   s c r o l l H e i g h t   o f   t h e   w i n d o w .  
 	 	 T h i s   v a l u e   i s   e q u a l   t o   o r   b i g g e r   t h a n   < g e t H e i g h t > .  
  
 	 S e e   A l s o :  
 	 	 < h t t p : / / d e v e l o p e r . m o z i l l a . o r g / e n / d o c s / D O M : e l e m e n t . s c r o l l H e i g h t >  
 	 * /  
  
 	 g e t S c r o l l H e i g h t :   f u n c t i o n ( ) {  
 	 	 i f   ( t h i s . i e )   r e t u r n   M a t h . m a x ( d o c u m e n t . d o c u m e n t E l e m e n t . o f f s e t H e i g h t ,   d o c u m e n t . d o c u m e n t E l e m e n t . s c r o l l H e i g h t ) ;  
 	 	 i f   ( t h i s . w e b k i t )   r e t u r n   d o c u m e n t . b o d y . s c r o l l H e i g h t ;  
 	 	 r e t u r n   d o c u m e n t . d o c u m e n t E l e m e n t . s c r o l l H e i g h t ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t S c r o l l L e f t  
 	 	 R e t u r n s   a n   i n t e g e r   r e p r e s e n t i n g   t h e   s c r o l l L e f t   o f   t h e   w i n d o w   ( t h e   n u m b e r   o f   p i x e l s   t h e   w i n d o w   h a s   s c r o l l e d   f r o m   t h e   l e f t ) .  
  
 	 S e e   A l s o :  
 	 	 < h t t p : / / d e v e l o p e r . m o z i l l a . o r g / e n / d o c s / D O M : e l e m e n t . s c r o l l L e f t >  
 	 * /  
  
 	 g e t S c r o l l L e f t :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s . p a g e X O f f s e t   | |   d o c u m e n t . d o c u m e n t E l e m e n t . s c r o l l L e f t ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t S c r o l l T o p  
 	 	 R e t u r n s   a n   i n t e g e r   r e p r e s e n t i n g   t h e   s c r o l l T o p   o f   t h e   w i n d o w   ( t h e   n u m b e r   o f   p i x e l s   t h e   w i n d o w   h a s   s c r o l l e d   f r o m   t h e   t o p ) .  
  
 	 S e e   A l s o :  
 	 	 < h t t p : / / d e v e l o p e r . m o z i l l a . o r g / e n / d o c s / D O M : e l e m e n t . s c r o l l T o p >  
 	 * /  
  
 	 g e t S c r o l l T o p :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s . p a g e Y O f f s e t   | |   d o c u m e n t . d o c u m e n t E l e m e n t . s c r o l l T o p ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t S i z e  
 	 	 S a m e   a s   < E l e m e n t . g e t S i z e >  
 	 * /  
  
 	 g e t S i z e :   f u n c t i o n ( ) {  
 	 	 r e t u r n   {  
 	 	 	 ' s i z e ' :   { ' x ' :   t h i s . g e t W i d t h ( ) ,   ' y ' :   t h i s . g e t H e i g h t ( ) } ,  
 	 	 	 ' s c r o l l S i z e ' :   { ' x ' :   t h i s . g e t S c r o l l W i d t h ( ) ,   ' y ' :   t h i s . g e t S c r o l l H e i g h t ( ) } ,  
 	 	 	 ' s c r o l l ' :   { ' x ' :   t h i s . g e t S c r o l l L e f t ( ) ,   ' y ' :   t h i s . g e t S c r o l l T o p ( ) }  
 	 	 } ;  
 	 } ,  
  
 	 / / i g n o r e  
 	 g e t P o s i t i o n :   f u n c t i o n ( ) { r e t u r n   { ' x ' :   0 ,   ' y ' :   0 } ; }  
  
 } ) ;  
  
 / *  
 S c r i p t :   F x . B a s e . j s  
 	 C o n t a i n s   < F x . B a s e > ,   t h e   f o u n d a m e n t a l s   o f   t h e   M o o T o o l s   E f f e c t s .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 v a r   F x   =   { } ;  
  
 / *  
 C l a s s :   F x . B a s e  
 	 B a s e   c l a s s   f o r   t h e   E f f e c t s .  
  
 O p t i o n s :  
 	 t r a n s i t i o n   -   t h e   e q u a t i o n   t o   u s e   f o r   t h e   e f f e c t   s e e   < F x . T r a n s i t i o n s > ;   d e f a u l t   i s   < F x . T r a n s i t i o n s . S i n e . e a s e I n O u t >  
 	 d u r a t i o n   -   t h e   d u r a t i o n   o f   t h e   e f f e c t   i n   m s ;   5 0 0   i s   t h e   d e f a u l t .  
 	 u n i t   -   t h e   u n i t   i s   ' p x '   b y   d e f a u l t   ( o t h e r   v a l u e s   i n c l u d e   t h i n g s   l i k e   ' e m '   f o r   f o n t s   o r   ' % ' ) .  
 	 w a i t   -   b o o l e a n :   t o   w a i t   o r   n o t   t o   w a i t   f o r   a   c u r r e n t   t r a n s i t i o n   t o   e n d   b e f o r e   r u n n i n g   a n o t h e r   o f   t h e   s a m e   i n s t a n c e .   d e f a u l t s   t o   t r u e .  
 	 f p s   -   t h e   f r a m e s   p e r   s e c o n d   f o r   t h e   t r a n s i t i o n ;   d e f a u l t   i s   5 0  
 	  
 E v e n t s :  
 	 o n S t a r t   -   t h e   f u n c t i o n   t o   e x e c u t e   a s   t h e   e f f e c t   b e g i n s ;   n o t h i n g   ( < C l a s s . e m p t y > )   b y   d e f a u l t .  
 	 o n C o m p l e t e   -   t h e   f u n c t i o n   t o   e x e c u t e   a f t e r   t h e   e f f e c t   h a s   p r o c e s s e d ;   n o t h i n g   ( < C l a s s . e m p t y > )   b y   d e f a u l t .  
 	 o n C a n c e l   -   t h e   f u n c t i o n   t o   e x e c u t e   w h e n   y o u   m a n u a l l y   s t o p   t h e   e f f e c t .  
 * /  
  
 F x . B a s e   =   n e w   C l a s s ( {  
  
 	 o p t i o n s :   {  
 	 	 o n S t a r t :   C l a s s . e m p t y ,  
 	 	 o n C o m p l e t e :   C l a s s . e m p t y ,  
 	 	 o n C a n c e l :   C l a s s . e m p t y ,  
 	 	 t r a n s i t i o n :   f u n c t i o n ( p ) {  
 	 	 	 r e t u r n   - ( M a t h . c o s ( M a t h . P I   *   p )   -   1 )   /   2 ;  
 	 	 } ,  
 	 	 d u r a t i o n :   5 0 0 ,  
 	 	 u n i t :   ' p x ' ,  
 	 	 w a i t :   t r u e ,  
 	 	 f p s :   5 0  
 	 } ,  
  
 	 i n i t i a l i z e :   f u n c t i o n ( o p t i o n s ) {  
 	 	 t h i s . e l e m e n t   =   t h i s . e l e m e n t   | |   n u l l ;  
 	 	 t h i s . s e t O p t i o n s ( o p t i o n s ) ;  
 	 	 i f   ( t h i s . o p t i o n s . i n i t i a l i z e )   t h i s . o p t i o n s . i n i t i a l i z e . c a l l ( t h i s ) ;  
 	 } ,  
  
 	 s t e p :   f u n c t i o n ( ) {  
 	 	 v a r   t i m e   =   $ t i m e ( ) ;  
 	 	 i f   ( t i m e   <   t h i s . t i m e   +   t h i s . o p t i o n s . d u r a t i o n ) {  
 	 	 	 t h i s . d e l t a   =   t h i s . o p t i o n s . t r a n s i t i o n ( ( t i m e   -   t h i s . t i m e )   /   t h i s . o p t i o n s . d u r a t i o n ) ;  
 	 	 	 t h i s . s e t N o w ( ) ;  
 	 	 	 t h i s . i n c r e a s e ( ) ;  
 	 	 }   e l s e   {  
 	 	 	 t h i s . s t o p ( t r u e ) ;  
 	 	 	 t h i s . s e t ( t h i s . t o ) ;  
 	 	 	 t h i s . f i r e E v e n t ( ' o n C o m p l e t e ' ,   t h i s . e l e m e n t ,   1 0 ) ;  
 	 	 	 t h i s . c a l l C h a i n ( ) ;  
 	 	 }  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s e t  
 	 	 I m m e d i a t e l y   s e t s   t h e   v a l u e   w i t h   n o   t r a n s i t i o n .  
  
 	 A r g u m e n t s :  
 	 	 t o   -   t h e   p o i n t   t o   j u m p   t o  
  
 	 E x a m p l e :  
 	 	 > v a r   m y F x   =   n e w   F x . S t y l e ( ' m y E l e m e n t ' ,   ' o p a c i t y ' ) . s e t ( 0 ) ;   / / w i l l   m a k e   i t   i m m e d i a t e l y   t r a n s p a r e n t  
 	 * /  
  
 	 s e t :   f u n c t i o n ( t o ) {  
 	 	 t h i s . n o w   =   t o ;  
 	 	 t h i s . i n c r e a s e ( ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 s e t N o w :   f u n c t i o n ( ) {  
 	 	 t h i s . n o w   =   t h i s . c o m p u t e ( t h i s . f r o m ,   t h i s . t o ) ;  
 	 } ,  
  
 	 c o m p u t e :   f u n c t i o n ( f r o m ,   t o ) {  
 	 	 r e t u r n   ( t o   -   f r o m )   *   t h i s . d e l t a   +   f r o m ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s t a r t  
 	 	 E x e c u t e s   a n   e f f e c t   f r o m   o n e   p o s i t i o n   t o   t h e   o t h e r .  
  
 	 A r g u m e n t s :  
 	 	 f r o m   -   i n t e g e r :   s t a r i n g   v a l u e  
 	 	 t o   -   i n t e g e r :   t h e   e n d i n g   v a l u e  
  
 	 E x a m p l e s :  
 	 	 > v a r   m y F x   =   n e w   F x . S t y l e ( ' m y E l e m e n t ' ,   ' o p a c i t y ' ) . s t a r t ( 0 , 1 ) ;   / / d i s p l a y   a   t r a n s i t i o n   f r o m   t r a n s p a r e n t   t o   o p a q u e .  
 	 * /  
  
 	 s t a r t :   f u n c t i o n ( f r o m ,   t o ) {  
 	 	 i f   ( ! t h i s . o p t i o n s . w a i t )   t h i s . s t o p ( ) ;  
 	 	 e l s e   i f   ( t h i s . t i m e r )   r e t u r n   t h i s ;  
 	 	 t h i s . f r o m   =   f r o m ;  
 	 	 t h i s . t o   =   t o ;  
 	 	 t h i s . c h a n g e   =   t h i s . t o   -   t h i s . f r o m ;  
 	 	 t h i s . t i m e   =   $ t i m e ( ) ;  
 	 	 t h i s . t i m e r   =   t h i s . s t e p . p e r i o d i c a l ( M a t h . r o u n d ( 1 0 0 0   /   t h i s . o p t i o n s . f p s ) ,   t h i s ) ;  
 	 	 t h i s . f i r e E v e n t ( ' o n S t a r t ' ,   t h i s . e l e m e n t ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s t o p  
 	 	 S t o p s   t h e   t r a n s i t i o n .  
 	 * /  
  
 	 s t o p :   f u n c t i o n ( e n d ) {  
 	 	 i f   ( ! t h i s . t i m e r )   r e t u r n   t h i s ;  
 	 	 t h i s . t i m e r   =   $ c l e a r ( t h i s . t i m e r ) ;  
 	 	 i f   ( ! e n d )   t h i s . f i r e E v e n t ( ' o n C a n c e l ' ,   t h i s . e l e m e n t ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } / * c o m p a t i b i l i t y * / ,  
 	  
 	 c u s t o m :   f u n c t i o n ( f r o m ,   t o ) {  
 	 	 r e t u r n   t h i s . s t a r t ( f r o m ,   t o ) ;  
 	 } ,  
  
 	 c l e a r T i m e r :   f u n c t i o n ( e n d ) {  
 	 	 r e t u r n   t h i s . s t o p ( e n d ) ;  
 	 }  
  
 	 / * e n d   c o m p a t i b i l i t y * /  
  
 } ) ;  
  
 F x . B a s e . i m p l e m e n t ( n e w   C h a i n ,   n e w   E v e n t s ,   n e w   O p t i o n s ) ;  
  
 / *  
 S c r i p t :   F x . C S S . j s  
 	 C s s   p a r s i n g   c l a s s   f o r   e f f e c t s .   R e q u i r e d   b y   < F x . S t y l e > ,   < F x . S t y l e s > ,   < F x . E l e m e n t s > .   N o   d o c u m e n t a t i o n   n e e d e d ,   a s   i t s   u s e d   i n t e r n a l l y .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 F x . C S S   =   {  
  
 	 s e l e c t :   f u n c t i o n ( p r o p e r t y ,   t o ) {  
 	 	 i f   ( p r o p e r t y . t e s t ( / c o l o r / i ) )   r e t u r n   t h i s . C o l o r ;  
 	 	 v a r   t y p e   =   $ t y p e ( t o ) ;  
 	 	 i f   ( ( t y p e   = =   ' a r r a y ' )   | |   ( t y p e   = =   ' s t r i n g '   & &   t o . c o n t a i n s ( '   ' ) ) )   r e t u r n   t h i s . M u l t i ;  
 	 	 r e t u r n   t h i s . S i n g l e ;  
 	 } ,  
  
 	 p a r s e :   f u n c t i o n ( e l ,   p r o p e r t y ,   f r o m T o ) {  
 	 	 i f   ( ! f r o m T o . p u s h )   f r o m T o   =   [ f r o m T o ] ;  
 	 	 v a r   f r o m   =   f r o m T o [ 0 ] ,   t o   =   f r o m T o [ 1 ] ;  
 	 	 i f   ( ! $ c h k ( t o ) ) {  
 	 	 	 t o   =   f r o m ;  
 	 	 	 f r o m   =   e l . g e t S t y l e ( p r o p e r t y ) ;  
 	 	 }  
 	 	 v a r   c s s   =   t h i s . s e l e c t ( p r o p e r t y ,   t o ) ;  
 	 	 r e t u r n   { ' f r o m ' :   c s s . p a r s e ( f r o m ) ,   ' t o ' :   c s s . p a r s e ( t o ) ,   ' c s s ' :   c s s } ;  
 	 }  
  
 } ;  
  
 F x . C S S . S i n g l e   =   {  
  
 	 p a r s e :   f u n c t i o n ( v a l u e ) {  
 	 	 r e t u r n   p a r s e F l o a t ( v a l u e ) ;  
 	 } ,  
  
 	 g e t N o w :   f u n c t i o n ( f r o m ,   t o ,   f x ) {  
 	 	 r e t u r n   f x . c o m p u t e ( f r o m ,   t o ) ;  
 	 } ,  
  
 	 g e t V a l u e :   f u n c t i o n ( v a l u e ,   u n i t ,   p r o p e r t y ) {  
 	 	 i f   ( u n i t   = =   ' p x '   & &   p r o p e r t y   ! =   ' o p a c i t y ' )   v a l u e   =   M a t h . r o u n d ( v a l u e ) ;  
 	 	 r e t u r n   v a l u e   +   u n i t ;  
 	 }  
  
 } ;  
  
 F x . C S S . M u l t i   =   {  
  
 	 p a r s e :   f u n c t i o n ( v a l u e ) {  
 	 	 r e t u r n   v a l u e . p u s h   ?   v a l u e   :   v a l u e . s p l i t ( '   ' ) . m a p ( f u n c t i o n ( v ) {  
 	 	 	 r e t u r n   p a r s e F l o a t ( v ) ;  
 	 	 } ) ;  
 	 } ,  
  
 	 g e t N o w :   f u n c t i o n ( f r o m ,   t o ,   f x ) {  
 	 	 v a r   n o w   =   [ ] ;  
 	 	 f o r   ( v a r   i   =   0 ;   i   <   f r o m . l e n g t h ;   i + + )   n o w [ i ]   =   f x . c o m p u t e ( f r o m [ i ] ,   t o [ i ] ) ;  
 	 	 r e t u r n   n o w ;  
 	 } ,  
  
 	 g e t V a l u e :   f u n c t i o n ( v a l u e ,   u n i t ,   p r o p e r t y ) {  
 	 	 i f   ( u n i t   = =   ' p x '   & &   p r o p e r t y   ! =   ' o p a c i t y ' )   v a l u e   =   v a l u e . m a p ( M a t h . r o u n d ) ;  
 	 	 r e t u r n   v a l u e . j o i n ( u n i t   +   '   ' )   +   u n i t ;  
 	 }  
  
 } ;  
  
 F x . C S S . C o l o r   =   {  
  
 	 p a r s e :   f u n c t i o n ( v a l u e ) {  
 	 	 r e t u r n   v a l u e . p u s h   ?   v a l u e   :   v a l u e . h e x T o R g b ( t r u e ) ;  
 	 } ,  
  
 	 g e t N o w :   f u n c t i o n ( f r o m ,   t o ,   f x ) {  
 	 	 v a r   n o w   =   [ ] ;  
 	 	 f o r   ( v a r   i   =   0 ;   i   <   f r o m . l e n g t h ;   i + + )   n o w [ i ]   =   M a t h . r o u n d ( f x . c o m p u t e ( f r o m [ i ] ,   t o [ i ] ) ) ;  
 	 	 r e t u r n   n o w ;  
 	 } ,  
  
 	 g e t V a l u e :   f u n c t i o n ( v a l u e ) {  
 	 	 r e t u r n   ' r g b ( '   +   v a l u e . j o i n ( ' , ' )   +   ' ) ' ;  
 	 }  
  
 } ;  
  
 / *  
 S c r i p t :   F x . S t y l e . j s  
 	 C o n t a i n s   < F x . S t y l e >  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   F x . S t y l e  
 	 T h e   S t y l e   e f f e c t ,   u s e d   t o   t r a n s i t i o n   a n y   c s s   p r o p e r t y   f r o m   o n e   v a l u e   t o   a n o t h e r .   I n c l u d e s   c o l o r s .  
 	 C o l o r s   m u s t   b e   i n   h e x   f o r m a t .  
 	 I n h e r i t s   m e t h o d s ,   p r o p e r t i e s ,   o p t i o n s   a n d   e v e n t s   f r o m   < F x . B a s e > .  
  
 A r g u m e n t s :  
 	 e l   -   t h e   $ ( e l e m e n t )   t o   a p p l y   t h e   s t y l e   t r a n s i t i o n   t o  
 	 p r o p e r t y   -   t h e   p r o p e r t y   t o   t r a n s i t i o n  
 	 o p t i o n s   -   t h e   F x . B a s e   o p t i o n s   ( s e e :   < F x . B a s e > )  
  
 E x a m p l e :  
 	 > v a r   m a r g i n C h a n g e   =   n e w   F x . S t y l e ( ' m y E l e m e n t ' ,   ' m a r g i n - t o p ' ,   { d u r a t i o n : 5 0 0 } ) ;  
 	 > m a r g i n C h a n g e . s t a r t ( 1 0 ,   1 0 0 ) ;  
 * /  
  
 F x . S t y l e   =   F x . B a s e . e x t e n d ( {  
  
 	 i n i t i a l i z e :   f u n c t i o n ( e l ,   p r o p e r t y ,   o p t i o n s ) {  
 	 	 t h i s . e l e m e n t   =   $ ( e l ) ;  
 	 	 t h i s . p r o p e r t y   =   p r o p e r t y ;  
 	 	 t h i s . p a r e n t ( o p t i o n s ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   h i d e  
 	 	 S a m e   a s   < F x . B a s e . s e t >   ( 0 ) ;   h i d e s   t h e   e l e m e n t   i m m e d i a t e l y   w i t h o u t   t r a n s i t i o n .  
 	 * /  
  
 	 h i d e :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s . s e t ( 0 ) ;  
 	 } ,  
  
 	 s e t N o w :   f u n c t i o n ( ) {  
 	 	 t h i s . n o w   =   t h i s . c s s . g e t N o w ( t h i s . f r o m ,   t h i s . t o ,   t h i s ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s e t  
 	 	 S e t s   t h e   e l e m e n t ' s   c s s   p r o p e r t y   ( s p e c i f i e d   a t   i n s t a n t i a t i o n )   t o   t h e   s p e c i f i e d   v a l u e   i m m e d i a t e l y .  
  
 	 E x a m p l e :  
 	 	 ( s t a r t   c o d e )  
 	 	 v a r   m a r g i n C h a n g e   =   n e w   F x . S t y l e ( ' m y E l e m e n t ' ,   ' m a r g i n - t o p ' ,   { d u r a t i o n : 5 0 0 } ) ;  
 	 	 m a r g i n C h a n g e . s e t ( 1 0 ) ;   / / m a r g i n - t o p   i s   s e t   t o   1 0 p x   i m m e d i a t e l y  
 	 	 ( e n d )  
 	 * /  
  
 	 s e t :   f u n c t i o n ( t o ) {  
 	 	 t h i s . c s s   =   F x . C S S . s e l e c t ( t h i s . p r o p e r t y ,   t o ) ;  
 	 	 r e t u r n   t h i s . p a r e n t ( t h i s . c s s . p a r s e ( t o ) ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s t a r t  
 	 	 D i s p l a y s   t h e   t r a n s i t i o n   t o   t h e   v a l u e / v a l u e s   p a s s e d   i n  
  
 	 A r g u m e n t s :  
 	 	 f r o m   -   ( i n t e g e r ;   o p t i o n a l )   t h e   s t a r t i n g   p o s i t i o n   f o r   t h e   t r a n s i t i o n  
 	 	 t o   -   ( i n t e g e r )   t h e   e n d i n g   p o s i t i o n   f o r   t h e   t r a n s i t i o n  
  
 	 N o t e :  
 	 	 I f   y o u   p r o v i d e   o n l y   o n e   a r g u m e n t ,   t h e   t r a n s i t i o n   w i l l   u s e   t h e   c u r r e n t   c s s   v a l u e   f o r   i t s   s t a r t i n g   v a l u e .  
  
 	 E x a m p l e :  
 	 	 ( s t a r t   c o d e )  
 	 	 v a r   m a r g i n C h a n g e   =   n e w   F x . S t y l e ( ' m y E l e m e n t ' ,   ' m a r g i n - t o p ' ,   { d u r a t i o n : 5 0 0 } ) ;  
 	 	 m a r g i n C h a n g e . s t a r t ( 1 0 ) ;   / / t r i e s   t o   r e a d   c u r r e n t   m a r g i n   t o p   v a l u e   a n d   g o e s   f r o m   c u r r e n t   t o   1 0  
 	 	 ( e n d )  
 	 * /  
  
 	 s t a r t :   f u n c t i o n ( f r o m ,   t o ) {  
 	 	 i f   ( t h i s . t i m e r   & &   t h i s . o p t i o n s . w a i t )   r e t u r n   t h i s ;  
 	 	 v a r   p a r s e d   =   F x . C S S . p a r s e ( t h i s . e l e m e n t ,   t h i s . p r o p e r t y ,   [ f r o m ,   t o ] ) ;  
 	 	 t h i s . c s s   =   p a r s e d . c s s ;  
 	 	 r e t u r n   t h i s . p a r e n t ( p a r s e d . f r o m ,   p a r s e d . t o ) ;  
 	 } ,  
  
 	 i n c r e a s e :   f u n c t i o n ( ) {  
 	 	 t h i s . e l e m e n t . s e t S t y l e ( t h i s . p r o p e r t y ,   t h i s . c s s . g e t V a l u e ( t h i s . n o w ,   t h i s . o p t i o n s . u n i t ,   t h i s . p r o p e r t y ) ) ;  
 	 }  
  
 } ) ;  
  
 / *  
 C l a s s :   E l e m e n t  
 	 C u s t o m   c l a s s   t o   a l l o w   a l l   o f   i t s   m e t h o d s   t o   b e   u s e d   w i t h   a n y   D O M   e l e m e n t   v i a   t h e   d o l l a r   f u n c t i o n   < $ > .  
 * /  
  
 E l e m e n t . e x t e n d ( {  
  
 	 / *  
 	 P r o p e r t y :   e f f e c t  
 	 	 A p p l i e s   a n   < F x . S t y l e >   t o   t h e   E l e m e n t ;   T h i s   a   s h o r t c u t   f o r   < F x . S t y l e > .  
  
 	 A r g u m e n t s :  
 	 	 p r o p e r t y   -   ( s t r i n g )   t h e   c s s   p r o p e r t y   t o   a l t e r  
 	 	 o p t i o n s   -   ( o b j e c t ;   o p t i o n a l )   k e y / v a l u e   s e t   o f   o p t i o n s   ( s e e   < F x . S t y l e > )  
  
 	 E x a m p l e :  
 	 	 > v a r   m y E f f e c t   =   $ ( ' m y E l e m e n t ' ) . e f f e c t ( ' h e i g h t ' ,   { d u r a t i o n :   1 0 0 0 ,   t r a n s i t i o n :   F x . T r a n s i t i o n s . l i n e a r } ) ;  
 	 	 > m y E f f e c t . s t a r t ( 1 0 ,   1 0 0 ) ;  
 	 	 > / / O R  
 	 	 > $ ( ' m y E l e m e n t ' ) . e f f e c t ( ' h e i g h t ' ,   { d u r a t i o n :   1 0 0 0 ,   t r a n s i t i o n :   F x . T r a n s i t i o n s . l i n e a r } ) . s t a r t ( 1 0 , 1 0 0 ) ;  
 	 * /  
  
 	 e f f e c t :   f u n c t i o n ( p r o p e r t y ,   o p t i o n s ) {  
 	 	 r e t u r n   n e w   F x . S t y l e ( t h i s ,   p r o p e r t y ,   o p t i o n s ) ;  
 	 }  
  
 } ) ;  
  
 / *  
 S c r i p t :   F x . S t y l e s . j s  
 	 C o n t a i n s   < F x . S t y l e s >  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   F x . S t y l e s  
 	 A l l o w s   y o u   t o   a n i m a t e   m u l t i p l e   c s s   p r o p e r t i e s   a t   o n c e ;  
 	 C o l o r s   m u s t   b e   i n   h e x   f o r m a t .  
 	 I n h e r i t s   m e t h o d s ,   p r o p e r t i e s ,   o p t i o n s   a n d   e v e n t s   f r o m   < F x . B a s e > .  
  
 A r g u m e n t s :  
 	 e l   -   t h e   $ ( e l e m e n t )   t o   a p p l y   t h e   s t y l e s   t r a n s i t i o n   t o  
 	 o p t i o n s   -   t h e   f x   o p t i o n s   ( s e e :   < F x . B a s e > )  
  
 E x a m p l e :  
 	 ( s t a r t   c o d e )  
 	 v a r   m y E f f e c t s   =   n e w   F x . S t y l e s ( ' m y E l e m e n t ' ,   { d u r a t i o n :   1 0 0 0 ,   t r a n s i t i o n :   F x . T r a n s i t i o n s . l i n e a r } ) ;  
  
 	 / / h e i g h t   f r o m   1 0   t o   1 0 0   a n d   w i d t h   f r o m   9 0 0   t o   3 0 0  
 	 m y E f f e c t s . s t a r t ( {  
 	 	 ' h e i g h t ' :   [ 1 0 ,   1 0 0 ] ,  
 	 	 ' w i d t h ' :   [ 9 0 0 ,   3 0 0 ]  
 	 } ) ;  
  
 	 / / o r   h e i g h t   f r o m   c u r r e n t   h e i g h t   t o   1 0 0   a n d   w i d t h   f r o m   c u r r e n t   w i d t h   t o   3 0 0  
 	 m y E f f e c t s . s t a r t ( {  
 	 	 ' h e i g h t ' :   1 0 0 ,  
 	 	 ' w i d t h ' :   3 0 0  
 	 } ) ;  
 	 ( e n d )  
 * /  
  
 F x . S t y l e s   =   F x . B a s e . e x t e n d ( {  
  
 	 i n i t i a l i z e :   f u n c t i o n ( e l ,   o p t i o n s ) {  
 	 	 t h i s . e l e m e n t   =   $ ( e l ) ;  
 	 	 t h i s . p a r e n t ( o p t i o n s ) ;  
 	 } ,  
  
 	 s e t N o w :   f u n c t i o n ( ) {  
 	 	 f o r   ( v a r   p   i n   t h i s . f r o m )   t h i s . n o w [ p ]   =   t h i s . c s s [ p ] . g e t N o w ( t h i s . f r o m [ p ] ,   t h i s . t o [ p ] ,   t h i s ) ;  
 	 } ,  
  
 	 s e t :   f u n c t i o n ( t o ) {  
 	 	 v a r   p a r s e d   =   { } ;  
 	 	 t h i s . c s s   =   { } ;  
 	 	 f o r   ( v a r   p   i n   t o ) {  
 	 	 	 t h i s . c s s [ p ]   =   F x . C S S . s e l e c t ( p ,   t o [ p ] ) ;  
 	 	 	 p a r s e d [ p ]   =   t h i s . c s s [ p ] . p a r s e ( t o [ p ] ) ;  
 	 	 }  
 	 	 r e t u r n   t h i s . p a r e n t ( p a r s e d ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s t a r t  
 	 	 E x e c u t e s   a   t r a n s i t i o n   f o r   a n y   n u m b e r   o f   c s s   p r o p e r t i e s   i n   t a n d e m .  
  
 	 A r g u m e n t s :  
 	 	 o b j   -   a n   o b j e c t   c o n t a i n i n g   k e y s   t h a t   s p e c i f y   c s s   p r o p e r t i e s   t o   a l t e r   a n d   v a l u e s   t h a t   s p e c i f y   e i t h e r   t h e   f r o m / t o   v a l u e s   ( a s   a n   a r r a y )   o r   j u s t   t h e   e n d   v a l u e   ( a n   i n t e g e r ) .  
  
 	 E x a m p l e :  
 	 	 s e e   < F x . S t y l e s >  
 	 * /  
  
 	 s t a r t :   f u n c t i o n ( o b j ) {  
 	 	 i f   ( t h i s . t i m e r   & &   t h i s . o p t i o n s . w a i t )   r e t u r n   t h i s ;  
 	 	 t h i s . n o w   =   { } ;  
 	 	 t h i s . c s s   =   { } ;  
 	 	 v a r   f r o m   =   { } ,   t o   =   { } ;  
 	 	 f o r   ( v a r   p   i n   o b j ) {  
 	 	 	 v a r   p a r s e d   =   F x . C S S . p a r s e ( t h i s . e l e m e n t ,   p ,   o b j [ p ] ) ;  
 	 	 	 f r o m [ p ]   =   p a r s e d . f r o m ;  
 	 	 	 t o [ p ]   =   p a r s e d . t o ;  
 	 	 	 t h i s . c s s [ p ]   =   p a r s e d . c s s ;  
 	 	 }  
 	 	 r e t u r n   t h i s . p a r e n t ( f r o m ,   t o ) ;  
 	 } ,  
  
 	 i n c r e a s e :   f u n c t i o n ( ) {  
 	 	 f o r   ( v a r   p   i n   t h i s . n o w )   t h i s . e l e m e n t . s e t S t y l e ( p ,   t h i s . c s s [ p ] . g e t V a l u e ( t h i s . n o w [ p ] ,   t h i s . o p t i o n s . u n i t ,   p ) ) ;  
 	 }  
  
 } ) ;  
  
 / *  
 C l a s s :   E l e m e n t  
 	 C u s t o m   c l a s s   t o   a l l o w   a l l   o f   i t s   m e t h o d s   t o   b e   u s e d   w i t h   a n y   D O M   e l e m e n t   v i a   t h e   d o l l a r   f u n c t i o n   < $ > .  
 * /  
  
 E l e m e n t . e x t e n d ( {  
  
 	 / *  
 	 P r o p e r t y :   e f f e c t s  
 	 	 A p p l i e s   a n   < F x . S t y l e s >   t o   t h e   E l e m e n t ;   T h i s   a   s h o r t c u t   f o r   < F x . S t y l e s > .  
  
 	 E x a m p l e :  
 	 	 > v a r   m y E f f e c t s   =   $ ( m y E l e m e n t ) . e f f e c t s ( { d u r a t i o n :   1 0 0 0 ,   t r a n s i t i o n :   F x . T r a n s i t i o n s . S i n e . e a s e I n O u t } ) ;  
   	 	 > m y E f f e c t s . s t a r t ( { ' h e i g h t ' :   [ 1 0 ,   1 0 0 ] ,   ' w i d t h ' :   [ 9 0 0 ,   3 0 0 ] } ) ;  
 	 * /  
  
 	 e f f e c t s :   f u n c t i o n ( o p t i o n s ) {  
 	 	 r e t u r n   n e w   F x . S t y l e s ( t h i s ,   o p t i o n s ) ;  
 	 }  
  
 } ) ;  
  
 / *  
 S c r i p t :   F x . E l e m e n t s . j s  
 	 C o n t a i n s   < F x . E l e m e n t s >  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   F x . E l e m e n t s  
 	 F x . E l e m e n t s   a l l o w s   y o u   t o   a p p l y   a n y   n u m b e r   o f   s t y l e s   t r a n s i t i o n s   t o   a   s e l e c t i o n   o f   e l e m e n t s .   I n c l u d e s   c o l o r s   ( m u s t   b e   i n   h e x   f o r m a t ) .  
 	 I n h e r i t s   m e t h o d s ,   p r o p e r t i e s ,   o p t i o n s   a n d   e v e n t s   f r o m   < F x . B a s e > .  
  
 A r g u m e n t s :  
 	 e l e m e n t s   -   a   c o l l e c t i o n   o f   e l e m e n t s   t h e   e f f e c t s   w i l l   b e   a p p l i e d   t o .  
 	 o p t i o n s   -   s a m e   a s   < F x . B a s e >   o p t i o n s .  
 * /  
  
 F x . E l e m e n t s   =   F x . B a s e . e x t e n d ( {  
  
 	 i n i t i a l i z e :   f u n c t i o n ( e l e m e n t s ,   o p t i o n s ) {  
 	 	 t h i s . e l e m e n t s   =   $ $ ( e l e m e n t s ) ;  
 	 	 t h i s . p a r e n t ( o p t i o n s ) ;  
 	 } ,  
  
 	 s e t N o w :   f u n c t i o n ( ) {  
 	 	 f o r   ( v a r   i   i n   t h i s . f r o m ) {  
 	 	 	 v a r   i F r o m   =   t h i s . f r o m [ i ] ,   i T o   =   t h i s . t o [ i ] ,   i C s s   =   t h i s . c s s [ i ] ,   i N o w   =   t h i s . n o w [ i ]   =   { } ;  
 	 	 	 f o r   ( v a r   p   i n   i F r o m )   i N o w [ p ]   =   i C s s [ p ] . g e t N o w ( i F r o m [ p ] ,   i T o [ p ] ,   t h i s ) ;  
 	 	 }  
 	 } ,  
  
 	 s e t :   f u n c t i o n ( t o ) {  
 	 	 v a r   p a r s e d   =   { } ;  
 	 	 t h i s . c s s   =   { } ;  
 	 	 f o r   ( v a r   i   i n   t o ) {  
 	 	 	 v a r   i T o   =   t o [ i ] ,   i C s s   =   t h i s . c s s [ i ]   =   { } ,   i P a r s e d   =   p a r s e d [ i ]   =   { } ;  
 	 	 	 f o r   ( v a r   p   i n   i T o ) {  
 	 	 	 	 i C s s [ p ]   =   F x . C S S . s e l e c t ( p ,   i T o [ p ] ) ;  
 	 	 	 	 i P a r s e d [ p ]   =   i C s s [ p ] . p a r s e ( i T o [ p ] ) ;  
 	 	 	 }  
 	 	 }  
 	 	 r e t u r n   t h i s . p a r e n t ( p a r s e d ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s t a r t  
 	 	 A p p l i e s   t h e   p a s s e d   i n   s t y l e   t r a n s i t i o n s   t o   e a c h   o b j e c t   n a m e d   ( s e e   e x a m p l e ) .   E a c h   i t e m   i n   t h e   c o l l e c t i o n   i s   r e f e r e d   t o   a s   a   n u m e r i c a l   s t r i n g   ( " 1 "   f o r   i n s t a n c e ) .   T h e   f i r s t   i t e m   i s   " 0 " ,   t h e   s e c o n d   " 1 " ,   e t c .  
  
 	 E x a m p l e :  
 	 	 ( s t a r t   c o d e )  
 	 	 v a r   m y E l e m e n t s E f f e c t s   =   n e w   F x . E l e m e n t s ( $ $ ( ' a ' ) ) ;  
 	 	 m y E l e m e n t s E f f e c t s . s t a r t ( {  
 	 	 	 ' 0 ' :   {   / / l e t ' s   c h a n g e   t h e   f i r s t   e l e m e n t ' s   o p a c i t y   a n d   w i d t h  
 	 	 	 	 ' o p a c i t y ' :   [ 0 , 1 ] ,  
 	 	 	 	 ' w i d t h ' :   [ 1 0 0 , 2 0 0 ]  
 	 	 	 } ,  
 	 	 	 ' 4 ' :   {   / / a n d   t h e   f i f t h   o n e ' s   o p a c i t y  
 	 	 	 	 ' o p a c i t y ' :   [ 0 . 2 ,   0 . 5 ]  
 	 	 	 }  
 	 	 } ) ;  
 	 	 ( e n d )  
 	 * /  
  
 	 s t a r t :   f u n c t i o n ( o b j ) {  
 	 	 i f   ( t h i s . t i m e r   & &   t h i s . o p t i o n s . w a i t )   r e t u r n   t h i s ;  
 	 	 t h i s . n o w   =   { } ;  
 	 	 t h i s . c s s   =   { } ;  
 	 	 v a r   f r o m   =   { } ,   t o   =   { } ;  
 	 	 f o r   ( v a r   i   i n   o b j ) {  
 	 	 	 v a r   i P r o p s   =   o b j [ i ] ,   i F r o m   =   f r o m [ i ]   =   { } ,   i T o   =   t o [ i ]   =   { } ,   i C s s   =   t h i s . c s s [ i ]   =   { } ;  
 	 	 	 f o r   ( v a r   p   i n   i P r o p s ) {  
 	 	 	 	 v a r   p a r s e d   =   F x . C S S . p a r s e ( t h i s . e l e m e n t s [ i ] ,   p ,   i P r o p s [ p ] ) ;  
 	 	 	 	 i F r o m [ p ]   =   p a r s e d . f r o m ;  
 	 	 	 	 i T o [ p ]   =   p a r s e d . t o ;  
 	 	 	 	 i C s s [ p ]   =   p a r s e d . c s s ;  
 	 	 	 }  
 	 	 }  
 	 	 r e t u r n   t h i s . p a r e n t ( f r o m ,   t o ) ;  
 	 } ,  
  
 	 i n c r e a s e :   f u n c t i o n ( ) {  
 	 	 f o r   ( v a r   i   i n   t h i s . n o w ) {  
 	 	 	 v a r   i N o w   =   t h i s . n o w [ i ] ,   i C s s   =   t h i s . c s s [ i ] ;  
 	 	 	 f o r   ( v a r   p   i n   i N o w )   t h i s . e l e m e n t s [ i ] . s e t S t y l e ( p ,   i C s s [ p ] . g e t V a l u e ( i N o w [ p ] ,   t h i s . o p t i o n s . u n i t ,   p ) ) ;  
 	 	 }  
 	 }  
  
 } ) ;  
  
 / *  
 S c r i p t :   F x . S c r o l l . j s  
 	 C o n t a i n s   < F x . S c r o l l >  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   F x . S c r o l l  
 	 S c r o l l   a n y   e l e m e n t   w i t h   a n   o v e r f l o w ,   i n c l u d i n g   t h e   w i n d o w   e l e m e n t .  
 	 I n h e r i t s   m e t h o d s ,   p r o p e r t i e s ,   o p t i o n s   a n d   e v e n t s   f r o m   < F x . B a s e > .  
  
 N o t e :  
 	 F x . S c r o l l   r e q u i r e s   a n   X H T M L   d o c t y p e .  
  
 A r g u m e n t s :  
 	 e l e m e n t   -   t h e   e l e m e n t   t o   s c r o l l  
 	 o p t i o n s   -   o p t i o n a l ,   s e e   O p t i o n s   b e l o w .  
  
 O p t i o n s :  
 	 a l l   t h e   F x . B a s e   o p t i o n s   a n d   e v e n t s ,   p l u s :  
 	 o f f s e t   -   t h e   d i s t a n c e   f o r   t h e   s c r o l l T o   p o i n t / e l e m e n t .   a n   O b j e c t   w i t h   x / y   p r o p e r t i e s .  
 	 o v e r f l o w n   -   a n   a r r a y   o f   n e s t e d   s c r o l l i n g   c o n t a i n e r s ,   s e e   < E l e m e n t . g e t P o s i t i o n >  
 * /  
  
 F x . S c r o l l   =   F x . B a s e . e x t e n d ( {  
  
 	 o p t i o n s :   {  
 	 	 o v e r f l o w n :   [ ] ,  
 	 	 o f f s e t :   { ' x ' :   0 ,   ' y ' :   0 } ,  
 	 	 w h e e l S t o p s :   t r u e  
 	 } ,  
  
 	 i n i t i a l i z e :   f u n c t i o n ( e l e m e n t ,   o p t i o n s ) {  
 	 	 t h i s . n o w   =   [ ] ;  
 	 	 t h i s . e l e m e n t   =   $ ( e l e m e n t ) ;  
 	 	 t h i s . b o u n d   =   { ' s t o p ' :   t h i s . s t o p . b i n d ( t h i s ,   f a l s e ) } ;  
 	 	 t h i s . p a r e n t ( o p t i o n s ) ;  
 	 	 i f   ( t h i s . o p t i o n s . w h e e l S t o p s ) {  
 	 	 	 t h i s . a d d E v e n t ( ' o n S t a r t ' ,   f u n c t i o n ( ) {  
 	 	 	 	 d o c u m e n t . a d d E v e n t ( ' m o u s e w h e e l ' ,   t h i s . b o u n d . s t o p ) ;  
 	 	 	 } . b i n d ( t h i s ) ) ;  
 	 	 	 t h i s . a d d E v e n t ( ' o n C o m p l e t e ' ,   f u n c t i o n ( ) {  
 	 	 	 	 d o c u m e n t . r e m o v e E v e n t ( ' m o u s e w h e e l ' ,   t h i s . b o u n d . s t o p ) ;  
 	 	 	 } . b i n d ( t h i s ) ) ;  
 	 	 }  
 	 } ,  
  
 	 s e t N o w :   f u n c t i o n ( ) {  
 	 	 f o r   ( v a r   i   =   0 ;   i   <   2 ;   i + + )   t h i s . n o w [ i ]   =   t h i s . c o m p u t e ( t h i s . f r o m [ i ] ,   t h i s . t o [ i ] ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s c r o l l T o  
 	 	 S c r o l l s   t h e   c h o s e n   e l e m e n t   t o   t h e   x / y   c o o r d i n a t e s .  
  
 	 A r g u m e n t s :  
 	 	 x   -   t h e   x   c o o r d i n a t e   t o   s c r o l l   t h e   e l e m e n t   t o  
 	 	 y   -   t h e   y   c o o r d i n a t e   t o   s c r o l l   t h e   e l e m e n t   t o  
 	 * /  
  
 	 s c r o l l T o :   f u n c t i o n ( x ,   y ) {  
 	 	 i f   ( t h i s . t i m e r   & &   t h i s . o p t i o n s . w a i t )   r e t u r n   t h i s ;  
 	 	 v a r   e l   =   t h i s . e l e m e n t . g e t S i z e ( ) ;  
 	 	 v a r   v a l u e s   =   { ' x ' :   x ,   ' y ' :   y } ;  
 	 	 f o r   ( v a r   z   i n   e l . s i z e ) {  
 	 	 	 v a r   m a x   =   e l . s c r o l l S i z e [ z ]   -   e l . s i z e [ z ] ;  
 	 	 	 i f   ( $ c h k ( v a l u e s [ z ] ) )   v a l u e s [ z ]   =   ( $ t y p e ( v a l u e s [ z ] )   = =   ' n u m b e r ' )   ?   v a l u e s [ z ] . l i m i t ( 0 ,   m a x )   :   m a x ;  
 	 	 	 e l s e   v a l u e s [ z ]   =   e l . s c r o l l [ z ] ;  
 	 	 	 v a l u e s [ z ]   + =   t h i s . o p t i o n s . o f f s e t [ z ] ;  
 	 	 }  
 	 	 r e t u r n   t h i s . s t a r t ( [ e l . s c r o l l . x ,   e l . s c r o l l . y ] ,   [ v a l u e s . x ,   v a l u e s . y ] ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   t o T o p  
 	 	 S c r o l l s   t h e   c h o s e n   e l e m e n t   t o   i t s   m a x i m u m   t o p .  
 	 * /  
  
 	 t o T o p :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s . s c r o l l T o ( f a l s e ,   0 ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   t o B o t t o m  
 	 	 S c r o l l s   t h e   c h o s e n   e l e m e n t   t o   i t s   m a x i m u m   b o t t o m .  
 	 * /  
  
 	 t o B o t t o m :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s . s c r o l l T o ( f a l s e ,   ' f u l l ' ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   t o L e f t  
 	 	 S c r o l l s   t h e   c h o s e n   e l e m e n t   t o   i t s   m a x i m u m   l e f t .  
 	 * /  
  
 	 t o L e f t :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s . s c r o l l T o ( 0 ,   f a l s e ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   t o R i g h t  
 	 	 S c r o l l s   t h e   c h o s e n   e l e m e n t   t o   i t s   m a x i m u m   r i g h t .  
 	 * /  
  
 	 t o R i g h t :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s . s c r o l l T o ( ' f u l l ' ,   f a l s e ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   t o E l e m e n t  
 	 	 S c r o l l s   t h e   s p e c i f i e d   e l e m e n t   t o   t h e   p o s i t i o n   t h e   p a s s e d   i n   e l e m e n t   i s   f o u n d .  
  
 	 A r g u m e n t s :  
 	 	 e l   -   t h e   $ ( e l e m e n t )   t o   s c r o l l   t h e   w i n d o w   t o  
 	 * /  
  
 	 t o E l e m e n t :   f u n c t i o n ( e l ) {  
 	 	 v a r   p a r e n t   =   t h i s . e l e m e n t . g e t P o s i t i o n ( t h i s . o p t i o n s . o v e r f l o w n ) ;  
 	 	 v a r   t a r g e t   =   $ ( e l ) . g e t P o s i t i o n ( t h i s . o p t i o n s . o v e r f l o w n ) ;  
 	 	 r e t u r n   t h i s . s c r o l l T o ( t a r g e t . x   -   p a r e n t . x ,   t a r g e t . y   -   p a r e n t . y ) ;  
 	 } ,  
  
 	 i n c r e a s e :   f u n c t i o n ( ) {  
 	 	 t h i s . e l e m e n t . s c r o l l T o ( t h i s . n o w [ 0 ] ,   t h i s . n o w [ 1 ] ) ;  
 	 }  
  
 } ) ;  
  
 / *  
 S c r i p t :   F x . S l i d e . j s  
 	 C o n t a i n s   < F x . S l i d e >  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   F x . S l i d e  
 	 T h e   s l i d e   e f f e c t ;   s l i d e s   a n   e l e m e n t   i n   h o r i z o n t a l l y   o r   v e r t i c a l l y ,   t h e   c o n t e n t s   w i l l   f o l d   i n s i d e .  
 	 I n h e r i t s   m e t h o d s ,   p r o p e r t i e s ,   o p t i o n s   a n d   e v e n t s   f r o m   < F x . B a s e > .  
 	  
 N o t e :  
 	 F x . S l i d e   r e q u i r e s   a n   X H T M L   d o c t y p e .  
  
 O p t i o n s :  
 	 m o d e   -   s e t   i t   t o   v e r t i c a l   o r   h o r i z o n t a l .   D e f a u l t s   t o   v e r t i c a l .  
 	 o p t i o n s   -   a l l   t h e   < F x . B a s e >   o p t i o n s  
  
 E x a m p l e :  
 	 ( s t a r t   c o d e )  
 	 v a r   m y S l i d e r   =   n e w   F x . S l i d e ( ' m y E l e m e n t ' ,   { d u r a t i o n :   5 0 0 } ) ;  
 	 m y S l i d e r . t o g g l e ( )   / / t o g g l e   t h e   s l i d e r   u p   a n d   d o w n .  
 	 ( e n d )  
 * /  
  
 F x . S l i d e   =   F x . B a s e . e x t e n d ( {  
  
 	 o p t i o n s :   {  
 	 	 m o d e :   ' v e r t i c a l '  
 	 } ,  
  
 	 i n i t i a l i z e :   f u n c t i o n ( e l ,   o p t i o n s ) {  
 	 	 t h i s . e l e m e n t   =   $ ( e l ) ;  
 	 	 t h i s . w r a p p e r   =   n e w   E l e m e n t ( ' d i v ' ,   { ' s t y l e s ' :   $ e x t e n d ( t h i s . e l e m e n t . g e t S t y l e s ( ' m a r g i n ' ) ,   { ' o v e r f l o w ' :   ' h i d d e n ' } ) } ) . i n j e c t A f t e r ( t h i s . e l e m e n t ) . a d o p t ( t h i s . e l e m e n t ) ;  
 	 	 t h i s . e l e m e n t . s e t S t y l e ( ' m a r g i n ' ,   0 ) ;  
 	 	 t h i s . s e t O p t i o n s ( o p t i o n s ) ;  
 	 	 t h i s . n o w   =   [ ] ;  
 	 	 t h i s . p a r e n t ( t h i s . o p t i o n s ) ;  
 	 	 t h i s . o p e n   =   t r u e ;  
 	 	 t h i s . a d d E v e n t ( ' o n C o m p l e t e ' ,   f u n c t i o n ( ) {  
 	 	 	 t h i s . o p e n   =   ( t h i s . n o w [ 0 ]   = = =   0 ) ;  
 	 	 } ) ;  
 	 	 i f   ( w i n d o w . w e b k i t 4 1 9 )   t h i s . a d d E v e n t ( ' o n C o m p l e t e ' ,   f u n c t i o n ( ) {  
 	 	 	 i f   ( t h i s . o p e n )   t h i s . e l e m e n t . r e m o v e ( ) . i n j e c t ( t h i s . w r a p p e r ) ;  
 	 	 } ) ;  
 	 } ,  
  
 	 s e t N o w :   f u n c t i o n ( ) {  
 	 	 f o r   ( v a r   i   =   0 ;   i   <   2 ;   i + + )   t h i s . n o w [ i ]   =   t h i s . c o m p u t e ( t h i s . f r o m [ i ] ,   t h i s . t o [ i ] ) ;  
 	 } ,  
  
 	 v e r t i c a l :   f u n c t i o n ( ) {  
 	 	 t h i s . m a r g i n   =   ' m a r g i n - t o p ' ;  
 	 	 t h i s . l a y o u t   =   ' h e i g h t ' ;  
 	 	 t h i s . o f f s e t   =   t h i s . e l e m e n t . o f f s e t H e i g h t ;  
 	 } ,  
  
 	 h o r i z o n t a l :   f u n c t i o n ( ) {  
 	 	 t h i s . m a r g i n   =   ' m a r g i n - l e f t ' ;  
 	 	 t h i s . l a y o u t   =   ' w i d t h ' ;  
 	 	 t h i s . o f f s e t   =   t h i s . e l e m e n t . o f f s e t W i d t h ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s l i d e I n  
 	 	 S l i d e s   t h e   e l e m e n t s   i n   v i e w   h o r i z o n t a l l y   o r   v e r t i c a l l y .  
  
 	 A r g u m e n t s :  
 	 	 m o d e   -   ( o p t i o n a l ,   s t r i n g )   ' h o r i z o n t a l '   o r   ' v e r t i c a l ' ;   d e f a u l t s   t o   o p t i o n s . m o d e .  
 	 * /  
  
 	 s l i d e I n :   f u n c t i o n ( m o d e ) {  
 	 	 t h i s [ m o d e   | |   t h i s . o p t i o n s . m o d e ] ( ) ;  
 	 	 r e t u r n   t h i s . s t a r t ( [ t h i s . e l e m e n t . g e t S t y l e ( t h i s . m a r g i n ) . t o I n t ( ) ,   t h i s . w r a p p e r . g e t S t y l e ( t h i s . l a y o u t ) . t o I n t ( ) ] ,   [ 0 ,   t h i s . o f f s e t ] ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s l i d e O u t  
 	 	 S i d e s   t h e   e l e m e n t s   o u t   o f   v i e w   h o r i z o n t a l l y   o r   v e r t i c a l l y .  
  
 	 A r g u m e n t s :  
 	 	 m o d e   -   ( o p t i o n a l ,   s t r i n g )   ' h o r i z o n t a l '   o r   ' v e r t i c a l ' ;   d e f a u l t s   t o   o p t i o n s . m o d e .  
 	 * /  
  
 	 s l i d e O u t :   f u n c t i o n ( m o d e ) {  
 	 	 t h i s [ m o d e   | |   t h i s . o p t i o n s . m o d e ] ( ) ;  
 	 	 r e t u r n   t h i s . s t a r t ( [ t h i s . e l e m e n t . g e t S t y l e ( t h i s . m a r g i n ) . t o I n t ( ) ,   t h i s . w r a p p e r . g e t S t y l e ( t h i s . l a y o u t ) . t o I n t ( ) ] ,   [ - t h i s . o f f s e t ,   0 ] ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   h i d e  
 	 	 H i d e s   t h e   e l e m e n t   w i t h o u t   a   t r a n s i t i o n .  
  
 	 A r g u m e n t s :  
 	 	 m o d e   -   ( o p t i o n a l ,   s t r i n g )   ' h o r i z o n t a l '   o r   ' v e r t i c a l ' ;   d e f a u l t s   t o   o p t i o n s . m o d e .  
 	 * /  
  
 	 h i d e :   f u n c t i o n ( m o d e ) {  
 	 	 t h i s [ m o d e   | |   t h i s . o p t i o n s . m o d e ] ( ) ;  
 	 	 t h i s . o p e n   =   f a l s e ;  
 	 	 r e t u r n   t h i s . s e t ( [ - t h i s . o f f s e t ,   0 ] ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s h o w  
 	 	 S h o w s   t h e   e l e m e n t   w i t h o u t   a   t r a n s i t i o n .  
  
 	 A r g u m e n t s :  
 	 	 m o d e   -   ( o p t i o n a l ,   s t r i n g )   ' h o r i z o n t a l '   o r   ' v e r t i c a l ' ;   d e f a u l t s   t o   o p t i o n s . m o d e .  
 	 * /  
  
 	 s h o w :   f u n c t i o n ( m o d e ) {  
 	 	 t h i s [ m o d e   | |   t h i s . o p t i o n s . m o d e ] ( ) ;  
 	 	 t h i s . o p e n   =   t r u e ;  
 	 	 r e t u r n   t h i s . s e t ( [ 0 ,   t h i s . o f f s e t ] ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   t o g g l e  
 	 	 S l i d e s   i n   o r   O u t   t h e   e l e m e n t ,   d e p e n d i n g   o n   i t s   s t a t e  
  
 	 A r g u m e n t s :  
 	 	 m o d e   -   ( o p t i o n a l ,   s t r i n g )   ' h o r i z o n t a l '   o r   ' v e r t i c a l ' ;   d e f a u l t s   t o   o p t i o n s . m o d e .  
  
 	 * /  
  
 	 t o g g l e :   f u n c t i o n ( m o d e ) {  
 	 	 i f   ( t h i s . w r a p p e r . o f f s e t H e i g h t   = =   0   | |   t h i s . w r a p p e r . o f f s e t W i d t h   = =   0 )   r e t u r n   t h i s . s l i d e I n ( m o d e ) ;  
 	 	 r e t u r n   t h i s . s l i d e O u t ( m o d e ) ;  
 	 } ,  
  
 	 i n c r e a s e :   f u n c t i o n ( ) {  
 	 	 t h i s . e l e m e n t . s e t S t y l e ( t h i s . m a r g i n ,   t h i s . n o w [ 0 ]   +   t h i s . o p t i o n s . u n i t ) ;  
 	 	 t h i s . w r a p p e r . s e t S t y l e ( t h i s . l a y o u t ,   t h i s . n o w [ 1 ]   +   t h i s . o p t i o n s . u n i t ) ;  
 	 }  
  
 } ) ;  
  
 / *  
 S c r i p t :   F x . T r a n s i t i o n s . j s  
 	 E f f e c t s   t r a n s i t i o n s ,   t o   b e   u s e d   w i t h   a l l   t h e   e f f e c t s .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
  
 C r e d i t s :  
 	 E a s i n g   E q u a t i o n s   b y   R o b e r t   P e n n e r ,   < h t t p : / / w w w . r o b e r t p e n n e r . c o m / e a s i n g / > ,   m o d i f i e d   &   o p t i m i z e d   t o   b e   u s e d   w i t h   m o o t o o l s .  
 * /  
  
 / *  
 C l a s s :   F x . T r a n s i t i o n s  
 	 A   c o l l e c t i o n   o f   t w e e n i n g   t r a n s i t i o n s   f o r   u s e   w i t h   t h e   < F x . B a s e >   c l a s s e s .  
  
 E x a m p l e :  
 	 > / / E l a s t i c . e a s e O u t   w i t h   d e f a u l t   v a l u e s :  
 	 > n e w   F x . S t y l e ( ' m a r g i n ' ,   { t r a n s i t i o n :   F x . T r a n s i t i o n s . E l a s t i c . e a s e O u t } ) ;  
 	 > / / E l a s t i c . e a s e O u t   w i t h   u s e r - d e f i n e d   v a l u e   f o r   e l a s t i c i t y .  
 	 >   v a r   m y T r a n s i t i o n   =   n e w   F x . T r a n s i t i o n ( F x . T r a n s i t i o n s . E l a s t i c ,   3 ) ;  
 	 > n e w   F x . S t y l e ( ' m a r g i n ' ,   { t r a n s i t i o n :   m y T r a n s i t i o n . e a s e O u t } ) ;  
  
 S e e   a l s o :  
 	 h t t p : / / w w w . r o b e r t p e n n e r . c o m / e a s i n g /  
 * /  
  
 F x . T r a n s i t i o n   =   f u n c t i o n ( t r a n s i t i o n ,   p a r a m s ) {  
 	 p a r a m s   =   p a r a m s   | |   [ ] ;  
 	 i f   ( $ t y p e ( p a r a m s )   ! =   ' a r r a y ' )   p a r a m s   =   [ p a r a m s ] ;  
 	 r e t u r n   $ e x t e n d ( t r a n s i t i o n ,   {  
 	 	 e a s e I n :   f u n c t i o n ( p o s ) {  
 	 	 	 r e t u r n   t r a n s i t i o n ( p o s ,   p a r a m s ) ;  
 	 	 } ,  
 	 	 e a s e O u t :   f u n c t i o n ( p o s ) {  
 	 	 	 r e t u r n   1   -   t r a n s i t i o n ( 1   -   p o s ,   p a r a m s ) ;  
 	 	 } ,  
 	 	 e a s e I n O u t :   f u n c t i o n ( p o s ) {  
 	 	 	 r e t u r n   ( p o s   < =   0 . 5 )   ?   t r a n s i t i o n ( 2   *   p o s ,   p a r a m s )   /   2   :   ( 2   -   t r a n s i t i o n ( 2   *   ( 1   -   p o s ) ,   p a r a m s ) )   /   2 ;  
 	 	 }  
 	 } ) ;  
 } ;  
  
 F x . T r a n s i t i o n s   =   n e w   A b s t r a c t ( {  
  
 	 / *  
 	 P r o p e r t y :   l i n e a r  
 	 	 d i s p l a y s   a   l i n e a r   t r a n s i t i o n .  
  
 	 G r a p h :  
 	 	 ( s e e   L i n e a r . p n g )  
 	 * /  
  
 	 l i n e a r :   f u n c t i o n ( p ) {  
 	 	 r e t u r n   p ;  
 	 }  
  
 } ) ;  
  
 F x . T r a n s i t i o n s . e x t e n d   =   f u n c t i o n ( t r a n s i t i o n s ) {  
 	 f o r   ( v a r   t r a n s i t i o n   i n   t r a n s i t i o n s ) {  
 	 	 F x . T r a n s i t i o n s [ t r a n s i t i o n ]   =   n e w   F x . T r a n s i t i o n ( t r a n s i t i o n s [ t r a n s i t i o n ] ) ;  
 	 	 / * c o m p a t i b i l i t y * /  
 	 	 F x . T r a n s i t i o n s . c o m p a t ( t r a n s i t i o n ) ;  
 	 	 / * e n d   c o m p a t i b i l i t y * /  
 	 }  
 } ;  
  
 / * c o m p a t i b i l i t y * /  
  
 F x . T r a n s i t i o n s . c o m p a t   =   f u n c t i o n ( t r a n s i t i o n ) {  
 	 [ ' I n ' ,   ' O u t ' ,   ' I n O u t ' ] . e a c h ( f u n c t i o n ( e a s e T y p e ) {  
 	 	 F x . T r a n s i t i o n s [ t r a n s i t i o n . t o L o w e r C a s e ( )   +   e a s e T y p e ]   =   F x . T r a n s i t i o n s [ t r a n s i t i o n ] [ ' e a s e '   +   e a s e T y p e ] ;  
 	 } ) ;  
 } ;  
  
 / * e n d   c o m p a t i b i l i t y * /  
  
 F x . T r a n s i t i o n s . e x t e n d ( {  
  
 	 / *  
 	 P r o p e r t y :   Q u a d  
 	 	 d i s p l a y s   a   q u a d r a t i c   t r a n s i t i o n .   M u s t   b e   u s e d   a s   Q u a d . e a s e I n   o r   Q u a d . e a s e O u t   o r   Q u a d . e a s e I n O u t  
  
 	 G r a p h :  
 	 	 ( s e e   Q u a d . p n g )  
 	 * /  
  
 	 / / a u t o   g e n e r a t e d  
  
 	 / *  
 	 P r o p e r t y :   C u b i c  
 	 	 d i s p l a y s   a   c u b i c u l a r   t r a n s i t i o n .   M u s t   b e   u s e d   a s   C u b i c . e a s e I n   o r   C u b i c . e a s e O u t   o r   C u b i c . e a s e I n O u t  
  
 	 G r a p h :  
 	 	 ( s e e   C u b i c . p n g )  
 	 * /  
  
 	 / / a u t o   g e n e r a t e d  
  
 	 / *  
 	 P r o p e r t y :   Q u a r t  
 	 	 d i s p l a y s   a   q u a r t e t i c   t r a n s i t i o n .   M u s t   b e   u s e d   a s   Q u a r t . e a s e I n   o r   Q u a r t . e a s e O u t   o r   Q u a r t . e a s e I n O u t  
  
 	 G r a p h :  
 	 	 ( s e e   Q u a r t . p n g )  
 	 * /  
  
 	 / / a u t o   g e n e r a t e d  
  
 	 / *  
 	 P r o p e r t y :   Q u i n t  
 	 	 d i s p l a y s   a   q u i n t i c   t r a n s i t i o n .   M u s t   b e   u s e d   a s   Q u i n t . e a s e I n   o r   Q u i n t . e a s e O u t   o r   Q u i n t . e a s e I n O u t  
  
 	 G r a p h :  
 	 	 ( s e e   Q u i n t . p n g )  
 	 * /  
  
 	 / / a u t o   g e n e r a t e d  
  
 	 / *  
 	 P r o p e r t y :   P o w  
 	 	 U s e d   t o   g e n e r a t e   Q u a d ,   C u b i c ,   Q u a r t   a n d   Q u i n t .  
 	 	 B y   d e f a u l t   i s   p ^ 6 .  
  
 	 G r a p h :  
 	 	 ( s e e   P o w . p n g )  
 	 * /  
  
 	 P o w :   f u n c t i o n ( p ,   x ) {  
 	 	 r e t u r n   M a t h . p o w ( p ,   x [ 0 ]   | |   6 ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   E x p o  
 	 	 d i s p l a y s   a   e x p o n e n t i a l   t r a n s i t i o n .   M u s t   b e   u s e d   a s   E x p o . e a s e I n   o r   E x p o . e a s e O u t   o r   E x p o . e a s e I n O u t  
  
 	 G r a p h :  
 	 	 ( s e e   E x p o . p n g )  
 	 * /  
  
 	 E x p o :   f u n c t i o n ( p ) {  
 	 	 r e t u r n   M a t h . p o w ( 2 ,   8   *   ( p   -   1 ) ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   C i r c  
 	 	 d i s p l a y s   a   c i r c u l a r   t r a n s i t i o n .   M u s t   b e   u s e d   a s   C i r c . e a s e I n   o r   C i r c . e a s e O u t   o r   C i r c . e a s e I n O u t  
  
 	 G r a p h :  
 	 	 ( s e e   C i r c . p n g )  
 	 * /  
  
 	 C i r c :   f u n c t i o n ( p ) {  
 	 	 r e t u r n   1   -   M a t h . s i n ( M a t h . a c o s ( p ) ) ;  
 	 } ,  
  
  
 	 / *  
 	 P r o p e r t y :   S i n e  
 	 	 d i s p l a y s   a   s i n e o u s i d a l   t r a n s i t i o n .   M u s t   b e   u s e d   a s   S i n e . e a s e I n   o r   S i n e . e a s e O u t   o r   S i n e . e a s e I n O u t  
  
 	 G r a p h :  
 	 	 ( s e e   S i n e . p n g )  
 	 * /  
  
 	 S i n e :   f u n c t i o n ( p ) {  
 	 	 r e t u r n   1   -   M a t h . s i n ( ( 1   -   p )   *   M a t h . P I   /   2 ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   B a c k  
 	 	 m a k e s   t h e   t r a n s i t i o n   g o   b a c k ,   t h e n   a l l   f o r t h .   M u s t   b e   u s e d   a s   B a c k . e a s e I n   o r   B a c k . e a s e O u t   o r   B a c k . e a s e I n O u t  
  
 	 G r a p h :  
 	 	 ( s e e   B a c k . p n g )  
 	 * /  
  
 	 B a c k :   f u n c t i o n ( p ,   x ) {  
 	 	 x   =   x [ 0 ]   | |   1 . 6 1 8 ;  
 	 	 r e t u r n   M a t h . p o w ( p ,   2 )   *   ( ( x   +   1 )   *   p   -   x ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   B o u n c e  
 	 	 m a k e s   t h e   t r a n s i t i o n   b o u n c y .   M u s t   b e   u s e d   a s   B o u n c e . e a s e I n   o r   B o u n c e . e a s e O u t   o r   B o u n c e . e a s e I n O u t  
  
 	 G r a p h :  
 	 	 ( s e e   B o u n c e . p n g )  
 	 * /  
  
 	 B o u n c e :   f u n c t i o n ( p ) {  
 	 	 v a r   v a l u e ;  
 	 	 f o r   ( v a r   a   =   0 ,   b   =   1 ;   1 ;   a   + =   b ,   b   / =   2 ) {  
 	 	 	 i f   ( p   > =   ( 7   -   4   *   a )   /   1 1 ) {  
 	 	 	 	 v a l u e   =   -   M a t h . p o w ( ( 1 1   -   6   *   a   -   1 1   *   p )   /   4 ,   2 )   +   b   *   b ;  
 	 	 	 	 b r e a k ;  
 	 	 	 }  
 	 	 }  
 	 	 r e t u r n   v a l u e ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   E l a s t i c  
 	 	 E l a s t i c   c u r v e .   M u s t   b e   u s e d   a s   E l a s t i c . e a s e I n   o r   E l a s t i c . e a s e O u t   o r   E l a s t i c . e a s e I n O u t  
  
 	 G r a p h :  
 	 	 ( s e e   E l a s t i c . p n g )  
 	 * /  
  
 	 E l a s t i c :   f u n c t i o n ( p ,   x ) {  
 	 	 r e t u r n   M a t h . p o w ( 2 ,   1 0   *   - - p )   *   M a t h . c o s ( 2 0   *   p   *   M a t h . P I   *   ( x [ 0 ]   | |   1 )   /   3 ) ;  
 	 }  
  
 } ) ;  
  
 [ ' Q u a d ' ,   ' C u b i c ' ,   ' Q u a r t ' ,   ' Q u i n t ' ] . e a c h ( f u n c t i o n ( t r a n s i t i o n ,   i ) {  
 	 F x . T r a n s i t i o n s [ t r a n s i t i o n ]   =   n e w   F x . T r a n s i t i o n ( f u n c t i o n ( p ) {  
 	 	 r e t u r n   M a t h . p o w ( p ,   [ i   +   2 ] ) ;  
 	 } ) ;  
 	  
 	 / * c o m p a t i b i l i t y * /  
 	 F x . T r a n s i t i o n s . c o m p a t ( t r a n s i t i o n ) ;  
 	 / * e n d   c o m p a t i b i l i t y * /  
 } ) ;  
  
 / *  
 S c r i p t :   D r a g . B a s e . j s  
 	 C o n t a i n s   < D r a g . B a s e > ,   < E l e m e n t . m a k e R e s i z a b l e >  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 v a r   D r a g   =   { } ;  
  
 / *  
 C l a s s :   D r a g . B a s e  
 	 M o d i f y   t w o   c s s   p r o p e r t i e s   o f   a n   e l e m e n t   b a s e d   o n   t h e   p o s i t i o n   o f   t h e   m o u s e .  
 	  
 N o t e :  
 	 D r a g . B a s e   r e q u i r e s   a n   X H T M L   d o c t y p e .  
  
 A r g u m e n t s :  
 	 e l   -   t h e   $ ( e l e m e n t )   t o   a p p l y   t h e   t r a n s f o r m a t i o n s   t o .  
 	 o p t i o n s   -   o p t i o n a l .   T h e   o p t i o n s   o b j e c t .  
  
 O p t i o n s :  
 	 h a n d l e   -   t h e   $ ( e l e m e n t )   t o   a c t   a s   t h e   h a n d l e   f o r   t h e   d r a g g a b l e   e l e m e n t .   d e f a u l t s   t o   t h e   $ ( e l e m e n t )   i t s e l f .  
 	 m o d i f i e r s   -   a n   o b j e c t .   s e e   M o d i f i e r s   B e l o w .  
 	 l i m i t   -   a n   o b j e c t ,   s e e   L i m i t   b e l o w .  
 	 g r i d   -   o p t i o n a l ,   d i s t a n c e   i n   p x   f o r   s n a p - t o - g r i d   d r a g g i n g  
 	 s n a p   -   o p t i o n a l ,   t h e   d i s t a n c e   y o u   h a v e   t o   d r a g   b e f o r e   t h e   e l e m e n t   s t a r t s   t o   r e s p o n d   t o   t h e   d r a g .   d e f a u l t s   t o   f a l s e  
  
 	 m o d i f i e r s :  
 	 	 x   -   s t r i n g ,   t h e   s t y l e   y o u   w a n t   t o   m o d i f y   w h e n   t h e   m o u s e   m o v e s   i n   a n   h o r i z o n t a l   d i r e c t i o n .   d e f a u l t s   t o   ' l e f t '  
 	 	 y   -   s t r i n g ,   t h e   s t y l e   y o u   w a n t   t o   m o d i f y   w h e n   t h e   m o u s e   m o v e s   i n   a   v e r t i c a l   d i r e c t i o n .   d e f a u l t s   t o   ' t o p '  
  
 	 l i m i t :  
 	 	 x   -   a r r a y   w i t h   s t a r t   a n d   e n d   l i m i t   r e l a t i v e   t o   m o d i f i e r s . x  
 	 	 y   -   a r r a y   w i t h   s t a r t   a n d   e n d   l i m i t   r e l a t i v e   t o   m o d i f i e r s . y  
 	 	  
 E v e n t s :  
 	 o n S t a r t   -   o p t i o n a l ,   f u n c t i o n   t o   e x e c u t e   w h e n   t h e   u s e r   s t a r t s   t o   d r a g   ( o n   m o u s e d o w n ) ;  
 	 o n C o m p l e t e   -   o p t i o n a l ,   f u n c t i o n   t o   e x e c u t e   w h e n   t h e   u s e r   c o m p l e t e s   t h e   d r a g .  
 	 o n D r a g   -   o p t i o n a l ,   f u n c t i o n   t o   e x e c u t e   a t   e v e r y   s t e p   o f   t h e   d r a g  
 * /  
  
 D r a g . B a s e   =   n e w   C l a s s ( {  
  
 	 o p t i o n s :   {  
 	 	 h a n d l e :   f a l s e ,  
 	 	 u n i t :   ' p x ' ,  
 	 	 o n S t a r t :   C l a s s . e m p t y ,  
 	 	 o n B e f o r e S t a r t :   C l a s s . e m p t y ,  
 	 	 o n C o m p l e t e :   C l a s s . e m p t y ,  
 	 	 o n S n a p :   C l a s s . e m p t y ,  
 	 	 o n D r a g :   C l a s s . e m p t y ,  
 	 	 l i m i t :   f a l s e ,  
 	 	 m o d i f i e r s :   { x :   ' l e f t ' ,   y :   ' t o p ' } ,  
 	 	 g r i d :   f a l s e ,  
 	 	 s n a p :   6  
 	 } ,  
  
 	 i n i t i a l i z e :   f u n c t i o n ( e l ,   o p t i o n s ) {  
 	 	 t h i s . s e t O p t i o n s ( o p t i o n s ) ;  
 	 	 t h i s . e l e m e n t   =   $ ( e l ) ;  
 	 	 t h i s . h a n d l e   =   $ ( t h i s . o p t i o n s . h a n d l e )   | |   t h i s . e l e m e n t ;  
 	 	 t h i s . m o u s e   =   { ' n o w ' :   { } ,   ' p o s ' :   { } } ;  
 	 	 t h i s . v a l u e   =   { ' s t a r t ' :   { } ,   ' n o w ' :   { } } ;  
 	 	 t h i s . b o u n d   =   {  
 	 	 	 ' s t a r t ' :   t h i s . s t a r t . b i n d W i t h E v e n t ( t h i s ) ,  
 	 	 	 ' c h e c k ' :   t h i s . c h e c k . b i n d W i t h E v e n t ( t h i s ) ,  
 	 	 	 ' d r a g ' :   t h i s . d r a g . b i n d W i t h E v e n t ( t h i s ) ,  
 	 	 	 ' s t o p ' :   t h i s . s t o p . b i n d ( t h i s )  
 	 	 } ;  
 	 	 t h i s . a t t a c h ( ) ;  
 	 	 i f   ( t h i s . o p t i o n s . i n i t i a l i z e )   t h i s . o p t i o n s . i n i t i a l i z e . c a l l ( t h i s ) ;  
 	 } ,  
  
 	 a t t a c h :   f u n c t i o n ( ) {  
 	 	 t h i s . h a n d l e . a d d E v e n t ( ' m o u s e d o w n ' ,   t h i s . b o u n d . s t a r t ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 d e t a c h :   f u n c t i o n ( ) {  
 	 	 t h i s . h a n d l e . r e m o v e E v e n t ( ' m o u s e d o w n ' ,   t h i s . b o u n d . s t a r t ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 s t a r t :   f u n c t i o n ( e v e n t ) {  
 	 	 t h i s . f i r e E v e n t ( ' o n B e f o r e S t a r t ' ,   t h i s . e l e m e n t ) ;  
 	 	 t h i s . m o u s e . s t a r t   =   e v e n t . p a g e ;  
 	 	 v a r   l i m i t   =   t h i s . o p t i o n s . l i m i t ;  
 	 	 t h i s . l i m i t   =   { ' x ' :   [ ] ,   ' y ' :   [ ] } ;  
 	 	 f o r   ( v a r   z   i n   t h i s . o p t i o n s . m o d i f i e r s ) {  
 	 	 	 i f   ( ! t h i s . o p t i o n s . m o d i f i e r s [ z ] )   c o n t i n u e ;  
 	 	 	 t h i s . v a l u e . n o w [ z ]   =   t h i s . e l e m e n t . g e t S t y l e ( t h i s . o p t i o n s . m o d i f i e r s [ z ] ) . t o I n t ( ) ;  
 	 	 	 t h i s . m o u s e . p o s [ z ]   =   e v e n t . p a g e [ z ]   -   t h i s . v a l u e . n o w [ z ] ;  
 	 	 	 i f   ( l i m i t   & &   l i m i t [ z ] ) {  
 	 	 	 	 f o r   ( v a r   i   =   0 ;   i   <   2 ;   i + + ) {  
 	 	 	 	 	 i f   ( $ c h k ( l i m i t [ z ] [ i ] ) )   t h i s . l i m i t [ z ] [ i ]   =   ( $ t y p e ( l i m i t [ z ] [ i ] )   = =   ' f u n c t i o n ' )   ?   l i m i t [ z ] [ i ] ( )   :   l i m i t [ z ] [ i ] ;  
 	 	 	 	 }  
 	 	 	 }  
 	 	 }  
 	 	 i f   ( $ t y p e ( t h i s . o p t i o n s . g r i d )   = =   ' n u m b e r ' )   t h i s . o p t i o n s . g r i d   =   { ' x ' :   t h i s . o p t i o n s . g r i d ,   ' y ' :   t h i s . o p t i o n s . g r i d } ;  
 	 	 d o c u m e n t . a d d L i s t e n e r ( ' m o u s e m o v e ' ,   t h i s . b o u n d . c h e c k ) ;  
 	 	 d o c u m e n t . a d d L i s t e n e r ( ' m o u s e u p ' ,   t h i s . b o u n d . s t o p ) ;  
 	 	 t h i s . f i r e E v e n t ( ' o n S t a r t ' ,   t h i s . e l e m e n t ) ;  
 	 	 e v e n t . s t o p ( ) ;  
 	 } ,  
  
 	 c h e c k :   f u n c t i o n ( e v e n t ) {  
 	 	 v a r   d i s t a n c e   =   M a t h . r o u n d ( M a t h . s q r t ( M a t h . p o w ( e v e n t . p a g e . x   -   t h i s . m o u s e . s t a r t . x ,   2 )   +   M a t h . p o w ( e v e n t . p a g e . y   -   t h i s . m o u s e . s t a r t . y ,   2 ) ) ) ;  
 	 	 i f   ( d i s t a n c e   >   t h i s . o p t i o n s . s n a p ) {  
 	 	 	 d o c u m e n t . r e m o v e L i s t e n e r ( ' m o u s e m o v e ' ,   t h i s . b o u n d . c h e c k ) ;  
 	 	 	 d o c u m e n t . a d d L i s t e n e r ( ' m o u s e m o v e ' ,   t h i s . b o u n d . d r a g ) ;  
 	 	 	 t h i s . d r a g ( e v e n t ) ;  
 	 	 	 t h i s . f i r e E v e n t ( ' o n S n a p ' ,   t h i s . e l e m e n t ) ;  
 	 	 }  
 	 	 e v e n t . s t o p ( ) ;  
 	 } ,  
  
 	 d r a g :   f u n c t i o n ( e v e n t ) {  
 	 	 t h i s . o u t   =   f a l s e ;  
 	 	 t h i s . m o u s e . n o w   =   e v e n t . p a g e ;  
 	 	 f o r   ( v a r   z   i n   t h i s . o p t i o n s . m o d i f i e r s ) {  
 	 	 	 i f   ( ! t h i s . o p t i o n s . m o d i f i e r s [ z ] )   c o n t i n u e ;  
 	 	 	 t h i s . v a l u e . n o w [ z ]   =   t h i s . m o u s e . n o w [ z ]   -   t h i s . m o u s e . p o s [ z ] ;  
 	 	 	 i f   ( t h i s . l i m i t [ z ] ) {  
 	 	 	 	 i f   ( $ c h k ( t h i s . l i m i t [ z ] [ 1 ] )   & &   ( t h i s . v a l u e . n o w [ z ]   >   t h i s . l i m i t [ z ] [ 1 ] ) ) {  
 	 	 	 	 	 t h i s . v a l u e . n o w [ z ]   =   t h i s . l i m i t [ z ] [ 1 ] ;  
 	 	 	 	 	 t h i s . o u t   =   t r u e ;  
 	 	 	 	 }   e l s e   i f   ( $ c h k ( t h i s . l i m i t [ z ] [ 0 ] )   & &   ( t h i s . v a l u e . n o w [ z ]   <   t h i s . l i m i t [ z ] [ 0 ] ) ) {  
 	 	 	 	 	 t h i s . v a l u e . n o w [ z ]   =   t h i s . l i m i t [ z ] [ 0 ] ;  
 	 	 	 	 	 t h i s . o u t   =   t r u e ;  
 	 	 	 	 }  
 	 	 	 }  
 	 	 	 i f   ( t h i s . o p t i o n s . g r i d [ z ] )   t h i s . v a l u e . n o w [ z ]   - =   ( t h i s . v a l u e . n o w [ z ]   %   t h i s . o p t i o n s . g r i d [ z ] ) ;  
 	 	 	 t h i s . e l e m e n t . s e t S t y l e ( t h i s . o p t i o n s . m o d i f i e r s [ z ] ,   t h i s . v a l u e . n o w [ z ]   +   t h i s . o p t i o n s . u n i t ) ;  
 	 	 }  
 	 	 t h i s . f i r e E v e n t ( ' o n D r a g ' ,   t h i s . e l e m e n t ) ;  
 	 	 e v e n t . s t o p ( ) ;  
 	 } ,  
  
 	 s t o p :   f u n c t i o n ( ) {  
 	 	 d o c u m e n t . r e m o v e L i s t e n e r ( ' m o u s e m o v e ' ,   t h i s . b o u n d . c h e c k ) ;  
 	 	 d o c u m e n t . r e m o v e L i s t e n e r ( ' m o u s e m o v e ' ,   t h i s . b o u n d . d r a g ) ;  
 	 	 d o c u m e n t . r e m o v e L i s t e n e r ( ' m o u s e u p ' ,   t h i s . b o u n d . s t o p ) ;  
 	 	 t h i s . f i r e E v e n t ( ' o n C o m p l e t e ' ,   t h i s . e l e m e n t ) ;  
 	 }  
  
 } ) ;  
  
 D r a g . B a s e . i m p l e m e n t ( n e w   E v e n t s ,   n e w   O p t i o n s ) ;  
  
 / *  
 C l a s s :   E l e m e n t  
 	 C u s t o m   c l a s s   t o   a l l o w   a l l   o f   i t s   m e t h o d s   t o   b e   u s e d   w i t h   a n y   D O M   e l e m e n t   v i a   t h e   d o l l a r   f u n c t i o n   < $ > .  
 * /  
  
 E l e m e n t . e x t e n d ( {  
  
 	 / *  
 	 P r o p e r t y :   m a k e R e s i z a b l e  
 	 	 M a k e s   a n   e l e m e n t   r e s i z a b l e   ( b y   d r a g g i n g )   w i t h   t h e   s u p p l i e d   o p t i o n s .  
  
 	 A r g u m e n t s :  
 	 	 o p t i o n s   -   s e e   < D r a g . B a s e >   f o r   a c c e p t a b l e   o p t i o n s .  
 	 * /  
  
 	 m a k e R e s i z a b l e :   f u n c t i o n ( o p t i o n s ) {  
 	 	 r e t u r n   n e w   D r a g . B a s e ( t h i s ,   $ m e r g e ( { m o d i f i e r s :   { x :   ' w i d t h ' ,   y :   ' h e i g h t ' } } ,   o p t i o n s ) ) ;  
 	 }  
  
 } ) ;  
  
 / *  
 S c r i p t :   D r a g . M o v e . j s  
 	 C o n t a i n s   < D r a g . M o v e > ,   < E l e m e n t . m a k e D r a g g a b l e >  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   D r a g . M o v e  
 	 E x t e n d s   < D r a g . B a s e > ,   h a s   a d d i t i o n a l   f u n c t i o n a l i t y   f o r   d r a g g i n g   a n   e l e m e n t ,   s u p p o r t   s n a p p i n g   a n d   d r o p p a b l e s .  
 	 D r a g . m o v e   s u p p o r t s   e i t h e r   p o s i t i o n   a b s o l u t e   o r   r e l a t i v e .   I f   n o   p o s i t i o n   i s   f o u n d ,   a b s o l u t e   w i l l   b e   s e t .  
 	 I n h e r i t s   m e t h o d s ,   p r o p e r t i e s ,   o p t i o n s   a n d   e v e n t s   f r o m   < D r a g . B a s e > .  
  
 N o t e :  
 	 D r a g . M o v e   r e q u i r e s   a n   X H T M L   d o c t y p e .  
  
 A r g u m e n t s :  
 	 e l   -   t h e   $ ( e l e m e n t )   t o   a p p l y   t h e   d r a g   t o .  
 	 o p t i o n s   -   o p t i o n a l .   s e e   O p t i o n s   b e l o w .  
  
 O p t i o n s :  
 	 a l l   t h e   d r a g . B a s e   o p t i o n s ,   p l u s :  
 	 c o n t a i n e r   -   a n   e l e m e n t ,   w i l l   f i l l   a u t o m a t i c a l l y   l i m i t i n g   o p t i o n s   b a s e d   o n   t h e   $ ( e l e m e n t )   s i z e   a n d   p o s i t i o n .   d e f a u l t s   t o   f a l s e   ( n o   l i m i t i n g )  
 	 d r o p p a b l e s   -   a n   a r r a y   o f   e l e m e n t s   y o u   c a n   d r o p   y o u r   d r a g g a b l e   t o .  
 	 o v e r f l o w n   -   a n   a r r a y   o f   n e s t e d   s c r o l l i n g   c o n t a i n e r s ,   s e e   E l e m e n t : : g e t P o s i t i o n  
 * /  
  
 D r a g . M o v e   =   D r a g . B a s e . e x t e n d ( {  
  
 	 o p t i o n s :   {  
 	 	 d r o p p a b l e s :   [ ] ,  
 	 	 c o n t a i n e r :   f a l s e ,  
 	 	 o v e r f l o w n :   [ ]  
 	 } ,  
  
 	 i n i t i a l i z e :   f u n c t i o n ( e l ,   o p t i o n s ) {  
 	 	 t h i s . s e t O p t i o n s ( o p t i o n s ) ;  
 	 	 t h i s . e l e m e n t   =   $ ( e l ) ;  
 	 	 t h i s . d r o p p a b l e s   =   $ $ ( t h i s . o p t i o n s . d r o p p a b l e s ) ;  
 	 	 t h i s . c o n t a i n e r   =   $ ( t h i s . o p t i o n s . c o n t a i n e r ) ;  
 	 	 t h i s . p o s i t i o n   =   { ' e l e m e n t ' :   t h i s . e l e m e n t . g e t S t y l e ( ' p o s i t i o n ' ) ,   ' c o n t a i n e r ' :   f a l s e } ;  
 	 	 i f   ( t h i s . c o n t a i n e r )   t h i s . p o s i t i o n . c o n t a i n e r   =   t h i s . c o n t a i n e r . g e t S t y l e ( ' p o s i t i o n ' ) ;  
 	 	 i f   ( ! [ ' r e l a t i v e ' ,   ' a b s o l u t e ' ,   ' f i x e d ' ] . c o n t a i n s ( t h i s . p o s i t i o n . e l e m e n t ) )   t h i s . p o s i t i o n . e l e m e n t   =   ' a b s o l u t e ' ;  
 	 	 v a r   t o p   =   t h i s . e l e m e n t . g e t S t y l e ( ' t o p ' ) . t o I n t ( ) ;  
 	 	 v a r   l e f t   =   t h i s . e l e m e n t . g e t S t y l e ( ' l e f t ' ) . t o I n t ( ) ;  
 	 	 i f   ( t h i s . p o s i t i o n . e l e m e n t   = =   ' a b s o l u t e '   & &   ! [ ' r e l a t i v e ' ,   ' a b s o l u t e ' ,   ' f i x e d ' ] . c o n t a i n s ( t h i s . p o s i t i o n . c o n t a i n e r ) ) {  
 	 	 	 t o p   =   $ c h k ( t o p )   ?   t o p   :   t h i s . e l e m e n t . g e t T o p ( t h i s . o p t i o n s . o v e r f l o w n ) ;  
 	 	 	 l e f t   =   $ c h k ( l e f t )   ?   l e f t   :   t h i s . e l e m e n t . g e t L e f t ( t h i s . o p t i o n s . o v e r f l o w n ) ;  
 	 	 }   e l s e   {  
 	 	 	 t o p   =   $ c h k ( t o p )   ?   t o p   :   0 ;  
 	 	 	 l e f t   =   $ c h k ( l e f t )   ?   l e f t   :   0 ;  
 	 	 }  
 	 	 t h i s . e l e m e n t . s e t S t y l e s ( { ' t o p ' :   t o p ,   ' l e f t ' :   l e f t ,   ' p o s i t i o n ' :   t h i s . p o s i t i o n . e l e m e n t } ) ;  
 	 	 t h i s . p a r e n t ( t h i s . e l e m e n t ) ;  
 	 } ,  
  
 	 s t a r t :   f u n c t i o n ( e v e n t ) {  
 	 	 t h i s . o v e r e d   =   n u l l ;  
 	 	 i f   ( t h i s . c o n t a i n e r ) {  
 	 	 	 v a r   c o n t   =   t h i s . c o n t a i n e r . g e t C o o r d i n a t e s ( ) ;  
 	 	 	 v a r   e l   =   t h i s . e l e m e n t . g e t C o o r d i n a t e s ( ) ;  
 	 	 	 i f   ( t h i s . p o s i t i o n . e l e m e n t   = =   ' a b s o l u t e '   & &   ! [ ' r e l a t i v e ' ,   ' a b s o l u t e ' ,   ' f i x e d ' ] . c o n t a i n s ( t h i s . p o s i t i o n . c o n t a i n e r ) ) {  
 	 	 	 	 t h i s . o p t i o n s . l i m i t   =   {  
 	 	 	 	 	 ' x ' :   [ c o n t . l e f t ,   c o n t . r i g h t   -   e l . w i d t h ] ,  
 	 	 	 	 	 ' y ' :   [ c o n t . t o p ,   c o n t . b o t t o m   -   e l . h e i g h t ]  
 	 	 	 	 } ;  
 	 	 	 }   e l s e   {  
 	 	 	 	 t h i s . o p t i o n s . l i m i t   =   {  
 	 	 	 	 	 ' y ' :   [ 0 ,   c o n t . h e i g h t   -   e l . h e i g h t ] ,  
 	 	 	 	 	 ' x ' :   [ 0 ,   c o n t . w i d t h   -   e l . w i d t h ]  
 	 	 	 	 } ;  
 	 	 	 }  
 	 	 }  
 	 	 t h i s . p a r e n t ( e v e n t ) ;  
 	 } ,  
  
 	 d r a g :   f u n c t i o n ( e v e n t ) {  
 	 	 t h i s . p a r e n t ( e v e n t ) ;  
 	 	 v a r   o v e r e d   =   t h i s . o u t   ?   f a l s e   :   t h i s . d r o p p a b l e s . f i l t e r ( t h i s . c h e c k A g a i n s t ,   t h i s ) . g e t L a s t ( ) ;  
 	 	 i f   ( t h i s . o v e r e d   ! =   o v e r e d ) {  
 	 	 	 i f   ( t h i s . o v e r e d )   t h i s . o v e r e d . f i r e E v e n t ( ' l e a v e ' ,   [ t h i s . e l e m e n t ,   t h i s ] ) ;  
 	 	 	 t h i s . o v e r e d   =   o v e r e d   ?   o v e r e d . f i r e E v e n t ( ' o v e r ' ,   [ t h i s . e l e m e n t ,   t h i s ] )   :   n u l l ;  
 	 	 }  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 c h e c k A g a i n s t :   f u n c t i o n ( e l ) {  
 	 	 e l   =   e l . g e t C o o r d i n a t e s ( t h i s . o p t i o n s . o v e r f l o w n ) ;  
 	 	 v a r   n o w   =   t h i s . m o u s e . n o w ;  
 	 	 r e t u r n   ( n o w . x   >   e l . l e f t   & &   n o w . x   <   e l . r i g h t   & &   n o w . y   <   e l . b o t t o m   & &   n o w . y   >   e l . t o p ) ;  
 	 } ,  
  
 	 s t o p :   f u n c t i o n ( ) {  
 	 	 i f   ( t h i s . o v e r e d   & &   ! t h i s . o u t )   t h i s . o v e r e d . f i r e E v e n t ( ' d r o p ' ,   [ t h i s . e l e m e n t ,   t h i s ] ) ;  
 	 	 e l s e   t h i s . e l e m e n t . f i r e E v e n t ( ' e m p t y d r o p ' ,   t h i s ) ;  
 	 	 t h i s . p a r e n t ( ) ;  
 	 	 r e t u r n   t h i s ;  
 	 }  
  
 } ) ;  
  
 / *  
 C l a s s :   E l e m e n t  
 	 C u s t o m   c l a s s   t o   a l l o w   a l l   o f   i t s   m e t h o d s   t o   b e   u s e d   w i t h   a n y   D O M   e l e m e n t   v i a   t h e   d o l l a r   f u n c t i o n   < $ > .  
 * /  
  
 E l e m e n t . e x t e n d ( {  
  
 	 / *  
 	 P r o p e r t y :   m a k e D r a g g a b l e  
 	 	 M a k e s   a n   e l e m e n t   d r a g g a b l e   w i t h   t h e   s u p p l i e d   o p t i o n s .  
  
 	 A r g u m e n t s :  
 	 	 o p t i o n s   -   s e e   < D r a g . M o v e >   a n d   < D r a g . B a s e >   f o r   a c c e p t a b l e   o p t i o n s .  
 	 * /  
  
 	 m a k e D r a g g a b l e :   f u n c t i o n ( o p t i o n s ) {  
 	 	 r e t u r n   n e w   D r a g . M o v e ( t h i s ,   o p t i o n s ) ;  
 	 }  
  
 } ) ;  
  
 / *  
 S c r i p t :   X H R . j s  
 	 C o n t a i n s   t h e   b a s i c   X M L H t t p R e q u e s t   C l a s s   W r a p p e r .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   X H R  
 	 B a s i c   X M L H t t p R e q u e s t   W r a p p e r .  
  
 A r g u m e n t s :  
 	 o p t i o n s   -   a n   o b j e c t   w i t h   o p t i o n s   n a m e s   a s   k e y s .   S e e   o p t i o n s   b e l o w .  
  
 O p t i o n s :  
 	 m e t h o d   -   ' p o s t '   o r   ' g e t '   -   t h e   p r o t o c o l   f o r   t h e   r e q u e s t ;   o p t i o n a l ,   d e f a u l t s   t o   ' p o s t ' .  
 	 a s y n c   -   b o o l e a n :   a s y n c h r o n o u s   o p t i o n ;   t r u e   u s e s   a s y n c h r o n o u s   r e q u e s t s .   D e f a u l t s   t o   t r u e .  
 	 e n c o d i n g   -   t h e   e n c o d i n g ,   d e f a u l t s   t o   u t f - 8 .  
 	 a u t o C a n c e l   -   c a n c e l s   t h e   a l r e a d y   r u n n i n g   r e q u e s t   i f   a n o t h e r   o n e   i s   s e n t .   d e f a u l t s   t o   f a l s e .  
 	 h e a d e r s   -   a c c e p t s   a n   o b j e c t ,   t h a t   w i l l   b e   s e t   t o   r e q u e s t   h e a d e r s .  
 	  
 E v e n t s :  
 	 o n R e q u e s t   -   f u n c t i o n   t o   e x e c u t e   w h e n   t h e   X H R   r e q u e s t   i s   f i r e d .  
 	 o n S u c c e s s   -   f u n c t i o n   t o   e x e c u t e   w h e n   t h e   X H R   r e q u e s t   c o m p l e t e s .  
 	 o n S t a t e C h a n g e   -   f u n c t i o n   t o   e x e c u t e   w h e n   t h e   s t a t e   o f   t h e   X M L H t t p R e q u e s t   c h a n g e s .  
 	 o n F a i l u r e   -   f u n c t i o n   t o   e x e c u t e   w h e n   t h e   s t a t e   o f   t h e   X M L H t t p R e q u e s t   c h a n g e s .  
  
 P r o p e r t i e s :  
 	 r u n n i n g   -   t r u e   i f   t h e   r e q u e s t   i s   r u n n i n g .  
 	 r e s p o n s e   -   o b j e c t ,   t e x t   a n d   x m l   a s   k e y s .   Y o u   c a n   a c c e s s   t h i s   p r o p e r t y   i n   t h e   o n S u c c e s s   e v e n t .  
  
 E x a m p l e :  
 	 > v a r   m y X H R   =   n e w   X H R ( { m e t h o d :   ' g e t ' } ) . s e n d ( ' h t t p : / / s i t e . c o m / r e q u e s t H a n d l e r . p h p ' ,   ' n a m e = j o h n & l a s t n a m e = d o r i a n ' ) ;  
 * /  
  
 v a r   X H R   =   n e w   C l a s s ( {  
  
 	 o p t i o n s :   {  
 	 	 m e t h o d :   ' p o s t ' ,  
 	 	 a s y n c :   t r u e ,  
 	 	 o n R e q u e s t :   C l a s s . e m p t y ,  
 	 	 o n S u c c e s s :   C l a s s . e m p t y ,  
 	 	 o n F a i l u r e :   C l a s s . e m p t y ,  
 	 	 u r l E n c o d e d :   t r u e ,  
 	 	 e n c o d i n g :   ' u t f - 8 ' ,  
 	 	 a u t o C a n c e l :   f a l s e ,  
 	 	 h e a d e r s :   { }  
 	 } ,  
  
 	 s e t T r a n s p o r t :   f u n c t i o n ( ) {  
 	 	 t h i s . t r a n s p o r t   =   ( w i n d o w . X M L H t t p R e q u e s t )   ?   n e w   X M L H t t p R e q u e s t ( )   :   ( w i n d o w . i e   ?   n e w   A c t i v e X O b j e c t ( ' M i c r o s o f t . X M L H T T P ' )   :   f a l s e ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 i n i t i a l i z e :   f u n c t i o n ( o p t i o n s ) {  
 	 	 t h i s . s e t T r a n s p o r t ( ) . s e t O p t i o n s ( o p t i o n s ) ;  
 	 	 t h i s . o p t i o n s . i s S u c c e s s   =   t h i s . o p t i o n s . i s S u c c e s s   | |   t h i s . i s S u c c e s s ;  
 	 	 t h i s . h e a d e r s   =   { } ;  
 	 	 i f   ( t h i s . o p t i o n s . u r l E n c o d e d   & &   t h i s . o p t i o n s . m e t h o d   = =   ' p o s t ' ) {  
 	 	 	 v a r   e n c o d i n g   =   ( t h i s . o p t i o n s . e n c o d i n g )   ?   ' ;   c h a r s e t = '   +   t h i s . o p t i o n s . e n c o d i n g   :   ' ' ;  
 	 	 	 t h i s . s e t H e a d e r ( ' C o n t e n t - t y p e ' ,   ' a p p l i c a t i o n / x - w w w - f o r m - u r l e n c o d e d '   +   e n c o d i n g ) ;  
 	 	 }  
 	 	 i f   ( t h i s . o p t i o n s . i n i t i a l i z e )   t h i s . o p t i o n s . i n i t i a l i z e . c a l l ( t h i s ) ;  
 	 } ,  
  
 	 o n 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 . t r a n s p o r t . r e a d y S t a t e   ! =   4   | |   ! t h i s . r u n n i n g )   r e t u r n ;  
 	 	 t h i s . r u n n i n g   =   f a l s e ;  
 	 	 v a r   s t a t u s   =   0 ;  
 	 	 t r y   { s t a t u s   =   t h i s . t r a n s p o r t . s t a t u s ; }   c a t c h ( e ) { } ;  
 	 	 i f   ( t h i s . o p t i o n s . i s S u c c e s s . c a l l ( t h i s ,   s t a t u s ) )   t h i s . o n S u c c e s s ( ) ;  
 	 	 e l s e   t h i s . o n F a i l u r e ( ) ;  
 	 	 t h i s . t r a n s p o r t . o n r e a d y s t a t e c h a n g e   =   C l a s s . e m p t y ;  
 	 } ,  
  
 	 i s S u c c e s s :   f u n c t i o n ( s t a t u s ) {  
 	 	 r e t u r n   ( ( s t a t u s   > =   2 0 0 )   & &   ( s t a t u s   <   3 0 0 ) ) ;  
 	 } ,  
  
 	 o n S u c c e s s :   f u n c t i o n ( ) {  
 	 	 t h i s . r e s p o n s e   =   {  
 	 	 	 ' t e x t ' :   t h i s . t r a n s p o r t . r e s p o n s e T e x t ,  
 	 	 	 ' x m l ' :   t h i s . t r a n s p o r t . r e s p o n s e X M L  
 	 	 } ;  
 	 	 t h i s . f i r e E v e n t ( ' o n S u c c e s s ' ,   [ t h i s . r e s p o n s e . t e x t ,   t h i s . r e s p o n s e . x m l ] ) ;  
 	 	 t h i s . c a l l C h a i n ( ) ;  
 	 } ,  
  
 	 o n F a i l u r e :   f u n c t i o n ( ) {  
 	 	 t h i s . f i r e E v e n t ( ' o n F a i l u r e ' ,   t h i s . t r a n s p o r t ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s e t H e a d e r  
 	 	 A d d / m o d i f y   a n   h e a d e r   f o r   t h e   r e q u e s t .   I t   w i l l   n o t   o v e r r i d e   h e a d e r s   f r o m   t h e   o p t i o n s .  
  
 	 E x a m p l e :  
 	 	 > v a r   m y X h r   =   n e w   X H R ( u r l ,   { m e t h o d :   ' g e t ' ,   h e a d e r s :   { ' X - R e q u e s t ' :   ' J S O N ' } } ) ;  
 	 	 > m y X h r . s e t H e a d e r ( ' L a s t - M o d i f i e d ' , ' S a t ,   1   J a n   2 0 0 5   0 5 : 0 0 : 0 0   G M T ' ) ;  
 	 * /  
  
 	 s e t H e a d e r :   f u n c t i o n ( n a m e ,   v a l u e ) {  
 	 	 t h i s . h e a d e r s [ n a m e ]   =   v a l u e ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s e n d  
 	 	 O p e n s   t h e   X H R   c o n n e c t i o n   a n d   s e n d s   t h e   d a t a .   D a t a   h a s   t o   b e   n u l l   o r   a   s t r i n g .  
  
 	 E x a m p l e :  
 	 	 > v a r   m y X h r   =   n e w   X H R ( { m e t h o d :   ' p o s t ' } ) ;  
 	 	 > m y X h r . s e n d ( u r l ,   q u e r y s t r i n g ) ;  
 	 	 >  
 	 	 > v a r   s y n c X h r   =   n e w   X H R ( { a s y n c :   f a l s e ,   m e t h o d :   ' p o s t ' } ) ;  
 	 	 > s y n c X h r . s e n d ( u r l ,   n u l l ) ;  
 	 	 >  
 	 * /  
  
 	 s e n d :   f u n c t i o n ( u r l ,   d a t a ) {  
 	 	 i f   ( t h i s . o p t i o n s . a u t o C a n c e l )   t h i s . c a n c e l ( ) ;  
 	 	 e l s e   i f   ( t h i s . r u n n i n g )   r e t u r n   t h i s ;  
 	 	 t h i s . r u n n i n g   =   t r u e ;  
 	 	 i f   ( d a t a   & &   t h i s . o p t i o n s . m e t h o d   = =   ' g e t ' ) {  
 	 	 	 u r l   =   u r l   +   ( u r l . c o n t a i n s ( ' ? ' )   ?   ' & '   :   ' ? ' )   +   d a t a ;  
 	 	 	 d a t a   =   n u l l ;  
 	 	 }  
 	 	 t h i s . t r a n s p o r t . o p e n ( t h i s . o p t i o n s . m e t h o d . t o U p p e r C a s e ( ) ,   u r l ,   t h i s . o p t i o n s . a s y n c ) ;  
 	 	 t h i s . t r a n s p o r t . o n r e a d y s t a t e c h a n g e   =   t h i s . o n S t a t e C h a n g e . b i n d ( t h i s ) ;  
 	 	 i f   ( ( t h i s . o p t i o n s . m e t h o d   = =   ' p o s t ' )   & &   t h i s . t r a n s p o r t . o v e r r i d e M i m e T y p e )   t h i s . s e t H e a d e r ( ' C o n n e c t i o n ' ,   ' c l o s e ' ) ;  
 	 	 $ e x t e n d ( t h i s . h e a d e r s ,   t h i s . o p t i o n s . h e a d e r s ) ;  
 	 	 f o r   ( v a r   t y p e   i n   t h i s . h e a d e r s )   t r y   { t h i s . t r a n s p o r t . s e t R e q u e s t H e a d e r ( t y p e ,   t h i s . h e a d e r s [ t y p e ] ) ; }   c a t c h ( e ) { } ;  
 	 	 t h i s . f i r e E v e n t ( ' o n R e q u e s t ' ) ;  
 	 	 t h i s . t r a n s p o r t . s e n d ( $ p i c k ( d a t a ,   n u l l ) ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   c a n c e l  
 	 	 C a n c e l s   t h e   r u n n i n g   r e q u e s t .   N o   e f f e c t   i f   t h e   r e q u e s t   i s   n o t   r u n n i n g .  
  
 	 E x a m p l e :  
 	 	 > v a r   m y X h r   =   n e w   X H R ( { m e t h o d :   ' g e t ' } ) . s e n d ( u r l ) ;  
 	 	 > m y X h r . c a n c e l ( ) ;  
 	 * /  
  
 	 c a n c e l :   f u n c t i o n ( ) {  
 	 	 i f   ( ! t h i s . r u n n i n g )   r e t u r n   t h i s ;  
 	 	 t h i s . r u n n i n g   =   f a l s e ;  
 	 	 t h i s . t r a n s p o r t . a b o r t ( ) ;  
 	 	 t h i s . t r a n s p o r t . o n r e a d y s t a t e c h a n g e   =   C l a s s . e m p t y ;  
 	 	 t h i s . s e t T r a n s p o r t ( ) ;  
 	 	 t h i s . f i r e E v e n t ( ' o n C a n c e l ' ) ;  
 	 	 r e t u r n   t h i s ;  
 	 }  
  
 } ) ;  
  
 X H R . i m p l e m e n t ( n e w   C h a i n ,   n e w   E v e n t s ,   n e w   O p t i o n s ) ;  
  
 / *  
 S c r i p t :   A j a x . j s  
 	 C o n t a i n s   t h e   < A j a x >   c l a s s .   A l s o   c o n t a i n s   m e t h o d s   t o   g e n e r a t e   q u e r y s t i n g s   f r o m   f o r m s   a n d   O b j e c t s .  
  
 C r e d i t s :  
 	 L o o s e l y   b a s e d   o n   t h e   v e r s i o n   f r o m   p r o t o t y p e . j s   < h t t p : / / p r o t o t y p e . c o n i o . n e t >  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   A j a x  
 	 A n   A j a x   c l a s s ,   F o r   a l l   y o u r   a s y n c h r o n o u s   n e e d s .  
 	 I n h e r i t s   m e t h o d s ,   p r o p e r t i e s ,   o p t i o n s   a n d   e v e n t s   f r o m   < X H R > .  
  
 A r g u m e n t s :  
 	 u r l   -   t h e   u r l   p o i n t i n g   t o   t h e   s e r v e r - s i d e   s c r i p t .  
 	 o p t i o n s   -   o p t i o n a l ,   a n   o b j e c t   c o n t a i n i n g   o p t i o n s .  
  
 O p t i o n s :  
 	 d a t a   -   y o u   c a n   w r i t e   p a r a m e t e r s   h e r e .   C a n   b e   a   q u e r y s t r i n g ,   a n   o b j e c t   o r   a   F o r m   e l e m e n t .  
 	 u p d a t e   -   $ ( e l e m e n t )   t o   i n s e r t   t h e   r e s p o n s e   t e x t   o f   t h e   X H R   i n t o ,   u p o n   c o m p l e t i o n   o f   t h e   r e q u e s t .  
 	 e v a l S c r i p t s   -   b o o l e a n ;   d e f a u l t   i s   f a l s e .   E x e c u t e   s c r i p t s   i n   t h e   r e s p o n s e   t e x t   o n C o m p l e t e .   W h e n   t h e   r e s p o n s e   i s   j a v a s c r i p t   t h e   w h o l e   r e s p o n s e   i s   e v a l u a t e d .  
 	 e v a l R e s p o n s e   -   b o o l e a n ;   d e f a u l t   i s   f a l s e .   F o r c e   g l o b a l   e v a l u l a t i o n   o f   t h e   w h o l e   r e s p o n s e ,   n o   m a t t e r   w h a t   c o n t e n t - t y p e   i t   i s .  
 	  
 E v e n t s :  
 	 o n C o m p l e t e   -   f u n c t i o n   t o   e x e c u t e   w h e n   t h e   a j a x   r e q u e s t   c o m p l e t e s .  
  
 E x a m p l e :  
 	 > v a r   m y A j a x   =   n e w   A j a x ( u r l ,   { m e t h o d :   ' g e t ' } ) . r e q u e s t ( ) ;  
 * /  
  
 v a r   A j a x   =   X H R . e x t e n d ( {  
  
 	 o p t i o n s :   {  
 	 	 d a t a :   n u l l ,  
 	 	 u p d a t e :   n u l l ,  
 	 	 o n C o m p l e t e :   C l a s s . e m p t y ,  
 	 	 e v a l S c r i p t s :   f a l s e ,  
 	 	 e v a l R e s p o n s e :   f a l s e  
 	 } ,  
  
 	 i n i t i a l i z e :   f u n c t i o n ( u r l ,   o p t i o n s ) {  
 	 	 t h i s . a d d E v e n t ( ' o n S u c c e s s ' ,   t h i s . o n C o m p l e t e ) ;  
 	 	 t h i s . s e t O p t i o n s ( o p t i o n s ) ;  
 	 	 / * c o m p a t i b i l i t y * /  
 	 	 t h i s . o p t i o n s . d a t a   =   t h i s . o p t i o n s . d a t a   | |   t h i s . o p t i o n s . p o s t B o d y ;  
 	 	 / * e n d   c o m p a t i b i l i t y * /  
 	 	 i f   ( ! [ ' p o s t ' ,   ' g e t ' ] . c o n t a i n s ( t h i s . o p t i o n s . m e t h o d ) ) {  
 	 	 	 t h i s . _ m e t h o d   =   ' _ m e t h o d = '   +   t h i s . o p t i o n s . m e t h o d ;  
 	 	 	 t h i s . o p t i o n s . m e t h o d   =   ' p o s t ' ;  
 	 	 }  
 	 	 t h i s . p a r e n t ( ) ;  
 	 	 t h i s . s e 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 ' ) ;  
 	 	 t h i s . s e t H e a d e r ( ' A c c e p t ' ,   ' t e x t / j a v a s c r i p t ,   t e x t / h t m l ,   a p p l i c a t i o n / x m l ,   t e x t / x m l ,   * / * ' ) ;  
 	 	 t h i s . u r l   =   u r l ;  
 	 } ,  
  
 	 o n C o m p l e t e :   f u n c t i o n ( ) {  
 	 	 i f   ( t h i s . o p t i o n s . u p d a t e )   $ ( t h i s . o p t i o n s . u p d a t e ) . e m p t y ( ) . s e t H T M L ( t h i s . r e s p o n s e . t e x t ) ;  
 	 	 i f   ( t h i s . o p t i o n s . e v a l S c r i p t s   | |   t h i s . o p t i o n s . e v a l R e s p o n s e )   t h i s . e v a l S c r i p t s ( ) ;  
 	 	 t h i s . f i r e E v e n t ( ' o n C o m p l e t e ' ,   [ t h i s . r e s p o n s e . t e x t ,   t h i s . r e s p o n s e . x m l ] ,   2 0 ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   r e q u e s t  
 	 	 E x e c u t e s   t h e   a j a x   r e q u e s t .  
  
 	 E x a m p l e :  
 	 	 > v a r   m y A j a x   =   n e w   A j a x ( u r l ,   { m e t h o d :   ' g e t ' } ) ;  
 	 	 > m y A j a x . r e q u e s t ( ) ;  
  
 	 	 O R  
  
 	 	 > n e w   A j a x ( u r l ,   { m e t h o d :   ' g e t ' } ) . r e q u e s t ( ) ;  
 	 * /  
  
 	 r e q u e s t :   f u n c t i o n ( d a t a ) {  
 	 	 d a t a   =   d a t a   | |   t h i s . o p t i o n s . d a t a ;  
 	 	 s w i t c h ( $ t y p e ( d a t a ) ) {  
 	 	 	 c a s e   ' e l e m e n t ' :   d a t a   =   $ ( d a t a ) . t o Q u e r y S t r i n g ( ) ;   b r e a k ;  
 	 	 	 c a s e   ' o b j e c t ' :   d a t a   =   O b j e c t . t o Q u e r y S t r i n g ( d a t a ) ;  
 	 	 }  
 	 	 i f   ( t h i s . _ m e t h o d )   d a t a   =   ( d a t a )   ?   [ t h i s . _ m e t h o d ,   d a t a ] . j o i n ( ' & ' )   :   t h i s . _ m e t h o d ;  
 	 	 r e t u r n   t h i s . s e n d ( t h i s . u r l ,   d a t a ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   e v a l S c r i p t s  
 	 	 E x e c u t e s   s c r i p t s   i n   t h e   r e s p o n s e   t e x t  
 	 * /  
  
 	 e v a l S c r i p t s :   f u n c t i o n ( ) {  
 	 	 v a r   s c r i p t ,   s c r i p t s ;  
 	 	 i f   ( t h i s . o p t i o n s . e v a l R e s p o n s e   | |   ( / ( e c m a | j a v a ) s c r i p t / ) . t e s t ( t h i s . g e t H e a d e r ( ' C o n t e n t - t y p e ' ) ) )   s c r i p t s   =   t h i s . r e s p o n s e . t e x t ;  
 	 	 e l s e   {  
 	 	 	 s c r i p t s   =   [ ] ;  
 	 	 	 v a r   r e g e x p   =   / < s c r i p t [ ^ > ] * > ( [ \ s \ S ] * ? ) < \ / s c r i p t > / g i ;  
 	 	 	 w h i l e   ( ( s c r i p t   =   r e g e x p . e x e c ( t h i s . r e s p o n s e . t e x t ) ) )   s c r i p t s . p u s h ( s c r i p t [ 1 ] ) ;  
 	 	 	 s c r i p t s   =   s c r i p t s . j o i n ( ' \ n ' ) ;  
 	 	 }  
 	 	 i f   ( s c r i p t s )   ( 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 ( s c r i p t s )   :   w i n d o w . s e t T i m e o u t ( s c r i p t s ,   0 ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t H e a d e r  
 	 	 R e t u r n s   t h e   g i v e n   r e s p o n s e   h e a d e r   o r   n u l l  
 	 * /  
  
 	 g e t H e a d e r :   f u n c t i o n ( n a m e ) {  
 	 	 t r y   { r e t u r n   t h i s . t r a n s p o r t . g e t R e s p o n s e H e a d e r ( n a m e ) ; }   c a t c h ( e ) { } ;  
 	 	 r e t u r n   n u l l ;  
 	 }  
  
 } ) ;  
  
 / *   S e c t i o n :   O b j e c t   r e l a t e d   F u n c t i o n s   * /  
  
 / *  
 F u n c t i o n :   O b j e c t . t o Q u e r y S t r i n g  
 	 G e n e r a t e s   a   q u e r y s t r i n g   f r o m   k e y / p a i r   v a l u e s   i n   a n   o b j e c t  
  
 A r g u m e n t s :  
 	 s o u r c e   -   t h e   o b j e c t   t o   g e n e r a t e   t h e   q u e r y s t r i n g   f r o m .  
  
 R e t u r n s :  
 	 t h e   q u e r y   s t r i n g .  
  
 E x a m p l e :  
 	 > O b j e c t . t o Q u e r y S t r i n g ( { a p p l e :   " r e d " ,   l e m o n :   " y e l l o w " } ) ;   / / r e t u r n s   " a p p l e = r e d & l e m o n = y e l l o w "  
 * /  
  
 O b j e c t . t o Q u e r y S t r i n g   =   f u n c t i o n ( s o u r c e ) {  
 	 v a r   q u e r y S t r i n g   =   [ ] ;  
 	 f o r   ( v a r   p r o p e r t y   i n   s o u r c e )   q u e r y S t r i n g . p u s h ( e n c o d e U R I C o m p o n e n t ( p r o p e r t y )   +   ' = '   +   e n c o d e U R I C o m p o n e n t ( s o u r c e [ p r o p e r t y ] ) ) ;  
 	 r e t u r n   q u e r y S t r i n g . j o i n ( ' & ' ) ;  
 } ;  
  
 / *  
 C l a s s :   E l e m e n t  
 	 C u s t o m   c l a s s   t o   a l l o w   a l l   o f   i t s   m e t h o d s   t o   b e   u s e d   w i t h   a n y   D O M   e l e m e n t   v i a   t h e   d o l l a r   f u n c t i o n   < $ > .  
 * /  
  
 E l e m e n t . e x t e n d ( {  
  
 	 / *  
 	 P r o p e r t y :   s e n d  
 	 	 S e n d s   a   f o r m   w i t h   a n   a j a x   p o s t   r e q u e s t  
  
 	 A r g u m e n t s :  
 	 	 o p t i o n s   -   o p t i o n   c o l l e c t i o n   f o r   a j a x   r e q u e s t .   S e e   < A j a x >   f o r   t h e   o p t i o n s   l i s t .  
  
 	 R e t u r n s :  
 	 	 T h e   A j a x   C l a s s   I n s t a n c e  
  
 	 E x a m p l e :  
 	 	 ( s t a r t   c o d e )  
 	 	 < f o r m   i d = " m y F o r m "   a c t i o n = " s u b m i t . p h p " >  
 	 	 < i n p u t   n a m e = " e m a i l "   v a l u e = " b o b @ b o b . c o m " >  
 	 	 < i n p u t   n a m e = " z i p C o d e "   v a l u e = " 9 0 2 1 0 " >  
 	 	 < / f o r m >  
 	 	 < s c r i p t >  
 	 	 $ ( ' m y F o r m ' ) . s e n d ( )  
 	 	 < / s c r i p t >  
 	 	 ( e n d )  
 	 * /  
  
 	 s e n d :   f u n c t i o n ( o p t i o n s ) {  
 	 	 r e t u r n   n e w   A j a x ( t h i s . g e t P r o p e r t y ( ' a c t i o n ' ) ,   $ m e r g e ( { d a t a :   t h i s . t o Q u e r y S t r i n g ( ) } ,   o p t i o n s ,   { m e t h o d :   ' p o s t ' } ) ) . r e q u e s t ( ) ;  
 	 }  
  
 } ) ;  
  
 / *  
 S c r i p t :   C o o k i e . j s  
 	 A   c o o k i e   r e a d e r / c r e a t o r  
  
 C r e d i t s :  
 	 b a s e d   o n   t h e   f u n c t i o n s   b y   P e t e r - P a u l   K o c h   ( h t t p : / / q u i r k s m o d e . o r g )  
 * /  
  
 / *  
 C l a s s :   C o o k i e  
 	 C l a s s   f o r   c r e a t i n g ,   g e t t i n g ,   a n d   r e m o v i n g   c o o k i e s .  
 * /  
  
 v a r   C o o k i e   =   n e w   A b s t r a c t ( {  
  
 	 o p t i o n s :   {  
 	 	 d o m a i n :   f a l s e ,  
 	 	 p a t h :   f a l s e ,  
 	 	 d u r a t i o n :   f a l s e ,  
 	 	 s e c u r e :   f a l s e  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s e t  
 	 	 S e t s   a   c o o k i e   i n   t h e   b r o w s e r .  
  
 	 A r g u m e n t s :  
 	 	 k e y   -   t h e   k e y   ( n a m e )   f o r   t h e   c o o k i e  
 	 	 v a l u e   -   t h e   v a l u e   t o   s e t ,   c a n n o t   c o n t a i n   s e m i c o l o n s  
 	 	 o p t i o n s   -   a n   o b j e c t   r e p r e s e n t i n g   t h e   C o o k i e   o p t i o n s .   S e e   O p t i o n s   b e l o w .   D e f a u l t   v a l u e s   a r e   s t o r e d   i n   C o o k i e . o p t i o n s .  
  
 	 O p t i o n s :  
 	 	 d o m a i n   -   t h e   d o m a i n   t h e   C o o k i e   b e l o n g s   t o .   I f   y o u   w a n t   t o   s h a r e   t h e   c o o k i e   w i t h   p a g e s   l o c a t e d   o n   a   d i f f e r e n t   d o m a i n ,   y o u   h a v e   t o   s e t   t h i s   v a l u e .   D e f a u l t s   t o   t h e   c u r r e n t   d o m a i n .  
 	 	 p a t h   -   t h e   p a t h   t h e   C o o k i e   b e l o n g s   t o .   I f   y o u   w a n t   t o   s h a r e   t h e   c o o k i e   w i t h   p a g e s   l o c a t e d   i n   a   d i f f e r e n t   p a t h ,   y o u   h a v e   t o   s e t   t h i s   v a l u e ,   f o r   e x a m p l e   t o   " / "   t o   s h a r e   t h e   c o o k i e   w i t h   a l l   p a g e s   o n   t h e   d o m a i n .   D e f a u l t s   t o   t h e   c u r r e n t   p a t h .  
 	 	 d u r a t i o n   -   t h e   d u r a t i o n   o f   t h e   C o o k i e   b e f o r e   i t   e x p i r e s ,   i n   d a y s .  
 	 	 	 	 	 I f   s e t   t o   f a l s e   o r   0 ,   t h e   c o o k i e   w i l l   b e   a   s e s s i o n   c o o k i e   t h a t   e x p i r e s   w h e n   t h e   b r o w s e r   i s   c l o s e d .   T h i s   i s   d e f a u l t .  
 	 	 s e c u r e   -   S t o r e d   c o o k i e   i n f o r m a t i o n   c a n   b e   a c c e s s e d   o n l y   f r o m   a   s e c u r e   e n v i r o n m e n t .  
  
 	 R e t u r n s :  
 	 	 A n   o b j e c t   w i t h   t h e   o p t i o n s ,   t h e   k e y   a n d   t h e   v a l u e .   Y o u   c a n   g i v e   i t   a s   f i r s t   p a r a m e t e r   t o   C o o k i e . r e m o v e .  
  
 	 E x a m p l e :  
 	 	 > C o o k i e . s e t ( ' u s e r n a m e ' ,   ' H a r a l d ' ) ;   / /   s e s s i o n   c o o k i e   ( d u r a t i o n   i s   f a l s e ) ,   o r   . . .  
 	 	 > C o o k i e . s e t ( ' u s e r n a m e ' ,   ' J a c k B a u e r ' ,   { d u r a t i o n :   1 } ) ;   / /   s a v e   t h i s   f o r   1   d a y  
  
 	 * /  
  
 	 s e t :   f u n c t i o n ( k e y ,   v a l u e ,   o p t i o n s ) {  
 	 	 o p t i o n s   =   $ m e r g e ( t h i s . o p t i o n s ,   o p t i o n s ) ;  
 	 	 v a l u e   =   e n c o d e U R I C o m p o n e n t ( v a l u e ) ;  
 	 	 i f   ( o p t i o n s . d o m a i n )   v a l u e   + =   ' ;   d o m a i n = '   +   o p t i o n s . d o m a i n ;  
 	 	 i f   ( o p t i o n s . p a t h )   v a l u e   + =   ' ;   p a t h = '   +   o p t i o n s . p a t h ;  
 	 	 i f   ( o p t i o n s . d u r a t i o n ) {  
 	 	 	 v a r   d a t e   =   n e w   D a t e ( ) ;  
 	 	 	 d a t e . s e t T i m e ( d a t e . g e t T i m e ( )   +   o p t i o n s . d u r a t i o n   *   2 4   *   6 0   *   6 0   *   1 0 0 0 ) ;  
 	 	 	 v a l u e   + =   ' ;   e x p i r e s = '   +   d a t e . t o G M T S t r i n g ( ) ;  
 	 	 }  
 	 	 i f   ( o p t i o n s . s e c u r e )   v a l u e   + =   ' ;   s e c u r e ' ;  
 	 	 d o c u m e n t . c o o k i e   =   k e y   +   ' = '   +   v a l u e ;  
 	 	 r e t u r n   $ e x t e n d ( o p t i o n s ,   { ' k e y ' :   k e y ,   ' v a l u e ' :   v a l u e } ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t  
 	 	 G e t s   t h e   v a l u e   o f   a   c o o k i e .  
  
 	 A r g u m e n t s :  
 	 	 k e y   -   t h e   n a m e   o f   t h e   c o o k i e   y o u   w i s h   t o   r e t r i e v e .  
  
 	 R e t u r n s :  
 	 	 T h e   c o o k i e   s t r i n g   v a l u e ,   o r   f a l s e   i f   n o t   f o u n d .  
  
 	 E x a m p l e :  
 	 	 > C o o k i e . g e t ( " u s e r n a m e " )   / / r e t u r n s   J a c k B a u e r  
 	 * /  
  
 	 g e t :   f u n c t i o n ( k e y ) {  
 	 	 v a r   v a l u e   =   d o c u m e n t . c o o k i e . m a t c h ( ' ( ? : ^ | ; ) \ \ s * '   +   k e y . e s c a p e R e g E x p ( )   +   ' = ( [ ^ ; ] * ) ' ) ;  
 	 	 r e t u r n   v a l u e   ?   d e c o d e U R I C o m p o n e n t ( v a l u e [ 1 ] )   :   f a l s e ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   r e m o v e  
 	 	 R e m o v e s   a   c o o k i e   f r o m   t h e   b r o w s e r .  
  
 	 A r g u m e n t s :  
 	 	 c o o k i e   -   t h e   n a m e   o f   t h e   c o o k i e   t o   r e m o v e   o r   a   p r e v i o u s   c o o k i e   ( f o r   d o m a i n s )  
 	 	 o p t i o n s   -   o p t i o n a l .   y o u   c a n   a l s o   p a s s   t h e   d o m a i n   a n d   p a t h   h e r e .   S a m e   a s   o p t i o n s   i n   < C o o k i e . s e t >  
  
 	 E x a m p l e s :  
 	 	 > C o o k i e . r e m o v e ( ' u s e r n a m e ' )   / / b y e - b y e   J a c k B a u e r ,   c y a   i n   2 4   h o u r s  
 	 	 >  
 	 	 > v a r   m y C o o k i e   =   C o o k i e . s e t ( ' u s e r n a m e ' ,   ' A a r o n ' ,   { d o m a i n :   ' m o o t o o l s . n e t ' } ) ;   / /   C o o k i e . s e t   r e t u r n s   a n   o b j e c t   w i t h   a l l   v a l u e s   n e e d   t o   r e m o v e   t h e   c o o k i e  
 	 	 > C o o k i e . r e m o v e ( m y C o o k i e ) ;  
 	 * /  
  
 	 r e m o v e :   f u n c t i o n ( c o o k i e ,   o p t i o n s ) {  
 	 	 i f   ( $ t y p e ( c o o k i e )   = =   ' o b j e c t ' )   t h i s . s e t ( c o o k i e . k e y ,   ' ' ,   $ m e r g e ( c o o k i e ,   { d u r a t i o n :   - 1 } ) ) ;  
 	 	 e l s e   t h i s . s e t ( c o o k i e ,   ' ' ,   $ m e r g e ( o p t i o n s ,   { d u r a t i o n :   - 1 } ) ) ;  
 	 }  
  
 } ) ;  
  
 / *  
 S c r i p t :   J s o n . j s  
 	 S i m p l e   J s o n   p a r s e r   a n d   S t r i n g y f i e r ,   S e e :   < h t t p : / / w w w . j s o n . o r g / >  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   J s o n  
 	 S i m p l e   J s o n   p a r s e r   a n d   S t r i n g y f i e r ,   S e e :   < h t t p : / / w w w . j s o n . o r g / >  
 * /  
  
 v a r   J s o n   =   {  
  
 	 / *  
 	 P r o p e r t y :   t o S t r i n g  
 	 	 C o n v e r t s   a n   o b j e c t   t o   a   s t r i n g ,   t o   b e   p a s s e d   i n   s e r v e r - s i d e   s c r i p t s   a s   a   p a r a m e t e r .   A l t h o u g h   i t s   n o t   n o r m a l   u s a g e   f o r   t h i s   c l a s s ,   t h i s   m e t h o d   c a n   a l s o   b e   u s e d   t o   c o n v e r t   f u n c t i o n s   a n d   a r r a y s   t o   s t r i n g s .  
  
 	 A r g u m e n t s :  
 	 	 o b j   -   t h e   o b j e c t   t o   c o n v e r t   t o   s t r i n g  
  
 	 R e t u r n s :  
 	 	 A   j s o n   s t r i n g  
  
 	 E x a m p l e :  
 	 	 ( s t a r t   c o d e )  
 	 	 J s o n . t o S t r i n g ( { a p p l e :   ' r e d ' ,   l e m o n :   ' y e l l o w ' } ) ;   ' { " a p p l e " : " r e d " , " l e m o n " : " y e l l o w " } '  
 	 	 ( e n d )  
 	 * /  
  
 	 t o S t r i n g :   f u n c t i o n ( o b j ) {  
 	 	 s w i t c h ( $ t y p e ( o b j ) ) {  
 	 	 	 c a s e   ' s t r i n g ' :  
 	 	 	 	 r e t u r n   ' " '   +   o b j . r e p l a c e ( / ( [ " \ \ ] ) / g ,   ' \ \ $ 1 ' )   +   ' " ' ;  
 	 	 	 c a s e   ' a r r a y ' :  
 	 	 	 	 r e t u r n   ' [ '   +   o b j . m a p ( J s o n . t o S t r i n g ) . j o i n ( ' , ' )   +   ' ] ' ;  
 	 	 	 c a s e   ' o b j e c t ' :  
 	 	 	 	 v a r   s t r i n g   =   [ ] ;  
 	 	 	 	 f o r   ( v a r   p r o p e r t y   i n   o b j )   s t r i n g . p u s h ( J s o n . t o S t r i n g ( p r o p e r t y )   +   ' : '   +   J s o n . t o S t r i n g ( o b j [ p r o p e r t y ] ) ) ;  
 	 	 	 	 r e t u r n   ' { '   +   s t r i n g . j o i n ( ' , ' )   +   ' } ' ;  
 	 	 	 c a s e   ' n u m b e r ' :  
 	 	 	 	 i f   ( i s F i n i t e ( o b j ) )   b r e a k ;  
 	 	 	 c a s e   f a l s e :  
 	 	 	 	 r e t u r n   ' n u l l ' ;  
 	 	 }  
 	 	 r e t u r n   S t r i n g ( o b j ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   e v a l u a t e  
 	 	 c o n v e r t s   a   j s o n   s t r i n g   t o   a n   j a v a s c r i p t   O b j e c t .  
  
 	 A r g u m e n t s :  
 	 	 s t r   -   t h e   s t r i n g   t o   e v a l u a t e .   i f   i t s   n o t   a   s t r i n g ,   i t   r e t u r n s   f a l s e .  
 	 	 s e c u r e   -   o p t i o n a l l y ,   p e r f o r m s   s y n t a x   c h e c k   o n   j s o n   s t r i n g .   D e f a u l t s   t o   f a l s e .  
  
 	 C r e d i t s :  
 	 	 J s o n   t e s t   r e g e x p   i s   b y   D o u g l a s   C r o c k f o r d   < h t t p : / / c r o c k f o r d . o r g > .  
  
 	 E x a m p l e :  
 	 	 > v a r   m y O b j e c t   =   J s o n . e v a l u a t e ( ' { " a p p l e " : " r e d " , " l e m o n " : " y e l l o w " } ' ) ;  
 	 	 > / / m y O b j e c t   w i l l   b e c o m e   { a p p l e :   ' r e d ' ,   l e m o n :   ' y e l l o w ' }  
 	 * /  
  
 	 e v a l u a t e :   f u n c t i o n ( s t r ,   s e c u r e ) {  
 	 	 r e t u r n   ( ( $ t y p e ( s t r )   ! =   ' s t r i n g ' )   | |   ( s e c u r e   & &   ! s t r . t e s t ( / ^ ( " ( \ \ . | [ ^ " \ \ \ n \ r ] ) * ? " | [ , : { } \ [ \ ] 0 - 9 . \ - + E a e f l n r - u   \ n \ r \ t ] ) + ? $ / ) ) )   ?   n u l l   :   e v a l ( ' ( '   +   s t r   +   ' ) ' ) ;  
 	 }  
  
 } ;  
  
 / *  
 S c r i p t :   J s o n . R e m o t e . j s  
 	 C o n t a i n s   < J s o n . R e m o t e > .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   J s o n . R e m o t e  
 	 W r a p p e d   X H R   w i t h   a u t o m a t e d   s e n d i n g   a n d   r e c e i v i n g   o f   J a v a s c r i p t   O b j e c t s   i n   J s o n   F o r m a t .  
 	 I n h e r i t s   m e t h o d s ,   p r o p e r t i e s ,   o p t i o n s   a n d   e v e n t s   f r o m   < X H R > .  
  
 A r g u m e n t s :  
 	 u r l   -   t h e   u r l   y o u   w a n t   t o   s e n d   y o u r   o b j e c t   t o .  
 	 o p t i o n s   -   s e e   < X H R >   o p t i o n s  
  
 E x a m p l e :  
 	 t h i s   c o d e   w i l l   s e n d   u s e r   i n f o r m a t i o n   b a s e d   o n   n a m e / l a s t   n a m e  
 	 ( s t a r t   c o d e )  
 	 v a r   j S o n R e q u e s t   =   n e w   J s o n . R e m o t e ( " h t t p : / / s i t e . c o m / t e l l M e A g e . p h p " ,   { o n C o m p l e t e :   f u n c t i o n ( p e r s o n ) {  
 	 	 a l e r t ( p e r s o n . a g e ) ;   / / i s   2 5   y e a r s  
 	 	 a l e r t ( p e r s o n . h e i g h t ) ;   / / i s   1 7 0   c m  
 	 	 a l e r t ( p e r s o n . w e i g h t ) ;   / / i s   1 2 0   k g  
 	 } } ) . s e n d ( { ' n a m e ' :   ' J o h n ' ,   ' l a s t N a m e ' :   ' D o e ' } ) ;  
 	 ( e n d )  
 * /  
  
 J s o n . R e m o t e   =   X H R . e x t e n d ( {  
  
 	 i n i t i a l i z e :   f u n c t i o n ( u r l ,   o p t i o n s ) {  
 	 	 t h i s . u r l   =   u r l ;  
 	 	 t h i s . a d d E v e n t ( ' o n S u c c e s s ' ,   t h i s . o n C o m p l e t e ) ;  
 	 	 t h i s . p a r e n t ( o p t i o n s ) ;  
 	 	 t h i s . s e t H e a d e r ( ' X - R e q u e s t ' ,   ' J S O N ' ) ;  
 	 } ,  
  
 	 s e n d :   f u n c t i o n ( o b j ) {  
 	 	 r e t u r n   t h i s . p a r e n t ( t h i s . u r l ,   ' j s o n = '   +   J s o n . t o S t r i n g ( o b j ) ) ;  
 	 } ,  
  
 	 o n C o m p l e t e :   f u n c t i o n ( ) {  
 	 	 t h i s . f i r e E v e n t ( ' o n C o m p l e t e ' ,   [ J s o n . e v a l u a t e ( t h i s . r e s p o n s e . t e x t ,   t h i s . o p t i o n s . s e c u r e ) ] ) ;  
 	 }  
  
 } ) ;  
  
 / *  
 S c r i p t :   A s s e t s . j s  
 	 p r o v i d e s   d y n a m i c   l o a d i n g   f o r   i m a g e s ,   c s s   a n d   j a v a s c r i p t   f i l e s .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 v a r   A s s e t   =   n e w   A b s t r a c t ( {  
  
 	 / *  
 	 P r o p e r t y :   j a v a s c r i p t  
 	 	 I n j e c t s   a   j a v a s c r i p t   f i l e   i n   t h e   p a g e .  
  
 	 A r g u m e n t s :  
 	 	 s o u r c e   -   t h e   p a t h   o f   t h e   j a v a s c r i p t   f i l e  
 	 	 p r o p e r t i e s   -   s o m e   a d d i t i o n a l   a t t r i b u t e s   y o u   m i g h t   w a n t   t o   a d d   t o   t h e   s c r i p t   e l e m e n t  
  
 	 E x a m p l e :  
 	 	 >   n e w   A s s e t . j a v a s c r i p t ( ' / s c r i p t s / m y S c r i p t . j s ' ,   { i d :   ' m y S c r i p t ' } ) ;  
 	 * /  
  
 	 j a v a s c r i p t :   f u n c t i o n ( s o u r c e ,   p r o p e r t i e s ) {  
 	 	 p r o p e r t i e s   =   $ m e r g e ( {  
 	 	 	 ' o n l o a d ' :   C l a s s . e m p t y  
 	 	 } ,   p r o p e r t i e s ) ;  
 	 	 v a r   s c r i p t   =   n e w   E l e m e n t ( ' s c r i p t ' ,   { ' s r c ' :   s o u r c e } ) . a d d E v e n t s ( {  
 	 	 	 ' l o a d ' :   p r o p e r t i e s . o n l o a d ,  
 	 	 	 ' r e a d y s t a t e c h a n g e ' :   f u n c t i o n ( ) {  
 	 	 	 	 i f   ( t h i s . r e a d y S t a t e   = =   ' c o m p l e t e ' )   t h i s . f i r e E v e n t ( ' l o a d ' ) ;  
 	 	 	 }  
 	 	 } ) ;  
 	 	 d e l e t e   p r o p e r t i e s . o n l o a d ;  
 	 	 r e t u r n   s c r i p t . s e t P r o p e r t i e s ( p r o p e r t i e s ) . i n j e c t ( d o c u m e n t . h e a d ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   c s s  
 	 	 I n j e c t s   a   c s s   f i l e   i n   t h e   p a g e .  
  
 	 A r g u m e n t s :  
 	 	 s o u r c e   -   t h e   p a t h   o f   t h e   c s s   f i l e  
 	 	 p r o p e r t i e s   -   s o m e   a d d i t i o n a l   a t t r i b u t e s   y o u   m i g h t   w a n t   t o   a d d   t o   t h e   l i n k   e l e m e n t  
  
 	 E x a m p l e :  
 	 	 >   n e w   A s s e t . c s s ( ' / c s s / m y S t y l e . c s s ' ,   { i d :   ' m y S t y l e ' ,   t i t l e :   ' m y S t y l e ' } ) ;  
 	 * /  
  
 	 c s s :   f u n c t i o n ( s o u r c e ,   p r o p e r t i e s ) {  
 	 	 r e t u r n   n e w   E l e m e n t ( ' l i n k ' ,   $ m e r g e ( {  
 	 	 	 ' r e l ' :   ' s t y l e s h e e t ' ,   ' m e d i a ' :   ' s c r e e n ' ,   ' t y p e ' :   ' t e x t / c s s ' ,   ' h r e f ' :   s o u r c e  
 	 	 } ,   p r o p e r t i e s ) ) . i n j e c t ( d o c u m e n t . h e a d ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   i m a g e  
 	 	 P r e l o a d s   a n   i m a g e   a n d   r e t u r n s   t h e   i m g   e l e m e n t .   d o e s   n o t   i n j e c t   i t   t o   t h e   p a g e .  
  
 	 A r g u m e n t s :  
 	 	 s o u r c e   -   t h e   p a t h   o f   t h e   i m a g e   f i l e  
 	 	 p r o p e r t i e s   -   s o m e   a d d i t i o n a l   a t t r i b u t e s   y o u   m i g h t   w a n t   t o   a d d   t o   t h e   i m g   e l e m e n t  
  
 	 E x a m p l e :  
 	 	 >   n e w   A s s e t . i m a g e ( ' / i m a g e s / m y I m a g e . p n g ' ,   { i d :   ' m y I m a g e ' ,   t i t l e :   ' m y I m a g e ' ,   o n l o a d :   m y F u n c t i o n } ) ;  
  
 	 R e t u r n s :  
 	 	 t h e   i m g   e l e m e n t .   y o u   c a n   i n j e c t   i t   a n y w h e r e   y o u   w a n t   w i t h   < E l e m e n t . i n j e c t I n s i d e > / < E l e m e n t . i n j e c t A f t e r > / < E l e m e n t . i n j e c t B e f o r e >  
 	 * /  
  
 	 i m a g e :   f u n c t i o n ( s o u r c e ,   p r o p e r t i e s ) {  
 	 	 p r o p e r t i e s   =   $ m e r g e ( {  
 	 	 	 ' o n l o a d ' :   C l a s s . e m p t y ,  
 	 	 	 ' o n a b o r t ' :   C l a s s . e m p t y ,  
 	 	 	 ' o n e r r o r ' :   C l a s s . e m p t y  
 	 	 } ,   p r o p e r t i e s ) ;  
 	 	 v a r   i m a g e   =   n e w   I m a g e ( ) ;  
 	 	 i m a g e . s r c   =   s o u r c e ;  
 	 	 v a r   e l e m e n t   =   n e w   E l e m e n t ( ' i m g ' ,   { ' s r c ' :   s o u r c e } ) ;  
 	 	 [ ' l o a d ' ,   ' a b o r t ' ,   ' e r r o r ' ] . e a c h ( f u n c t i o n ( t y p e ) {  
 	 	 	 v a r   e v e n t   =   p r o p e r t i e s [ ' o n '   +   t y p e ] ;  
 	 	 	 d e l e t e   p r o p e r t i e s [ ' o n '   +   t y p e ] ;  
 	 	 	 e l e m e n t . a d d E v e n t ( t y p e ,   f u n c t i o n ( ) {  
 	 	 	 	 t h i s . r e m o v e E v e n t ( t y p e ,   a r g u m e n t s . c a l l e e ) ;  
 	 	 	 	 e v e n t . c a l l ( t h i s ) ;  
 	 	 	 } ) ;  
 	 	 } ) ;  
 	 	 i f   ( i m a g e . w i d t h   & &   i m a g e . h e i g h t )   e l e m e n t . f i r e E v e n t ( ' l o a d ' ,   e l e m e n t ,   1 ) ;  
 	 	 r e t u r n   e l e m e n t . s e t P r o p e r t i e s ( p r o p e r t i e s ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   i m a g e s  
 	 	 P r e l o a d s   a n   a r r a y   o f   i m a g e s   ( a s   s t r i n g s )   a n d   r e t u r n s   a n   a r r a y   o f   i m g   e l e m e n t s .   d o e s   n o t   i n j e c t   t h e m   t o   t h e   p a g e .  
  
 	 A r g u m e n t s :  
 	 	 s o u r c e s   -   a r r a y ,   t h e   p a t h s   o f   t h e   i m a g e   f i l e s  
 	 	 o p t i o n s   -   o b j e c t ,   s e e   b e l o w  
  
 	 O p t i o n s :  
 	 	 o n C o m p l e t e   -   a   f u n c t i o n   t o   e x e c u t e   w h e n   a l l   i m a g e   f i l e s   a r e   l o a d e d   i n   t h e   b r o w s e r ' s   c a c h e  
 	 	 o n P r o g r e s s   -   a   f u n c t i o n   t o   e x e c u t e   w h e n   o n e   i m a g e   f i l e   i s   l o a d e d   i n   t h e   b r o w s e r ' s   c a c h e  
  
 	 E x a m p l e :  
 	 	 ( s t a r t   c o d e )  
 	 	 n e w   A s s e t . i m a g e s ( [ ' / i m a g e s / m y I m a g e . p n g ' ,   ' / i m a g e s / m y I m a g e 2 . g i f ' ] ,   {  
 	 	 	 o n C o m p l e t e :   f u n c t i o n ( ) {  
 	 	 	 	 a l e r t ( ' a l l   i m a g e s   l o a d e d ! ' ) ;  
 	 	 	 }  
 	 	 } ) ;  
 	 	 ( e n d )  
  
 	 R e t u r n s :  
 	 	 t h e   i m g   e l e m e n t s   a s   $ $ .   y o u   c a n   i n j e c t   t h e m   a n y w h e r e   y o u   w a n t   w i t h   < E l e m e n t . i n j e c t I n s i d e > / < E l e m e n t . i n j e c t A f t e r > / < E l e m e n t . i n j e c t B e f o r e >  
 	 * /  
  
 	 i m a g e s :   f u n c t i o n ( s o u r c e s ,   o p t i o n s ) {  
 	 	 o p t i o n s   =   $ m e r g e ( {  
 	 	 	 o n C o m p l e t e :   C l a s s . e m p t y ,  
 	 	 	 o n P r o g r e s s :   C l a s s . e m p t y  
 	 	 } ,   o p t i o n s ) ;  
 	 	 i f   ( ! s o u r c e s . p u s h )   s o u r c e s   =   [ s o u r c e s ] ;  
 	 	 v a r   i m a g e s   =   [ ] ;  
 	 	 v a r   c o u n t e r   =   0 ;  
 	 	 s o u r c e s . e a c h ( f u n c t i o n ( s o u r c e ) {  
 	 	 	 v a r   i m g   =   n e w   A s s e t . i m a g e ( s o u r c e ,   {  
 	 	 	 	 ' o n l o a d ' :   f u n c t i o n ( ) {  
 	 	 	 	 	 o p t i o n s . o n P r o g r e s s . c a l l ( t h i s ,   c o u n t e r ) ;  
 	 	 	 	 	 c o u n t e r + + ;  
 	 	 	 	 	 i f   ( c o u n t e r   = =   s o u r c e s . l e n g t h )   o p t i o n s . o n C o m p l e t e ( ) ;  
 	 	 	 	 }  
 	 	 	 } ) ;  
 	 	 	 i m a g e s . p u s h ( i m g ) ;  
 	 	 } ) ;  
 	 	 r e t u r n   n e w   E l e m e n t s ( i m a g e s ) ;  
 	 }  
  
 } ) ;  
  
 / *  
 S c r i p t :   H a s h . j s  
 	 C o n t a i n s   t h e   c l a s s   H a s h .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   H a s h  
 	 I t   w r a p s   a n   o b j e c t   t h a t   i t   u s e s   i n t e r n a l l y   a s   a   m a p .   T h e   u s e r   m u s t   u s e   s e t ( ) ,   g e t ( ) ,   a n d   r e m o v e ( )   t o   a d d / c h a n g e ,   r e t r i e v e   a n d   r e m o v e   v a l u e s ,   i t   m u s t   n o t   a c c e s s   t h e   i n t e r n a l   o b j e c t   d i r e c t l y .   n u l l / u n d e f i n e d   v a l u e s   a r e   a l l o w e d .  
  
 N o t e :  
 	 E a c h   h a s h   i n s t a n c e   h a s   t h e   l e n g t h   p r o p e r t y .  
  
 A r g u m e n t s :  
 	 o b j   -   a n   o b j e c t   t o   c o n v e r t   i n t o   a   H a s h   i n s t a n c e .  
  
 E x a m p l e :  
 	 ( s t a r t   c o d e )  
 	 v a r   h a s h   =   n e w   H a s h ( { a :   ' h i ' ,   b :   ' w o r l d ' ,   c :   ' h o w d y ' } ) ;  
 	 h a s h . r e m o v e ( ' b ' ) ;   / /   b   i s   r e m o v e d .  
 	 h a s h . s e t ( ' c ' ,   ' h e l l o ' ) ;  
 	 h a s h . g e t ( ' c ' ) ;   / /   r e t u r n s   ' h e l l o '  
 	 h a s h . l e n g t h   / /   r e t u r n s   2   ( a   a n d   c )  
 	 ( e n d )  
 * /  
  
 v a r   H a s h   =   n e w   C l a s s ( {  
  
 	 l e n g t h :   0 ,  
  
 	 i n i t i a l i z e :   f u n c t i o n ( o b j e c t ) {  
 	 	 t h i s . o b j   =   o b j e c t   | |   { } ;  
 	 	 t h i s . s e t L e n g t h ( ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   g e t  
 	 	 R e t r i e v e s   a   v a l u e   f r o m   t h e   h a s h .  
  
 	 A r g u m e n t s :  
 	 	 k e y   -   T h e   k e y  
  
 	 R e t u r n s :  
 	 	 T h e   v a l u e  
 	 * /  
  
 	 g e t :   f u n c t i o n ( k e y ) {  
 	 	 r e t u r n   ( t h i s . h a s K e y ( k e y ) )   ?   t h i s . o b j [ k e y ]   :   n u l l ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   h a s K e y  
 	 	 C h e c k   t h e   p r e s e n c e   o f   a   s p e c i f i e d   k e y - v a l u e   p a i r   i n   t h e   h a s h .  
  
 	 A r g u m e n t s :  
 	 	 k e y   -   T h e   k e y  
  
 	 R e t u r n s :  
 	 	 T r u e   i f   t h e   H a s h   c o n t a i n s   a   v a l u e   f o r   t h e   s p e c i f i e d   k e y ,   o t h e r w i s e   f a l s e  
 	 * /  
  
 	 h a s K e y :   f u n c t i o n ( k e y ) {  
 	 	 r e t u r n   ( k e y   i n   t h i s . o b j ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s e t  
 	 	 A d d s   a   k e y - v a l u e   p a i r   t o   t h e   h a s h   o r   r e p l a c e s   a   p r e v i o u s   v a l u e   a s s o c i a t e d   w i t h   t h e   k e y .  
  
 	 A r g u m e n t s :  
 	 	 k e y   -   T h e   k e y  
 	 	 v a l u e   -   T h e   v a l u e  
 	 * /  
  
 	 s e t :   f u n c t i o n ( k e y ,   v a l u e ) {  
 	 	 i f   ( ! t h i s . h a s K e y ( k e y ) )   t h i s . l e n g t h + + ;  
 	 	 t h i s . o b j [ k e y ]   =   v a l u e ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 s e t L e n g t h :   f u n c t i o n ( ) {  
 	 	 t h i s . l e n g t h   =   0 ;  
 	 	 f o r   ( v a r   p   i n   t h i s . o b j )   t h i s . l e n g t h + + ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   r e m o v e  
 	 	 R e m o v e s   a   k e y - v a l u e   p a i r   f r o m   t h e   h a s h .  
  
 	 A r g u m e n t s :  
 	 	 k e y   -   T h e   k e y  
 	 * /  
  
 	 r e m o v e :   f u n c t i o n ( k e y ) {  
 	 	 i f   ( t h i s . h a s K e y ( k e y ) ) {  
 	 	 	 d e l e t e   t h i s . o b j [ k e y ] ;  
 	 	 	 t h i s . l e n g t h - - ;  
 	 	 }  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   e a c h  
 	 	 C a l l s   a   f u n c t i o n   f o r   e a c h   k e y - v a l u e   p a i r .   T h e   f i r s t   a r g u m e n t   p a s s e d   t o   t h e   f u n c t i o n   w i l l   b e   t h e   v a l u e ,   t h e   s e c o n d   o n e   w i l l   b e   t h e   k e y ,   l i k e   $ e a c h .  
  
 	 A r g u m e n t s :  
 	 	 f n   -   T h e   f u n c t i o n   t o   c a l l   f o r   e a c h   k e y - v a l u e   p a i r  
 	 	 b i n d   -   O p t i o n a l ,   t h e   o b j e c t   t h a t   w i l l   b e   r e f e r r e d   t o   a s   " t h i s "   i n   t h e   f u n c t i o n  
 	 * /  
  
 	 e a c h :   f u n c t i o n ( f n ,   b i n d ) {  
 	 	 $ e a c h ( t h i s . o b j ,   f n ,   b i n d ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   e x t e n d  
 	 	 E x t e n d s   t h e   c u r r e n t   h a s h   w i t h   a n   o b j e c t   c o n t a i n i n g   k e y - v a l u e   p a i r s .   V a l u e s   f o r   d u p l i c a t e   k e y s   w i l l   b e   r e p l a c e d   b y   t h e   n e w   o n e s .  
  
 	 A r g u m e n t s :  
 	 	 o b j   -   A n   o b j e c t   c o n t a i n i n g   k e y - v a l u e   p a i r s  
 	 * /  
  
 	 e x t e n d :   f u n c t i o n ( o b j ) {  
 	 	 $ e x t e n d ( t h i s . o b j ,   o b j ) ;  
 	 	 r e t u r n   t h i s . s e t L e n g t h ( ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   m e r g e  
 	 	 M e r g e s   t h e   c u r r e n t   h a s h   w i t h   m u l t i p l e   o b j e c t s .  
 	 * /  
  
 	 m e r g e :   f u n c t i o n ( ) {  
 	 	 t h i s . o b j   =   $ m e r g e . a p p l y ( n u l l ,   [ t h i s . o b j ] . e x t e n d ( a r g u m e n t s ) ) ;  
 	 	 r e t u r n   t h i s . s e t L e n g t h ( ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   e m p t y  
 	 	 E m p t i e s   a l l   h a s h   v a l u e s   p r o p e r t i e s   a n d   v a l u e s .  
 	 * /  
  
 	 e m p t y :   f u n c t i o n ( ) {  
 	 	 t h i s . o b j   =   { } ;  
 	 	 t h i s . l e n g t h   =   0 ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   k e y s  
 	 	 R e t u r n s   a n   a r r a y   c o n t a i n i n g   a l l   t h e   k e y s ,   i n   t h e   s a m e   o r d e r   a s   t h e   v a l u e s   r e t u r n e d   b y   < H a s h . v a l u e s > .  
  
 	 R e t u r n s :  
 	 	 A n   a r r a y   c o n t a i n i n g   a l l   t h e   k e y s   o f   t h e   h a s h  
 	 * /  
  
 	 k e y s :   f u n c t i o n ( ) {  
 	 	 v a r   k e y s   =   [ ] ;  
 	 	 f o r   ( v a r   p r o p e r t y   i n   t h i s . o b j )   k e y s . p u s h ( p r o p e r t y ) ;  
 	 	 r e t u r n   k e y s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   v a l u e s  
 	 	 R e t u r n s   a n   a r r a y   c o n t a i n i n g   a l l   t h e   v a l u e s ,   i n   t h e   s a m e   o r d e r   a s   t h e   k e y s   r e t u r n e d   b y   < H a s h . k e y s > .  
  
 	 R e t u r n s :  
 	 	 A n   a r r a y   c o n t a i n i n g   a l l   t h e   v a l u e s   o f   t h e   h a s h  
 	 * /  
  
 	 v a l u e s :   f u n c t i o n ( ) {  
 	 	 v a r   v a l u e s   =   [ ] ;  
 	 	 f o r   ( v a r   p r o p e r t y   i n   t h i s . o b j )   v a l u e s . p u s h ( t h i s . o b j [ p r o p e r t y ] ) ;  
 	 	 r e t u r n   v a l u e s ;  
 	 }  
  
 } ) ;  
  
 / *   S e c t i o n :   U t i l i t y   F u n c t i o n s   * /  
  
 / *  
 F u n c t i o n :   $ H  
 	 S h o r t c u t   t o   c r e a t e   a   H a s h   f r o m   a n   O b j e c t .  
 * /  
  
 f u n c t i o n   $ H ( o b j ) {  
 	 r e t u r n   n e w   H a s h ( o b j ) ;  
 } ;  
  
 / *  
 S c r i p t :   H a s h . C o o k i e . j s  
 	 S t o r e s   a n d   l o a d s   a n   H a s h   a s   a   c o o k i e   u s i n g   J s o n   f o r m a t .  
 * /  
  
 / *  
 C l a s s :   H a s h . C o o k i e  
 	 I n h e r i t s   a l l   t h e   m e t h o d s   f r o m   < H a s h > ,   a d d i t i o n a l   m e t h o d s   a r e   s a v e   a n d   l o a d .  
 	 H a s h   j s o n   s t r i n g   h a s   a   l i m i t   o f   4 k b   ( 4 0 9 6 b y t e ) ,   s o   b e   c a r e f u l   w i t h   y o u r   H a s h   s i z e .  
 	 C r e a t i n g   a   n e w   i n s t a n c e   a u t o m a t i c a l l y   l o a d s   t h e   d a t a   f r o m   t h e   C o o k i e   i n t o   t h e   H a s h .  
 	 I f   t h e   H a s h   i s   e m p t i e d ,   t h e   c o o k i e   i s   a l s o   r e m o v e d .  
  
 A r g u m e n t s :  
 	 n a m e   -   t h e   k e y   ( n a m e )   f o r   t h e   c o o k i e  
 	 o p t i o n s   -   o p t i o n s   a r e   i d e n t i c a l   t o   < C o o k i e >   a n d   a r e   s i m p l y   p a s s e d   a l o n g   t o   i t .  
 	 	 I n   a d d i t i o n ,   i t   h a s   t h e   a u t o S a v e   o p t i o n ,   t o   s a v e   t h e   c o o k i e   a t   e v e r y   o p e r a t i o n .   d e f a u l t s   t o   t r u e .  
  
 E x a m p l e :  
 	 ( s t a r t   c o d e )  
 	 v a r   f r u i t s   =   n e w   H a s h . C o o k i e ( ' m y C o o k i e N a m e ' ,   { d u r a t i o n :   3 6 0 0 } ) ;  
 	 f r u i t s . e x t e n d ( {  
 	 	 ' l e m o n ' :   ' y e l l o w ' ,  
 	 	 ' a p p l e ' :   ' r e d '  
 	 } ) ;  
 	 f r u i t s . s e t ( ' m e l o n ' ,   ' g r e e n ' ) ;  
 	 f r u i t s . g e t ( ' l e m o n ' ) ;   / /   y e l l o w  
  
 	 / /   . . .   o n   a n o t h e r   p a g e   . . .   v a l u e s   l o a d   a u t o m a t i c a l l y  
  
 	 v a r   f r u i t s   =   n e w   H a s h . C o o k i e ( ' m y C o o k i e N a m e ' ,   { d u r a t i o n :   3 6 5 } ) ;  
 	 f r u i t s . g e t ( ' m e l o n ' ) ;   / /   g r e e n  
  
 	 f r u i t s . e r a s e ( ) ;   / /   d e l e t e   c o o k i e  
 	 ( e n d )  
 * /  
  
 H a s h . C o o k i e   =   H a s h . e x t e n d ( {  
  
 	 i n i t i a l i z e :   f u n c t i o n ( n a m e ,   o p t i o n s ) {  
 	 	 t h i s . n a m e   =   n a m e ;  
 	 	 t h i s . o p t i o n s   =   $ e x t e n d ( { ' a u t o S a v e ' :   t r u e } ,   o p t i o n s   | |   { } ) ;  
 	 	 t h i s . l o a d ( ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s a v e  
 	 	 S a v e s   t h e   H a s h   t o   t h e   c o o k i e .   I f   t h e   h a s h   i s   e m p t y ,   r e m o v e s   t h e   c o o k i e .  
  
 	 R e t u r n s :  
 	 	 R e t u r n s   f a l s e   w h e n   t h e   J S O N   s t r i n g   c o o k i e   i s   t o o   l o n g   ( 4 k b ) ,   o t h e r w i s e   t r u e .  
  
 	 E x a m p l e :  
 	 	 ( s t a r t   c o d e )  
 	 	 v a r   l o g i n   =   n e w   H a s h . C o o k i e ( ' u s e r s t a t u s ' ,   { a u t o S a v e :   f a l s e } ) ;  
  
 	 	 l o g i n . e x t e n d ( {  
 	 	 	 ' u s e r n a m e ' :   ' J o h n ' ,  
 	 	 	 ' c r e d e n t i a l s ' :   [ 4 ,   7 ,   9 ]  
 	 	 } ) ;  
 	 	 l o g i n . s e t ( ' l a s t _ m e s s a g e ' ,   ' U s e r   l o g g e d   i n ! ' ) ;  
  
 	 	 l o g i n . s a v e ( ) ;   / /   f i n a l l y   s a v e   t h e   H a s h  
 	 	 ( e n d )  
 	 * /  
  
 	 s a v e :   f u n c t i o n ( ) {  
 	 	 i f   ( t h i s . l e n g t h   = =   0 ) {  
 	 	 	 C o o k i e . r e m o v e ( t h i s . n a m e ,   t h i s . o p t i o n s ) ;  
 	 	 	 r e t u r n   t r u e ;  
 	 	 }  
 	 	 v a r   s t r   =   J s o n . t o S t r i n g ( t h i s . o b j ) ;  
 	 	 i f   ( s t r . l e n g t h   >   4 0 9 6 )   r e t u r n   f a l s e ;   / / c o o k i e   w o u l d   b e   t r u n c a t e d !  
 	 	 C o o k i e . s e t ( t h i s . n a m e ,   s t r ,   t h i s . o p t i o n s ) ;  
 	 	 r e t u r n   t r u e ;  
 	 } ,  
 	  
 	 / *  
 	 P r o p e r t y :   l o a d  
 	 	 L o a d s   t h e   c o o k i e   a n d   a s s i g n s   i t   t o   t h e   H a s h .  
 	 * /  
  
 	 l o a d :   f u n c t i o n ( ) {  
 	 	 t h i s . o b j   =   J s o n . e v a l u a t e ( C o o k i e . g e t ( t h i s . n a m e ) ,   t r u e )   | |   { } ;  
 	 	 t h i s . s e t L e n g t h ( ) ;  
 	 }  
  
 } ) ;  
  
 H a s h . C o o k i e . M e t h o d s   =   { } ;  
 [ ' e x t e n d ' ,   ' s e t ' ,   ' m e r g e ' ,   ' e m p t y ' ,   ' r e m o v e ' ] . e a c h ( f u n c t i o n ( m e t h o d ) {  
 	 H a s h . C o o k i e . M e t h o d s [ m e t h o d ]   =   f u n c t i o n ( ) {  
 	 	 H a s h . p r o t o t y p e [ m e t h o d ] . a p p l y ( t h i s ,   a r g u m e n t s ) ;  
 	 	 i f   ( t h i s . o p t i o n s . a u t o S a v e )   t h i s . s a v e ( ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ;  
 } ) ;  
 H a s h . C o o k i e . i m p l e m e n t ( H a s h . C o o k i e . M e t h o d s ) ;  
  
 / *  
 S c r i p t :   C o l o r . j s  
 	 C o n t a i n s   t h e   C o l o r   c l a s s .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   C o l o r  
 	 C r e a t e s   a   n e w   C o l o r   O b j e c t ,   w h i c h   i s   a n   a r r a y   w i t h   s o m e   c o l o r   s p e c i f i c   m e t h o d s .  
 A r g u m e n t s :  
 	 c o l o r   -   t h e   h e x ,   t h e   R G B   a r r a y   o r   t h e   H S B   a r r a y   o f   t h e   c o l o r   t o   c r e a t e .   F o r   H S B   c o l o r s ,   y o u   n e e d   t o   s p e c i f y   t h e   s e c o n d   a r g u m e n t .  
 	 t y p e   -   a   s t r i n g   r e p r e s e n t i n g   t h e   t y p e   o f   t h e   c o l o r   t o   c r e a t e .   n e e d s   t o   b e   s p e c i f i e d   i f   y o u   i n t e n d   t o   c r e a t e   t h e   c o l o r   w i t h   H S B   v a l u e s ,   o r   a n   a r r a y   o f   H E X   v a l u e s .   C a n   b e   ' r g b ' ,   ' h s b '   o r   ' h e x ' .  
  
 E x a m p l e :  
 	 ( s t a r t   c o d e )  
 	 v a r   b l a c k   =   n e w   C o l o r ( ' # 0 0 0 ' ) ;  
 	 v a r   p u r p l e   =   n e w   C o l o r ( [ 2 5 5 , 0 , 2 5 5 ] ) ;  
 	 / /   m i x   b l a c k   w i t h   w h i t e   a n d   p u r p l e ,   e a c h   t i m e   a t   1 0 %   o f   t h e   n e w   c o l o r  
 	 v a r   d a r k p u r p l e   =   b l a c k . m i x ( ' # f f f ' ,   p u r p l e ,   1 0 ) ;  
 	 $ ( ' m y D i v ' ) . s e t S t y l e ( ' b a c k g r o u n d - c o l o r ' ,   d a r k p u r p l e ) ;  
 	 ( e n d )  
 * /  
  
 v a r   C o l o r   =   n e w   C l a s s ( {  
  
 	 i n i t i a l i z e :   f u n c t i o n ( c o l o r ,   t y p e ) {  
 	 	 t y p e   =   t y p e   | |   ( c o l o r . p u s h   ?   ' r g b '   :   ' h e x ' ) ;  
 	 	 v a r   r g b ,   h s b ;  
 	 	 s w i t c h ( t y p e ) {  
 	 	 	 c a s e   ' r g b ' :  
 	 	 	 	 r g b   =   c o l o r ;  
 	 	 	 	 h s b   =   r g b . r g b T o H s b ( ) ;  
 	 	 	 	 b r e a k ;  
 	 	 	 c a s e   ' h s b ' :  
 	 	 	 	 r g b   =   c o l o r . h s b T o R g b ( ) ;  
 	 	 	 	 h s b   =   c o l o r ;  
 	 	 	 	 b r e a k ;  
 	 	 	 d e f a u l t :  
 	 	 	 	 r g b   =   c o l o r . h e x T o R g b ( t r u e ) ;  
 	 	 	 	 h s b   =   r g b . r g b T o H s b ( ) ;  
 	 	 }  
 	 	 r g b . h s b   =   h s b ;  
 	 	 r g b . h e x   =   r g b . r g b T o H e x ( ) ;  
 	 	 r e t u r n   $ e x t e n d ( r g b ,   C o l o r . p r o t o t y p e ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   m i x  
 	 	 M i x e s   t w o   o r   m o r e   c o l o r s   w i t h   t h e   C o l o r .  
 	 	  
 	 A r g u m e n t s :  
 	 	 c o l o r   -   a   c o l o r   t o   m i x .   y o u   c a n   u s e   a s   a r g u m e n t s   h o w   m a n y   c o l o r s   a s   y o u   w a n t   t o   m i x   w i t h   t h e   o r i g i n a l   o n e .  
 	 	 a l p h a   -   i f   y o u   u s e   a   n u m b e r   a s   t h e   l a s t   a r g u m e n t ,   i t   w i l l   b e   t h r e a t e d   a s   t h e   a m o u n t   o f   t h e   c o l o r   t o   m i x .  
 	 * /  
  
 	 m i x :   f u n c t i o n ( ) {  
 	 	 v a r   c o l o r s   =   $ A ( a r g u m e n t s ) ;  
 	 	 v a r   a l p h a   =   ( $ t y p e ( c o l o r s [ c o l o r s . l e n g t h   -   1 ] )   = =   ' n u m b e r ' )   ?   c o l o r s . p o p ( )   :   5 0 ;  
 	 	 v a r   r g b   =   t h i s . c o p y ( ) ;  
 	 	 c o l o r s . e a c h ( f u n c t i o n ( c o l o r ) {  
 	 	 	 c o l o r   =   n e w   C o l o r ( c o l o r ) ;  
 	 	 	 f o r   ( v a r   i   =   0 ;   i   <   3 ;   i + + )   r g b [ i ]   =   M a t h . r o u n d ( ( r g b [ i ]   /   1 0 0   *   ( 1 0 0   -   a l p h a ) )   +   ( c o l o r [ i ]   /   1 0 0   *   a l p h a ) ) ;  
 	 	 } ) ;  
 	 	 r e t u r n   n e w   C o l o r ( r g b ,   ' r g b ' ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   i n v e r t  
 	 	 I n v e r t s   t h e   C o l o r .  
 	 * /  
  
 	 i n v e r t :   f u n c t i o n ( ) {  
 	 	 r e t u r n   n e w   C o l o r ( t h i s . m a p ( f u n c t i o n ( v a l u e ) {  
 	 	 	 r e t u r n   2 5 5   -   v a l u e ;  
 	 	 } ) ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s e t H u e  
 	 	 M o d i f i e s   t h e   h u e   o f   t h e   C o l o r ,   a n d   r e t u r n s   a   n e w   o n e .  
 	  
 	 A r g u m e n t s :  
 	 	 v a l u e   -   t h e   h u e   t o   s e t  
 	 * /  
  
 	 s e t H u e :   f u n c t i o n ( v a l u e ) {  
 	 	 r e t u r n   n e w   C o l o r ( [ v a l u e ,   t h i s . h s b [ 1 ] ,   t h i s . h s b [ 2 ] ] ,   ' h s b ' ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s e t S a t u r a t i o n  
 	 	 C h a n g e s   t h e   s a t u r a t i o n   o f   t h e   C o l o r ,   a n d   r e t u r n s   a   n e w   o n e .  
 	  
 	 A r g u m e n t s :  
 	 	 p e r c e n t   -   t h e   p e r c e n t a g e   o f   t h e   s a t u r a t i o n   t o   s e t  
 	 * /  
  
 	 s e t S a t u r a t i o n :   f u n c t i o n ( p e r c e n t ) {  
 	 	 r e t u r n   n e w   C o l o r ( [ t h i s . h s b [ 0 ] ,   p e r c e n t ,   t h i s . h s b [ 2 ] ] ,   ' h s b ' ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s e t B r i g h t n e s s  
 	 	 C h a n g e s   t h e   b r i g h t n e s s   o f   t h e   C o l o r ,   a n d   r e t u r n s   a   n e w   o n e .  
 	  
 	 A r g u m e n t s :  
 	 	 p e r c e n t   -   t h e   p e r c e n t a g e   o f   t h e   b r i g h t n e s s   t o   s e t  
 	 * /  
  
 	 s e t B r i g h t n e s s :   f u n c t i o n ( p e r c e n t ) {  
 	 	 r e t u r n   n e w   C o l o r ( [ t h i s . h s b [ 0 ] ,   t h i s . h s b [ 1 ] ,   p e r c e n t ] ,   ' h s b ' ) ;  
 	 }  
  
 } ) ;  
  
 / *   S e c t i o n :   U t i l i t y   F u n c t i o n s   * /  
  
 / *  
 F u n c t i o n :   $ R G B  
 	 S h o r t c u t   t o   c r e a t e   a   n e w   c o l o r ,   b a s e d   o n   r e d ,   g r e e n ,   b l u e   v a l u e s .  
  
 A r g u m e n t s :  
 	 r   -   ( i n t e g e r )   r e d   v a l u e   ( 0 - 2 5 5 )  
 	 g   -   ( i n t e g e r )   g r e e n   v a l u e   ( 0 - 2 5 5 )  
 	 b   -   ( i n t e g e r )   b l u e   v a l u e   ( 0 - 2 5 5 )  
  
 * /  
  
 f u n c t i o n   $ R G B ( r ,   g ,   b ) {  
 	 r e t u r n   n e w   C o l o r ( [ r ,   g ,   b ] ,   ' r g b ' ) ;  
 } ;  
  
 / *  
 F u n c t i o n :   $ H S B  
 	 S h o r t c u t   t o   c r e a t e   a   n e w   c o l o r ,   b a s e d   o n   h u e ,   s a t u r a t i o n ,   b r i g h t n e s s   v a l u e s .  
  
 A r g u m e n t s :  
 	 h   -   ( i n t e g e r )   h u e   v a l u e   ( 0 - 1 0 0 )  
 	 s   -   ( i n t e g e r )   s a t u r a t i o n   v a l u e   ( 0 - 1 0 0 )  
 	 b   -   ( i n t e g e r )   b r i g h t n e s s   v a l u e   ( 0 - 1 0 0 )  
 * /  
  
 f u n c t i o n   $ H S B ( h ,   s ,   b ) {  
 	 r e t u r n   n e w   C o l o r ( [ h ,   s ,   b ] ,   ' h s b ' ) ;  
 } ;  
  
 / *  
 C l a s s :   A r r a y  
 	 A   c o l l e c t i o n   o f   T h e   A r r a y   O b j e c t   p r o t o t y p e   m e t h o d s .  
 * /  
  
 A r r a y . e x t e n d ( {  
 	  
 	 / *  
 	 P r o p e r t y :   r g b T o H s b  
 	 	 C o n v e r t s   a   R G B   a r r a y   t o   a n   H S B   a r r a y .  
  
 	 R e t u r n s :  
 	 	 t h e   H S B   a r r a y .  
 	 * /  
  
 	 r g b T o H s b :   f u n c t i o n ( ) {  
 	 	 v a r   r e d   =   t h i s [ 0 ] ,   g r e e n   =   t h i s [ 1 ] ,   b l u e   =   t h i s [ 2 ] ;  
 	 	 v a r   h u e ,   s a t u r a t i o n ,   b r i g h t n e s s ;  
 	 	 v a r   m a x   =   M a t h . m a x ( r e d ,   g r e e n ,   b l u e ) ,   m i n   =   M a t h . m i n ( r e d ,   g r e e n ,   b l u e ) ;  
 	 	 v a r   d e l t a   =   m a x   -   m i n ;  
 	 	 b r i g h t n e s s   =   m a x   /   2 5 5 ;  
 	 	 s a t u r a t i o n   =   ( m a x   ! =   0 )   ?   d e l t a   /   m a x   :   0 ;  
 	 	 i f   ( s a t u r a t i o n   = =   0 ) {  
 	 	 	 h u e   =   0 ;  
 	 	 }   e l s e   {  
 	 	 	 v a r   r r   =   ( m a x   -   r e d )   /   d e l t a ;  
 	 	 	 v a r   g r   =   ( m a x   -   g r e e n )   /   d e l t a ;  
 	 	 	 v a r   b r   =   ( m a x   -   b l u e )   /   d e l t a ;  
 	 	 	 i f   ( r e d   = =   m a x )   h u e   =   b r   -   g r ;  
 	 	 	 e l s e   i f   ( g r e e n   = =   m a x )   h u e   =   2   +   r r   -   b r ;  
 	 	 	 e l s e   h u e   =   4   +   g r   -   r r ;  
 	 	 	 h u e   / =   6 ;  
 	 	 	 i f   ( h u e   <   0 )   h u e + + ;  
 	 	 }  
 	 	 r e t u r n   [ M a t h . r o u n d ( h u e   *   3 6 0 ) ,   M a t h . r o u n d ( s a t u r a t i o n   *   1 0 0 ) ,   M a t h . r o u n d ( b r i g h t n e s s   *   1 0 0 ) ] ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   h s b T o R g b  
 	 	 C o n v e r t s   a n   H S B   a r r a y   t o   a n   R G B   a r r a y .  
  
 	 R e t u r n s :  
 	 	 t h e   R G B   a r r a y .  
 	 * /  
  
 	 h s b T o R g b :   f u n c t i o n ( ) {  
 	 	 v a r   b r   =   M a t h . r o u n d ( t h i s [ 2 ]   /   1 0 0   *   2 5 5 ) ;  
 	 	 i f   ( t h i s [ 1 ]   = =   0 ) {  
 	 	 	 r e t u r n   [ b r ,   b r ,   b r ] ;  
 	 	 }   e l s e   {  
 	 	 	 v a r   h u e   =   t h i s [ 0 ]   %   3 6 0 ;  
 	 	 	 v a r   f   =   h u e   %   6 0 ;  
 	 	 	 v a r   p   =   M a t h . r o u n d ( ( t h i s [ 2 ]   *   ( 1 0 0   -   t h i s [ 1 ] ) )   /   1 0 0 0 0   *   2 5 5 ) ;  
 	 	 	 v a r   q   =   M a t h . r o u n d ( ( t h i s [ 2 ]   *   ( 6 0 0 0   -   t h i s [ 1 ]   *   f ) )   /   6 0 0 0 0 0   *   2 5 5 ) ;  
 	 	 	 v a r   t   =   M a t h . r o u n d ( ( t h i s [ 2 ]   *   ( 6 0 0 0   -   t h i s [ 1 ]   *   ( 6 0   -   f ) ) )   /   6 0 0 0 0 0   *   2 5 5 ) ;  
 	 	 	 s w i t c h ( M a t h . f l o o r ( h u e   /   6 0 ) ) {  
 	 	 	 	 c a s e   0 :   r e t u r n   [ b r ,   t ,   p ] ;  
 	 	 	 	 c a s e   1 :   r e t u r n   [ q ,   b r ,   p ] ;  
 	 	 	 	 c a s e   2 :   r e t u r n   [ p ,   b r ,   t ] ;  
 	 	 	 	 c a s e   3 :   r e t u r n   [ p ,   q ,   b r ] ;  
 	 	 	 	 c a s e   4 :   r e t u r n   [ t ,   p ,   b r ] ;  
 	 	 	 	 c a s e   5 :   r e t u r n   [ b r ,   p ,   q ] ;  
 	 	 	 }  
 	 	 }  
 	 	 r e t u r n   f a l s e ;  
 	 }  
  
 } ) ;  
  
 / *  
 S c r i p t :   S c r o l l e r . j s  
 	 C o n t a i n s   t h e   < S c r o l l e r > .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   S c r o l l e r  
 	 T h e   S c r o l l e r   i s   a   c l a s s   t o   s c r o l l   a n y   e l e m e n t   w i t h   a n   o v e r f l o w   ( i n c l u d i n g   t h e   w i n d o w )   w h e n   t h e   m o u s e   c u r s o r   r e a c h e s   c e r t a i n   b u o n d a r i e s   o f   t h a t   e l e m e n t .  
 	 Y o u   m u s t   c a l l   i t s   s t a r t   m e t h o d   t o   s t a r t   l i s t e n i n g   t o   m o u s e   m o v e m e n t s .  
  
 N o t e :  
 	 T h e   S c r o l l e r   r e q u i r e s   a n   X H T M L   d o c t y p e .  
  
 A r g u m e n t s :  
 	 e l e m e n t   -   r e q u i r e d ,   t h e   e l e m e n t   t o   s c r o l l .  
 	 o p t i o n s   -   o p t i o n a l ,   s e e   o p t i o n s   b e l o w ,   a n d   < F x . B a s e >   o p t i o n s .  
  
 O p t i o n s :  
 	 a r e a   -   i n t e g e r ,   t h e   n e c e s s a r y   b o u n d a r i e s   t o   m a k e   t h e   e l e m e n t   s c r o l l .  
 	 v e l o c i t y   -   i n t e g e r ,   v e l o c i t y   r a t i o ,   t h e   m o d i f i e r   f o r   t h e   w i n d o w   s c r o l l i n g   s p e e d .  
  
 E v e n t s :  
 	 o n C h a n g e   -   o p t i o n a l l y ,   w h e n   t h e   m o u s e   r e a c h e s   s o m e   b o u n d a r i e s ,   y o u   c a n   c h o o s e   t o   a l t e r   s o m e   o t h e r   v a l u e s ,   i n s t e a d   o f   t h e   s c r o l l i n g   o f f s e t s .  
 	 	 A u t o m a t i c a l l y   p a s s e s   a s   p a r a m e t e r s   x   a n d   y   v a l u e s .  
 * /  
  
 v a r   S c r o l l e r   =   n e w   C l a s s ( {  
  
 	 o p t i o n s :   {  
 	 	 a r e a :   2 0 ,  
 	 	 v e l o c i t y :   1 ,  
 	 	 o n C h a n g e :   f u n c t i o n ( x ,   y ) {  
 	 	 	 t h i s . e l e m e n t . s c r o l l T o ( x ,   y ) ;  
 	 	 }  
 	 } ,  
  
 	 i n i t i a l i z e :   f u n c t i o n ( e l e m e n t ,   o p t i o n s ) {  
 	 	 t h i s . s e t O p t i o n s ( o p t i o n s ) ;  
 	 	 t h i s . e l e m e n t   =   $ ( e l e m e n t ) ;  
 	 	 t h i s . m o u s e m o v e r   =   ( [ w i n d o w ,   d o c u m e n t ] . c o n t a i n s ( e l e m e n t ) )   ?   $ ( d o c u m e n t . b o d y )   :   t h i s . e l e m e n t ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s t a r t  
 	 	 T h e   s c r o l l e r   s t a r t s   l i s t e n i n g   t o   m o u s e   m o v e m e n t s .  
 	 * /  
  
 	 s t a r t :   f u n c t i o n ( ) {  
 	 	 t h i s . c o o r d   =   t h i s . g e t C o o r d s . b i n d W i t h E v e n t ( t h i s ) ;  
 	 	 t h i s . m o u s e m o v e r . a d d L i s t e n e r ( ' m o u s e m o v e ' ,   t h i s . c o o r d ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s t o p  
 	 	 T h e   s c r o l l e r   s t o p s   l i s t e n i n g   t o   m o u s e   m o v e m e n t s .  
 	 * /  
  
 	 s t o p :   f u n c t i o n ( ) {  
 	 	 t h i s . m o u s e m o v e r . r e m o v e L i s t e n e r ( ' m o u s e m o v e ' ,   t h i s . c o o r d ) ;  
 	 	 t h i s . t i m e r   =   $ c l e a r ( t h i s . t i m e r ) ;  
 	 } ,  
  
 	 g e t C o o r d s :   f u n c t i o n ( e v e n t ) {  
 	 	 t h i s . p a g e   =   ( t h i s . e l e m e n t   = =   w i n d o w )   ?   e v e n t . c l i e n t   :   e v e n t . p a g e ;  
 	 	 i f   ( ! t h i s . t i m e r )   t h i s . t i m e r   =   t h i s . s c r o l l . p e r i o d i c a l ( 5 0 ,   t h i s ) ;  
 	 } ,  
  
 	 s c r o l l :   f u n c t i o n ( ) {  
 	 	 v a r   e l   =   t h i s . e l e m e n t . g e t S i z e ( ) ;  
 	 	 v a r   p o s   =   t h i s . e l e m e n t . g e t P o s i t i o n ( ) ;  
  
 	 	 v a r   c h a n g e   =   { ' x ' :   0 ,   ' y ' :   0 } ;  
 	 	 f o r   ( v a r   z   i n   t h i s . p a g e ) {  
 	 	 	 i f   ( t h i s . p a g e [ z ]   <   ( t h i s . o p t i o n s . a r e a   +   p o s [ z ] )   & &   e l . s c r o l l [ z ]   ! =   0 )  
 	 	 	 	 c h a n g e [ z ]   =   ( t h i s . p a g e [ z ]   -   t h i s . o p t i o n s . a r e a   -   p o s [ z ] )   *   t h i s . o p t i o n s . v e l o c i t y ;  
 	 	 	 e l s e   i f   ( t h i s . p a g e [ z ]   +   t h i s . o p t i o n s . a r e a   >   ( e l . s i z e [ z ]   +   p o s [ z ] )   & &   e l . s c r o l l [ z ]   +   e l . s i z e [ z ]   ! =   e l . s c r o l l S i z e [ z ] )  
 	 	 	 	 c h a n g e [ z ]   =   ( t h i s . p a g e [ z ]   -   e l . s i z e [ z ]   +   t h i s . o p t i o n s . a r e a   -   p o s [ z ] )   *   t h i s . o p t i o n s . v e l o c i t y ;  
 	 	 }  
 	 	 i f   ( c h a n g e . y   | |   c h a n g e . x )   t h i s . f i r e E v e n t ( ' o n C h a n g e ' ,   [ e l . s c r o l l . x   +   c h a n g e . x ,   e l . s c r o l l . y   +   c h a n g e . y ] ) ;  
 	 }  
  
 } ) ;  
  
 S c r o l l e r . i m p l e m e n t ( n e w   E v e n t s ,   n e w   O p t i o n s ) ;  
  
 / *  
 S c r i p t :   S l i d e r . j s  
 	 C o n t a i n s   < S l i d e r >  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   S l i d e r  
 	 C r e a t e s   a   s l i d e r   w i t h   t w o   e l e m e n t s :   a   k n o b   a n d   a   c o n t a i n e r .   R e t u r n s   t h e   v a l u e s .  
 	  
 N o t e :  
 	 T h e   S l i d e r   r e q u i r e s   a n   X H T M L   d o c t y p e .  
  
 A r g u m e n t s :  
 	 e l e m e n t   -   t h e   k n o b   c o n t a i n e r  
 	 k n o b   -   t h e   h a n d l e  
 	 o p t i o n s   -   s e e   O p t i o n s   b e l o w  
  
 O p t i o n s :  
 	 s t e p s   -   t h e   n u m b e r   o f   s t e p s   f o r   y o u r   s l i d e r .  
 	 m o d e   -   e i t h e r   ' h o r i z o n t a l '   o r   ' v e r t i c a l ' .   d e f a u l t s   t o   h o r i z o n t a l .  
 	 o f f s e t   -   r e l a t i v e   o f f s e t   f o r   k n o b   p o s i t i o n .   d e f a u l t   t o   0 .  
 	  
 E v e n t s :  
 	 o n C h a n g e   -   a   f u n c t i o n   t o   f i r e   w h e n   t h e   v a l u e   c h a n g e s .  
 	 o n C o m p l e t e   -   a   f u n c t i o n   t o   f i r e   w h e n   y o u ' r e   d o n e   d r a g g i n g .  
 	 o n T i c k   -   o p t i o n a l l y ,   y o u   c a n   a l t e r   t h e   o n T i c k   b e h a v i o r ,   f o r   e x a m p l e   d i s p l a y i n g   a n   e f f e c t   o f   t h e   k n o b   m o v i n g   t o   t h e   d e s i r e d   p o s i t i o n .  
 	 	 P a s s e s   a s   p a r a m e t e r   t h e   n e w   p o s i t i o n .  
 * /  
  
 v a r   S l i d e r   =   n e w   C l a s s ( {  
  
 	 o p t i o n s :   {  
 	 	 o n C h a n g e :   C l a s s . e m p t y ,  
 	 	 o n C o m p l e t e :   C l a s s . e m p t y ,  
 	 	 o n T i c k :   f u n c t i o n ( p o s ) {  
 	 	 	 t h i s . k n o b . s e t S t y l e ( t h i s . p ,   p o s ) ;  
 	 	 } ,  
 	 	 m o d e :   ' h o r i z o n t a l ' ,  
 	 	 s t e p s :   1 0 0 ,  
 	 	 o f f s e t :   0  
 	 } ,  
  
 	 i n i t i a l i z e :   f u n c t i o n ( e l ,   k n o b ,   o p t i o n s ) {  
 	 	 t h i s . e l e m e n t   =   $ ( e l ) ;  
 	 	 t h i s . k n o b   =   $ ( k n o b ) ;  
 	 	 t h i s . s e t O p t i o n s ( o p t i o n s ) ;  
 	 	 t h i s . p r e v i o u s C h a n g e   =   - 1 ;  
 	 	 t h i s . p r e v i o u s E n d   =   - 1 ;  
 	 	 t h i s . s t e p   =   - 1 ;  
 	 	 t h i s . e l e m e n t . a d d E v e n t ( ' m o u s e d o w n ' ,   t h i s . c l i c k e d E l e m e n t . b i n d W i t h E v e n t ( t h i s ) ) ;  
 	 	 v a r   m o d ,   o f f s e t ;  
 	 	 s w i t c h ( t h i s . o p t i o n s . m o d e ) {  
 	 	 	 c a s e   ' h o r i z o n t a l ' :  
 	 	 	 	 t h i s . z   =   ' x ' ;  
 	 	 	 	 t h i s . p   =   ' l e f t ' ;  
 	 	 	 	 m o d   =   { ' x ' :   ' l e f t ' ,   ' y ' :   f a l s e } ;  
 	 	 	 	 o f f s e t   =   ' o f f s e t W i d t h ' ;  
 	 	 	 	 b r e a k ;  
 	 	 	 c a s e   ' v e r t i c a l ' :  
 	 	 	 	 t h i s . z   =   ' y ' ;  
 	 	 	 	 t h i s . p   =   ' t o p ' ;  
 	 	 	 	 m o d   =   { ' x ' :   f a l s e ,   ' y ' :   ' t o p ' } ;  
 	 	 	 	 o f f s e t   =   ' o f f s e t H e i g h t ' ;  
 	 	 }  
 	 	 t h i s . m a x   =   t h i s . e l e m e n t [ o f f s e t ]   -   t h i s . k n o b [ o f f s e t ]   +   ( t h i s . o p t i o n s . o f f s e t   *   2 ) ;  
 	 	 t h i s . h a l f   =   t h i s . k n o b [ o f f s e t ] / 2 ;  
 	 	 t h i s . g e t P o s   =   t h i s . e l e m e n t [ ' g e t '   +   t h i s . p . c a p i t a l i z e ( ) ] . b i n d ( t h i s . e l e m e n t ) ;  
 	 	 t h i s . k n o b . s e t S t y l e ( ' p o s i t i o n ' ,   ' r e l a t i v e ' ) . s e t S t y l e ( t h i s . p ,   -   t h i s . o p t i o n s . o f f s e t ) ;  
 	 	 v a r   l i m   =   { } ;  
 	 	 l i m [ t h i s . z ]   =   [ -   t h i s . o p t i o n s . o f f s e t ,   t h i s . m a x   -   t h i s . o p t i o n s . o f f s e t ] ;  
 	 	 t h i s . d r a g   =   n e w   D r a g . B a s e ( t h i s . k n o b ,   {  
 	 	 	 l i m i t :   l i m ,  
 	 	 	 m o d i f i e r s :   m o d ,  
 	 	 	 s n a p :   0 ,  
 	 	 	 o n S t a r t :   f u n c t i o n ( ) {  
 	 	 	 	 t h i s . d r a g g e d K n o b ( ) ;  
 	 	 	 } . b i n d ( t h i s ) ,  
 	 	 	 o n D r a g :   f u n c t i o n ( ) {  
 	 	 	 	 t h i s . d r a g g e d K n o b ( ) ;  
 	 	 	 } . b i n d ( t h i s ) ,  
 	 	 	 o n C o m p l e t e :   f u n c t i o n ( ) {  
 	 	 	 	 t h i s . d r a g g e d K n o b ( ) ;  
 	 	 	 	 t h i s . e n d ( ) ;  
 	 	 	 } . b i n d ( t h i s )  
 	 	 } ) ;  
 	 	 i f   ( t h i s . o p t i o n s . i n i t i a l i z e )   t h i s . o p t i o n s . i n i t i a l i z e . c a l l ( t h i s ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s e t  
 	 	 T h e   s l i d e r   w i l l   g e t   t h e   s t e p   y o u   p a s s .  
  
 	 A r g u m e n t s :  
 	 	 s t e p   -   o n e   i n t e g e r  
 	 * /  
  
 	 s e t :   f u n c t i o n ( s t e p ) {  
 	 	 t h i s . s t e p   =   s t e p . l i m i t ( 0 ,   t h i s . o p t i o n s . s t e p s ) ;  
 	 	 t h i s . c h e c k S t e p ( ) ;  
 	 	 t h i s . e n d ( ) ;  
 	 	 t h i s . f i r e E v e n t ( ' o n T i c k ' ,   t h i s . t o P o s i t i o n ( t h i s . s t e p ) ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 c l i c k e d E l e m e n t :   f u n c t i o n ( e v e n t ) {  
 	 	 v a r   p o s i t i o n   =   e v e n t . p a g e [ t h i s . z ]   -   t h i s . g e t P o s ( )   -   t h i s . h a l f ;  
 	 	 p o s i t i o n   =   p o s i t i o n . l i m i t ( - t h i s . o p t i o n s . o f f s e t ,   t h i s . m a x   - t h i s . o p t i o n s . o f f s e t ) ;  
 	 	 t h i s . s t e p   =   t h i s . t o S t e p ( p o s i t i o n ) ;  
 	 	 t h i s . c h e c k S t e p ( ) ;  
 	 	 t h i s . e n d ( ) ;  
 	 	 t h i s . f i r e E v e n t ( ' o n T i c k ' ,   p o s i t i o n ) ;  
 	 } ,  
  
 	 d r a g g e d K n o b :   f u n c t i o n ( ) {  
 	 	 t h i s . s t e p   =   t h i s . t o S t e p ( t h i s . d r a g . v a l u e . n o w [ t h i s . z ] ) ;  
 	 	 t h i s . c h e c k S t e p ( ) ;  
 	 } ,  
  
 	 c h e c k S t e p :   f u n c t i o n ( ) {  
 	 	 i f   ( t h i s . p r e v i o u s C h a n g e   ! =   t h i s . s t e p ) {  
 	 	 	 t h i s . p r e v i o u s C h a n g e   =   t h i s . s t e p ;  
 	 	 	 t h i s . f i r e E v e n t ( ' o n C h a n g e ' ,   t h i s . s t e p ) ;  
 	 	 }  
 	 } ,  
  
 	 e n d :   f u n c t i o n ( ) {  
 	 	 i f   ( t h i s . p r e v i o u s E n d   ! = =   t h i s . s t e p ) {  
 	 	 	 t h i s . p r e v i o u s E n d   =   t h i s . s t e p ;  
 	 	 	 t h i s . f i r e E v e n t ( ' o n C o m p l e t e ' ,   t h i s . s t e p   +   ' ' ) ;  
 	 	 }  
 	 } ,  
  
 	 t o S t e p :   f u n c t i o n ( p o s i t i o n ) {  
 	 	 r e t u r n   M a t h . r o u n d ( ( p o s i t i o n   +   t h i s . o p t i o n s . o f f s e t )   /   t h i s . m a x   *   t h i s . o p t i o n s . s t e p s ) ;  
 	 } ,  
  
 	 t o P o s i t i o n :   f u n c t i o n ( s t e p ) {  
 	 	 r e t u r n   t h i s . m a x   *   s t e p   /   t h i s . o p t i o n s . s t e p s ;  
 	 }  
  
 } ) ;  
  
 S l i d e r . i m p l e m e n t ( n e w   E v e n t s ) ;  
 S l i d e r . i m p l e m e n t ( n e w   O p t i o n s ) ;  
  
 / *  
 S c r i p t :   S m o o t h S c r o l l . j s  
 	 C o n t a i n s   < S m o o t h S c r o l l >  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   S m o o t h S c r o l l  
 	 A u t o   t a r g e t s   a l l   t h e   a n c h o r s   i n   a   p a g e   a n d   d i s p l a y   a   s m o o t h   s c r o l l i n g   e f f e c t   u p o n   c l i c k i n g   t h e m .  
 	 I n h e r i t s   m e t h o d s ,   p r o p e r t i e s ,   o p t i o n s   a n d   e v e n t s   f r o m   < F x . S c r o l l > .  
  
 N o t e :  
 	 S m o o t h S c r o l l   r e q u i r e s   a n   X H T M L   d o c t y p e .  
  
 A r g u m e n t s :  
 	 o p t i o n s   -   t h e   F x . S c r o l l   o p t i o n s   ( s e e :   < F x . S c r o l l > )   p l u s   l i n k s ,   a   c o l l e c t i o n   o f   e l e m e n t s   y o u   w a n t   y o u r   s m o o t h s c r o l l   o n .   D e f a u l t s   t o   d o c u m e n t . l i n k s .  
  
 E x a m p l e :  
 	 > n e w   S m o o t h S c r o l l ( ) ;  
 * /  
  
 v a r   S m o o t h S c r o l l   =   F x . S c r o l l . e x t e n d ( {  
  
 	 i n i t i a l i z e :   f u n c t i o n ( o p t i o n s ) {  
 	 	 t h i s . p a r e n t ( w i n d o w ,   o p t i o n s ) ;  
 	 	 t h i s . l i n k s   =   ( t h i s . o p t i o n s . l i n k s )   ?   $ $ ( t h i s . o p t i o n s . l i n k s )   :   $ $ ( d o c u m e n t . l i n k s ) ;  
 	 	 v a r   l o c a t i o n   =   w i n d o w . l o c a t i o n . h r e f . m a t c h ( / ^ [ ^ # ] * / ) [ 0 ]   +   ' # ' ;  
 	 	 t h i s . l i n k s . e a c h ( f u n c t i o n ( l i n k ) {  
 	 	 	 i f   ( l i n k . h r e f . i n d e x O f ( l o c a t i o n )   ! =   0 )   r e t u r n ;  
 	 	 	 v a r   a n c h o r   =   l i n k . h r e f . s u b s t r ( l o c a t i o n . l e n g t h ) ;  
 	 	 	 i f   ( a n c h o r   & &   $ ( a n c h o r ) )   t h i s . u s e L i n k ( l i n k ,   a n c h o r ) ;  
 	 	 } ,   t h i s ) ;  
 	 	 i f   ( ! w i n d o w . w e b k i t 4 1 9 )   t h i s . a d d E v e n t ( ' o n C o m p l e t e ' ,   f u n c t i o n ( ) {  
 	 	 	 w i n d o w . l o c a t i o n . h a s h   =   t h i s . a n c h o r ;  
 	 	 } ) ;  
 	 } ,  
  
 	 u s e L i n k :   f u n c t i o n ( l i n k ,   a n c h o r ) {  
 	 	 l i n k . a d d E v e n t ( ' c l i c k ' ,   f u n c t i o n ( e v e n t ) {  
 	 	 	 t h i s . a n c h o r   =   a n c h o r ;  
 	 	 	 t h i s . t o E l e m e n t ( a n c h o r ) ;  
 	 	 	 e v e n t . s t o p ( ) ;  
 	 	 } . b i n d W i t h E v e n t ( t h i s ) ) ;  
 	 }  
  
 } ) ;  
  
 / *  
 S c r i p t :   S o r t a b l e s . j s  
 	 C o n t a i n s   < S o r t a b l e s >   C l a s s .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   S o r t a b l e s  
 	 C r e a t e s   a n   i n t e r f a c e   f o r   < D r a g . B a s e >   a n d   d r o p ,   r e s o r t i n g   o f   a   l i s t .  
  
 N o t e :  
 	 T h e   S o r t a b l e s   r e q u i r e   a n   X H T M L   d o c t y p e .  
  
 A r g u m e n t s :  
 	 l i s t   -   r e q u i r e d ,   t h e   l i s t   t h a t   w i l l   b e c o m e   s o r t a b l e .  
 	 o p t i o n s   -   a n   O b j e c t ,   s e e   o p t i o n s   b e l o w .  
  
 O p t i o n s :  
 	 h a n d l e s   -   a   c o l l e c t i o n   o f   e l e m e n t s   t o   b e   u s e d   f o r   d r a g   h a n d l e s .   d e f a u l t s   t o   t h e   e l e m e n t s .  
 	  
 E v e n t s :  
 	 o n S t a r t   -   f u n c t i o n   e x e c u t e d   w h e n   t h e   i t e m   s t a r t s   d r a g g i n g  
 	 o n C o m p l e t e   -   f u n c t i o n   e x e c u t e d   w h e n   t h e   i t e m   e n d s   d r a g g i n g  
 * /  
  
 v a r   S o r t a b l e s   =   n e w   C l a s s ( {  
  
 	 o p t i o n s :   {  
 	 	 h a n d l e s :   f a l s e ,  
 	 	 o n S t a r t :   C l a s s . e m p t y ,  
 	 	 o n C o m p l e t e :   C l a s s . e m p t y ,  
 	 	 g h o s t :   t r u e ,  
 	 	 s n a p :   3 ,  
 	 	 o n D r a g S t a r t :   f u n c t i o n ( e l e m e n t ,   g h o s t ) {  
 	 	 	 g h o s t . s e t S t y l e ( ' o p a c i t y ' ,   0 . 7 ) ;  
 	 	 	 e l e m e n t . s e t S t y l e ( ' o p a c i t y ' ,   0 . 7 ) ;  
 	 	 } ,  
 	 	 o n D r a g C o m p l e t e :   f u n c t i o n ( e l e m e n t ,   g h o s t ) {  
 	 	 	 e l e m e n t . s e t S t y l e ( ' o p a c i t y ' ,   1 ) ;  
 	 	 	 g h o s t . r e m o v e ( ) ;  
 	 	 	 t h i s . t r a s h . r e m o v e ( ) ;  
 	 	 }  
 	 } ,  
  
 	 i n i t i a l i z e :   f u n c t i o n ( l i s t ,   o p t i o n s ) {  
 	 	 t h i s . s e t O p t i o n s ( o p t i o n s ) ;  
 	 	 t h i s . l i s t   =   $ ( l i s t ) ;  
 	 	 t h i s . e l e m e n t s   =   t h i s . l i s t . g e t C h i l d r e n ( ) ;  
 	 	 t h i s . h a n d l e s   =   ( t h i s . o p t i o n s . h a n d l e s )   ?   $ $ ( t h i s . o p t i o n s . h a n d l e s )   :   t h i s . e l e m e n t s ;  
 	 	 t h i s . b o u n d   =   {  
 	 	 	 ' s t a r t ' :   [ ] ,  
 	 	 	 ' m o v e G h o s t ' :   t h i s . m o v e G h o s t . b i n d W i t h E v e n t ( t h i s )  
 	 	 } ;  
 	 	 f o r   ( v a r   i   =   0 ,   l   =   t h i s . h a n d l e s . l e n g t h ;   i   <   l ;   i + + ) {  
 	 	 	 t h i s . b o u n d . s t a r t [ i ]   =   t h i s . s t a r t . b i n d W i t h E v e n t ( t h i s ,   t h i s . e l e m e n t s [ i ] ) ;  
 	 	 }  
 	 	 t h i s . a t t a c h ( ) ;  
 	 	 i f   ( t h i s . o p t i o n s . i n i t i a l i z e )   t h i s . o p t i o n s . i n i t i a l i z e . c a l l ( t h i s ) ;  
 	 	 t h i s . b o u n d . m o v e   =   t h i s . m o v e . b i n d W i t h E v e n t ( t h i s ) ;  
 	 	 t h i s . b o u n d . e n d   =   t h i s . e n d . b i n d ( t h i s ) ;  
 	 } ,  
  
 	 a t t a c h :   f u n c t i o n ( ) {  
 	 	 t h i s . h a n d l e s . e a c h ( f u n c t i o n ( h a n d l e ,   i ) {  
 	 	 	 h a n d l e . a d d E v e n t ( ' m o u s e d o w n ' ,   t h i s . b o u n d . s t a r t [ i ] ) ;  
 	 	 } ,   t h i s ) ;  
 	 } ,  
  
 	 d e t a c h :   f u n c t i o n ( ) {  
 	 	 t h i s . h a n d l e s . e a c h ( f u n c t i o n ( h a n d l e ,   i ) {  
 	 	 	 h a n d l e . r e m o v e E v e n t ( ' m o u s e d o w n ' ,   t h i s . b o u n d . s t a r t [ i ] ) ;  
 	 	 } ,   t h i s ) ;  
 	 } ,  
  
 	 s t a r t :   f u n c t i o n ( e v e n t ,   e l ) {  
 	 	 t h i s . a c t i v e   =   e l ;  
 	 	 t h i s . c o o r d i n a t e s   =   t h i s . l i s t . g e t C o o r d i n a t e s ( ) ;  
 	 	 i f   ( t h i s . o p t i o n s . g h o s t ) {  
 	 	 	 v a r   p o s i t i o n   =   e l . g e t P o s i t i o n ( ) ;  
 	 	 	 t h i s . o f f s e t   =   e v e n t . p a g e . y   -   p o s i t i o n . y ;  
 	 	 	 t h i s . t r a s h   =   n e w   E l e m e n t ( ' d i v ' ) . i n j e c t ( d o c u m e n t . b o d y ) ;  
 	 	 	 t h i s . g h o s t   =   e l . c l o n e ( ) . i n j e c t ( t h i s . t r a s h ) . s e t S t y l e s ( {  
 	 	 	 	 ' p o s i t i o n ' :   ' a b s o l u t e ' ,  
 	 	 	 	 ' l e f t ' :   p o s i t i o n . x ,  
 	 	 	 	 ' t o p ' :   e v e n t . p a g e . y   -   t h i s . o f f s e t  
 	 	 	 } ) ;  
 	 	 	 d o c u m e n t . a d d L i s t e n e r ( ' m o u s e m o v e ' ,   t h i s . b o u n d . m o v e G h o s t ) ;  
 	 	 	 t h i s . f i r e E v e n t ( ' o n D r a g S t a r t ' ,   [ e l ,   t h i s . g h o s t ] ) ;  
 	 	 }  
 	 	 d o c u m e n t . a d d L i s t e n e r ( ' m o u s e m o v e ' ,   t h i s . b o u n d . m o v e ) ;  
 	 	 d o c u m e n t . a d d L i s t e n e r ( ' m o u s e u p ' ,   t h i s . b o u n d . e n d ) ;  
 	 	 t h i s . f i r e E v e n t ( ' o n S t a r t ' ,   e l ) ;  
 	 	 e v e n t . s t o p ( ) ;  
 	 } ,  
  
 	 m o v e G h o s t :   f u n c t i o n ( e v e n t ) {  
 	 	 v a r   v a l u e   =   e v e n t . p a g e . y   -   t h i s . o f f s e t ;  
 	 	 v a l u e   =   v a l u e . l i m i t ( t h i s . c o o r d i n a t e s . t o p ,   t h i s . c o o r d i n a t e s . b o t t o m   -   t h i s . g h o s t . o f f s e t H e i g h t ) ;  
 	 	 t h i s . g h o s t . s e t S t y l e ( ' t o p ' ,   v a l u e ) ;  
 	 	 e v e n t . s t o p ( ) ;  
 	 } ,  
  
 	 m o v e :   f u n c t i o n ( e v e n t ) {  
 	 	 v a r   n o w   =   e v e n t . p a g e . y ;  
 	 	 t h i s . p r e v i o u s   =   t h i s . p r e v i o u s   | |   n o w ;  
 	 	 v a r   u p   =   ( ( t h i s . p r e v i o u s   -   n o w )   >   0 ) ;  
 	 	 v a r   p r e v   =   t h i s . a c t i v e . g e t P r e v i o u s ( ) ;  
 	 	 v a r   n e x t   =   t h i s . a c t i v e . g e t N e x t ( ) ;  
 	 	 i f   ( p r e v   & &   u p   & &   n o w   <   p r e v . g e t C o o r d i n a t e s ( ) . b o t t o m )   t h i s . a c t i v e . i n j e c t B e f o r e ( p r e v ) ;  
 	 	 i f   ( n e x t   & &   ! u p   & &   n o w   >   n e x t . g e t C o o r d i n a t e s ( ) . t o p )   t h i s . a c t i v e . i n j e c t A f t e r ( n e x t ) ;  
 	 	 t h i s . p r e v i o u s   =   n o w ;  
 	 } ,  
  
 	 s e r i a l i z e :   f u n c t i o n ( c o n v e r t e r ) {  
 	 	 r e t u r n   t h i s . l i s t . g e t C h i l d r e n ( ) . m a p ( c o n v e r t e r   | |   f u n c t i o n ( e l ) {  
 	 	 	 r e t u r n   t h i s . e l e m e n t s . i n d e x O f ( e l ) ;  
 	 	 } ,   t h i s ) ;  
 	 } ,  
  
 	 e n d :   f u n c t i o n ( ) {  
 	 	 t h i s . p r e v i o u s   =   n u l l ;  
 	 	 d o c u m e n t . r e m o v e L i s t e n e r ( ' m o u s e m o v e ' ,   t h i s . b o u n d . m o v e ) ;  
 	 	 d o c u m e n t . r e m o v e L i s t e n e r ( ' m o u s e u p ' ,   t h i s . b o u n d . e n d ) ;  
 	 	 i f   ( t h i s . o p t i o n s . g h o s t ) {  
 	 	 	 d o c u m e n t . r e m o v e L i s t e n e r ( ' m o u s e m o v e ' ,   t h i s . b o u n d . m o v e G h o s t ) ;  
 	 	 	 t h i s . f i r e E v e n t ( ' o n D r a g C o m p l e t e ' ,   [ t h i s . a c t i v e ,   t h i s . g h o s t ] ) ;  
 	 	 }  
 	 	 t h i s . f i r e E v e n t ( ' o n C o m p l e t e ' ,   t h i s . a c t i v e ) ;  
 	 }  
  
 } ) ;  
  
 S o r t a b l e s . i m p l e m e n t ( n e w   E v e n t s ,   n e w   O p t i o n s ) ;  
  
 / *  
 S c r i p t :   T i p s . j s  
 	 T o o l t i p s ,   B u b b l e T i p s ,   w h a t e v e r   t h e y   a r e ,   t h e y   w i l l   a p p e a r   o n   m o u s e o v e r  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
  
 C r e d i t s :  
 	 T h e   i d e a   b e h i n d   T i p s . j s   i s   b a s e d   o n   B u b b l e   T o o l t i p s   ( < h t t p : / / w e b - g r a p h i c s . c o m / m t a r c h i v e / 0 0 1 7 1 7 . p h p > )   b y   A l e s s a n d r o   F u l c i t i n i t i   < h t t p : / / w e b - g r a p h i c s . c o m >  
 * /  
  
 / *  
 C l a s s :   T i p s  
 	 D i s p l a y   a   t i p   o n   a n y   e l e m e n t   w i t h   a   t i t l e   a n d / o r   h r e f .  
  
 N o t e :  
 	 T i p s   r e q u i r e s   a n   X H T M L   d o c t y p e .  
  
 A r g u m e n t s :  
 	 e l e m e n t s   -   a   c o l l e c t i o n   o f   e l e m e n t s   t o   a p p l y   t h e   t o o l t i p s   t o   o n   m o u s e o v e r .  
 	 o p t i o n s   -   a n   o b j e c t .   S e e   o p t i o n s   B e l o w .  
  
 O p t i o n s :  
 	 m a x T i t l e C h a r s   -   t h e   m a x i m u m   n u m b e r   o f   c h a r a c t e r s   t o   d i s p l a y   i n   t h e   t i t l e   o f   t h e   t i p .   d e f a u l t s   t o   3 0 .  
 	 s h o w D e l a y   -   t h e   d e l a y   t h e   o n S h o w   m e t h o d   i s   c a l l e d .   ( d e f a u l t s   t o   1 0 0   m s )  
 	 h i d e D e l a y   -   t h e   d e l a y   t h e   o n H i d e   m e t h o d   i s   c a l l e d .   ( d e f a u l t s   t o   1 0 0   m s )  
  
 	 c l a s s N a m e   -   t h e   p r e f i x   f o r   y o u r   t o o l t i p   c l a s s N a m e s .   d e f a u l t s   t o   ' t o o l ' .  
  
 	 	 t h e   w h o l e   t o o l t i p   w i l l   h a v e   a s   c l a s s n a m e :   t o o l - t i p  
  
 	 	 t h e   t i t l e   w i l l   h a v e   a s   c l a s s n a m e :   t o o l - t i t l e  
  
 	 	 t h e   t e x t   w i l l   h a v e   a s   c l a s s n a m e :   t o o l - t e x t  
  
 	 o f f s e t s   -   t h e   d i s t a n c e   o f   y o u r   t o o l t i p   f r o m   t h e   m o u s e .   a n   O b j e c t   w i t h   x / y   p r o p e r t i e s .  
 	 f i x e d   -   i f   s e t   t o   t r u e ,   t h e   t o o l T i p   w i l l   n o t   f o l l o w   t h e   m o u s e .  
 	  
 E v e n t s :  
 	 o n S h o w   -   o p t i o n a l l y   y o u   c a n   a l t e r   t h e   d e f a u l t   o n S h o w   b e h a v i o u r   w i t h   t h i s   o p t i o n   ( l i k e   d i s p l a y i n g   a   f a d e   i n   e f f e c t ) ;  
 	 o n H i d e   -   o p t i o n a l l y   y o u   c a n   a l t e r   t h e   d e f a u l t   o n H i d e   b e h a v i o u r   w i t h   t h i s   o p t i o n   ( l i k e   d i s p l a y i n g   a   f a d e   o u t   e f f e c t ) ;  
  
 E x a m p l e :  
 	 ( s t a r t   c o d e )  
 	 < i m g   s r c = " / i m a g e s / i . p n g "   t i t l e = " T h e   b o d y   o f   t h e   t o o l t i p   i s   s t o r e d   i n   t h e   t i t l e "   c l a s s = " t o o l T i p I m g " / >  
 	 < s c r i p t >  
 	 	 v a r   m y T i p s   =   n e w   T i p s ( $ $ ( ' . t o o l T i p I m g ' ) ,   {  
 	 	 	 m a x T i t l e C h a r s :   5 0 	 / / I   l i k e   m y   c a p t i o n s   a   l i t t l e   l o n g  
 	 	 } ) ;  
 	 < / s c r i p t >  
 	 ( e n d )  
  
 N o t e :  
 	 T h e   t i t l e   o f   t h e   e l e m e n t   w i l l   a l w a y s   b e   u s e d   a s   t h e   t o o l t i p   b o d y .   I f   y o u   p u t   : :   o n   y o u r   t i t l e ,   t h e   t e x t   b e f o r e   : :   w i l l   b e c o m e   t h e   t o o l t i p   t i t l e .  
 * /  
  
 v a r   T i p s   =   n e w   C l a s s ( {  
  
 	 o p t i o n s :   {  
 	 	 o n S h o w :   f u n c t i o n ( t i p ) {  
 	 	 	 t i p . s e t S t y l e ( ' v i s i b i l i t y ' ,   ' v i s i b l e ' ) ;  
 	 	 } ,  
 	 	 o n H i d e :   f u n c t i o n ( t i p ) {  
 	 	 	 t i p . s e t S t y l e ( ' v i s i b i l i t y ' ,   ' h i d d e n ' ) ;  
 	 	 } ,  
 	 	 m a x T i t l e C h a r s :   3 0 ,  
 	 	 s h o w D e l a y :   1 0 0 ,  
 	 	 h i d e D e l a y :   1 0 0 ,  
 	 	 c l a s s N a m e :   ' t o o l ' ,  
 	 	 o f f s e t s :   { ' x ' :   1 6 ,   ' y ' :   1 6 } ,  
 	 	 f i x e d :   f a l s e  
 	 } ,  
  
 	 i n i t i a l i z e :   f u n c t i o n ( e l e m e n t s ,   o p t i o n s ) {  
 	 	 t h i s . s e t O p t i o n s ( o p t i o n s ) ;  
 	 	 t h i s . t o o l T i p   =   n e w   E l e m e n t ( ' d i v ' ,   {  
 	 	 	 ' c l a s s ' :   t h i s . o p t i o n s . c l a s s N a m e   +   ' - t i p ' ,  
 	 	 	 ' s t y l e s ' :   {  
 	 	 	 	 ' p o s i t i o n ' :   ' a b s o l u t e ' ,  
 	 	 	 	 ' t o p ' :   ' 0 ' ,  
 	 	 	 	 ' l e f t ' :   ' 0 ' ,  
 	 	 	 	 ' v i s i b i l i t y ' :   ' h i d d e n '  
 	 	 	 }  
 	 	 } ) . i n j e c t ( d o c u m e n t . b o d y ) ;  
 	 	 t h i s . w r a p p e r   =   n e w   E l e m e n t ( ' d i v ' ) . i n j e c t ( t h i s . t o o l T i p ) ;  
 	 	 $ $ ( e l e m e n t s ) . e a c h ( t h i s . b u i l d ,   t h i s ) ;  
 	 	 i f   ( t h i s . o p t i o n s . i n i t i a l i z e )   t h i s . o p t i o n s . i n i t i a l i z e . c a l l ( t h i s ) ;  
 	 } ,  
  
 	 b u i l d :   f u n c t i o n ( e l ) {  
 	 	 e l . $ t m p . m y T i t l e   =   ( e l . h r e f   & &   e l . g e t T a g ( )   = =   ' a ' )   ?   e l . h r e f . r e p l a c e ( ' h t t p : / / ' ,   ' ' )   :   ( e l . r e l   | |   f a l s e ) ;  
 	 	 i f   ( e l . t i t l e ) {  
 	 	 	 v a r   d u a l   =   e l . t i t l e . s p l i t ( ' : : ' ) ;  
 	 	 	 i f   ( d u a l . l e n g t h   >   1 ) {  
 	 	 	 	 e l . $ t m p . m y T i t l e   =   d u a l [ 0 ] . t r i m ( ) ;  
 	 	 	 	 e l . $ t m p . m y T e x t   =   d u a l [ 1 ] . t r i m ( ) ;  
 	 	 	 }   e l s e   {  
 	 	 	 	 e l . $ t m p . m y T e x t   =   e l . t i t l e ;  
 	 	 	 }  
 	 	 	 e l . r e m o v e A t t r i b u t e ( ' t i t l e ' ) ;  
 	 	 }   e l s e   {  
 	 	 	 e l . $ t m p . m y T e x t   =   f a l s e ;  
 	 	 }  
 	 	 i f   ( e l . $ t m p . m y T i t l e   & &   e l . $ t m p . m y T i t l e . l e n g t h   >   t h i s . o p t i o n s . m a x T i t l e C h a r s )   e l . $ t m p . m y T i t l e   =   e l . $ t m p . m y T i t l e . s u b s t r ( 0 ,   t h i s . o p t i o n s . m a x T i t l e C h a r s   -   1 )   +   " & h e l l i p ; " ;  
 	 	 e l . a d d E v e n t ( ' m o u s e e n t e r ' ,   f u n c t i o n ( e v e n t ) {  
 	 	 	 t h i s . s t a r t ( e l ) ;  
 	 	 	 i f   ( ! t h i s . o p t i o n s . f i x e d )   t h i s . l o c a t e ( e v e n t ) ;  
 	 	 	 e l s e   t h i s . p o s i t i o n ( e l ) ;  
 	 	 } . b i n d ( t h i s ) ) ;  
 	 	 i f   ( ! t h i s . o p t i o n s . f i x e d )   e l . a d d E v e n t ( ' m o u s e m o v e ' ,   t h i s . l o c a t e . b i n d W i t h E v e n t ( t h i s ) ) ;  
 	 	 v a r   e n d   =   t h i s . e n d . b i n d ( t h i s ) ;  
 	 	 e l . a d d E v e n t ( ' m o u s e l e a v e ' ,   e n d ) ;  
 	 	 e l . a d d E v e n t ( ' t r a s h ' ,   e n d ) ;  
 	 } ,  
  
 	 s t a r t :   f u n c t i o n ( e l ) {  
 	 	 t h i s . w r a p p e r . e m p t y ( ) ;  
 	 	 i f   ( e l . $ t m p . m y T i t l e ) {  
 	 	 	 t h i s . t i t l e   =   n e w   E l e m e n t ( ' s p a n ' ) . i n j e c t ( n e w   E l e m e n t ( ' d i v ' ,   { ' c l a s s ' :   t h i s . o p t i o n s . c l a s s N a m e   +   ' - t i t l e ' } ) . i n j e c t ( t h i s . w r a p p e r ) ) . s e t H T M L ( e l . $ t m p . m y T i t l e ) ;  
 	 	 }  
 	 	 i f   ( e l . $ t m p . m y T e x t ) {  
 	 	 	 t h i s . t e x t   =   n e w   E l e m e n t ( ' s p a n ' ) . i n j e c t ( n e w   E l e m e n t ( ' d i v ' ,   { ' c l a s s ' :   t h i s . o p t i o n s . c l a s s N a m e   +   ' - t e x t ' } ) . i n j e c t ( t h i s . w r a p p e r ) ) . s e t H T M L ( e l . $ t m p . m y T e x t ) ;  
 	 	 }  
 	 	 $ c l e a r ( t h i s . t i m e r ) ;  
 	 	 t h i s . t i m e r   =   t h i s . s h o w . d e l a y ( t h i s . o p t i o n s . s h o w D e l a y ,   t h i s ) ;  
 	 } ,  
  
 	 e n d :   f u n c t i o n ( e v e n t ) {  
 	 	 $ c l e a r ( t h i s . t i m e r ) ;  
 	 	 t h i s . t i m e r   =   t h i s . h i d e . d e l a y ( t h i s . o p t i o n s . h i d e D e l a y ,   t h i s ) ;  
 	 } ,  
  
 	 p o s i t i o n :   f u n c t i o n ( e l e m e n t ) {  
 	 	 v a r   p o s   =   e l e m e n t . g e t P o s i t i o n ( ) ;  
 	 	 t h i s . t o o l T i p . s e t S t y l e s ( {  
 	 	 	 ' l e f t ' :   p o s . x   +   t h i s . o p t i o n s . o f f s e t s . x ,  
 	 	 	 ' t o p ' :   p o s . y   +   t h i s . o p t i o n s . o f f s e t s . y  
 	 	 } ) ;  
 	 } ,  
  
 	 l o c a t e :   f u n c t i o n ( e v e n t ) {  
 	 	 v a r   w i n   =   { ' x ' :   w i n d o w . g e t W i d t h ( ) ,   ' y ' :   w i n d o w . g e t H e i g h t ( ) } ;  
 	 	 v a r   s c r o l l   =   { ' x ' :   w i n d o w . g e t S c r o l l L e f t ( ) ,   ' y ' :   w i n d o w . g e t S c r o l l T o p ( ) } ;  
 	 	 v a r   t i p   =   { ' x ' :   t h i s . t o o l T i p . o f f s e t W i d t h ,   ' y ' :   t h i s . t o o l T i p . o f f s e t H e i g h t } ;  
 	 	 v a r   p r o p   =   { ' x ' :   ' l e f t ' ,   ' y ' :   ' t o p ' } ;  
 	 	 f o r   ( v a r   z   i n   p r o p ) {  
 	 	 	 v a r   p o s   =   e v e n t . p a g e [ z ]   +   t h i s . o p t i o n s . o f f s e t s [ z ] ;  
 	 	 	 i f   ( ( p o s   +   t i p [ z ]   -   s c r o l l [ z ] )   >   w i n [ z ] )   p o s   =   e v e n t . p a g e [ z ]   -   t h i s . o p t i o n s . o f f s e t s [ z ]   -   t i p [ z ] ;  
 	 	 	 t h i s . t o o l T i p . s e t S t y l e ( p r o p [ z ] ,   p o s ) ;  
 	 	 } ;  
 	 } ,  
  
 	 s h o w :   f u n c t i o n ( ) {  
 	 	 i f   ( t h i s . o p t i o n s . t i m e o u t )   t h i s . t i m e r   =   t h i s . h i d e . d e l a y ( t h i s . o p t i o n s . t i m e o u t ,   t h i s ) ;  
 	 	 t h i s . f i r e E v e n t ( ' o n S h o w ' ,   [ t h i s . t o o l T i p ] ) ;  
 	 } ,  
  
 	 h i d e :   f u n c t i o n ( ) {  
 	 	 t h i s . f i r e E v e n t ( ' o n H i d e ' ,   [ t h i s . t o o l T i p ] ) ;  
 	 }  
  
 } ) ;  
  
 T i p s . i m p l e m e n t ( n e w   E v e n t s ,   n e w   O p t i o n s ) ;  
  
 / *  
 S c r i p t :   G r o u p . j s  
 	 F o r   G r o u p i n g   C l a s s e s   o r   E l e m e n t s   E v e n t s .   T h e   E v e n t   a d d e d   t o   t h e   G r o u p   w i l l   f i r e   w h e n   a l l   o f   t h e   e v e n t s   o f   t h e   i t e m s   o f   t h e   g r o u p   a r e   f i r e d .  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   G r o u p  
 	 A n   " U t i l i t y "   C l a s s .  
  
 A r g u m e n t s :  
 	 L i s t   o f   C l a s s   i n s t a n c e s  
  
 E x a m p l e :  
 	 ( s t a r t   c o d e )  
 	 x h r 1   =   n e w   A j a x ( ' d a t a . j s ' ,   { e v a l S c r i p t :   t r u e } ) ;  
 	 x h r 2   =   n e w   A j a x ( ' a b s t r a c t i o n . j s ' ,   { e v a l S c r i p t :   t r u e } ) ;  
 	 x h r 3   =   n e w   A j a x ( ' t e m p l a t e . j s ' ,   { e v a l S c r i p t :   t r u e } ) ;  
  
 	 v a r   g r o u p   =   n e w   G r o u p ( x h r 1 ,   x h r 2 ,   x h r 3 ) ;  
 	 g r o u p . a d d E v e n t ( ' o n C o m p l e t e ' ,   f u n c t i o n ( ) {  
 	 	 a l e r t ( ' A l l   S c r i p t s   l o a d e d ' ) ;  
 	 } ) ;  
  
 	 x h r 1 . r e q u e s t ( ) ;  
 	 x h r 2 . r e q u e s t ( ) ;  
 	 x h r 3 . r e q u e s t ( ) ;  
 	 ( e n d )  
  
 * /  
  
 v a r   G r o u p   =   n e w   C l a s s ( {  
  
 	 i n i t i a l i z e :   f u n c t i o n ( ) {  
 	 	 t h i s . i n s t a n c e s   =   $ A ( a r g u m e n t s ) ;  
 	 	 t h i s . e v e n t s   =   { } ;  
 	 	 t h i s . c h e c k e r   =   { } ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   a d d E v e n t  
 	 	 a d d s   a n   e v e n t   t o   t h e   s t a c k   o f   e v e n t s   o f   t h e   C l a s s   i n s t a n c e s .  
  
 	 A r g u m e n t s :  
 	 	 t y p e   -   s t r i n g ;   t h e   e v e n t   n a m e   ( e . g .   ' o n C o m p l e t e ' )  
 	 	 f n   -   f u n c t i o n   t o   e x e c u t e   w h e n   a l l   i n s t a n c e s   f i r e d   t h i s   e v e n t  
 	 * /  
  
 	 a d d E v e n t :   f u n c t i o n ( t y p e ,   f n ) {  
 	 	 t h i s . c h e c k e r [ t y p e ]   =   t h i s . c h e c k e r [ t y p e ]   | |   { } ;  
 	 	 t h i s . e v e n t s [ t y p e ]   =   t h i s . e v e n t s [ t y p e ]   | |   [ ] ;  
 	 	 i f   ( t h i s . e v e n t s [ t y p e ] . c o n t a i n s ( f n ) )   r e t u r n   f a l s e ;  
 	 	 e l s e   t h i s . e v e n t s [ t y p e ] . p u s h ( f n ) ;  
 	 	 t h i s . i n s t a n c e s . e a c h ( f u n c t i o n ( i n s t a n c e ,   i ) {  
 	 	 	 i n s t a n c e . a d d E v e n t ( t y p e ,   t h i s . c h e c k . b i n d ( t h i s ,   [ t y p e ,   i n s t a n c e ,   i ] ) ) ;  
 	 	 } ,   t h i s ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 c h e c k :   f u n c t i o n ( t y p e ,   i n s t a n c e ,   i ) {  
 	 	 t h i s . c h e c k e r [ t y p e ] [ i ]   =   t r u e ;  
 	 	 v a r   e v e r y   =   t h i s . i n s t a n c e s . e v e r y ( f u n c t i o n ( c u r r e n t ,   j ) {  
 	 	 	 r e t u r n   t h i s . c h e c k e r [ t y p e ] [ j ]   | |   f a l s e ;  
 	 	 } ,   t h i s ) ;  
 	 	 i f   ( ! e v e r y )   r e t u r n ;  
 	 	 t h i s . c h e c k e r [ t y p e ]   =   { } ;  
 	 	 t h i s . e v e n t s [ t y p e ] . e a c h ( f u n c t i o n ( e v e n t ) {  
 	 	 	 e v e n t . c a l l ( t h i s ,   t h i s . i n s t a n c e s ,   i n s t a n c e ) ;  
 	 	 } ,   t h i s ) ;  
 	 }  
  
 } ) ;  
  
 / *  
 S c r i p t :   A c c o r d i o n . j s  
 	 C o n t a i n s   < A c c o r d i o n >  
  
 L i c e n s e :  
 	 M I T - s t y l e   l i c e n s e .  
 * /  
  
 / *  
 C l a s s :   A c c o r d i o n  
 	 T h e   A c c o r d i o n   c l a s s   c r e a t e s   a   g r o u p   o f   e l e m e n t s   t h a t   a r e   t o g g l e d   w h e n   t h e i r   h a n d l e s   a r e   c l i c k e d .   W h e n   o n e   e l e m e n t s   t o g g l e s   i n ,   t h e   o t h e r s   t o g g l e s   b a c k .  
 	 I n h e r i t s   m e t h o d s ,   p r o p e r t i e s ,   o p t i o n s   a n d   e v e n t s   f r o m   < F x . E l e m e n t s > .  
 	  
 N o t e :  
 	 T h e   A c c o r d i o n   r e q u i r e s   a n   X H T M L   d o c t y p e .  
  
 A r g u m e n t s :  
 	 t o g g l e r s   -   r e q u i r e d ,   a   c o l l e c t i o n   o f   e l e m e n t s ,   t h e   e l e m e n t s   h a n d l e r s   t h a t   w i l l   b e   c l i c k a b l e .  
 	 e l e m e n t s   -   r e q u i r e d ,   a   c o l l e c t i o n   o f   e l e m e n t s   t h e   t r a n s i t i o n s   w i l l   b e   a p p l i e d   t o .  
 	 o p t i o n s   -   o p t i o n a l ,   s e e   o p t i o n s   b e l o w ,   a n d   < F x . B a s e >   o p t i o n s   a n d   e v e n t s .  
  
 O p t i o n s :  
 	 s h o w   -   i n t e g e r ,   t h e   I n d e x   o f   t h e   e l e m e n t   t o   s h o w   a t   s t a r t .  
 	 d i s p l a y   -   i n t e g e r ,   t h e   I n d e x   o f   t h e   e l e m e n t   t o   s h o w   a t   s t a r t   ( w i t h   a   t r a n s i t i o n ) .   d e f a u l t s   t o   0 .  
 	 f i x e d H e i g h t   -   i n t e g e r ,   i f   y o u   w a n t   t h e   e l e m e n t s   t o   h a v e   a   f i x e d   h e i g h t .   d e f a u l t s   t o   f a l s e .  
 	 f i x e d W i d t h   -   i n t e g e r ,   i f   y o u   w a n t   t h e   e l e m e n t s   t o   h a v e   a   f i x e d   w i d t h .   d e f a u l t s   t o   f a l s e .  
 	 h e i g h t   -   b o o l e a n ,   w i l l   a d d   a   h e i g h t   t r a n s i t i o n   t o   t h e   a c c o r d i o n   i f   t r u e .   d e f a u l t s   t o   t r u e .  
 	 o p a c i t y   -   b o o l e a n ,   w i l l   a d d   a n   o p a c i t y   t r a n s i t i o n   t o   t h e   a c c o r d i o n   i f   t r u e .   d e f a u l t s   t o   t r u e .  
 	 w i d t h   -   b o o l e a n ,   w i l l   a d d   a   w i d t h   t r a n s i t i o n   t o   t h e   a c c o r d i o n   i f   t r u e .   d e f a u l t s   t o   f a l s e ,   c s s   m a s t e r y   i s   r e q u i r e d   t o   m a k e   t h i s   w o r k !  
 	 a l w a y s H i d e   -   b o o l e a n ,   w i l l   a l l o w   t o   h i d e   a l l   e l e m e n t s   i f   t r u e ,   i n s t e a d   o f   a l w a y s   k e e p i n g   o n e   e l e m e n t   s h o w n .   d e f a u l t s   t o   f a l s e .  
 	  
 E v e n t s :  
 	 o n A c t i v e   -   f u n c t i o n   t o   e x e c u t e   w h e n   a n   e l e m e n t   s t a r t s   t o   s h o w  
 	 o n B a c k g r o u n d   -   f u n c t i o n   t o   e x e c u t e   w h e n   a n   e l e m e n t   s t a r t s   t o   h i d e  
 * /  
  
 v a r   A c c o r d i o n   =   F x . E l e m e n t s . e x t e n d ( {  
  
 	 o p t i o n s :   {  
 	 	 o n A c t i v e :   C l a s s . e m p t y ,  
 	 	 o n B a c k g r o u n d :   C l a s s . e m p t y ,  
 	 	 d i s p l a y :   0 ,  
 	 	 s h o w :   f a l s e ,  
 	 	 h e i g h t :   t r u e ,  
 	 	 w i d t h :   f a l s e ,  
 	 	 o p a c i t y :   t r u e ,  
 	 	 f i x e d H e i g h t :   f a l s e ,  
 	 	 f i x e d W i d t h :   f a l s e ,  
 	 	 w a i t :   f a l s e ,  
 	 	 a l w a y s H i d e :   f a l s e  
 	 } ,  
  
 	 i n i t i a l i z e :   f u n c t i o n ( ) {  
 	 	 v a r   o p t i o n s ,   t o g g l e r s ,   e l e m e n t s ,   c o n t a i n e r ;  
 	 	 $ e a c h ( a r g u m e n t s ,   f u n c t i o n ( a r g u m e n t ,   i ) {  
 	 	 	 s w i t c h ( $ t y p e ( a r g u m e n t ) ) {  
 	 	 	 	 c a s e   ' o b j e c t ' :   o p t i o n s   =   a r g u m e n t ;   b r e a k ;  
 	 	 	 	 c a s e   ' e l e m e n t ' :   c o n t a i n e r   =   $ ( a r g u m e n t ) ;   b r e a k ;  
 	 	 	 	 d e f a u l t :  
 	 	 	 	 	 v a r   t e m p   =   $ $ ( a r g u m e n t ) ;  
 	 	 	 	 	 i f   ( ! t o g g l e r s )   t o g g l e r s   =   t e m p ;  
 	 	 	 	 	 e l s e   e l e m e n t s   =   t e m p ;  
 	 	 	 }  
 	 	 } ) ;  
 	 	 t h i s . t o g g l e r s   =   t o g g l e r s   | |   [ ] ;  
 	 	 t h i s . e l e m e n t s   =   e l e m e n t s   | |   [ ] ;  
 	 	 t h i s . c o n t a i n e r   =   $ ( c o n t a i n e r ) ;  
 	 	 t h i s . s e t O p t i o n s ( o p t i o n s ) ;  
 	 	 t h i s . p r e v i o u s   =   - 1 ;  
 	 	 i f   ( t h i s . o p t i o n s . a l w a y s H i d e )   t h i s . o p t i o n s . w a i t   =   t r u e ;  
 	 	 i f   ( $ c h k ( t h i s . o p t i o n s . s h o w ) ) {  
 	 	 	 t h i s . o p t i o n s . d i s p l a y   =   f a l s e ;  
 	 	 	 t h i s . p r e v i o u s   =   t h i s . o p t i o n s . s h o w ;  
 	 	 }  
 	 	 i f   ( t h i s . o p t i o n s . s t a r t ) {  
 	 	 	 t h i s . o p t i o n s . d i s p l a y   =   f a l s e ;  
 	 	 	 t h i s . o p t i o n s . s h o w   =   f a l s e ;  
 	 	 }  
 	 	 t h i s . e f f e c t s   =   { } ;  
 	 	 i f   ( t h i s . o p t i o n s . o p a c i t y )   t h i s . e f f e c t s . o p a c i t y   =   ' f u l l O p a c i t y ' ;  
 	 	 i f   ( t h i s . o p t i o n s . w i d t h )   t h i s . e f f e c t s . w i d t h   =   t h i s . o p t i o n s . f i x e d W i d t h   ?   ' f u l l W i d t h '   :   ' o f f s e t W i d t h ' ;  
 	 	 i f   ( t h i s . o p t i o n s . h e i g h t )   t h i s . e f f e c t s . h e i g h t   =   t h i s . o p t i o n s . f i x e d H e i g h t   ?   ' f u l l H e i g h t '   :   ' s c r o l l H e i g h t ' ;  
 	 	 f o r   ( v a r   i   =   0 ,   l   =   t h i s . t o g g l e r s . l e n g t h ;   i   <   l ;   i + + )   t h i s . a d d S e c t i o n ( t h i s . t o g g l e r s [ i ] ,   t h i s . e l e m e n t s [ i ] ) ;  
 	 	 t h i s . e l e m e n t s . e a c h ( f u n c t i o n ( e l ,   i ) {  
 	 	 	 i f   ( t h i s . o p t i o n s . s h o w   = = =   i ) {  
 	 	 	 	 t h i s . f i r e E v e n t ( ' o n A c t i v e ' ,   [ t h i s . t o g g l e r s [ i ] ,   e l ] ) ;  
 	 	 	 }   e l s e   {  
 	 	 	 	 f o r   ( v a r   f x   i n   t h i s . e f f e c t s )   e l . s e t S t y l e ( f x ,   0 ) ;  
 	 	 	 }  
 	 	 } ,   t h i s ) ;  
 	 	 t h i s . p a r e n t ( t h i s . e l e m e n t s ) ;  
 	 	 i f   ( $ c h k ( t h i s . o p t i o n s . d i s p l a y ) )   t h i s . d i s p l a y ( t h i s . o p t i o n s . d i s p l a y ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   a d d S e c t i o n  
 	 	 D y n a m i c a l l y   a d d s   a   n e w   s e c t i o n   i n t o   t h e   a c c o r d i o n   a t   t h e   s p e c i f i e d   p o s i t i o n .  
  
 	 A r g u m e n t s :  
 	 	 t o g g l e r   -   ( d o m   e l e m e n t )   t h e   e l e m e n t   t h a t   t o g g l e s   t h e   a c c o r d i o n   s e c t i o n   o p e n .  
 	 	 e l e m e n t   -   ( d o m   e l e m e n t )   t h e   e l e m e n t   t h a t   s t r e t c h e s   o p e n   w h e n   t h e   t o g g l e r   i s   c l i c k e d .  
 	 	 p o s   -   ( i n t e g e r )   t h e   i n d e x   w h e r e   t h e s e   o b j e c t s   a r e   t o   b e   i n s e r t e d   w i t h i n   t h e   a c c o r d i o n .  
 	 * /  
  
 	 a d d S e c t i o n :   f u n c t i o n ( t o g g l e r ,   e l e m e n t ,   p o s ) {  
 	 	 t o g g l e r   =   $ ( t o g g l e r ) ;  
 	 	 e l e m e n t   =   $ ( e l e m e n t ) ;  
 	 	 v a r   t e s t   =   t h i s . t o g g l e r s . c o n t a i n s ( t o g g l e r ) ;  
 	 	 v a r   l e n   =   t h i s . t o g g l e r s . l e n g t h ;  
 	 	 t h i s . t o g g l e r s . i n c l u d e ( t o g g l e r ) ;  
 	 	 t h i s . e l e m e n t s . i n c l u d e ( e l e m e n t ) ;  
 	 	 i f   ( l e n   & &   ( ! t e s t   | |   p o s ) ) {  
 	 	 	 p o s   =   $ p i c k ( p o s ,   l e n   -   1 ) ;  
 	 	 	 t o g g l e r . i n j e c t B e f o r e ( t h i s . t o g g l e r s [ p o s ] ) ;  
 	 	 	 e l e m e n t . i n j e c t A f t e r ( t o g g l e r ) ;  
 	 	 }   e l s e   i f   ( t h i s . c o n t a i n e r   & &   ! t e s t ) {  
 	 	 	 t o g g l e r . i n j e c t ( t h i s . c o n t a i n e r ) ;  
 	 	 	 e l e m e n t . i n j e c t ( t h i s . c o n t a i n e r ) ;  
 	 	 }  
 	 	 v a r   i d x   =   t h i s . t o g g l e r s . i n d e x O f ( t o g g l e r ) ;  
 	 	 t o g g l e r . a d d E v e n t ( ' c l i c k ' ,   t h i s . d i s p l a y . b i n d ( t h i s ,   i d x ) ) ;  
 	 	 i f   ( t h i s . o p t i o n s . h e i g h t )   e l e m e n t . s e t S t y l e s ( { ' p a d d i n g - t o p ' :   0 ,   ' b o r d e r - t o p ' :   ' n o n e ' ,   ' p a d d i n g - b o t t o m ' :   0 ,   ' b o r d e r - b o t t o m ' :   ' n o n e ' } ) ;  
 	 	 i f   ( t h i s . o p t i o n s . w i d t h )   e l e m e n t . s e t S t y l e s ( { ' p a d d i n g - l e f t ' :   0 ,   ' b o r d e r - l e f t ' :   ' n o n e ' ,   ' p a d d i n g - r i g h t ' :   0 ,   ' b o r d e r - r i g h t ' :   ' n o n e ' } ) ;  
 	 	 e l e m e n t . f u l l O p a c i t y   =   1 ;  
 	 	 i f   ( t h i s . o p t i o n s . f i x e d W i d t h )   e l e m e n t . f u l l W i d t h   =   t h i s . o p t i o n s . f i x e d W i d t h ;  
 	 	 i f   ( t h i s . o p t i o n s . f i x e d H e i g h t )   e l e m e n t . f u l l H e i g h t   =   t h i s . o p t i o n s . f i x e d H e i g h t ;  
 	 	 e l e m e n t . s e t S t y l e ( ' o v e r f l o w ' ,   ' h i d d e n ' ) ;  
 	 	 i f   ( ! t e s t ) {  
 	 	 	 f o r   ( v a r   f x   i n   t h i s . e f f e c t s )   e l e m e n t . s e t S t y l e ( f x ,   0 ) ;  
 	 	 }  
 	 	 r e t u r n   t h i s ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   d i s p l a y  
 	 	 S h o w s   a   s p e c i f i c   s e c t i o n   a n d   h i d e s   a l l   o t h e r s .   U s e f u l   w h e n   t r i g g e r i n g   a n   a c c o r d i o n   f r o m   o u t s i d e .  
  
 	 A r g u m e n t s :  
 	 	 i n d e x   -   i n t e g e r ,   t h e   i n d e x   o f   t h e   i t e m   t o   s h o w ,   o r   t h e   a c t u a l   e l e m e n t   t o   s h o w .  
 	 * /  
  
 	 d i s p l a y :   f u n c t i o n ( i n d e x ) {  
 	 	 i n d e x   =   ( $ t y p e ( i n d e x )   = =   ' e l e m e n t ' )   ?   t h i s . e l e m e n t s . i n d e x O f ( i n d e x )   :   i n d e x ;  
 	 	 i f   ( ( t h i s . t i m e r   & &   t h i s . o p t i o n s . w a i t )   | |   ( i n d e x   = = =   t h i s . p r e v i o u s   & &   ! t h i s . o p t i o n s . a l w a y s H i d e ) )   r e t u r n   t h i s ;  
 	 	 t h i s . p r e v i o u s   =   i n d e x ;  
 	 	 v a r   o b j   =   { } ;  
 	 	 t h i s . e l e m e n t s . e a c h ( f u n c t i o n ( e l ,   i ) {  
 	 	 	 o b j [ i ]   =   { } ;  
 	 	 	 v a r   h i d e   =   ( i   ! =   i n d e x )   | |   ( t h i s . o p t i o n s . a l w a y s H i d e   & &   ( e l . o f f s e t H e i g h t   >   0 ) ) ;  
 	 	 	 t h i s . f i r e E v e n t ( h i d e   ?   ' o n B a c k g r o u n d '   :   ' o n A c t i v e ' ,   [ t h i s . t o g g l e r s [ i ] ,   e l ] ) ;  
 	 	 	 f o r   ( v a r   f x   i n   t h i s . e f f e c t s )   o b j [ i ] [ f x ]   =   h i d e   ?   0   :   e l [ t h i s . e f f e c t s [ f x ] ] ;  
 	 	 } ,   t h i s ) ;  
 	 	 r e t u r n   t h i s . s t a r t ( o b j ) ;  
 	 } ,  
  
 	 s h o w T h i s H i d e O p e n :   f u n c t i o n ( i n d e x ) { r e t u r n   t h i s . d i s p l a y ( i n d e x ) ; }  
  
 } ) ;  
  
 F x . A c c o r d i o n   =   A c c o r d i o n ;  
  
  
  
  
  
  
  
  
  
  
  
 / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /  
  
  
  
  
  
 F x . P r o p   =   F x . B a s e . e x t e n d ( {  
  
 	 i n i t i a l i z e :   f u n c t i o n ( e l ,   p r o p e r t y ,   o p t i o n s ) {  
 	 	 t h i s . e l e m e n t   =   $ ( e l ) ;  
 	 	 t h i s . p r o p e r t y   =   p r o p e r t y ;  
 	 	 t h i s . p a r e n t ( o p t i o n s ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   h i d e  
 	 	 S a m e   a s   < F x . B a s e . s e t >   ( 0 ) ;   h i d e s   t h e   e l e m e n t   i m m e d i a t e l y   w i t h o u t   t r a n s i t i o n .  
 	 * /  
  
 	 h i d e :   f u n c t i o n ( ) {  
 	 	 r e t u r n   t h i s . s e t ( 0 ) ;  
 	 } ,  
  
 	 s e t N o w :   f u n c t i o n ( ) {  
 	 	 t h i s . n o w   =   t h i s . c s s . g e t N o w ( t h i s . f r o m ,   t h i s . t o ,   t h i s ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s e t  
 	 	 S e t s   t h e   e l e m e n t ' s   c s s   p r o p e r t y   ( s p e c i f i e d   a t   i n s t a n t i a t i o n )   t o   t h e   s p e c i f i e d   v a l u e   i m m e d i a t e l y .  
  
 	 E x a m p l e :  
 	 	 ( s t a r t   c o d e )  
 	 	 v a r   m a r g i n C h a n g e   =   n e w   F x . S t y l e ( ' m y E l e m e n t ' ,   ' m a r g i n - t o p ' ,   { d u r a t i o n : 5 0 0 } ) ;  
 	 	 m a r g i n C h a n g e . s e t ( 1 0 ) ;   / / m a r g i n - t o p   i s   s e t   t o   1 0 p x   i m m e d i a t e l y  
 	 	 ( e n d )  
 	 * /  
  
 	 s e t :   f u n c t i o n ( t o ) {  
 	 	 t h i s . c s s   =   F x . C S S . s e l e c t ( t h i s . p r o p e r t y ,   t o ) ;  
 	 	 r e t u r n   t h i s . p a r e n t ( t h i s . c s s . p a r s e ( t o ) ) ;  
 	 } ,  
  
 	 / *  
 	 P r o p e r t y :   s t a r t  
 	 	 D i s p l a y s   t h e   t r a n s i t i o n   t o   t h e   v a l u e / v a l u e s   p a s s e d   i n  
  
 	 A r g u m e n t s :  
 	 	 f r o m   -   ( i n t e g e r ;   o p t i o n a l )   t h e   s t a r t i n g   p o s i t i o n   f o r   t h e   t r a n s i t i o n  
 	 	 t o   -   ( i n t e g e r )   t h e   e n d i n g   p o s i t i o n   f o r   t h e   t r a n s i t i o n  
  
 	 N o t e :  
 	 	 I f   y o u   p r o v i d e   o n l y   o n e   a r g u m e n t ,   t h e   t r a n s i t i o n   w i l l   u s e   t h e   c u r r e n t   c s s   v a l u e   f o r   i t s   s t a r t i n g   v a l u e .  
  
 	 E x a m p l e :  
 	 	 ( s t a r t   c o d e )  
 	 	 v a r   m a r g i n C h a n g e   =   n e w   F x . S t y l e ( ' m y E l e m e n t ' ,   ' m a r g i n - t o p ' ,   { d u r a t i o n : 5 0 0 } ) ;  
 	 	 m a r g i n C h a n g e . s t a r t ( 1 0 ) ;   / / t r i e s   t o   r e a d   c u r r e n t   m a r g i n   t o p   v a l u e   a n d   g o e s   f r o m   c u r r e n t   t o   1 0  
 	 	 ( e n d )  
 	 * /  
  
 	 s t a r t :   f u n c t i o n ( f r o m ,   t o ) {  
 	 	 i f   ( t h i s . t i m e r   & &   t h i s . o p t i o n s . w a i t )   r e t u r n   t h i s ;  
 	 	 v a r   p a r s e d   =   F x . C S S . p a r s e ( t h i s . e l e m e n t ,   t h i s . p r o p e r t y ,   [ f r o m ,   t o ] ) ;  
 	 	 t h i s . c s s   =   p a r s e d . c s s ;  
 	 	 r e t u r n   t h i s . p a r e n t ( p a r s e d . f r o m ,   p a r s e d . t o ) ;  
 	 } ,  
  
 	 i n c r e a s e :   f u n c t i o n ( ) {  
 	 	 t h i s . e l e m e n t . s e t P r o p e r t y ( t h i s . p r o p e r t y ,   p a r s e I n t ( t h i s . c s s . g e t V a l u e ( t h i s . n o w ,   t h i s . o p t i o n s . u n i t ,   t h i s . p r o p e r t y ) ) ) ;  
 	 }  
  
 } ) ;  
  
 / *  
 C l a s s :   E l e m e n t  
 	 C u s t o m   c l a s s   t o   a l l o w   a l l   o f   i t s   m e t h o d s   t o   b e   u s e d   w i t h   a n y   D O M   e l e m e n t   v i a   t h e   d o l l a r   f u n c t i o n   < $ > .  
 * /  
  
 E l e m e n t . e x t e n d ( {  
  
 	 / *  
 	 P r o p e r t y :   e f f e c t  
 	 	 A p p l i e s   a n   < F x . S t y l e >   t o   t h e   E l e m e n t ;   T h i s   a   s h o r t c u t   f o r   < F x . S t y l e > .  
  
 	 A r g u m e n t s :  
 	 	 p r o p e r t y   -   ( s t r i n g )   t h e   c s s   p r o p e r t y   t o   a l t e r  
 	 	 o p t i o n s   -   ( o b j e c t ;   o p t i o n a l )   k e y / v a l u e   s e t   o f   o p t i o n s   ( s e e   < F x . S t y l e > )  
  
 	 E x a m p l e :  
 	 	 > v a r   m y E f f e c t   =   $ ( ' m y E l e m e n t ' ) . e f f e c t ( ' h e i g h t ' ,   { d u r a t i o n :   1 0 0 0 ,   t r a n s i t i o n :   F x . T r a n s i t i o n s . l i n e a r } ) ;  
 	 	 > m y E f f e c t . s t a r t ( 1 0 ,   1 0 0 ) ;  
 	 	 > / / O R  
 	 	 > $ ( ' m y E l e m e n t ' ) . e f f e c t ( ' h e i g h t ' ,   { d u r a t i o n :   1 0 0 0 ,   t r a n s i t i o n :   F x . T r a n s i t i o n s . l i n e a r } ) . s t a r t ( 1 0 , 1 0 0 ) ;  
 	 * /  
  
 	 e f f e c t :   f u n c t i o n ( p r o p e r t y ,   o p t i o n s ) {  
 	 	 r e t u r n   n e w   F x . P r o p ( t h i s ,   p r o p e r t y ,   o p t i o n s ) ;  
 	 }  
  
 } ) ;  
  
  
  
  
  
  
 
