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