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