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