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