ÿþ/ /   w h e n   t h e   D O M   i s   r e a d y . . .  
 $ ( d o c u m e n t ) . r e a d y ( f u n c t i o n   ( )   {  
  
         v a r   $ p a n e l s   =   $ ( ' # s l i d e r   . s c r o l l C o n t a i n e r   >   d i v ' ) ;  
         v a r   $ c o n t a i n e r   =   $ ( ' # s l i d e r   . s c r o l l C o n t a i n e r ' ) ;  
  
         / /   i f   f a l s e ,   w e ' l l   f l o a t   a l l   t h e   p a n e l s   l e f t   a n d   f i x   t h e   w i d t h    
         / /   o f   t h e   c o n t a i n e r  
         v a r   h o r i z o n t a l   =   t r u e ;  
  
         / /   f l o a t   t h e   p a n e l s   l e f t   i f   w e ' r e   g o i n g   h o r i z o n t a l  
         i f   ( h o r i z o n t a l )   {  
                 $ p a n e l s . c s s ( {  
                         ' f l o a t '   :   ' l e f t ' ,  
                         ' p o s i t i o n '   :   ' r e l a t i v e '   / /   I E   f i x   t o   e n s u r e   o v e r f l o w   i s   h i d d e n  
                 } ) ;  
  
                 / /   c a l c u l a t e   a   n e w   w i d t h   f o r   t h e   c o n t a i n e r   ( s o   i t   h o l d s   a l l   p a n e l s )  
                 $ c o n t a i n e r . c s s ( ' w i d t h ' ,   $ p a n e l s [ 0 ] . o f f s e t W i d t h   *   $ p a n e l s . l e n g t h ) ;  
         }  
  
         / /   c o l l e c t   t h e   s c r o l l   o b j e c t ,   a t   t h e   s a m e   t i m e   a p p l y   t h e   h i d d e n   o v e r f l o w  
         / /   t o   r e m o v e   t h e   d e f a u l t   s c r o l l b a r s   t h a t   w i l l   a p p e a r  
         v a r   $ s c r o l l   =   $ ( ' # s l i d e r   . s c r o l l ' ) . c s s ( ' o v e r f l o w ' ,   ' h i d d e n ' ) ;  
  
         / /   a p p l y   o u r   l e f t   +   r i g h t   b u t t o n s  
    
  
         / /   h a n d l e   n a v   s e l e c t i o n  
         f u n c t i o n   s e l e c t N a v ( )   {  
                 $ ( t h i s )  
                         . p a r e n t s ( ' u l : f i r s t ' )  
                                 . f i n d ( ' a ' )  
                                         . r e m o v e C l a s s ( ' s e l e c t e d ' )  
                                 . e n d ( )  
                         . e n d ( )  
                         . a d d C l a s s ( ' s e l e c t e d ' ) ;  
         }  
  
         $ ( ' # s l i d e r   . n a v i g a t i o n ' ) . f i n d ( ' a ' ) . c l i c k ( s e l e c t N a v ) ;  
  
         / /   g o   f i n d   t h e   n a v i g a t i o n   l i n k   t h a t   h a s   t h i s   t a r g e t   a n d   s e l e c t   t h e   n a v  
         f u n c t i o n   t r i g g e r ( d a t a )   {  
                 v a r   e l   =   $ ( ' # s l i d e r   . n a v i g a t i o n ' ) . f i n d ( ' a [ h r e f $ = " '   +   d a t a . i d   +   ' " ] ' ) . g e t ( 0 ) ;  
                 s e l e c t N a v . c a l l ( e l ) ;  
         }  
  
         i f   ( w i n d o w . l o c a t i o n . h a s h )   {  
                 t r i g g e r ( {   i d   :   w i n d o w . l o c a t i o n . h a s h . s u b s t r ( 1 )   } ) ;  
         }   e l s e   {  
                 $ ( ' u l . n a v i g a t i o n   a : f i r s t ' ) . c l i c k ( ) ;  
         }  
  
         / /   o f f s e t   i s   u s e d   t o   m o v e   t o   * e x a c t l y *   t h e   r i g h t   p l a c e ,   s i n c e   I ' m   u s i n g  
         / /   p a d d i n g   o n   m y   e x a m p l e ,   I   n e e d   t o   s u b t r a c t   t h e   a m o u n t   o f   p a d d i n g   t o  
         / /   t h e   o f f s e t .     T r y   r e m o v i n g   t h i s   t o   g e t   a   g o o d   i d e a   o f   t h e   e f f e c t  
         v a r   o f f s e t   =   p a r s e I n t ( ( h o r i z o n t a l   ?    
                 $ c o n t a i n e r . c s s ( ' p a d d i n g T o p ' )   :    
                 $ c o n t a i n e r . c s s ( ' p a d d i n g L e f t ' ) )    
                 | |   0 )   *   - 1 ;  
  
  
         v a r   s c r o l l O p t i o n s   =   {  
                 t a r g e t :   $ s c r o l l ,   / /   t h e   e l e m e n t   t h a t   h a s   t h e   o v e r f l o w  
  
                 / /   c a n   b e   a   s e l e c t o r   w h i c h   w i l l   b e   r e l a t i v e   t o   t h e   t a r g e t  
                 i t e m s :   $ p a n e l s ,  
  
                 n a v i g a t i o n :   ' . n a v i g a t i o n   a ' ,  
  
                 / /   s e l e c t o r s   a r e   N O T   r e l a t i v e   t o   d o c u m e n t ,   i . e .   m a k e   s u r e   t h e y ' r e   u n i q u e  
                 p r e v :   ' i m g . l e f t ' ,    
                 n e x t :   ' i m g . r i g h t ' ,  
  
                 / /   a l l o w   t h e   s c r o l l   e f f e c t   t o   r u n   b o t h   d i r e c t i o n s  
                 a x i s :   ' x y ' ,  
  
                 o n A f t e r :   t r i g g e r ,   / /   o u r   f i n a l   c a l l b a c k  
  
                 o f f s e t :   o f f s e t ,  
  
                 / /   d u r a t i o n   o f   t h e   s l i d i n g   e f f e c t  
                 d u r a t i o n :   5 0 0 ,  
  
                 / /   e a s i n g   -   c a n   b e   u s e d   w i t h   t h e   e a s i n g   p l u g i n :    
                 / /   h t t p : / / g s g d . c o . u k / s a n d b o x / j q u e r y / e a s i n g /  
                 e a s i n g :   ' s w i n g '  
         } ;  
  
         / /   a p p l y   s e r i a l S c r o l l   t o   t h e   s l i d e r   -   w e   c h o s e   t h i s   p l u g i n   b e c a u s e   i t    
         / /   s u p p o r t s / /   t h e   i n d e x e d   n e x t   a n d   p r e v i o u s   s c r o l l   a l o n g   w i t h   h o o k i n g    
         / /   i n   t o   o u r   n a v i g a t i o n .  
         $ ( ' # s l i d e r ' ) . s e r i a l S c r o l l ( s c r o l l O p t i o n s ) ;  
  
         / /   n o w   a p p l y   l o c a l S c r o l l   t o   h o o k   a n y   o t h e r   a r b i t r a r y   l i n k s   t o   t r i g g e r    
         / /   t h e   e f f e c t  
         $ . l o c a l S c r o l l ( s c r o l l O p t i o n s ) ;  
  
         / /   f i n a l l y ,   i f   t h e   U R L   h a s   a   h a s h ,   m o v e   t h e   s l i d e r   i n   t o   p o s i t i o n ,    
         / /   s e t t i n g   t h e   d u r a t i o n   t o   1   b e c a u s e   I   d o n ' t   w a n t   i t   t o   s c r o l l   i n   t h e  
         / /   v e r y   f i r s t   p a g e   l o a d .     W e   d o n ' t   a l w a y s   n e e d   t h i s ,   b u t   i t   e n s u r e s  
         / /   t h e   p o s i t i o n i n g   i s   a b s o l u t e l y   s p o t   o n   w h e n   t h e   p a g e s   l o a d s .  
         s c r o l l O p t i o n s . d u r a t i o n   =   1 ;  
         $ . l o c a l S c r o l l . h a s h ( s c r o l l O p t i o n s ) ;  
  
 } ) ; 
