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