ÿþ$ . f n . i n f i n i t e C a r o u s e l   =   f u n c t i o n   ( w r a p p e r S e l e c t o r )   { 
         f u n c t i o n   r e p e a t ( s t r ,   n u m )   { 
                 r e t u r n   n e w   A r r a y (   n u m   +   1   ) . j o i n (   s t r   ) ; 
         } 
     
         r e t u r n   t h i s . e a c h ( f u n c t i o n   ( )   { 
                 v a r   $ w r a p p e r   =   $ ( w r a p p e r S e l e c t o r ,   t h i s ) , 
                         $ s l i d e r   =   $ w r a p p e r . f i n d ( ' >   u l ' ) , 
                         $ i t e m s   =   $ s l i d e r . f i n d ( ' >   l i ' ) , 
                         $ s i n g l e   =   $ i t e m s . f i l t e r ( ' : f i r s t ' ) , 
                         
                         s i n g l e W i d t h   =   $ s i n g l e . o u t e r W i d t h ( ) ,   / / p a r s e I n t ( $ s i n g l e . w i d t h ( ) )   +   p a r s e I n t ( $ s i n g l e . c s s ( ' p a d d i n g - l e f t ' ) )   +   p a r s e I n t ( $ s i n g l e . c s s ( ' p a d d i n g - r i g h t ' ) ) , 
                         v i s i b l e   =   M a t h . c e i l ( $ w r a p p e r . i n n e r W i d t h ( )   /   s i n g l e W i d t h ) ,   / /   n o t e :   d o e s n ' t   i n c l u d e   p a d d i n g   o r   b o r d e r 
                         c u r r e n t P a g e   =   1 , 
                         p a g e s   =   M a t h . c e i l ( $ i t e m s . l e n g t h   /   v i s i b l e ) ;                         
 
                 / /   1 .   P a d   s o   t h a t   ' v i s i b l e '   n u m b e r   w i l l   a l w a y s   b e   s e e n ,   o t h e r w i s e   c r e a t e   e m p t y   i t e m s 
                 i f   ( ( $ i t e m s . l e n g t h   %   v i s i b l e )   ! =   0 )   { 
                         $ s l i d e r . a p p e n d ( r e p e a t ( ' < l i   c l a s s = " e m p t y "   / > ' ,   v i s i b l e   -   ( $ i t e m s . l e n g t h   %   v i s i b l e ) ) ) ; 
                         $ i t e m s   =   $ s l i d e r . f i n d ( ' >   l i ' ) ; 
                 } 
 
                 / /   2 .   T o p   a n d   t a i l   t h e   l i s t   w i t h   ' v i s i b l e '   n u m b e r   o f   i t e m s ,   t o p   h a s   t h e   l a s t   s e c t i o n ,   a n d   t a i l   h a s   t h e   f i r s t 
                 $ i t e m s . f i l t e r ( ' : f i r s t ' ) . b e f o r e ( $ i t e m s . s l i c e ( -   v i s i b l e ) . c l o n e ( ) . a d d C l a s s ( ' c l o n e d ' ) ) ; 
                 $ i t e m s . f i l t e r ( ' : l a s t ' ) . a f t e r ( $ i t e m s . s l i c e ( 0 ,   v i s i b l e ) . c l o n e ( ) . a d d C l a s s ( ' c l o n e d ' ) ) ; 
                 $ i t e m s   =   $ s l i d e r . f i n d ( ' >   l i ' ) ;   / /   r e s e l e c t 
                 
                 / /   3 .   S e t   t h e   l e f t   p o s i t i o n   t o   t h e   f i r s t   ' r e a l '   i t e m 
                 / /   $ w r a p p e r . c s s ( ' s c r o l l L e f t ' ,   s i n g l e W i d t h   *   v i s i b l e ) ;   / /   *   - 1 
                 $ w r a p p e r . g e t ( 0 ) . s c r o l l L e f t   =   s i n g l e W i d t h   *   v i s i b l e ; 
                 
                 / /   4 .   B i n d   t o   t h e   f o r w a r d   a n d   b a c k   b u t t o n s 
                 $ ( ' a . b a c k ' ,   t h i s ) . c l i c k ( f u n c t i o n   ( )   { 
                         r e t u r n   g o t o P a g e ( c u r r e n t P a g e   -   1 ) ;                                 
                 } ) ; 
                 
                 $ ( ' a . f o r w a r d ' ,   t h i s ) . c l i c k ( f u n c t i o n   ( )   { 
                         r e t u r n   g o t o P a g e ( c u r r e n t P a g e   +   1 ) ; 
                 } ) ; 
                 
                 / /   5 .   p a g i n g   f u n c t i o n 
                 f u n c t i o n   g o t o P a g e ( p a g e )   { 
                         v a r   d i r   =   p a g e   <   c u r r e n t P a g e   ?   - 1   :   1 ,   / /   p a g e   <   c u r r e n t P a g e   ?   1   :   - 1 , 
                                 n   =   M a t h . a b s ( c u r r e n t P a g e   -   p a g e ) , 
                                 l e f t   =   s i n g l e W i d t h   *   d i r   *   v i s i b l e   *   n ; 
                         
                         / /   c o n s o l e . l o g ( ' c u r r e n t P a g e ' ,   c u r r e n t P a g e ,   ' l e f t ' ,   l e f t ,   ' n ' ,   n ) ; 
                         
                         $ w r a p p e r . f i l t e r ( ' : n o t ( : a n i m a t e d ) ' ) . a n i m a t e ( { 
                                 s c r o l l L e f t   :   ' + = '   +   l e f t 
                         } ,   5 0 0 ,   f u n c t i o n   ( )   { 
                                 i f   ( p a g e   = =   0 )   { 
                                         c u r r e n t P a g e   =   p a g e s ; 
                                         / /   $ w r a p p e r . c s s ( ' s c r o l l L e f t ' ,   s i n g l e W i d t h   *   v i s i b l e   *   p a g e s ) ;   / /     *   - 1 
                                         t h i s . s c r o l l L e f t   =   s i n g l e W i d t h   *   v i s i b l e   *   p a g e s ; 
                                 }   e l s e   i f   ( p a g e   >   p a g e s )   { 
                                         c u r r e n t P a g e   =   1 ; 
                                         t h i s . s c r o l l L e f t   =   s i n g l e W i d t h   *   v i s i b l e ;   / /     *   - 1 
                                         / /   $ w r a p p e r . c s s ( ' s c r o l l L e f t ' ,   s i n g l e W i d t h   *   v i s i b l e ) ;   / /     *   - 1 
                                         / /   r e s e t   b a c k   t o   s t a r t   p o s i t i o n 
                                 }   e l s e   { 
                                         c u r r e n t P a g e   =   p a g e ; 
                                 } 
                         } ) ;                                 
                         
                         r e t u r n   f a l s e ; 
                 } 
                 
                 / /   c r e a t e   a   p u b l i c   i n t e r f a c e   t o   m o v e   t o   a   s p e c i f i c   p a g e 
                 $ ( t h i s ) . b i n d ( ' g o t o ' ,   f u n c t i o n   ( e v e n t ,   p a g e )   { 
                         g o t o P a g e ( p a g e ) ; 
                 } ) ; 
         } ) ;     
 } ; 
 
 $ ( f u n c t i o n   ( )   { 
         $ ( ' # s c r o l l B u t t o n s   >   d i v ' ) . b e f o r e ( ' < a   c l a s s = " f o r w a r d "   h r e f = " # " > < i m g   b o r d e r = 0   s r c = " / s k i n / l e f t . g i f "   w i d t h = " 1 0 "   h e i g h t = " 4 2 "     a l t = " S c r o l l   R i g h t "   t i t l e = " S c r o l l   R i g h t "   c l a s s = " s c r o l l R i g h t "   / > < / a > ' ) . a f t e r ( ' < a   h r e f = " # "   c l a s s = " b a c k " > < i m g   b o r d e r = 0   s r c = " / s k i n / r i g h t . g i f "   w i d t h = " 1 0 "   h e i g h t = " 4 2 "     a l t = " S c r o l l   L e f t "   t i t l e = " S c r o l l   L e f t "   c l a s s = " s c r o l l L e f t "   / > < / a > ' ) . p a r e n t ( ) . i n f i n i t e C a r o u s e l ( ' >   d i v ' ) ; 
 } ) ; 
