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