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