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