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