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