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

