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