þÿ / * *  
   *   @ a u t h o r   V I M M  
   * /  
 / /   J a v a S c r i p t   D o c u m e n t  
  
 f u n c t i o n   s e t A c t i v e S t y l e S h e e t ( t i t l e )   {  
     v a r   i ,   a ,   m a i n ;  
     f o r ( i = 0 ;   ( a   =   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 ( " l i n k " ) [ i ] ) ;   i + + )   {  
         i f ( a . g e t A t t r i b u t e ( " r e l " ) . i n d e x O f ( " s t y l e " )   ! =   - 1   & &   a . g e t A t t r i b u t e ( " t i t l e " ) )   {  
             a . d i s a b l e d   =   t r u e ;  
             i f ( a . g e t A t t r i b u t e ( " t i t l e " )   = =   t i t l e )   a . d i s a b l e d   =   f a l s e ;  
         }  
     }  
 }  
  
 f u n c t i o n   g e t A c t i v e S t y l e S h e e t ( )   {  
     v a r   i ,   a ;  
     f o r ( i = 0 ;   ( a   =   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 ( " l i n k " ) [ i ] ) ;   i + + )   {  
         i f ( a . g e t A t t r i b u t e ( " r e l " ) . i n d e x O f ( " s t y l e " )   ! =   - 1   & &   a . g e t A t t r i b u t e ( " t i t l e " )   & &   ! a . d i s a b l e d )   r e t u r n   a . g e t A t t r i b u t e ( " t i t l e " ) ;  
     }  
     r e t u r n   n u l l ;  
 }  
  
 f u n c t i o n   g e t P r e f e r r e d S t y l e S h e e t ( )   {  
     v a r   i ,   a ;  
     f o r ( i = 0 ;   ( a   =   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 ( " l i n k " ) [ i ] ) ;   i + + )   {  
         i f ( a . g e t A t t r i b u t e ( " r e l " ) . i n d e x O f ( " s t y l e " )   ! =   - 1  
               & &   a . g e t A t t r i b u t e ( " r e l " ) . i n d e x O f ( " a l t " )   = =   - 1  
               & &   a . g e t A t t r i b u t e ( " t i t l e " )  
               )   r e t u r n   a . g e t A t t r i b u t e ( " t i t l e " ) ;  
     }  
     r e t u r n   n u l l ;  
 }  
  
 f u n c t i o n   c r e a t e C o o k i e ( n a m e , v a l u e , d a y s )   {  
     i f   ( d a y s )   {  
         v a r   d a t e   =   n e w   D a t e ( ) ;  
         v a r   m i l l i s T o d a y   =   d a t e . g e t T i m e ( ) ;  
         v a r   m i l l i s 3 M o n t h s   =   m i l l i s T o d a y   +   7 8 6 2 4 0 0 0 0 0 ;   / / a d d   3   m o n t h s   w o r t h   o f   m i l l i s   t o   c u r r e n t   t i m e  
         d a t e . s e t T i m e ( m i l l i s 3 M o n t h s ) ;  
         / / 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   =   " " ;  
     d o c u m e n t . c o o k i e   =   n a m e + " = " + v a l u e + 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 ( n a m e )   {  
     v a r   n a m e E Q   =   n a m e   +   " = " ;  
     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 )   r e t u r n   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 ) ;  
     }  
     r e t u r n   n u l l ;  
 }  
  
 w i n d o w . o n l o a d   =   f u n c t i o n ( e )   {  
         v a r   c o o k i e   =   r e a d C o o k i e ( " s t y l e " ) ;  
         v a r   t i t l e   =   c o o k i e   ?   c o o k i e   :   g e t P r e f e r r e d S t y l e S h e e t ( ) ;  
         s e t A c t i v e S t y l e S h e e t ( t i t l e ) ;  
 }  
  
 w i n d o w . o n u n l o a d   =   f u n c t i o n ( e )   {  
         v a r   t i t l e   =   g e t A c t i v e S t y l e S h e e t ( ) ;  
         c r e a t e C o o k i e ( " s t y l e " ,   t i t l e ,   3 6 5 ) ;  
 }  
  
 v a r   c o o k i e   =   r e a d C o o k i e ( " s t y l e " ) ;  
 v a r   t i t l e   =   c o o k i e   ?   c o o k i e   :   g e t P r e f e r r e d S t y l e S h e e t ( ) ;  
 s e t A c t i v e S t y l e S h e e t ( t i t l e ) ;  

