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