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