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