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