ÿþ/ * *    
 *   $ ( ) . V a l v o l i n e   ( o b j e c t )  
 *   T h i s   i s   a   j Q u e r y   p l u g i n   t h a t   w i l l   t a k e   i n   a n   h t m l   e l e m e n t   a n d   p o p u l a t e   i t   w i t h   a n   o b j e c t   t h a t   c a n   c a l l   a   v a r i e t y   o f   e x t e n s i o n s .  
 *   I f   a n   o b j e c t   i s   p a s s e d   t h r o u g h ,   t h e   s e t t i n g s   a r e   m e r g e d / o v e r w r i t t e n   w i t h   t h e   c u r r e n t   s e t t i n g s .  
 *   I f   a   s t r i n g   i s   p a s s e d   t h r o u g h ,   t h e   s e t t i n g s   a r e   m e r g e d / o v e r w r i t t e n   w i t h   a   s e t   o f   d e f a u l t s .  
 * * /  
 ( f u n c t i o n ( $ )   {  
         v a r   V a l v o l i n e O b j   =   f u n c t i o n ( e l e m ,   o p t i o n s )   {  
                 / * *    
                 *   T h i s   i s   w h e r e   s o m e   i n i t i a l   o b j e c t   i n s t a n t i a t i o n   t a k e s   p l a c e  
                 * * /  
                 v a r   o b j   =   t h i s ;  
                 o b j . e l e m   =   $ ( e l e m ) ;  
                 o b j . h t m l   =   $ ( ' < d i v   i d = " v a l v o l i n e " > < / d i v > ' ) ;  
  
                 o b j . b a d B r o w s e r U R L   =   f u n c t i o n ( )   {  
                         v a r   u p d a t e U R L   =   ' h t t p : / / w w w . m i c r o s o f t . c o m / w i n d o w s / i n t e r n e t - e x p l o r e r / ' ;  
                         i f   ( $ . b r o w s e r . m o z i l l a )   {  
                                 u p d a t e U R L   =   ' h t t p : / / w w w . f i r e f o x . c o m / ' ;  
                         }  
                         e l s e   i f   ( $ . b r o w s e r . s a f a r i )   {  
                                 u p d a t e U R L   =   ' h t t p : / / w w w . a p p l e . c o m / s a f a r i / ' ;  
                         }  
                         r e t u r n   u p d a t e U R L ;  
                 }  
  
                 / * *    
                 *   P u b i c   O b j e c t :   s e t t i n g s  
                 *   T h i s   i s   u s e d   t o   h o u s e   s e t t i n g s   f o r   t h e   b a s e   v a v l o l i n e   o b j e c t .  
                 * * /  
                 t h i s . s e t t i n g s   =   {  
                         c h a n g e H a s h :   f a l s e ,  
                         d e b u g :   t r u e ,  
                         w e b s e r v i c e :   ' h t t p : / / f i n d . v i o c . c o m / U I L o c a t o r W e b S e r v i c e . a s m x / F i n d A s J s o n ' ,  
                         t r a c k A n a l y t i c s :   t r u e ,  
                         m o b i l e :   f a l s e ,  
                         r a d i u s :   5 0 ,  
  
                         b a d B r o w s e r O b j :   $ ( ' < d i v   c l a s s = " u n s u p p o r t e d " > < d i v > W e \ ' r e   s o r r y   b u t   t h i s   t o o l   d o e s   n o t   c u r r e n t l y   s u p p o r t   y o u r   b r o w s e r . < b r / > < b r / > I f   y o u   w o u l d   l i k e   t o   u s e   t h i s   t o o l ,   p l e a s e   < a   h r e f = " '   +   o b j . b a d B r o w s e r U R L ( )   +   ' "   t a r g e t = " _ b l a n k " > u p g r a d e   y o u r   b r o w s e r < / a > . < / d i v > < / d i v > ' ) ,  
                         m a p C o n t r o l s :   {  
                                 p a n C o n t r o l :   f a l s e ,  
                                 z o o m C o n t r o l :   t r u e ,  
                                 m a p T y p e C o n t r o l :   f a l s e ,  
                                 s c a l e C o n t r o l :   f a l s e ,  
                                 s t r e e t V i e w C o n t r o l :   f a l s e ,  
                                 o v e r v i e w M a p C o n t r o l :   f a l s e  
                         }  
                 } ;  
  
                 t h i s . c o n s o l e   =   f u n c t i o n ( )   {  
                         i f   ( o b j . s e t t i n g s . d e b u g )   {  
                                 i f   ( t y p e o f   c o n s o l e   = =   " o b j e c t " )   {  
                                         c o n s o l e . l o g ( a r g u m e n t s ) ;  
                                 }  
                                 e l s e   i f   ( $ . b r o w s e r . m s i e   & &   p a r s e I n t ( $ . b r o w s e r . v e r s i o n )   = =   7 )   {  
                                         a l e r t ( a r g u m e n t s [ 0 ] ) ;  
                                 }  
                         }  
                 }  
  
                 t h i s . h a s h e s   =   { } ;  
  
                 t h i s . b r o w s e r O k   =   ! ( ( $ . b r o w s e r . m s i e   & &   $ . b r o w s e r . v e r s i o n   <   7 )   | |   ( $ . b r o w s e r . m o z i l l a   & &   $ . b r o w s e r . v e r s i o n   <   2 )   | |   ( $ . b r o w s e r . s a f a r i   & &   $ . b r o w s e r . v e r s i o n   <   5 2 5 ) ) ;  
  
  
                 / * *    
                 *   P u b i c   O b j e c t :   d e f a u l t s  
                 *   T h e s e   a r e   c a n n e d   d e f a u l t s   f o r   w h i c h   s e t t i n g s   a n d   w i d g e t s   t o   u s e   a s   a   b a s e .  
                 * * /  
                 t h i s . d e f a u l t s   =   {  
                         l o c a t o r :   {  
                                 s h o w S e a r c h :   t r u e ,  
                                 s h o w F i l t e r s :   t r u e ,  
                                 f i l t e r V I O C :   {   s h o w :   t r u e ,   c h e c k :   t r u e   } ,  
                                 f i l t e r E C :   {   s h o w :   t r u e ,   c h e c k :   t r u e   } ,  
                                 f i l t e r R e t a i l :   {   s h o w :   t r u e ,   c h e c k :   t r u e   } ,  
                                 f i l t e r O t h e r :   {   s h o w :   t r u e ,   c h e c k :   t r u e   } ,  
                                 f i l t e r N e x t g e n :   {   s h o w :   f a l s e ,   c h e c k :   f a l s e   } ,  
                                 s h o w R e s u l t s :   t r u e ,  
                                 s h o w M a p :   t r u e ,  
                                 s h o w F o o t e r :   f a l s e ,  
                                 m a p C o n t r o l s :   {  
                                         p a n C o n t r o l :   f a l s e ,  
                                         z o o m C o n t r o l :   t r u e ,  
                                         m a p T y p e C o n t r o l :   f a l s e ,  
                                         s c a l e C o n t r o l :   f a l s e ,  
                                         s t r e e t V i e w C o n t r o l :   f a l s e ,  
                                         o v e r v i e w M a p C o n t r o l :   f a l s e  
                                 } ,  
                                 l o c a t o r V i e w :   ' b o t h ' ,  
                                 t o g g l e D e f a u l t :   ' r e s u l t s ' ,  
                                 j a v a s c r i p t G P S :   t r u e ,  
                                 d a y O r d e r :   [ ' M o n ' ,   ' T u e ' ,   ' W e d ' ,   ' T h u ' ,   ' F r i ' ,   ' S a t ' ,   ' S u n ' ] ,  
                                 r e s u l t T e m p l a t e :   ' < d i v   c l a s s = " l o c a t i o n $ { $ i t e m . t y p e S h o r t ( ) } " > < d i v   c l a s s = " i n s i d e " > { { h t m l   $ i t e m . n a m e ( ) } } { { h t m l   $ i t e m . a d d r e s s ( ) } } { { h t m l   $ i t e m . p h o n e ( ) } } { { h t m l   $ i t e m . n e x t g e n ( ) } } { { h t m l   $ i t e m . d i r e c t i o n s ( ) } }   |   { { h t m l   $ i t e m . l i n k ( ) } } < / d i v > < d i v   c l a s s = " b o t t o m " > $ { $ i t e m . t y p e L o n g ( ) } < / d i v > < / d i v > ' ,  
                                 m a p T e m p l a t e :   ' < d i v > { { i f   N a m e } } < h 3 > $ { N a m e } < / h 3 > { { / i f } } { { h t m l   $ i t e m . a d d r e s s ( ) } } { { h t m l   $ i t e m . p h o n e ( ) } } { { h t m l   $ i t e m . n e x t g e n ( ) } } { { h t m l   $ i t e m . h o u r s ( ) } } { { h t m l   $ i t e m . d i r e c t i o n s ( ) } }   |   { { h t m l   $ i t e m . l i n k ( ) } } < / d i v > ' ,  
                                 s h o w R e s u l t s M i n :   1 ,  
                                 s h o w M a r k e r s :   t r u e ,  
                                 r e t u r n C o n t e n t T y p e s :   ' a d d r e s s , h o u r s , p r o m o t i o n s , f e a t u r e s , s p e c i a l s v c s ' ,  
                                 m a r k e r :   f u n c t i o n ( i n f o )   {  
                                         v a r   i c o n U r l   =   ' h t t p : / / f i n d . v i o c . c o m / i m a g e s / m a r k e r V I O C . p n g ' ;  
                                         s w i t c h   ( i n f o . b r a n d )   {  
                                                 c a s e   ' E C ' :  
                                                         i c o n U r l   =   o b j . s e t t i n g s . m a r k e r I m a g e s . E C ;  
                                                         b r e a k ;  
  
                                                 c a s e   ' D I Y ' :  
                                                         i c o n U r l   =   o b j . s e t t i n g s . m a r k e r I m a g e s . R e t a i l ;  
                                                         b r e a k ;  
  
                                                 c a s e   ' A V I ' :  
                                                         i c o n U r l   =   o b j . s e t t i n g s . m a r k e r I m a g e s . O t h e r ;  
                                                         b r e a k ;  
  
                                                 c a s e   " V I O C " :  
                                                 d e f a u l t :  
                                                         i f   ( i n f o . S p e c i a l S e r v i c e s . F e a t u r e s N e x t G e n   = =   ' Y ' )   {  
                                                                 i c o n U r l   =   o b j . s e t t i n g s . m a r k e r I m a g e s . V I O C _ N e x t g e n ;  
                                                         }  
                                                         e l s e   {  
                                                                 i c o n U r l   =   o b j . s e t t i n g s . m a r k e r I m a g e s . V I O C ;  
                                                         }  
                                                         b r e a k ;  
                                         }  
                                         r e t u r n   i c o n U r l ;  
                                 } ,  
                                 m a r k e r I m a g e s :   {  
                                         S h a d o w :   ' h t t p : / / f i n d . v i o c . c o m / i m a g e s / m a r k e r S h a d o w . p n g ' ,  
                                         E C :   ' h t t p : / / f i n d . v i o c . c o m / i m a g e s / m a r k e r E x p r e s s C a r e . p n g ' ,  
                                         R e t a i l :   ' h t t p : / / f i n d . v i o c . c o m / i m a g e s / m a r k e r R e t a i l . p n g ' ,  
                                         O t h e r :   ' h t t p : / / f i n d . v i o c . c o m / i m a g e s / m a r k e r O t h e r . p n g ' ,  
                                         V I O C :   ' h t t p : / / f i n d . v i o c . c o m / i m a g e s / m a r k e r V I O C . p n g ' ,  
                                         V I O C _ N e x t g e n :   ' h t t p : / / f i n d . v i o c . c o m / i m a g e s / m a r k e r V I O C _ N e x t g e n . p n g '  
                                 } ,  
                                 s h o w R e s u l t s M a x :   1 5  
                         } ,  
                         l o c a t o r C a r e e r :   {  
                                 s h o w S e a r c h :   t r u e ,  
                                 s h o w F i l t e r s :   f a l s e ,  
                                 s h o w C a r e e r :   f a l s e ,  
                                 f i l t e r V I O C :   {   s h o w :   t r u e ,   c h e c k :   t r u e   } ,  
                                 f i l t e r E C :   {   s h o w :   f a l s e ,   c h e c k :   f a l s e   } ,  
                                 f i l t e r R e t a i l :   {   s h o w :   f a l s e ,   c h e c k :   f a l s e   } ,  
                                 f i l t e r O t h e r :   {   s h o w :   f a l s e ,   c h e c k :   f a l s e   } ,  
                                 s h o w R e s u l t s :   t r u e ,  
                                 s h o w M a p :   t r u e ,  
                                 m a p C o n t r o l s :   {  
                                         p a n C o n t r o l :   f a l s e ,  
                                         z o o m C o n t r o l :   t r u e ,  
                                         m a p T y p e C o n t r o l :   t r u e ,  
                                         s c a l e C o n t r o l :   f a l s e ,  
                                         s t r e e t V i e w C o n t r o l :   t r u e ,  
                                         o v e r v i e w M a p C o n t r o l :   t r u e  
                                 } ,  
                                 l o c a t o r V i e w :   ' b o t h ' ,  
                                 t o g g l e D e f a u l t :   ' r e s u l t s ' ,  
                                 j a v a s c r i p t G P S :   t r u e ,  
                                 d a y O r d e r :   [ ' M o n ' ,   ' T u e ' ,   ' W e d ' ,   ' T h u ' ,   ' F r i ' ,   ' S a t ' ,   ' S u n ' ] ,  
                                 r e s u l t T e m p l a t e :   ' < d i v   c l a s s = " l o c a t i o n $ { $ i t e m . t y p e S h o r t ( ) } " > < d i v   c l a s s = " i n s i d e " > { { h t m l   $ i t e m . n a m e ( ) } } { { h t m l   $ i t e m . a d d r e s s ( ) } } { { h t m l   $ i t e m . p h o n e ( ) } } < b r / > { { h t m l   $ i t e m . l i n k ( ) } } { { h t m l   $ i t e m . c a r e e r s ( ) } } < / d i v > < / d i v > ' ,  
                                 m a p T e m p l a t e :   ' < d i v > { { i f   N a m e } } < h 3 > $ { N a m e } < / h 3 > { { / i f } } { { h t m l   $ i t e m . a d d r e s s ( ) } } { { h t m l   $ i t e m . p h o n e ( ) } } < b r / > { { h t m l   $ i t e m . l i n k ( ) } } { { h t m l   $ i t e m . c a r e e r s ( ) } } < / d i v > ' ,  
                                 s h o w R e s u l t s M i n :   1 ,  
                                 s h o w M a r k e r s :   t r u e ,  
                                 r e t u r n C o n t e n t T y p e s :   ' a d d r e s s , h o u r s , p r o m o t i o n s , f e a t u r e s , s p e c i a l s v c s , c a r e e r s ' ,  
                                 m a r k e r :   f u n c t i o n ( i n f o )   {  
                                         v a r   i c o n U r l   =   ' ' ;  
                                         s w i t c h   ( i n f o . b r a n d )   {  
                                                 c a s e   ' E C ' :  
                                                         i c o n U r l   =   o b j . s e t t i n g s . m a r k e r I m a g e s . E C ;  
                                                         b r e a k ;  
  
                                                 c a s e   ' D I Y ' :  
                                                         i c o n U r l   =   o b j . s e t t i n g s . m a r k e r I m a g e s . R e t a i l ;  
                                                         b r e a k ;  
  
                                                 c a s e   ' A V I ' :  
                                                         i c o n U r l   =   o b j . s e t t i n g s . m a r k e r I m a g e s . O t h e r ;  
                                                         b r e a k ;  
  
                                                 c a s e   " V I O C " :  
                                                 d e f a u l t :  
                                                         i f   ( t y p e o f   i n f o . C a r e e r s   = =   ' o b j e c t ' )   {  
                                                                 i c o n U r l   =   o b j . s e t t i n g s . m a r k e r I m a g e s . V I O C ;  
                                                         }  
                                                         e l s e   {  
                                                                 i c o n U r l   =   o b j . s e t t i n g s . m a r k e r I m a g e s . V I O C _ N o C a r e e r s ;  
                                                         }  
                                                         b r e a k ;  
                                         }  
                                         r e t u r n   i c o n U r l ;  
                                 } ,  
                                 m a r k e r I m a g e s :   {  
                                         S h a d o w :   ' h t t p : / / f i n d . v i o c . c o m / i m a g e s / m a r k e r S h a d o w . p n g ' ,  
                                         E C :   ' h t t p : / / f i n d . v i o c . c o m / i m a g e s / m a r k e r E x p r e s s C a r e . p n g ' ,  
                                         R e t a i l :   ' h t t p : / / f i n d . v i o c . c o m / i m a g e s / m a r k e r R e t a i l . p n g ' ,  
                                         O t h e r :   ' h t t p : / / f i n d . v i o c . c o m / i m a g e s / m a r k e r O t h e r . p n g ' ,  
                                         V I O C :   ' h t t p : / / f i n d . v i o c . c o m / i m a g e s / m a r k e r V I O C . p n g ' ,  
                                         V I O C _ N o C a r e e r s :   ' h t t p : / / f i n d . v i o c . c o m / i m a g e s / m a r k e r V I O C _ N o C a r e e r s . p n g ' ,  
                                         V I O C _ N e x t g e n :   ' h t t p : / / f i n d . v i o c . c o m / i m a g e s / m a r k e r V I O C _ N e x t g e n . p n g '  
                                 } ,  
                                 s h o w R e s u l t s M a x :   1 5  
                         } ,  
                         s t o r e :   {  
                                 s h o w S e a r c h :   f a l s e ,  
                                 s h o w F i l t e r s :   f a l s e ,  
                                 f i l t e r V I O C :   {   s h o w :   t r u e ,   c h e c k :   t r u e   } ,  
                                 f i l t e r E C :   {   s h o w :   t r u e ,   c h e c k :   t r u e   } ,  
                                 f i l t e r R e t a i l :   {   s h o w :   t r u e ,   c h e c k :   t r u e   } ,  
                                 f i l t e r O t h e r :   {   s h o w :   t r u e ,   c h e c k :   t r u e   } ,  
                                 s h o w R e s u l t s :   f a l s e ,  
                                 s h o w M a p :   t r u e ,  
                                 l o c a t o r V i e w :   ' m a p ' ,  
                                 t o g g l e D e f a u l t :   ' m a p ' ,  
                                 j a v a s c r i p t G P S :   f a l s e ,  
                                 d a y O r d e r :   [ ' M o n ' ,   ' T u e ' ,   ' W e d ' ,   ' T h u ' ,   ' F r i ' ,   ' S a t ' ,   ' S u n ' ] ,  
                                 s h o w R e s u l t s M i n :   1 ,  
                                 s h o w M a r k e r s :   f a l s e ,  
                                 r e t u r n C o n t e n t T y p e s :   ' a d d r e s s , h o u r s , p r o m o t i o n s , f e a t u r e s , s p e c i a l s v c s ' ,  
                                 m a r k e r :   f u n c t i o n ( i n f o )   {  
                                         v a r   i c o n U r l   =   ' h t t p : / / f i n d . v i o c . c o m / i m a g e s / m a r k e r V I O C . p n g ' ;  
                                         s w i t c h   ( i n f o . b r a n d )   {  
                                                 c a s e   ' E C ' :  
                                                         i c o n U r l   =   o b j . s e t t i n g s . m a r k e r I m a g e s . E C ;  
                                                         b r e a k ;  
  
                                                 c a s e   ' D I Y ' :  
                                                         i c o n U r l   =   o b j . s e t t i n g s . m a r k e r I m a g e s . R e t a i l ;  
                                                         b r e a k ;  
  
                                                 c a s e   ' A V I ' :  
                                                         i c o n U r l   =   o b j . s e t t i n g s . m a r k e r I m a g e s . O t h e r ;  
                                                         b r e a k ;  
  
                                                 c a s e   " V I O C " :  
                                                 d e f a u l t :  
                                                         i f   ( i n f o . S p e c i a l S e r v i c e s . F e a t u r e s N e x t G e n   = =   ' Y ' )   {  
                                                                 i c o n U r l   =   o b j . s e t t i n g s . m a r k e r I m a g e s . V I O C _ N e x t g e n ;  
                                                         }  
                                                         e l s e   {  
                                                                 i c o n U r l   =   o b j . s e t t i n g s . m a r k e r I m a g e s . V I O C ;  
                                                         }  
                                                         b r e a k ;  
                                         }  
                                         r e t u r n   i c o n U r l ;  
                                 } ,  
                                 m a r k e r I m a g e s :   {  
                                         S h a d o w :   ' h t t p : / / f i n d . v i o c . c o m / i m a g e s / m a r k e r S h a d o w . p n g ' ,  
                                         E C :   ' h t t p : / / f i n d . v i o c . c o m / i m a g e s / m a r k e r E x p r e s s C a r e . p n g ' ,  
                                         R e t a i l :   ' h t t p : / / f i n d . v i o c . c o m / i m a g e s / m a r k e r R e t a i l . p n g ' ,  
                                         O t h e r :   ' h t t p : / / f i n d . v i o c . c o m / i m a g e s / m a r k e r O t h e r . p n g ' ,  
                                         V I O C :   ' h t t p : / / f i n d . v i o c . c o m / i m a g e s / m a r k e r V I O C . p n g ' ,  
                                         V I O C _ N e x t g e n :   ' h t t p : / / f i n d . v i o c . c o m / i m a g e s / m a r k e r V I O C _ N e x t g e n . p n g '  
                                 } ,  
                                 s h o w R e s u l t s M a x :   1  
                         }  
                 }  
  
                 t h i s . t r a c k E v e n t   =   f u n c t i o n ( c a t e g o r y ,   a c t i o n ,   l a b e l ,   v a l u e )   {  
                         i f   ( o b j . s e t t i n g s . t r a c k A n a l y t i c s )   {  
                                 t r y   {  
                                         i f   ( ( v a l u e   ! =   u n d e f i n e d )   & &   ( v a l u e . t o S t r i n g ( ) . s e a r c h ( / ^ - ? [ 0 - 9 ] + $ / )   = =   0 ) )   {  
                                                 _ g a q . p u s h ( [ ' _ t r a c k E v e n t ' ,   c a t e g o r y ,   a c t i o n ,   l a b e l ,   v a l u e . p a r s e I n t ( ) ] ) ;  
                                         }  
                                         e l s e   {  
                                                 i f   ( v a l u e   ! =   u n d e f i n e d )   {  
                                                         l a b e l   =   l a b e l   +   ' | '   +   v a l u e ;  
                                                 }  
                                                 _ g a q . p u s h ( [ ' _ t r a c k E v e n t ' ,   c a t e g o r y ,   a c t i o n ,   l a b e l ] ) ;  
                                         }  
                                 }  
                                 c a t c h   ( e r r )   {   }  
                         }  
                 }  
  
                 t h i s . t r a c k P a g e v i e w   =   f u n c t i o n ( p a g e )   {  
                         i f   ( o b j . s e t t i n g s . t r a c k A n a l y t i c s )   {  
                                 t r y   {  
                                         _ g a q . p u s h ( [ ' _ t r a c k P a g e v i e w ' ,   p a g e ] ) ;  
                                 }  
                                 c a t c h   ( e r r )   {   }  
                         }  
                 }  
  
                 t h i s . l i g h t b o x   =   {  
                         c r e a t e :   f u n c t i o n ( c o n t e n t )   {  
                                 t h i s C o n t e n t   =   $ ( c o n t e n t ) . c l o n e ( t r u e ) ;  
                                 i f   ( $ ( ' # l i g h t b o x ' ) . l e n g t h   = =   0 )   {  
                                         v a r   l b   =   $ ( ' < d i v   i d = " l i g h t b o x " > < d i v   c l a s s = " t o p " > < / d i v > < d i v   c l a s s = " i n s i d e " > < d i v   c l a s s = " c o n t e n t " > < / d i v > < / d i v > < / d i v > ' ) ;  
                                         l b . c s s ( ' o p a c i t y ' ,   0 ) ;  
                                         l b . a p p e n d T o ( $ ( d o c u m e n t . b o d y ) ) ;  
  
                                         l b . f i n d ( ' . c o n t e n t ' ) . a p p e n d ( t h i s C o n t e n t ) ;  
                                         t h i s C o n t e n t . f i n d ( ' s p a n   [ s t y l e = " m s o - s p a c e r u n :   y e s ; " ] ' ) . r e p l a c e W i t h ( ' < b r / > < b r / > ' ) ;  
                                         t h i s C o n t e n t . f i n d ( ' i m g ' ) . e a c h ( f u n c t i o n ( i n d e x ,   e l e m )   {  
                                                 v a r   m y D i v   =   $ ( ' < d i v   c l a s s = " i m a g e " > < d i v   c l a s s = " t o p " > < / d i v > < d i v   c l a s s = " b o t t o m " > < / d i v > < / d i v > ' ) ;  
                                                 m y D i v . a p p e n d ( e l e m ) ;  
                                                 l b . f i n d ( ' h 3 ' ) . a f t e r ( m y D i v ) ;  
                                         } ) ;  
                                         l b . a p p e n d ( $ ( ' < d i v   c l a s s = " c l e a r " > < / d i v > ' ) ) ;  
  
                                         v a r   m y C l o s e   =   $ ( ' < a   h r e f = " # "   c l a s s = " c l o s e " > < / a > ' ) ;  
                                         m y C l o s e . c l i c k ( f u n c t i o n ( e )   {  
                                                 e . p r e v e n t D e f a u l t ( ) ;  
                                                 o b j . l i g h t b o x . c l o s e ( ) ;  
                                         } ) ;  
                                         m y C l o s e . a p p e n d T o ( l b . f i n d ( ' . c o n t e n t ' ) ) ;  
                                         o b j . l i g h t b o x . a d j u s t ( ) ;  
                                         i f   ( $ ( ' # s c r e e n ' ) . l e n g t h   = =   0 )   {  
                                                 v a r   s c   =   $ ( ' < d i v   i d = " s c r e e n " > < / d i v > ' ) ;  
                                                 s c . c l i c k ( f u n c t i o n ( )   {  
                                                         o b j . l i g h t b o x . c l o s e ( ) ;  
                                                 } ) ;  
  
                                                 s c . c s s ( ' o p a c i t y ' ,   0 ) ;  
                                                 s c . a p p e n d T o ( $ ( d o c u m e n t . b o d y ) ) ;  
                                                 i f   ( $ . b r o w s e r . m s i e   & &   ( $ . b r o w s e r . v e r s i o n   <   7 ) )   {  
                                                         s c . c s s ( ' t o p ' ,   p a r s e I n t ( $ ( d o c u m e n t . b o d y ) . s c r o l l T o p ( ) ) ) ;  
                                                         s c . c s s ( ' h e i g h t ' ,   p a r s e I n t ( $ ( d o c u m e n t . b o d y ) . h e i g h t ( ) ) ) ;  
                                                         s c . c s s ( ' w i d t h ' ,   p a r s e I n t ( $ ( d o c u m e n t . b o d y ) . w i d t h ( ) ) ) ;  
                                                 }  
                                                 s c . a n i m a t e ( {   ' o p a c i t y ' :   ' . 7 '   } ,   {   d u r a t i o n :   5 0 0 ,   q u e u e :   f a l s e ,   c o m p l e t e :   f u n c t i o n ( )   {  
                                                         l b . a n i m a t e ( {   ' o p a c i t y ' :   1   } ,   {   d u r a t i o n :   5 0 0 ,   q u e u e :   f a l s e   } ) ;  
                                                 }  
                                                 } ) ;  
                                         }  
                                 }  
                         } ,  
                         a d j u s t :   f u n c t i o n ( )   {  
                                 i f   ( $ ( ' # s c r e e n ' ) . l e n g t h   >   0 )   {  
                                         i f   ( $ . b r o w s e r . m s i e   & &   ( $ . b r o w s e r . v e r s i o n   <   7 ) )   {  
                                                 $ ( ' # s c r e e n ' ) . c s s ( ' t o p ' ,   p a r s e I n t ( $ ( d o c u m e n t . b o d y ) . s c r o l l T o p ( ) ) ) ;  
                                                 $ ( ' # s c r e e n ' ) . c s s ( ' h e i g h t ' ,   p a r s e I n t ( $ ( d o c u m e n t . b o d y ) . h e i g h t ( ) ) ) ;  
                                                 $ ( ' # s c r e e n ' ) . c s s ( ' w i d t h ' ,   p a r s e I n t ( $ ( d o c u m e n t . b o d y ) . w i d t h ( ) ) ) ;  
                                         }  
                                 }  
                                 i f   ( $ ( ' # l i g h t b o x ' ) . l e n g t h   >   0 )   {  
                                         $ ( d o c u m e n t . b o d y ) . p a r e n t ( ' h t m l ' ) . c s s ( ' o v e r f l o w - y ' ,   ' h i d d e n ' ) ;  
                                         i f   ( ( $ ( w i n d o w ) . h e i g h t ( )   -   4 0 )   <   $ ( ' # l i g h t b o x   . c o n t e n t ' ) . i n n e r H e i g h t ( ) )   {  
                                                 $ ( ' # l i g h t b o x   . c o n t e n t ' ) . c s s ( ' h e i g h t ' ,   $ ( w i n d o w ) . h e i g h t ( )   -   4 0 ) ;  
                                                 $ ( ' # l i g h t b o x   . c o n t e n t ' ) . c s s ( ' o v e r f l o w - y ' ,   ' s c r o l l ' ) ;  
                                         }  
                                         e l s e   {  
                                                 $ ( ' # l i g h t b o x   . c o n t e n t ' ) . c s s ( ' h e i g h t ' ,   ' a u t o ' ) ;  
                                                 $ ( ' # l i g h t b o x   . c o n t e n t ' ) . c s s ( ' o v e r f l o w - y ' ,   ' a u t o ' ) ;  
                                         }  
                                         v a r   l b L f t   =   ( M a t h . r o u n d ( $ ( w i n d o w ) . w i d t h ( )   /   2 ) )   -   M a t h . r o u n d ( ( $ ( ' # l i g h t b o x ' ) . w i d t h ( )   /   2 ) )   +   $ ( d o c u m e n t . b o d y ) . s c r o l l L e f t ( ) ;  
                                         v a r   l b T o p   =   ( M a t h . r o u n d ( $ ( w i n d o w ) . h e i g h t ( )   /   2 ) )   -   M a t h . r o u n d ( ( $ ( ' # l i g h t b o x ' ) . h e i g h t ( )   /   2 ) )   -   3 8   +   $ ( d o c u m e n t . b o d y ) . s c r o l l T o p ( ) ;  
  
                                         $ ( ' # l i g h t b o x ' ) . a n i m a t e ( {   ' l e f t ' :   l b L f t ,   ' t o p ' :   l b T o p   } ,   {   d u r a t i o n :   5 0 0 ,   q u e u e :   f a l s e   } ) ;  
                                 }  
                         } ,  
                         c l o s e :   f u n c t i o n ( )   {  
                                 i f   ( $ ( ' # l i g h t b o x ' ) . l e n g t h   >   0 )   {  
                                         $ ( ' # l i g h t b o x ' ) . a n i m a t e ( {   ' o p a c i t y ' :   0   } ,   {   d u r a t i o n :   5 0 0 ,   q u e u e :   f a l s e ,   c o m p l e t e :  
 	 	 	 	             	 f u n c t i o n ( )   {  
 	 	 	 	             	         $ ( ' # s c r e e n ' ) . a n i m a t e ( {   ' o p a c i t y ' :   0   } ,   {   d u r a t i o n :   5 0 0 ,   q u e u e :   f a l s e ,   c o m p l e t e :  
 	 	 	 	 	                 	 f u n c t i o n ( )   {  
 	 	 	 	 	                 	         $ ( ' # l i g h t b o x ' ) . r e m o v e ( ) ;  
 	 	 	 	 	                 	         $ ( ' # s c r e e n ' ) . r e m o v e ( ) ;  
 	 	 	 	 	                 	         $ ( d o c u m e n t . b o d y ) . p a r e n t ( ' h t m l ' ) . c s s ( ' o v e r f l o w ' ,   ' a u t o ' ) ;  
 	 	 	 	 	                 	         $ ( d o c u m e n t . b o d y ) . p a r e n t ( ' h t m l ' ) . r e m o v e A t t r ( ' s t y l e ' ) ;  
 	 	 	 	 	                 	 }  
 	 	 	 	             	         } ) ;  
 	 	 	 	             	 }  
                                         } ) ;  
                                 }  
                         }  
                 }  
  
                 $ ( w i n d o w ) . b i n d ( ' r e s i z e   s c r o l l ' ,   f u n c t i o n ( )   {  
                         o b j . l i g h t b o x . a d j u s t ( ) ;  
                 } ) ;  
                 $ ( w i n d o w ) . b i n d ( ' s c r o l l ' ,   f u n c t i o n ( )   {  
                         i f   ( o b j . s e t t i n g s . m o b i l e )   {  
                                 o b j . h t m l . f i n d ( ' # p r o m o t i o n s ,   # f o o t ' ) . a n i m a t e ( {   ' o p a c i t y ' :   0   } ,   {   d u r a t i o n :   1 0 0 ,   q u e u e :   f a l s e   } ) ;  
                         }  
                         s e t T i m e o u t ( f u n c t i o n ( )   {   o b j . l o c a t o r . r e s i z e ( f a l s e ) ;   } ,   5 0 ) ;  
                 } ) ;  
  
                 / * *    
                 *   P u b i c   F u n c t i o n :   i n i t   ( [ o b j e c t / s t r i n g ] )  
                 *   T h i s   i s   u s e d   t o   i n i t i a l i z e   t h e   v a l v o l i n e   o b j e c t .  
                 *   I f   a n   o b j e c t   i s   p a s s e d   t h r o u g h ,   t h e   s e t t i n g s   a r e   m e r g e d / o v e r w r i t t e n   w i t h   t h e   c u r r e n t   s e t t i n g s .  
                 *   I f   a   s t r i n g   i s   p a s s e d   t h r o u g h ,   t h e   s e t t i n g s   a r e   m e r g e d / o v e r w r i t t e n   w i t h   a   s e t   o f   d e f a u l t s .  
                 * * /  
                 t h i s . i n i t   =   f u n c t i o n ( o p t i o n s )   {  
                         i f   ( t y p e o f   o p t i o n s   = = =   ' o b j e c t ' )   {  
                                 $ . e x t e n d ( o b j . s e t t i n g s ,   o p t i o n s   | |   { } ) ;  
                                 i f   ( t y p e o f   o b j . s e t t i n g s . r e s u l t T e m p l a t e   = = =   ' s t r i n g '   & &   o b j . s e t t i n g s . r e s u l t T e m p l a t e   ! =   ' ' )   {  
                                         $ . t e m p l a t e ( ' r e s u l t I t e m ' ,   o b j . s e t t i n g s . r e s u l t T e m p l a t e ) ;  
                                 }  
                                 i f   ( t y p e o f   o b j . s e t t i n g s . m a p T e m p l a t e   = = =   ' s t r i n g '   & &   o b j . s e t t i n g s . m a p T e m p l a t e   ! =   ' ' )   {  
                                         $ . t e m p l a t e ( ' m a p I t e m ' ,   o b j . s e t t i n g s . m a p T e m p l a t e ) ;  
                                 }  
                         }  
                         e l s e   i f   ( t y p e o f   o p t i o n s   = = =   ' s t r i n g ' )   {  
                                 $ . e x t e n d ( o b j . s e t t i n g s ,   o b j . d e f a u l t s [ o p t i o n s ]   | |   { } ) ;  
                                 i f   ( t y p e o f   o b j . s e t t i n g s . r e s u l t T e m p l a t e   = = =   ' s t r i n g '   & &   o b j . s e t t i n g s . r e s u l t T e m p l a t e   ! =   ' ' )   {  
                                         $ . t e m p l a t e ( ' r e s u l t I t e m ' ,   o b j . s e t t i n g s . r e s u l t T e m p l a t e ) ;  
                                 }  
                                 i f   ( t y p e o f   o b j . s e t t i n g s . m a p T e m p l a t e   = = =   ' s t r i n g '   & &   o b j . s e t t i n g s . m a p T e m p l a t e   ! =   ' ' )   {  
                                         $ . t e m p l a t e ( ' m a p I t e m ' ,   o b j . s e t t i n g s . m a p T e m p l a t e ) ;  
                                 }  
                         }  
                         i f   ( o b j . s e t t i n g s . c h a n g e H a s h )   {  
                                 $ ( w i n d o w ) . h a s h c h a n g e ( f u n c t i o n ( )   {  
                                         v a r   h a s h   =   l o c a t i o n . h a s h ;  
                                         i f   ( h a s h . s u b s t r ( 0 ,   1 )   = =   ' # ' )   {  
                                                 h a s h   =   ' { " '   +   h a s h . s u b s t r ( 1 ) . r e p l a c e ( / : / g ,   ' " : " ' ) . r e p l a c e ( / , / g ,   ' " , " ' )   +   ' " } ' ;  
                                         }  
                                         h a s h   =   $ . p a r s e J S O N ( h a s h ) ;  
                                         $ . e a c h ( h a s h ,   f u n c t i o n ( k e y ,   v a l )   {  
                                                 s w i t c h   ( k e y )   {  
                                                         c a s e   ' t o g g l e ' :  
                                                                 s w i t c h   ( v a l )   {  
                                                                         c a s e   ' m a p ' :  
                                                                                 o b j . l o c a t o r . w i d g e t s . t o g g l e ( ' m a p ' ) ;  
                                                                                 b r e a k ;  
  
                                                                         c a s e   ' r e s u l t s ' :  
                                                                                 o b j . l o c a t o r . w i d g e t s . t o g g l e ( ' r e s u l t s ' ) ;  
                                                                                 b r e a k ;  
                                                                 }  
                                                                 b r e a k ;  
  
                                                         c a s e   ' a d d r e s s ' :  
                                                                 o b j . e l e m . f i n d ( ' # s e a r c h   . f i e l d ' ) . v a l ( v a l ) ;  
                                                                 o b j . l o c a t o r . f i n d ( v a l ,   t r u e ) ;  
                                                                 b r e a k ;  
                                                 }  
                                         } ) ;  
                                 } ) ;  
                         }  
                 }  
  
                 / * *    
                 *   P u b i c   F u n c t i o n :   d i s p l a y    
                 *   T h i s   i s   u s e d   t o   c a l l   t h e   i n i t i a l   d i s p l a y   o f   w i d g e t s   t o   t h e   p a g e .  
                 * * /  
                 t h i s . d i s p l a y   =   f u n c t i o n ( )   {  
                         / * *    
                         *   L o c a t o r   c h e c k  
                         *   T h i s   w i l l   c h e c k   i f   t h e   b a s e   l o c a t o r   c o n t a i n e r   n e e d s   t o   b e   a d d e d   t o   t h e   p a g e  
                         * * /  
                         i f   ( o b j . s e t t i n g s . s h o w S e a r c h   | |   o b j . s e t t i n g s . s h o w F i l t e r s   | |   o b j . s e t t i n g s . s h o w R e s u l t s   | |   o b j . s e t t i n g s . s h o w M a p )   {  
                                 o b j . l o c a t o r . i n i t ( ) ;  
                                 o b j . l o c a t o r . h t m l   =   $ ( ' < d i v   i d = " l o c a t o r " > < / d i v > ' ) ;  
                                 i f   ( o b j . s e t t i n g s . l o c a t o r V i e w )   o b j . l o c a t o r . h t m l . a d d C l a s s ( o b j . s e t t i n g s . l o c a t o r V i e w ) ;  
                         }  
                         i f   ( o b j . s e t t i n g s . s h o w S e a r c h )   {   o b j . l o c a t o r . h t m l . a p p e n d ( o b j . l o c a t o r . w i d g e t s . s e a r c h ( ) ) ;   o b j . l o c a t o r . h t m l . a d d C l a s s ( ' s e a r c h ' ) ;   }  
                         i f   ( o b j . s e t t i n g s . m o b i l e )   {   o b j . l o c a t o r . h t m l . a d d C l a s s ( ' m o b i l e ' ) ;   }  
                         s w i t c h   ( o b j . s e t t i n g s . l o c a t o r V i e w )   {  
                                 c a s e   ' t o g g l e ' :  
                                         i f   ( o b j . s e t t i n g s . s h o w M a p   & &   o b j . s e t t i n g s . s h o w R e s u l t s )   {   o b j . l o c a t o r . h t m l . a p p e n d ( o b j . l o c a t o r . w i d g e t s . t o g g l e ( ) ) ;   o b j . l o c a t o r . h t m l . a d d C l a s s ( ' t o g g l e _ '   +   o b j . s e t t i n g s . t o g g l e D e f a u l t ) ;   }  
                                         b r e a k ;  
  
                                 c a s e   ' m a p ' :  
                                         o b j . s e t t i n g s . s h o w M a p   =   t r u e ;  
                                         o b j . s e t t i n g s . s h o w R e s u l t s   =   f a l s e ;  
                                         b r e a k ;  
  
                                 c a s e   ' r e s u l t s ' :  
                                         o b j . s e t t i n g s . s h o w M a p   =   f a l s e ;  
                                         o b j . s e t t i n g s . s h o w R e s u l t s   =   t r u e ;  
                                         b r e a k ;  
                         }  
                         i f   ( o b j . s e t t i n g s . s h o w F i l t e r s )   {   o b j . l o c a t o r . h t m l . a p p e n d ( o b j . l o c a t o r . w i d g e t s . f i l t e r s ( ) ) ;   o b j . l o c a t o r . h t m l . a d d C l a s s ( ' f i l t e r s ' ) ;   }  
                         e l s e   {   o b j . l o c a t o r . h t m l . a p p e n d ( o b j . l o c a t o r . w i d g e t s . f i l t e r s ( ) ) ;   o b j . l o c a t o r . h t m l . a d d C l a s s ( ' n o f i l t e r s ' ) ;   }  
                         i f   ( o b j . s e t t i n g s . s h o w R e s u l t s )   {   o b j . l o c a t o r . h t m l . a p p e n d ( o b j . l o c a t o r . w i d g e t s . r e s u l t s ( ) ) ;   o b j . l o c a t o r . h t m l . a d d C l a s s ( ' r e s u l t s ' ) ;   }  
                         i f   ( o b j . s e t t i n g s . s h o w M a p )   {   o b j . l o c a t o r . h t m l . a p p e n d ( o b j . l o c a t o r . w i d g e t s . m a p ( ) ) ;   o b j . l o c a t o r . h t m l . a d d C l a s s ( ' m a p ' ) ;   }  
                         e l s e   {   o b j . l o c a t o r . h t m l . a p p e n d ( o b j . l o c a t o r . w i d g e t s . m a p ( ) ) ;   o b j . l o c a t o r . h t m l . a d d C l a s s ( ' n o m a p ' ) ;   }  
  
                         i f   ( o b j . s e t t i n g s . s h o w F o o t e r )   {   o b j . l o c a t o r . h t m l . a p p e n d ( o b j . l o c a t o r . w i d g e t s . f o o t e r ( ) ) ;   o b j . l o c a t o r . h t m l . a d d C l a s s ( ' f o o t e r ' ) ;   }  
  
                         o b j . h t m l . a p p e n d ( o b j . l o c a t o r . h t m l ) ;  
                         o b j . e l e m . a p p e n d ( o b j . h t m l ) ;  
                         $ . e a c h ( o b j . l o c a t o r . p r o m o t i o n s . i t e m s ,   f u n c t i o n ( i n d e x ,   p r o m o )   {  
                                 i f   ( p r o m o . c o n d i t i o n   = =   n u l l )   {  
                                         o b j . l o c a t o r . p r o m o t e ( p r o m o . c o n t e n t ,   p r o m o . n a m e ,   p r o m o . n o C l i c k ) ;  
                                 }  
                         } ) ;  
                         o b j . l o c a t o r . u p d a t e ( ) ;  
                         i f   ( o b j . s e t t i n g s . c h a n g e H a s h )   {  
                                 $ ( w i n d o w ) . t r i g g e r ( ' h a s h c h a n g e ' ) ;  
                         }  
                         $ ( w i n d o w ) . t r i g g e r ( ' r e s i z e ' ) ;  
                         i f   ( o b j . s e t t i n g s . o n D i s p l a y   & &   ( t y p e o f   o b j . s e t t i n g s . o n D i s p l a y   = =   ' f u n c t i o n ' ) )   {  
                                 o b j . s e t t i n g s . o n D i s p l a y ( ) ;  
                         }  
                         / * i f   ( t y p e o f   o p t i o n s . o n C o m p l e t e   = =   ' f u n c t i o n ' )   {  
                         o p t i o n s . o n C o m p l e t e ( ) ;  
                         } * /  
                 }  
  
                 t h i s . u p d a t e   =   f u n c t i o n ( )   {  
                         i f   ( o b j . s e t t i n g s . s h o w M a p )   {  
  
                         }  
                         i f   ( o b j . s e t t i n g s . s h o w R e s u l t s )   {  
  
                         }  
                 }  
  
                 t h i s . h a s h   =   {  
                         ' s e t ' :   f u n c t i o n ( n a m e ,   v a l )   {  
                                 o b j . h a s h e s [ n a m e ]   =   v a l ;  
                                 o b j . h a s h . w r i t e ( ) ;  
                         } ,  
                         ' g e t ' :   f u n c t i o n ( n a m e )   {  
                                 r e t u r n   o b j . h a s h e s [ n a m e ]  
                         } ,  
                         ' w r i t e ' :   f u n c t i o n ( )   {  
                                 v a r   t h i s H a s h e s   =   [ ] ;  
                                 $ . e a c h ( o b j . h a s h e s ,   f u n c t i o n ( k e y ,   v a l )   {  
                                         t h i s H a s h e s . p u s h ( k e y   +   ' : '   +   v a l ) ;  
                                 } ) ;  
                                 t h i s H a s h e s   =   t h i s H a s h e s . j o i n ( ' , ' ) ;  
                                 i f   ( o b j . s e t t i n g s . c h a n g e H a s h )   {  
                                         w i n d o w . l o c a t i o n . h a s h   =   t h i s H a s h e s ;  
                                 }  
                         }  
                 }  
  
                 / * *    
                 *   P u b i c   F u n c t i o n :   s e t   ( s t r i n g / o b j e c t [ ,   s t r i n g ] )  
                 *   T h i s   i s   u s e d   t o   s e t   a   s i n g l e   s e t t i n g   f o r   t h e   b a s e   v a l v o l i n e   o b j e c t .  
                 *   T h e   f i r s t   p a r a m e t e r   i s   e i t h e r   t h e   s e t t i n g   t o   b e   c h a n g e d   o r   a n   o b j e c t   w i t h   s e t t i n g s   a n d   v a l u e s   t o   c h a n g e .  
                 *   I f   t h e   f i r s t   p a r a m e t e r   i s   a   s t r i n g ,   t h e   s e c o n d   i s   t h e   v a l u e   t o   s e t   i t   w i t h .  
                 * * /  
                 t h i s . s e t   =   f u n c t i o n ( o p t i o n s )   {  
                         i f   ( t y p e o f   o p t i o n s   = =   ' s t r i n g ' )   {  
                                 v a r   v a l u e   =   a r g u m e n t s [ 1 ] ;  
                                 r e t u r n   o b j . s e t t i n g s [ o p t i o n s ]   =   v a l u e ;  
                         }  
                         e l s e   {  
                                 $ . e x t e n d ( o b j . s e t t i n g s ,   o p t i o n s   | |   { } ) ;  
                         }  
                         i f   ( t y p e o f   o b j . s e t t i n g s . r e s u l t T e m p l a t e   = = =   ' s t r i n g '   & &   o b j . s e t t i n g s . r e s u l t T e m p l a t e   ! =   ' ' )   {  
                                 $ . t e m p l a t e ( ' r e s u l t I t e m ' ,   o b j . s e t t i n g s . r e s u l t T e m p l a t e ) ;  
                         }  
                         i f   ( t y p e o f   o b j . s e t t i n g s . m a p T e m p l a t e   = = =   ' s t r i n g '   & &   o b j . s e t t i n g s . m a p T e m p l a t e   ! =   ' ' )   {  
                                 $ . t e m p l a t e ( ' m a p I t e m ' ,   o b j . s e t t i n g s . m a p T e m p l a t e ) ;  
                         }  
                 } ;  
  
                 / * *    
                 *   P u b i c   F u n c t i o n :   g e t   ( s t r i n g )  
                 *   T h i s   i s   u s e d   t o   g e t   a   s i n g l e   s e t t i n g   f r o m   t h e   b a s e   v a l v o l i n e   o b j e c t .  
                 *   T h e   p a r a m a t e r   p a s s e d   i s   t h e   s e t t i n g   t o   b e   r e t r i e v e d .  
                 * * /  
                 t h i s . g e t   =   f u n c t i o n ( n a m e )   {  
                         r e t u r n   o b j . s e t t i n g s [ n a m e ] ;  
                 } ;  
  
                 t h i s . s t o r e   =   {  
                         b u i l d :   f u n c t i o n ( o b j )   {  
                                 v a r   t h i s S t o r e   =   { } ;  
  
                         }  
                 }  
  
                 / * *    
                 *   P u b i c   O b j e c t :   l o c a t o r    
                 *   T h i s   w i l l   h o u s e   t h e   i n i t a l i z a t i o n   o f   t h e   l o c a t o r   o b j e c t ,   i n c l u d i n g   w i d g e t s   a n d   f u n c t i o n s   s p e c i f i c   t o   t h e   l o c a t o r .  
                 * * /  
                 t h i s . l o c a t o r   =   {  
                         s e t t i n g s :   {  
                                 i n i t i a l i z e d :   f a l s e ,  
                                 f i r s t :   f a l s e  
                         } ,  
  
                         f i l t e r s :   f u n c t i o n ( )   {  
                                 v a r   t h i s F i l t e r s   =   n e w   A r r a y ( ) ;  
                                 i f   ( o b j . s e t t i n g s . f i l t e r V I O C . c h e c k )   {   t h i s F i l t e r s . p u s h ( ' V I O C ' )   }  
                                 i f   ( o b j . s e t t i n g s . f i l t e r E C . c h e c k )   {   t h i s F i l t e r s . p u s h ( ' E C ' )   }  
                                 i f   ( o b j . s e t t i n g s . f i l t e r O t h e r . c h e c k )   {   t h i s F i l t e r s . p u s h ( ' A V I ' )   }  
                                 i f   ( o b j . s e t t i n g s . f i l t e r R e t a i l . c h e c k )   {   t h i s F i l t e r s . p u s h ( ' D I Y ' )   }  
  
                                 r e t u r n   t h i s F i l t e r s ;  
                         } ,  
  
                         / * *    
                         *   P u b i c   F u n c t i o n :   l o c a t o r . i n i t   ( o b j e c t )  
                         *   T h e   p a r a m e t e r   p a s s e d   i s   a n   o b j e c t   t h a t   m e r g e s / o v e r w r i t e s   t h e   c u r r e n t   s e t t i n g s .  
                         * * /  
                         i n i t :   f u n c t i o n ( o p t i o n s )   {  
                                 $ . e x t e n d ( { } ,   t h i s . s e t t i n g s ,   o p t i o n s ) ;  
                                 o b j . l o c a t o r . s e t t i n g s   =   t h i s . s e t t i n g s ;  
                                 o b j . l o c a t o r . l o c a t i o n s   =   {  
                                         i t e m s :   { } ,  
                                         i d s :   [ ] ,  
                                         m a r k e r s :   {  
                                                 c u r r e n t :   f u n c t i o n ( )   {  
                                                         v a r   m y B o u n d s   =   o b j . l o c a t o r . m a p . g e t B o u n d s ( ) ;  
                                                         v a r   l i s t   =   [ ] ;  
                                                         $ . e a c h ( o b j . l o c a t o r . l o c a t i o n s . m a r k e r s ,   f u n c t i o n ( i n d e x ,   v a l )   {  
                                                                 i f   ( t y p e o f   v a l   = =   ' o b j e c t ' )   {  
                                                                         i f   ( m y B o u n d s . c o n t a i n s ( v a l . p o s i t i o n ) )   {  
                                                                                 l i s t . p u s h ( v a l ) ;  
                                                                         }  
                                                                 }  
                                                         } ) ;  
                                                         r e t u r n   l i s t ;  
                                                 } ,  
                                                 r e s e t :   f u n c t i o n ( )   {  
                                                         $ . e a c h ( o b j . l o c a t o r . l o c a t i o n s . i d s ,   f u n c t i o n ( i n d e x ,   v a l u e )   {  
                                                                 $ . e a c h ( o b j . l o c a t o r . l o c a t i o n s . m a r k e r s . c u r r e n t ( ) ,   f u n c t i o n ( i n d e x 2 ,   v a l u e 2 )   {  
                                                                         i f   ( o b j . s e t t i n g s . f i l t e r N e x t g e n   & &   o b j . s e t t i n g s . f i l t e r N e x t g e n . c h e c k )   {  
                                                                                 i f   ( o b j . l o c a t o r . l o c a t i o n s . i t e m s [ v a l u e ] . S p e c i a l S e r v i c e s . F e a t u r e s N e x t G e n . t o L o w e r C a s e ( )   = =   ' y ' )   {  
                                                                                         i f   ( o b j . l o c a t o r . l o c a t i o n s . m a r k e r s [ v a l u e ] . g e t M a p ( )   = =   n u l l )   {  
                                                                                                 o b j . l o c a t o r . l o c a t i o n s . m a r k e r s [ v a l u e ] . s e t M a p ( o b j . l o c a t o r . m a p ) ;  
                                                                                         }  
                                                                                 }  
                                                                                 e l s e   {  
                                                                                         i f   ( o b j . l o c a t o r . l o c a t i o n s . m a r k e r s [ v a l u e ]   ! =   n u l l )   {  
                                                                                                 o b j . l o c a t o r . l o c a t i o n s . m a r k e r s [ v a l u e ] . s e t M a p ( n u l l ) ;  
                                                                                         }  
                                                                                 }  
                                                                         }  
                                                                         e l s e   {  
                                                                                 i f   ( $ . i n A r r a y ( o b j . l o c a t o r . l o c a t i o n s . i t e m s [ v a l u e ] . b r a n d ,   o b j . l o c a t o r . f i l t e r s ( ) )   > =   0 )   {  
                                                                                         i f   ( o b j . l o c a t o r . l o c a t i o n s . m a r k e r s [ v a l u e ]   ! =   n u l l )   {  
                                                                                                 i f   ( o b j . l o c a t o r . l o c a t i o n s . m a r k e r s [ v a l u e ] . g e t M a p ( )   = =   n u l l )   {  
                                                                                                         o b j . l o c a t o r . l o c a t i o n s . m a r k e r s [ v a l u e ] . s e t M a p ( o b j . l o c a t o r . m a p ) ;  
                                                                                                 }  
                                                                                         }  
                                                                                 }  
                                                                                 e l s e   {  
                                                                                         i f   ( o b j . l o c a t o r . l o c a t i o n s . m a r k e r s [ v a l u e ]   ! =   n u l l )   {  
                                                                                                 o b j . l o c a t o r . l o c a t i o n s . m a r k e r s [ v a l u e ] . s e t M a p ( n u l l ) ;  
                                                                                         }  
                                                                                 }  
                                                                         }  
                                                                 } ) ;  
                                                         } ) ;  
                                                 }  
                                         } ,  
                                         o r d e r e d :   f u n c t i o n ( )   {  
                                                 v a r   m y A r r a y   =   n e w   A r r a y ( ) ;  
                                                 $ . e a c h ( o b j . l o c a t o r . l o c a t i o n s . i d s ,   f u n c t i o n ( i n d ,   i n f o )   {  
                                                         m y A r r a y . p u s h ( o b j . l o c a t o r . l o c a t i o n s . i t e m s [ i n f o ] ) ;  
                                                 } ) ;  
                                                 m y A r r a y . s o r t ( f u n c t i o n ( a ,   b )   {  
                                                         r e t u r n   ( ( p a r s e F l o a t ( a . d i s t a n c e )   <   p a r s e F l o a t ( b . d i s t a n c e ) )   ?   - 1   :   ( ( p a r s e F l o a t ( a . d i s t a n c e )   >   p a r s e F l o a t ( b . d i s t a n c e ) )   ?   1   :   0 ) ) ;  
                                                 } ) ;  
                                                 r e t u r n   m y A r r a y ;  
                                         }  
                                 } ;  
                                 $ ( w i n d o w ) . r e s i z e ( f u n c t i o n ( )   {  
                                         i f   ( $ . b r o w s e r . m s i e )   {  
                                                 o b j . h t m l . f i n d ( ' # r e s u l t s ' ) . c s s ( ' h e i g h t ' ,   o b j . e l e m . h e i g h t ( )   -   p a r s e I n t ( o b j . h t m l . f i n d ( ' # r e s u l t s ' ) . c s s ( ' t o p ' ) ) ) ;  
                                                 o b j . h t m l . f i n d ( ' # m a p ' ) . c s s ( ' h e i g h t ' ,   o b j . e l e m . h e i g h t ( )   -   p a r s e I n t ( o b j . h t m l . f i n d ( ' # m a p ' ) . c s s ( ' t o p ' ) ) ) ;  
                                         }  
                                 } ) ;  
                                 r e t u r n   t h i s ;  
                         } ,  
  
                         e r r o r :   f u n c t i o n ( m e s s a g e )   {  
                                 i f   ( o b j . h t m l . f i n d ( ' # e r r o r s ' ) . l e n g t h   >   0 )   {  
                                         v a r   t h i s E r r o r s   =   o b j . h t m l . f i n d ( ' # e r r o r s ' ) ;  
                                 }  
                                 e l s e   {  
                                         v a r   t h i s E r r o r s   =   $ ( ' < d i v   i d = " e r r o r s " > < / d i v > ' ) ;  
                                         o b j . h t m l . f i n d ( ' # l o c a t o r ' ) . a p p e n d ( t h i s E r r o r s ) ;  
                                         t h i s E r r o r s . c s s ( ' t o p ' ,   o b j . h t m l . f i n d ( ' # r e s u l t s ,   # m a p ' ) . c s s ( ' p a d d i n g - t o p ' ) ) ;  
                                         i f   ( o b j . h t m l . f i n d ( ' # f i l t e r s ' )   & &   o b j . h t m l . f i n d ( ' # f i l t e r s ' ) . h a s C l a s s ( ' s h o w ' ) )   {  
                                                 t h i s E r r o r s . c s s ( ' t o p ' ,   p a r s e I n t ( o b j . h t m l . f i n d ( ' # f i l t e r s ' ) . p o s i t i o n ( ) . t o p )   +   p a r s e I n t ( o b j . h t m l . f i n d ( ' # f i l t e r s ' ) . h e i g h t ( ) ) ) ;  
                                         }  
                                 }  
                                 v a r   c o n t   =   t r u e ;  
                                 t h i s E r r o r s . f i n d ( ' . e r r o r   s p a n ' ) . e a c h ( f u n c t i o n ( i n d e x ,   v a l u e )   {  
                                         i f   ( $ ( v a l u e ) . h t m l ( )   = =   m e s s a g e )   {  
                                                 c o n t   =   f a l s e ;  
                                         }  
                                 } ) ;  
                                 i f   ( c o n t )   {  
                                         v a r   t h i s E r r o r   =   $ ( ' < d i v   c l a s s = " e r r o r " > < s p a n > '   +   m e s s a g e   +   ' < / s p a n > < b r / > < / d i v > ' ) ;  
                                         v a r   t h i s C l o s e   =   $ ( ' < a   h r e f = " # " > c l o s e < / a > ' ) ;  
                                         t h i s E r r o r . a p p e n d ( t h i s C l o s e ) ;  
                                         t h i s C l o s e . c l i c k ( f u n c t i o n ( E )   {  
                                                 E . p r e v e n t D e f a u l t ( ) ;  
                                                 $ ( t h i s ) . p a r e n t ( ) . f a d e O u t ( f u n c t i o n ( )   {  
                                                         i f   ( o b j . h t m l . f i n d ( ' # e r r o r s   . e r r o r ' ) . l e n g t h   >   1 )   {  
                                                                 $ ( t h i s ) . r e m o v e ( ) ;  
                                                         }  
                                                         e l s e   {  
                                                                 o b j . h t m l . f i n d ( ' # e r r o r s ' ) . r e m o v e ( ) ;  
                                                         }  
                                                 } ) ;  
                                         } ) ;  
                                         t h i s E r r o r . c l i c k ( f u n c t i o n ( )   {  
                                                 $ ( t h i s ) . f a d e O u t ( f u n c t i o n ( )   {  
                                                         i f   ( o b j . h t m l . f i n d ( ' # e r r o r s   . e r r o r ' ) . l e n g t h   >   1 )   {  
                                                                 $ ( t h i s ) . r e m o v e ( ) ;  
                                                         }  
                                                         e l s e   {  
                                                                 o b j . h t m l . f i n d ( ' # e r r o r s ' ) . r e m o v e ( ) ;  
                                                         }  
                                                 } ) ;  
                                         } ) ;  
                                         t h i s E r r o r s . a p p e n d ( t h i s E r r o r ) ;  
                                         t h i s E r r o r . h i d e ( ) . f a d e I n ( ) ;  
                                         o b j . t r a c k E v e n t ( ' e r r o r ' ,   ' s h o w ' ,   m e s s a g e ) ;  
                                 }  
                                 o b j . l o c a t o r . r e s i z e ( ) ;  
                                 / / o b j . c o n s o l e ( ' F u n c t i o n :   e r r o r ( ' + m e s s a g e + ' ) ' ) ;  
                         } ,  
  
                         p r o m o t e :   f u n c t i o n ( m e s s a g e ,   n a m e )   {  
                                 v a r   n o C l i c k   =   f a l s e ;  
                                 i f   ( a r g u m e n t s . l e n g t h   >   2 )   {  
                                         n o C l i c k   =   a r g u m e n t s [ 2 ] ;  
                                 }  
                                 i f   ( o b j . h t m l . f i n d ( ' # p r o m o t i o n s ' ) . l e n g t h   >   0 )   {  
                                         v a r   t h i s P r o m o s   =   o b j . h t m l . f i n d ( ' # p r o m o t i o n s ' ) ;  
                                 }  
                                 e l s e   {  
                                         v a r   t h i s P r o m o s   =   $ ( ' < d i v   i d = " p r o m o t i o n s " > < / d i v > ' ) ;  
                                         o b j . h t m l . f i n d ( ' # l o c a t o r ' ) . a p p e n d ( t h i s P r o m o s ) ;  
                                         t h i s P r o m o s . c s s ( ' b o t t o m ' ,   0 ) ;  
                                         i f   ( o b j . h t m l . f i n d ( ' # f o o t ' ) )   {  
                                                 t h i s P r o m o s . c s s ( ' b o t t o m ' ,   o b j . h t m l . f i n d ( ' # f o o t ' ) . o u t e r H e i g h t ( ) ) ;  
                                         }  
                                 }  
                                 i f   ( ( t h i s P r o m o s . f i n d ( ' # '   +   n a m e ) . l e n g t h   = =   0 )   & &   ( $ . i n A r r a y ( n a m e ,   o b j . l o c a t o r . p r o m o t i o n s . s h o w n )   <   0 ) )   {  
                                         v a r   t h i s P r o m o   =   $ ( ' < d i v   c l a s s = " p r o m o "   i d = " '   +   n a m e   +   ' " / > ' ) ;  
                                         t h i s P r o m o . a p p e n d ( m e s s a g e ) ;  
                                         v a r   t h i s C l o s e   =   $ ( ' < a   h r e f = " # "   c l a s s = " c l o s e " > c l o s e < / a > ' ) ;  
                                         t h i s P r o m o . a p p e n d ( t h i s C l o s e ) ;  
                                         i f   ( ! n o C l i c k )   {  
                                                 t h i s P r o m o . c l i c k ( f u n c t i o n ( )   {  
  
                                                         t h i s P r o m o . f a d e O u t ( 5 0 0 ,   f u n c t i o n ( )   {  
                                                                 i f   ( o b j . h t m l . f i n d ( ' # p r o m o t i o n s   . p r o m o ' ) . l e n g t h   >   2 )   {  
                                                                         t h i s P r o m o . r e m o v e ( ) ;  
                                                                 }  
                                                                 e l s e   {  
                                                                         o b j . h t m l . f i n d ( ' # p r o m o t i o n s ' ) . r e m o v e ( ) ;  
                                                                 }  
                                                                 o b j . l o c a t o r . r e s i z e ( ) ;  
                                                         } ) ;  
                                                 } ) ;  
                                         }  
                                         t h i s C l o s e . c l i c k ( f u n c t i o n ( E )   {  
                                                 E . p r e v e n t D e f a u l t ( ) ;  
                                                 $ ( t h i s ) . p a r e n t ( ) . f a d e O u t ( 5 0 0 ,   f u n c t i o n ( )   {  
                                                         i f   ( o b j . h t m l . f i n d ( ' # p r o m o t i o n s   . p r o m o ' ) . l e n g t h   >   2 )   {  
                                                                 $ ( t h i s ) . r e m o v e ( ) ;  
                                                         }  
                                                         e l s e   {  
                                                                 o b j . h t m l . f i n d ( ' # p r o m o t i o n s ' ) . r e m o v e ( ) ;  
                                                         }  
                                                         o b j . l o c a t o r . r e s i z e ( ) ;  
                                                 } ) ;  
                                         } ) ;  
                                         t h i s P r o m o s . p r e p e n d ( t h i s P r o m o ) ;  
                                         t h i s P r o m o . h i d e ( ) . d e l a y ( 1 5 0 0 ) . f a d e I n ( 5 0 0 ,   f u n c t i o n ( )   {  
                                                 o b j . l o c a t o r . r e s i z e ( ) ;  
                                         } ) ;  
                                         o b j . t r a c k E v e n t ( ' p r o m o t i o n ' ,   ' s h o w ' ,   m e s s a g e ) ;  
                                         o b j . l o c a t o r . p r o m o t i o n s . s h o w n . p u s h ( n a m e ) ;  
                                         $ . u n i q u e ( o b j . l o c a t o r . p r o m o t i o n s . s h o w n ) ;  
                                 }  
                                 o b j . l o c a t o r . r e s i z e ( ) ;  
                         } ,  
  
                         p r o m o t i o n s :   {  
                                 i t e m s :   [ ] ,  
                                 s h o w n :   [ ] ,  
                                 a d d :   f u n c t i o n ( p r o m o )   {  
                                         o b j . l o c a t o r . p r o m o t i o n s . i t e m s . p u s h ( p r o m o ) ;  
                                 }  
                         } ,  
  
                         / * *    
                         *   P u b i c   F u n c t i o n :   l o c a t o r . f i n d   ( s t r i n g ,   [ b o o l ] )  
                         *   T h e   p a r a m e t e r   p a s s e d   i s   a n   o b j e c t   t h a t   m e r g e s / o v e r w r i t e s   t h e   c u r r e n t   s e t t i n g s .  
                         *   T h e   s e c o n d ,   o p t i o n a l   p a r a m e t e r   p a s s e d   w i l l   t e l l   t h e   f u n c t i o n   w h e t h e r   o r   n o t   t o   c h a n g e   t h e   m a p ' s   z o o m .  
                         * * /  
  
                         f i n d :   f u n c t i o n ( a d d r e s s )   {  
                                 v a r   c e n t e r M a p   =   f a l s e ;  
                                 v a r   s t o p T h i s   =   f a l s e ;  
                                 i f   ( o b j . l o c a t o r . l a s t F i l t e r s   ! =   u n d e f i n e d   & &   o b j . l o c a t o r . f i l t e r s ( )   ! =   u n d e f i n e d )   {  
                                         i f   ( o b j . l o c a t o r . l a s t F i l t e r s . j o i n ( ' ; ' )   ! = =   o b j . l o c a t o r . f i l t e r s ( ) . j o i n ( ' ; ' ) )   {  
                                                 s t o p T h i s   =   t r u e ;  
                                         }  
                                 }  
                                 v a r   z o o m i n g   =   ( a r g u m e n t s . l e n g t h   >   2   & &   a r g u m e n t s [ 2 ]   = =   t r u e ) ;  
                                 i f   ( o b j . l o c a t o r . z o o m   & &   o b j . l o c a t o r . z o o m   > =   1 2 )   {  
                                         s t o p T h i s   =   t r u e ;  
                                 }  
                                 i f   ( ( o b j . l o c a t o r . l a s t S e a r c h   ! = =   a d d r e s s )   | |   s t o p T h i s   | |   z o o m i n g )   {  
                                         v a r   c h a n g e Z o o m   =   f a l s e ;  
                                         i f   ( a r g u m e n t s . l e n g t h   >   1 )   {  
                                                 c h a n g e Z o o m   =   a r g u m e n t s [ 1 ] ;  
                                         }  
                                         v a r   o p t i o n s   =   { } ;  
                                         v a r   l a s t A d d r e s s   =   ' ' ;  
                                         s w i t c h   ( t y p e o f   a d d r e s s )   {  
                                                 c a s e   ' s t r i n g ' :  
                                                         o p t i o n s   =   {   ' a d d r e s s ' :   a d d r e s s   } ;  
                                                         l a s t A d d r e s s   =   a d d r e s s  
                                                         o b j . h a s h . s e t ( ' a d d r e s s ' ,   a d d r e s s ) ;  
                                                         c e n t e r M a p   =   t r u e ;  
                                                         b r e a k ;  
  
                                                 d e f a u l t :  
                                                         o p t i o n s   =   {   ' l o c a t i o n ' :   o b j . l o c a t o r . c e n t e r   }  
                                                         l a s t A d d r e s s   =   o b j . l o c a t o r . c e n t e r . l a t ( )   +   ' , '   +   o b j . l o c a t o r . c e n t e r . l n g ( ) ;  
                                         }  
                                         i f   ( o b j . l o c a t o r . l a s t S e a r c h   ! = =   l a s t A d d r e s s )   {  
                                                 $ . c o o k i e ( ' l a s t A d d r e s s ' ,   l a s t A d d r e s s ,   {   e x p i r e s :   1 4   } ) ;  
  
                                                 o b j . l o c a t o r . l a s t S e a r c h   =   l a s t A d d r e s s ;  
                                                 o b j . l o c a t o r . l a s t F i l t e r s   =   o b j . l o c a t o r . f i l t e r s ( ) ;  
                                                 / / o b j . c o n s o l e ( ' F u n c t i o n :   f i n d ( " '   +   l a s t A d d r e s s   +   ' " ,   '   +   c h a n g e Z o o m   +   ' ) ' ) ;  
                                                 o b j . l o c a t o r . g e o c o d e r . g e o c o d e ( o p t i o n s ,  
 	 	 	 	 	 	 	 	                 f u n c t i o n ( r e s u l t s ,   s t a t u s )   {  
 	 	 	 	 	 	 	 	                         s w i t c h   ( s t a t u s )   {  
 	 	 	 	 	 	 	 	                                 c a s e   ' O K ' :  
 	 	 	 	 	 	 	 	                                         o b j . l o c a t o r . l o c a t i o n s . m a r k e r s . r e s e t ( ) ;  
 	 	 	 	 	 	 	 	                                         i f   ( r e s u l t s . l e n g t h   >   0 )   {  
 	 	 	 	 	 	 	 	                                                 v a r   r e s u l t   =   r e s u l t s [ 0 ] ;  
 	 	 	 	 	 	 	 	                                                 o b j . l o c a t o r . c e n t e r   =   n e w   g o o g l e . m a p s . L a t L n g ( r e s u l t . g e o m e t r y . l o c a t i o n . l a t ( ) ,   r e s u l t . g e o m e t r y . l o c a t i o n . l n g ( ) ) ;  
 	 	 	 	 	 	 	 	                                                 i f   ( c h a n g e Z o o m )   {  
 	 	 	 	 	 	 	 	                                                         / / o b j . c o n s o l e ( ' C h a n g e   Z o o m ' ) ;  
 	 	 	 	 	 	 	 	                                                         i f   ( t y p e o f   c h a n g e Z o o m   = =   ' b o o l e a n ' )   {  
 	 	 	 	 	 	 	 	                                                                 o b j . l o c a t o r . z o o m   =   1 2 ;  
 	 	 	 	 	 	 	 	                                                         }  
 	 	 	 	 	 	 	 	                                                         e l s e   {  
 	 	 	 	 	 	 	 	                                                                 o b j . l o c a t o r . z o o m   =   p a r s e I n t ( c h a n g e Z o o m ) ;  
 	 	 	 	 	 	 	 	                                                         }  
 	 	 	 	 	 	 	 	                                                         o b j . l o c a t o r . p r o m o t i o n s . s h o w n   =   n e w   A r r a y ( ) ;  
 	 	 	 	 	 	 	 	                                                 }  
  
 	 	 	 	 	 	 	 	                                                 v a r   t h i s O p t i o n s   =   {  
 	 	 	 	 	 	 	 	                                                         s L a t i t u d e :   o b j . l o c a t o r . c e n t e r . l a t ( ) ,  
 	 	 	 	 	 	 	 	                                                         s L o n g i t u d e :   o b j . l o c a t o r . c e n t e r . l n g ( ) ,  
 	 	 	 	 	 	 	 	                                                         s C h e c k V I O C :   o b j . s e t t i n g s . f i l t e r V I O C . c h e c k ,  
 	 	 	 	 	 	 	 	                                                         s C h e c k E C :   o b j . s e t t i n g s . f i l t e r E C . c h e c k ,  
 	 	 	 	 	 	 	 	                                                         s C h e c k O t h e r :   o b j . s e t t i n g s . f i l t e r O t h e r . c h e c k ,  
 	 	 	 	 	 	 	 	                                                         s C h e c k R e t a i l :   o b j . s e t t i n g s . f i l t e r R e t a i l . c h e c k ,  
 	 	 	 	 	 	 	 	                                                         s R e s u l t C o u n t :   o b j . s e t t i n g s . s h o w R e s u l t s M a x ,  
 	 	 	 	 	 	 	 	                                                         s R a d i u s :   o b j . s e t t i n g s . r a d i u s ,  
 	 	 	 	 	 	 	 	                                                         s R e t u r n C o n t e n t T y p e s :   o b j . s e t t i n g s . r e t u r n C o n t e n t T y p e s  
 	 	 	 	 	 	 	 	                                                 }  
 	 	 	 	 	 	 	 	                                                 v a r   d o S o m e t h i n g   =   f u n c t i o n ( r e s u l t s )   {  
 	 	 	 	 	 	 	 	                                                         i f   ( o b j . l o c a t o r . z o o m   <   1 1 )   {  
 	 	 	 	 	 	 	 	                                                                 o b j . l o c a t o r . e r r o r ( ' Y o u   m u s t   b e   z o o m e d   i n   f u r t h e r   t o   d o   a   s e a r c h . ' ) ;  
 	 	 	 	 	 	 	 	                                                         }  
 	 	 	 	 	 	 	 	                                                         e l s e   {  
 	 	 	 	 	 	 	 	                                                                 v a r   o l d L e n g t h   =   o b j . l o c a t o r . l o c a t i o n s . i d s . l e n g t h ;  
 	 	 	 	 	 	 	 	                                                                 i f   ( o l d L e n g t h   >   0 )   {  
 	 	 	 	 	 	 	 	                                                                         $ . e a c h ( ( o b j . l o c a t o r . l o c a t i o n s . i d s ) ,   f u n c t i o n ( i n d e x ,   v a l u e )   {  
 	 	 	 	 	 	 	 	                                                                                 i f   ( o b j . l o c a t o r . l o c a t i o n s . i t e m s [ v a l u e ]   ! = =   u n d e f i n e d )   {  
 	 	 	 	 	 	 	 	                                                                                         o b j . l o c a t o r . l o c a t i o n s . i t e m s [ v a l u e ] . d i s t a n c e   =   9 9 9 9 9 9 9 9 9 9 9 9 9 9 ;  
 	 	 	 	 	 	 	 	                                                                                         i f   ( o b j . l o c a t o r . l o c a t i o n s . i t e m s [ v a l u e ] . b r a n d   = =   ' V I O C ' )   {  
 	 	 	 	 	 	 	 	                                                                                                 o b j . l o c a t o r . l o c a t i o n s . i t e m s [ v a l u e ] . d i s t a n c e   =   p a r s e F l o a t ( o b j . l o c a t o r . l o c a t i o n s . i t e m s [ v a l u e ] . d i s t a n c e )   -   5 ;  
 	 	 	 	 	 	 	 	                                                                                         }  
 	 	 	 	 	 	 	 	                                                                                 }  
 	 	 	 	 	 	 	 	                                                                         } ) ;  
 	 	 	 	 	 	 	 	                                                                         / / o b j . c o n s o l e ( o b j . l o c a t o r . l o c a t i o n s . i t e m s ) ;  
 	 	 	 	 	 	 	 	                                                                 }  
 	 	 	 	 	 	 	 	                                                                 v a r   L o c a t i o n s   =   n e w   A r r a y ( ) ;  
  
 	 	 	 	 	 	 	 	                                                                 i f   ( a r g u m e n t s . l e n g t h   >   1 )   {  
 	 	 	 	 	 	 	 	                                                                         i f   ( a r g u m e n t s [ 1 ]   = =   ' j s o n ' )   {  
 	 	 	 	 	 	 	 	                                                                                 r e s u l t s   =   r e s u l t s ;  
 	 	 	 	 	 	 	 	                                                                                 L o c a t i o n s   =   r e s u l t s . L o c a t i o n ;  
 	 	 	 	 	 	 	 	                                                                         }  
 	 	 	 	 	 	 	 	                                                                         e l s e   {  
 	 	 	 	 	 	 	 	                                                                                 i f   ( r e s u l t s   ! = =   n u l l )   {  
 	 	 	 	 	 	 	 	                                                                                         i f   ( t y p e o f   r e s u l t s . L o c a t i o n s   = =   ' o b j e c t ' )   {  
 	 	 	 	 	 	 	 	                                                                                                 L o c a t i o n s   =   r e s u l t s . L o c a t i o n s ;  
 	 	 	 	 	 	 	 	                                                                                         }  
 	 	 	 	 	 	 	 	                                                                                         e l s e   i f   ( t y p e o f   r e s u l t s . L o c a t i o n   = =   ' o b j e c t ' )   {  
 	 	 	 	 	 	 	 	                                                                                                 L o c a t i o n s   =   r e s u l t s . L o c a t i o n ;  
 	 	 	 	 	 	 	 	                                                                                         }  
 	 	 	 	 	 	 	 	                                                                                 }  
 	 	 	 	 	 	 	 	                                                                         }  
 	 	 	 	 	 	 	 	                                                                 }  
 	 	 	 	 	 	 	 	                                                                 e l s e   {  
 	 	 	 	 	 	 	 	                                                                         i f   ( r e s u l t s   ! = =   n u l l )   {  
 	 	 	 	 	 	 	 	                                                                                 i f   ( t y p e o f   r e s u l t s . L o c a t i o n s   = =   ' o b j e c t ' )   {  
 	 	 	 	 	 	 	 	                                                                                         L o c a t i o n s   =   r e s u l t s . L o c a t i o n s ;  
 	 	 	 	 	 	 	 	                                                                                 }  
 	 	 	 	 	 	 	 	                                                                                 e l s e   i f   ( t y p e o f   r e s u l t s . L o c a t i o n   = =   ' o b j e c t ' )   {  
 	 	 	 	 	 	 	 	                                                                                         L o c a t i o n s   =   r e s u l t s . L o c a t i o n ;  
 	 	 	 	 	 	 	 	                                                                                 }  
 	 	 	 	 	 	 	 	                                                                         }  
 	 	 	 	 	 	 	 	                                                                 }  
  
 	 	 	 	 	 	 	 	                                                                 i f   ( ( t y p e o f   L o c a t i o n s   ! = =   ' u n d e f i n e d ' )   & &   L o c a t i o n s . l e n g t h   >   0 )   {  
 	 	 	 	 	 	 	 	                                                                         $ ( L o c a t i o n s ) . e a c h ( f u n c t i o n ( i n d e x ,   e l e m )   {  
 	 	 	 	 	 	 	 	                                                                                 i f   ( ( $ . i n A r r a y ( t h i s . I D ,   o b j . l o c a t o r . l o c a t i o n s . i d s ) )   <   0 )   {  
 	 	 	 	 	 	 	 	                                                                                         o b j . l o c a t o r . l o c a t i o n s . i t e m s [ e l e m . I D ]   =   e l e m ;  
 	 	 	 	 	 	 	 	                                                                                         o b j . l o c a t o r . l o c a t i o n s . i d s . p u s h ( e l e m . I D ) ;  
 	 	 	 	 	 	 	 	                                                                                         o b j . l o c a t o r . l o c a t i o n s . m a r k e r s [ e l e m . I D ]   =   o b j . l o c a t o r . w i d g e t s . m a r k e r ( e l e m ) ;  
 	 	 	 	 	 	 	 	                                                                                 }  
 	 	 	 	 	 	 	 	                                                                                 e l s e   {  
 	 	 	 	 	 	 	 	                                                                                         o b j . l o c a t o r . l o c a t i o n s . i t e m s [ e l e m . I D ]   =   e l e m ;  
 	 	 	 	 	 	 	 	                                                                                 }  
 	 	 	 	 	 	 	 	                                                                                 i f   ( o b j . l o c a t o r . l o c a t i o n s . i t e m s [ e l e m . I D ] . b r a n d   = =   ' V I O C ' )   {  
 	 	 	 	 	 	 	 	                                                                                         o b j . l o c a t o r . l o c a t i o n s . i t e m s [ e l e m . I D ] . d i s t a n c e   =   p a r s e F l o a t ( o b j . l o c a t o r . l o c a t i o n s . i t e m s [ e l e m . I D ] . d i s t a n c e )   -   5 ;  
 	 	 	 	 	 	 	 	                                                                                 }  
 	 	 	 	 	 	 	 	                                                                         } ) ;  
 	 	 	 	 	 	 	 	                                                                 }  
 	 	 	 	 	 	 	 	                                                                 e l s e   i f   ( t y p e o f   L o c a t i o n s   = =   ' o b j e c t '   & &   L o c a t i o n s . I D   ! = =   u n d e f i n e d )   {  
 	 	 	 	 	 	 	 	                                                                         v a r   e l e m   =   L o c a t i o n s ;  
 	 	 	 	 	 	 	 	                                                                         i f   ( ( $ . i n A r r a y ( e l e m . I D ,   o b j . l o c a t o r . l o c a t i o n s . i d s ) )   <   0 )   {  
 	 	 	 	 	 	 	 	                                                                                 o b j . l o c a t o r . l o c a t i o n s . i t e m s [ e l e m . I D ]   =   e l e m ;  
 	 	 	 	 	 	 	 	                                                                                 o b j . l o c a t o r . l o c a t i o n s . i d s . p u s h ( e l e m . I D ) ;  
 	 	 	 	 	 	 	 	                                                                                 o b j . l o c a t o r . l o c a t i o n s . m a r k e r s [ e l e m . I D ]   =   o b j . l o c a t o r . w i d g e t s . m a r k e r ( e l e m ) ;  
 	 	 	 	 	 	 	 	                                                                         }  
 	 	 	 	 	 	 	 	                                                                         e l s e   {  
 	 	 	 	 	 	 	 	                                                                                 o b j . l o c a t o r . l o c a t i o n s . i t e m s [ e l e m . I D ]   =   e l e m ;  
 	 	 	 	 	 	 	 	                                                                         }  
 	 	 	 	 	 	 	 	                                                                         i f   ( o b j . l o c a t o r . l o c a t i o n s . i t e m s [ e l e m . I D ] . b r a n d   = =   ' V I O C ' )   {  
 	 	 	 	 	 	 	 	                                                                                 o b j . l o c a t o r . l o c a t i o n s . i t e m s [ e l e m . I D ] . d i s t a n c e   =   p a r s e F l o a t ( o b j . l o c a t o r . l o c a t i o n s . i t e m s [ e l e m . I D ] . d i s t a n c e )   -   5 ;  
 	 	 	 	 	 	 	 	                                                                         }  
 	 	 	 	 	 	 	 	                                                                 }  
 	 	 	 	 	 	 	 	                                                                 e l s e   i f   ( t y p e o f   L o c a t i o n s   = =   ' o b j e c t '   & &   t y p e o f   L o c a t i o n s . L o c a t i o n   = =   ' o b j e c t ' )   {  
 	 	 	 	 	 	 	 	                                                                         v a r   e l e m   =   L o c a t i o n s . L o c a t i o n ;  
 	 	 	 	 	 	 	 	                                                                         i f   ( ( $ . i n A r r a y ( e l e m . I D ,   o b j . l o c a t o r . l o c a t i o n s . i d s ) )   <   0 )   {  
 	 	 	 	 	 	 	 	                                                                                 o b j . l o c a t o r . l o c a t i o n s . i t e m s [ e l e m . I D ]   =   e l e m ;  
 	 	 	 	 	 	 	 	                                                                                 o b j . l o c a t o r . l o c a t i o n s . i d s . p u s h ( e l e m . I D ) ;  
 	 	 	 	 	 	 	 	                                                                                 o b j . l o c a t o r . l o c a t i o n s . m a r k e r s [ e l e m . I D ]   =   o b j . l o c a t o r . w i d g e t s . m a r k e r ( e l e m ) ;  
 	 	 	 	 	 	 	 	                                                                         }  
 	 	 	 	 	 	 	 	                                                                         e l s e   {  
 	 	 	 	 	 	 	 	                                                                                 o b j . l o c a t o r . l o c a t i o n s . i t e m s [ e l e m . I D ]   =   e l e m ;  
 	 	 	 	 	 	 	 	                                                                         }  
 	 	 	 	 	 	 	 	                                                                         i f   ( o b j . l o c a t o r . l o c a t i o n s . i t e m s [ e l e m . I D ] . b r a n d   = =   ' V I O C ' )   {  
 	 	 	 	 	 	 	 	                                                                                 o b j . l o c a t o r . l o c a t i o n s . i t e m s [ e l e m . I D ] . d i s t a n c e   =   p a r s e F l o a t ( o b j . l o c a t o r . l o c a t i o n s . i t e m s [ e l e m . I D ] . d i s t a n c e )   -   5 ;  
 	 	 	 	 	 	 	 	                                                                         }  
 	 	 	 	 	 	 	 	                                                                 }  
 	 	 	 	 	 	 	 	                                                                 e l s e   {  
 	 	 	 	 	 	 	 	                                                                         o b j . l o c a t o r . e r r o r ( ' T h e r e   w e r e   n o   l o c a t i o n s   f o u n d   i n   t h i s   a r e a . ' ) ;  
 	 	 	 	 	 	 	 	                                                                 }  
 	 	 	 	 	 	 	 	                                                                 i f   ( o b j . l o c a t o r . z o o m   <   1 1 )   {  
 	 	 	 	 	 	 	 	                                                                         / / o b j . c o n s o l e ( ' T o o   f a r   o u t . ' ) ;  
 	 	 	 	 	 	 	 	                                                                         i f   ( o b j . s e t t i n g s . l o c a t o r V i e w   = =   ' b o t h '   | |   ( o b j . s e t t i n g s . l o c a t o r V i e w   = =   ' t o g g l e '   & &   o b j . l o c a t o r . h t m l . h a s C l a s s ( ' t o g g l e _ m a p ' ) ) )   {  
 	 	 	 	 	 	 	 	                                                                                 o b j . l o c a t o r . e r r o r ( ' Y o u   m u s t   b e   z o o m e d   i n   f u r t h e r   t o   d o   a   s e a r c h . ' ) ;  
 	 	 	 	 	 	 	 	                                                                         }  
 	 	 	 	 	 	 	 	                                                                 }  
 	 	 	 	 	 	 	 	                                                                 e l s e   {  
 	 	 	 	 	 	 	 	                                                                         o b j . l o c a t o r . u p d a t e ( ) ;  
 	 	 	 	 	 	 	 	                                                                 }  
 	 	 	 	 	 	 	 	                                                         }  
 	 	 	 	 	 	 	 	                                                 }  
 	 	 	 	 	 	 	 	                                                 v a r   m y U R L   =   o b j . s e t t i n g s . w e b s e r v i c e   +   ' ? '   +   $ . p a r a m ( t h i s O p t i o n s ) ;  
  
 	 	 	 	 	 	 	 	                                                 f u n c t i o n   f i l t e r D a t a ( d a t a )   {  
 	 	 	 	 	 	 	 	                                                         / /   f i l t e r   a l l   t h e   n a s t i e s   o u t  
 	 	 	 	 	 	 	 	                                                         / /   n o   b o d y   t a g s  
 	 	 	 	 	 	 	 	                                                         d a t a   =   d a t a . r e p l a c e ( " < b o d y > " ,   ' ' ) ;  
 	 	 	 	 	 	 	 	                                                         d a t a   =   d a t a . r e p l a c e ( " < / b o d y > " ,   ' ' ) ;  
 	 	 	 	 	 	 	 	                                                         d a t a   =   d a t a . r e p l a c e ( " < p > " ,   ' ' ) ;  
 	 	 	 	 	 	 	 	                                                         d a t a   =   d a t a . r e p l a c e ( " < / p > " ,   ' ' ) ;  
 	 	 	 	 	 	 	 	                                                         / /   n o   l i n e b r e a k s  
 	 	 	 	 	 	 	 	                                                         d a t a   =   d a t a . r e p l a c e ( / [ \ r | \ n ] + / g ,   ' ' ) ;  
 	 	 	 	 	 	 	 	                                                         / /   n o   c o m m e n t s  
 	 	 	 	 	 	 	 	                                                         d a t a   =   d a t a . r e p l a c e ( / < - - [ \ S \ s ] * ? - - > / g ,   ' ' ) ;  
 	 	 	 	 	 	 	 	                                                         / /   n o   n o s c r i p t   b l o c k s  
 	 	 	 	 	 	 	 	                                                         d a t a   =   d a t a . r e p l a c e ( / < n o s c r i p t [ ^ > ] * > [ \ S \ s ] * ? < \ / n o s c r i p t > / g ,   ' ' ) ;  
 	 	 	 	 	 	 	 	                                                         / /   n o   s c r i p t   b l o c k s  
 	 	 	 	 	 	 	 	                                                         d a t a   =   d a t a . r e p l a c e ( / < s c r i p t [ ^ > ] * > [ \ S \ s ] * ? < \ / s c r i p t > / g ,   ' ' ) ;  
 	 	 	 	 	 	 	 	                                                         / /   n o   s e l f   c l o s i n g   s c r i p t s  
 	 	 	 	 	 	 	 	                                                         d a t a   =   d a t a . r e p l a c e ( / < s c r i p t . * \ / > / ,   ' ' ) ;  
 	 	 	 	 	 	 	 	                                                         / /   [ . . .   a d d   a s   n e e d e d   . . . ]  
 	 	 	 	 	 	 	 	                                                         r e t u r n   $ . t r i m ( d a t a ) ;  
 	 	 	 	 	 	 	 	                                                 }  
  
 	 	 	 	 	 	 	 	                                                 / / C o d e   f o r   u s i n g   t h e   Y Q L   s e r v i c e :  
 	 	 	 	 	 	 	 	                                                 / *  
 	 	 	 	 	 	 	 	                                                 v a r   s e n d U R L   =   " h t t p : / / q u e r y . y a h o o a p i s . c o m / v 1 / p u b l i c / y q l ? "   +   " q = s e l e c t % 2 0 * % 2 0 f r o m % 2 0 h t m l % 2 0 w h e r e % 2 0 u r l % 3 D % 2 2 "   +   e n c o d e U R I C o m p o n e n t ( m y U R L )   +   " % 2 2 & f o r m a t = x m l ' & c a l l b a c k = ? " ;  
 	 	 	 	 	 	 	 	                                                 c o n s o l e . l o g ( s e n d U R L ) ;  
 	 	 	 	 	 	 	 	                                                 $ . g e t J S O N ( s e n d U R L ,  
 	 	 	 	 	 	 	 	                                                 f u n c t i o n ( d a t a )   {  
 	 	 	 	 	 	 	 	                                                 i f   ( d a t a . r e s u l t s [ 0 ] )   {  
 	 	 	 	 	 	 	 	                                                 d a t a   =   $ . e v a l J S O N ( f i l t e r D a t a ( d a t a . r e s u l t s [ 0 ] ) ) ;  
 	 	 	 	 	 	 	 	                                                 d a t a   =   d a t a . r e p l a c e ( / & a m p ; / g ,   ' & ' ) ;  
 	 	 	 	 	 	 	 	                                                 d a t a   =   d a t a . r e p l a c e ( / & g t ; / g ,   ' > ' ) ;  
 	 	 	 	 	 	 	 	                                                 d a t a   =   d a t a . r e p l a c e ( / & l t ; / g ,   ' < ' ) ;  
 	 	 	 	 	 	 	 	                                                 d a t a   =   d a t a . r e p l a c e ( / & a m p ; n b s p ; / g ,   ' ' ) ;  
 	 	 	 	 	 	 	 	                                                 d a t a   =   d a t a . r e p l a c e ( / & n b s p ; / g ,   '   ' ) ;  
 	 	 	 	 	 	 	 	                                                 d a t a   =   $ . p a r s e J S O N ( d a t a ) ;  
 	 	 	 	 	 	 	 	                                                 d o S o m e t h i n g ( d a t a ) ;  
 	 	 	 	 	 	 	 	                                                 }  
 	 	 	 	 	 	 	 	                                                 }  
 	 	 	 	 	 	 	 	                                                 ) ;  
 	 	 	 	 	 	 	 	                                                 * /  
 	 	 	 	 	 	 	 	                                                  
 	 	 	 	 	 	 	 	                                                 / / n o n   Y Q L   s e r v i c e   c o d e   ( n o t e :   d o e s   n o t   w o r k   i n   I E 7 )  
 	 	 	 	 	 	 	 	                                                 $ . a j a x ( {  
 	 	 	 	 	 	 	 	                                                         u r l :   o b j . s e t t i n g s . w e b s e r v i c e ,  
 	 	 	 	 	 	 	 	                                                         t y p e :   " G E T " ,  
 	 	 	 	 	 	 	 	                                                         d a t a :   t h i s O p t i o n s ,  
 	 	 	 	 	 	 	 	                                                         c a c h e :   f a l s e ,  
 	 	 	 	 	 	 	 	                                                         s u c c e s s :   f u n c t i o n ( r e s p o n s e )   {  
 	 	 	 	 	 	 	 	                                                                 l o a d M y X M L ( r e s p o n s e ) ;  
 	 	 	 	 	 	 	 	                                                         } ,  
 	 	 	 	 	 	 	 	                                                         e r r o r :   f u n c t i o n ( m s g )   {  
 	 	 	 	 	 	 	 	                                                                 a l e r t ( " W e ' r e   s o r r y .   W e   a r e   h a v i n g   s o m e   d i f f i c u l t y   a c c e s s i n g   o u r   d a t a . " ) ;  
 	 	 	 	 	 	 	 	                                                         }  
 	 	 	 	 	 	 	 	                                                 } ) ;  
 	 	 	 	 	 	 	 	                                                 f u n c t i o n   l o a d M y X M L ( m y O b j )   {  
 	 	 	 	 	 	 	 	                                                         i f   ( $ ( m y O b j ) . f i n d ( ' s t r i n g ' ) . l e n g t h   >   0 )   {  
 	 	 	 	 	 	 	 	                                                                 d a t a   =   $ . e v a l J S O N ( f i l t e r D a t a ( $ ( m y O b j ) . f i n d ( ' s t r i n g ' ) . t e x t ( ) ) ) ;  
 	 	 	 	 	 	 	 	                                                                 d a t a   =   d a t a . r e p l a c e ( / & a m p ; / g ,   ' & ' ) ;  
 	 	 	 	 	 	 	 	                                                                 d a t a   =   d a t a . r e p l a c e ( / & g t ; / g ,   ' > ' ) ;  
 	 	 	 	 	 	 	 	                                                                 d a t a   =   d a t a . r e p l a c e ( / & l t ; / g ,   ' < ' ) ;  
 	 	 	 	 	 	 	 	                                                                 d a t a   =   d a t a . r e p l a c e ( / & a m p ; n b s p ; / g ,   ' ' ) ;  
 	 	 	 	 	 	 	 	                                                                 d a t a   =   d a t a . r e p l a c e ( / & n b s p ; / g ,   '   ' ) ;  
 	 	 	 	 	 	 	 	                                                                 d a t a   =   $ . p a r s e J S O N ( d a t a ) ;  
 	 	 	 	 	 	 	 	                                                                 d o S o m e t h i n g ( d a t a ) ;  
 	 	 	 	 	 	 	 	                                                         }  
 	 	 	 	 	 	 	 	                                                 }  
  
  
 	 	 	 	 	 	 	 	                                                 $ . c o o k i e ( ' l a s t Z o o m ' ,   o b j . l o c a t o r . z o o m ,   {   e x p i r e s :   1 4   } ) ;  
  
 	 	 	 	 	 	 	 	                                                 i f   ( t y p e o f   o b j . l o c a t o r . m a p   ! = =   ' u n d e f i n e d ' )   {  
 	 	 	 	 	 	 	 	                                                         i f   ( o b j . l o c a t o r . c e n t e r   ! =   o b j . l o c a t o r . m a p . g e t C e n t e r ( ) )   {  
 	 	 	 	 	 	 	 	                                                                 i f   ( c e n t e r M a p )   {  
 	 	 	 	 	 	 	 	                                                                         o b j . l o c a t o r . m a p . p a n T o ( o b j . l o c a t o r . c e n t e r ) ;  
 	 	 	 	 	 	 	 	                                                                 }  
 	 	 	 	 	 	 	 	                                                                 i f   ( c h a n g e Z o o m )   {  
 	 	 	 	 	 	 	 	                                                                         o b j . l o c a t o r . m a p . s e t Z o o m ( o b j . l o c a t o r . z o o m ) ;  
 	 	 	 	 	 	 	 	                                                                         $ . c o o k i e ( ' l a s t Z o o m ' ,   o b j . l o c a t o r . z o o m ,   {   e x p i r e s :   1 4   } ) ;  
 	 	 	 	 	 	 	 	                                                                         o b j . l o c a t o r . r e z o o m   =   t r u e ;  
 	 	 	 	 	 	 	 	                                                                 }  
 	 	 	 	 	 	 	 	                                                         }  
 	 	 	 	 	 	 	 	                                                 }  
 	 	 	 	 	 	 	 	                                         }  
 	 	 	 	 	 	 	 	                                         e l s e   {  
 	 	 	 	 	 	 	 	                                                 o b j . l o c a t o r . e r r o r ( ' C o u l d   n o t   f i n d   t h a t   l o c a t i o n . ' ) ;  
 	 	 	 	 	 	 	 	                                         }  
 	 	 	 	 	 	 	 	                                         b r e a k ;  
  
 	 	 	 	 	 	 	 	                                 c a s e   ' Z E R O _ R E S U L T S ' :  
 	 	 	 	 	 	 	 	                                         o b j . l o c a t o r . e r r o r ( ' C o u l d   n o t   f i n d   t h a t   l o c a t i o n . ' ) ;  
 	 	 	 	 	 	 	 	                                         b r e a k ;  
 	 	 	 	 	 	 	 	                         }  
 	 	 	 	 	 	 	 	                         o b j . l o c a t o r . u p d a t e ( ) ;  
 	 	 	 	 	 	 	 	                 }  
 	 	 	 	 	 	 	 	         	 ) ;  
                                         }  
                                 }  
                         } ,  
  
                         / * *    
                         *   P u b i c   F u n c t i o n :   l o c a t o r . u p d a t e    
                         *   T h e   p a r a m e t e r   p a s s e d   i s   a n   o b j e c t   t h a t   m e r g e s / o v e r w r i t e s   t h e   c u r r e n t   s e t t i n g s .  
                         * * /  
                         u p d a t e :   f u n c t i o n ( )   {  
                                 / / o b j . c o n s o l e ( ' F u n c t i o n :   u p d a t e ( ) ' ) ;  
                                 o b j . l o c a t o r . g e o c o d e r   =   n e w   g o o g l e . m a p s . G e o c o d e r ( ) ;  
                                 v a r   t h i s L o c a t i o n s   =   [ ] ;  
                                 $ . e a c h ( ( o b j . l o c a t o r . l o c a t i o n s . i d s ) ,   f u n c t i o n ( i n d e x ,   v a l u e )   {  
                                         i f   ( o b j . l o c a t o r . l o c a t i o n s . i t e m s [ v a l u e ] . d i s t a n c e   < =   o b j . s e t t i n g s . r a d i u s )   {  
                                                 i f   ( o b j . s e t t i n g s . f i l t e r N e x t g e n   & &   o b j . s e t t i n g s . f i l t e r N e x t g e n . c h e c k )   {  
                                                         i f   ( o b j . l o c a t o r . l o c a t i o n s . i t e m s [ v a l u e ] . S p e c i a l S e r v i c e s . F e a t u r e s N e x t G e n . t o L o w e r C a s e ( )   = =   ' y ' )   {  
                                                                 t h i s L o c a t i o n s . p u s h ( o b j . l o c a t o r . l o c a t i o n s . i t e m s [ v a l u e ] ) ;  
                                                         }  
                                                 }  
                                                 e l s e   {  
                                                         i f   ( $ . i n A r r a y ( o b j . l o c a t o r . l o c a t i o n s . i t e m s [ v a l u e ] . b r a n d ,   o b j . l o c a t o r . f i l t e r s ( ) )   > =   0 )   {  
                                                                 t h i s L o c a t i o n s . p u s h ( o b j . l o c a t o r . l o c a t i o n s . i t e m s [ v a l u e ] ) ;  
                                                         }  
                                                 }  
                                         }  
                                 } ) ;  
                                 i f   ( t h i s L o c a t i o n s . l e n g t h   >   0 )   {  
                                         t h i s L o c a t i o n s . s o r t ( f u n c t i o n ( a ,   b )   {  
                                                 r e t u r n   ( ( p a r s e F l o a t ( a . d i s t a n c e )   <   p a r s e F l o a t ( b . d i s t a n c e ) )   ?   - 1   :   ( ( p a r s e F l o a t ( a . d i s t a n c e )   >   p a r s e F l o a t ( b . d i s t a n c e ) )   ?   1   :   0 ) ) ;  
                                         } ) ;  
                                         $ . e a c h ( o b j . l o c a t o r . p r o m o t i o n s . i t e m s ,   f u n c t i o n ( i n d e x ,   v a l )   {  
                                                 v a r   s h o w   =   f a l s e ;  
                                                 $ . e a c h ( t h i s L o c a t i o n s ,   f u n c t i o n ( i n d ,   i n f o )   {  
                                                         i f   ( v a l . c o n d i t i o n   ! =   n u l l   & &   v a l . c o n d i t i o n ( i n f o ) )   {  
                                                                 s h o w   =   t r u e ;  
                                                         }  
                                                 } ) ;  
                                                 i f   ( s h o w )   {  
                                                         o b j . l o c a t o r . p r o m o t e ( v a l . c o n t e n t ,   v a l . n a m e ) ;  
                                                 }  
                                         } ) ;  
                                 }  
  
                                 i f   ( o b j . s e t t i n g s . s h o w R e s u l t s )   {  
                                         v a r   n e w H T M L   =   $ ( ' < d i v   c l a s s = " w r a p p e d " / > ' ) ;  
                                         o b j . h t m l . f i n d ( ' # r e s u l t s   . w r a p p e d ,   # r e s u l t s   . d e f a u l t ' ) . r e m o v e ( ) ;  
                                         o b j . h t m l . f i n d ( ' # r e s u l t s ' ) . a p p e n d ( $ ( ' < d i v   c l a s s = " d e f a u l t " / > ' ) ) ;  
  
                                         i f   ( t h i s L o c a t i o n s . l e n g t h   >   0 )   {  
                                                 $ . e a c h ( t h i s L o c a t i o n s ,   f u n c t i o n ( i n d e x ,   v a l u e )   {  
                                                         i f   ( i n d e x   <   o b j . s e t t i n g s . s h o w R e s u l t s M a x )   {  
                                                                 v a r   t h i s R e s u l t   =   o b j . l o c a t o r . w i d g e t s . r e s u l t ( v a l u e ) ;  
                                                                 t h i s R e s u l t . f i n d ( ' . m a p S h o w ' ) . c l i c k ( f u n c t i o n ( E )   {  
                                                                         E . p r e v e n t D e f a u l t ( ) ;  
                                                                         i f   ( o b j . s e t t i n g s . l o c a t o r V i e w   = =   ' b o t h '   | |   o b j . s e t t i n g s . l o c a t o r V i e w   = =   ' t o g g l e ' )   {  
                                                                                 o b j . l o c a t o r . w i d g e t s . t o g g l e ( ' m a p ' ) ;  
                                                                                 i f   ( o b j . s e t t i n g s . s h o w M a r k e r s )   {  
                                                                                         v a r   m y L i n k   =   $ ( t h i s ) ;  
                                                                                         g o o g l e . m a p s . e v e n t . t r i g g e r ( o b j . l o c a t o r . l o c a t i o n s . m a r k e r s [ m y L i n k . a t t r ( ' i d ' ) . s u b s t r ( 4 ) ] ,   ' c l i c k ' ) ;  
                                                                                 }  
                                                                         }  
                                                                 } ) ;  
                                                                 t h i s R e s u l t . a p p e n d T o ( n e w H T M L ) ;  
                                                         }  
                                                 } ) ;  
                                                 $ ( ' < d i v   c l a s s = " w r a p p e d B o t t o m " > < / d i v > ' ) . a p p e n d T o ( n e w H T M L ) ;  
                                                 i f   ( o b j . h t m l . f i n d ( ' # r e s u l t s   . w r a p p e d ' ) . l e n g t h   = =   1 )   {  
                                                         i f   ( ( $ . t r i m ( n e w H T M L . h t m l ( ) )   ! = =   $ . t r i m ( o b j . h t m l . f i n d ( ' # r e s u l t s   . w r a p p e d ' ) . h t m l ( ) ) ) )   {  
                                                                 o b j . h t m l . f i n d ( ' # r e s u l t s   . w r a p p e d ,   # r e s u l t s   . d e f a u l t ' ) . r e m o v e ( ) ;  
                                                                 o b j . h t m l . f i n d ( ' # r e s u l t s ' ) . a p p e n d ( n e w H T M L ) ;  
                                                         }  
                                                 }  
                                                 e l s e   {  
                                                         o b j . h t m l . f i n d ( ' # r e s u l t s   . w r a p p e d ,   # r e s u l t s   . d e f a u l t ' ) . r e m o v e ( ) ;  
                                                         o b j . h t m l . f i n d ( ' # r e s u l t s ' ) . a p p e n d ( n e w H T M L ) ;  
                                                 }  
                                                 / / o b j . c o n s o l e ( ' l a t : ' + o b j . l o c a t o r . c e n t e r . l a t ( ) . t o F i x e d ( 5 ) + ' ,   l n g : ' + o b j . l o c a t o r . c e n t e r . l n g ( ) . t o F i x e d ( 5 ) ) ;  
                                                 / / o b j . c o n s o l e ( ' l a t : ' + o b j . l o c a t o r . m a p . g e t C e n t e r ( ) . l a t ( ) . t o F i x e d ( 5 ) + ' ,   l n g : ' + o b j . l o c a t o r . m a p . g e t C e n t e r ( ) . l n g ( ) . t o F i x e d ( 5 ) ) ;  
                                         }  
                                         e l s e   {  
                                                 n e w H T M L   =   $ ( ' < d i v   c l a s s = " d e f a u l t " / > ' ) ;  
                                                 o b j . h t m l . f i n d ( ' # r e s u l t s   . w r a p p e d ,   # r e s u l t s   . d e f a u l t ' ) . r e m o v e ( ) ;  
                                                 o b j . h t m l . f i n d ( ' # r e s u l t s ' ) . a p p e n d ( n e w H T M L ) ;  
                                         }  
                                         i f   ( ! $ . b r o w s e r . m s i e   & &   o b j . s e t t i n g s . m o b i l e )   {  
                                                 / / $ ( d o c u m e n t ) . b i n d ( ' t o u c h m o v e ' ,   f u n c t i o n ( e )   {   e . p r e v e n t D e f a u l t ( ) ;   } ) ;  
                                                 / / s e t T i m e o u t ( " n e w   i S c r o l l ( ' r e s u l t s ' ) " ,   1 0 0 ) ;  
                                         }  
                                 }  
                                 i f   ( o b j . s e t t i n g s . s h o w M a p )   {  
                                         i f   ( o b j . b r o w s e r O k )   {  
                                                 i f   ( t y p e o f   o b j . l o c a t o r . m a p   = = =   ' u n d e f i n e d ' )   {  
                                                         o b j . l o c a t o r . d o u b l e S e a r c h   =   f a l s e ;  
                                                         v a r   m a p B o u n d s   =   n e w   g o o g l e . m a p s . L a t L n g B o u n d s ( n e w   g o o g l e . m a p s . L a t L n g ( 2 5 ,   - 1 2 8 ) ,   n e w   g o o g l e . m a p s . L a t L n g ( 4 8 ,   - 6 1 ) ) ;  
                                                         o b j . l o c a t o r . c e n t e r   =   m a p B o u n d s . g e t C e n t e r ( ) ;  
                                                         v a r   m y O p t i o n s   =   {  
                                                                 c e n t e r :   o b j . l o c a t o r . c e n t e r ,  
                                                                 z o o m :   o b j . l o c a t o r . z o o m ,  
                                                                 m a p T y p e I d :   g o o g l e . m a p s . M a p T y p e I d . R O A D M A P ,  
                                                                 z o o m C o n t r o l O p t i o n s :   {  
                                                                         p o s i t i o n :   g o o g l e . m a p s . C o n t r o l P o s i t i o n . L E F T _ B O T T O M  
                                                                 }  
                                                         } ;  
                                                         $ . e x t e n d ( m y O p t i o n s ,   o b j . s e t t i n g s . m a p C o n t r o l s ) ;  
                                                         o b j . l o c a t o r . m a p   =   n e w   g o o g l e . m a p s . M a p ( d o c u m e n t . g e t E l e m e n t B y I d ( ' m a p _ d i s p l a y ' ) ,   m y O p t i o n s ) ;  
                                                         o b j . l o c a t o r . m a p . f i t B o u n d s ( m a p B o u n d s ) ;  
                                                         o b j . l o c a t o r . i n f o W i n d o w   =   n e w   g o o g l e . m a p s . I n f o W i n d o w ( {   m a x W i d t h :   3 0 0   } ) ;  
  
                                                         i f   ( $ . q u e r y . g e t ( ' a ' ) . t o S t r i n g ( )   ! =   ' '   & &   $ . q u e r y . g e t ( ' a ' ) . t o S t r i n g ( )   ! =   ' t r u e ' )   {  
                                                                 / / o b j . c o n s o l e ( ' Q u e r y ' ) ;  
                                                                 o b j . h t m l . f i n d ( ' # s e a r c h   . f i e l d ' ) . v a l ( $ . q u e r y . g e t ( ' a ' ) . t o S t r i n g ( ) ) ;  
                                                                 o b j . l o c a t o r . d o u b l e S e a r c h   =   t r u e ;  
                                                                 o b j . l o c a t o r . f i n d ( $ . q u e r y . g e t ( ' a ' ) . t o S t r i n g ( ) ,   t r u e ) ;  
                                                         }  
                                                         e l s e   i f   ( t y p e o f   o b j . s e t t i n g s . d e f a u l t S e a r c h   ! = =   ' u n d e f i n e d ' )   {  
                                                                 / / o b j . c o n s o l e ( ' D e f a u l t ' ) ;  
                                                                 o b j . l o c a t o r . d o u b l e S e a r c h   =   t r u e ;  
                                                                 o b j . l o c a t o r . f i n d ( o b j . s e t t i n g s . d e f a u l t S e a r c h ,   t r u e ) ;  
                                                         }  
                                                         e l s e   i f   ( $ . c o o k i e ( ' l a s t A d d r e s s ' )   ! =   n u l l )   {  
                                                                 / / o b j . c o n s o l e ( ' C o o k i e ' ) ;  
                                                                 o b j . l o c a t o r . z o o m   =   p a r s e I n t ( $ . c o o k i e ( ' l a s t Z o o m ' ) ) ;  
                                                                 o b j . l o c a t o r . d o u b l e S e a r c h   =   t r u e ;  
                                                                 o b j . l o c a t o r . f i n d ( $ . c o o k i e ( ' l a s t A d d r e s s ' ) ,   $ . c o o k i e ( ' l a s t Z o o m ' ) ) ;  
                                                         }  
                                                         e l s e   {  
                                                                 / / o b j . c o n s o l e ( ' G P S ' ) ;  
                                                                 i f   ( g e o _ p o s i t i o n _ j s . i n i t ( )   & &   o b j . s e t t i n g s . j a v a s c r i p t G P S )   {  
                                                                         f u n c t i o n   s u c c e s s _ c a l l b a c k ( p )   {  
                                                                                 i f   ( $ . c o o k i e ( ' l a s t Z o o m ' )   ! =   n u l l )   {  
                                                                                         o b j . l o c a t o r . z o o m   =   $ . c o o k i e ( ' l a s t Z o o m ' ) ;  
                                                                                 }  
                                                                                 o b j . l o c a t o r . d o u b l e S e a r c h   =   t r u e ;  
                                                                                 i f   ( $ . c o o k i e ( ' l a s t A d d r e s s ' )   ! =   n u l l )   {  
                                                                                         o b j . l o c a t o r . f i n d ( $ . c o o k i e ( ' l a s t A d d r e s s ' ) ,   o b j . l o c a t o r . z o o m ) ;  
                                                                                 }  
                                                                                 e l s e   {  
                                                                                         o b j . l o c a t o r . f i n d ( p . c o o r d s . l a t i t u d e . t o F i x e d ( 2 )   +   ' , '   +   p . c o o r d s . l o n g i t u d e . t o F i x e d ( 2 ) ,   t r u e ) ;  
                                                                                 }  
                                                                         }  
                                                                         f u n c t i o n   e r r o r _ c a l l b a c k ( p )   {   }  
                                                                         g e o _ p o s i t i o n _ j s . g e t C u r r e n t P o s i t i o n ( s u c c e s s _ c a l l b a c k ,   e r r o r _ c a l l b a c k ,   {   e n a b l e H i g h A c c u r a c y :   t r u e ,   o p t i o n s :   5 0 0 0   } ) ;  
                                                                 }  
                                                         }  
  
                                                         g o o g l e . m a p s . e v e n t . a d d L i s t e n e r ( o b j . l o c a t o r . m a p ,   ' i d l e ' ,   f u n c t i o n ( )   {  
                                                                 o b j . l o c a t o r . c e n t e r   =   o b j . l o c a t o r . m a p . g e t C e n t e r ( ) ;  
                                                                 o b j . l o c a t o r . z o o m   =   o b j . l o c a t o r . m a p . g e t Z o o m ( ) ;  
                                                                 $ . c o o k i e ( ' l a s t Z o o m ' ,   o b j . l o c a t o r . z o o m ,   {   e x p i r e s :   1 4   } ) ;  
                                                                 i f   ( ! o b j . l o c a t o r . d o u b l e S e a r c h )   {  
                                                                         o b j . l o c a t o r . f i n d ( ) ;  
                                                                 }  
                                                                 e l s e   {  
                                                                         s e t T i m e o u t ( f u n c t i o n ( )   {  
                                                                                 o b j . l o c a t o r . f i n d ( ) ;  
                                                                         } ,   1 5 0 0 ) ;  
                                                                         o b j . l o c a t o r . d o u b l e S e a r c h   =   f a l s e ;  
                                                                 }  
                                                         } ) ;  
                                                         g o o g l e . m a p s . e v e n t . a d d L i s t e n e r ( o b j . l o c a t o r . m a p ,   ' d r a g e n d ' ,   f u n c t i o n ( )   {  
                                                                 o b j . t r a c k E v e n t ( ' m a p _ c h a n g e ' ,   ' d r a g ' ) ;  
                                                                 o b j . l o c a t o r . r e z o o m   =   f a l s e ;  
                                                         } ) ;  
                                                         g o o g l e . m a p s . e v e n t . a d d L i s t e n e r ( o b j . l o c a t o r . m a p ,   ' z o o m _ c h a n g e d ' ,   f u n c t i o n ( )   {  
                                                                 o b j . l o c a t o r . c e n t e r   =   o b j . l o c a t o r . m a p . g e t C e n t e r ( ) ;  
                                                                 o b j . l o c a t o r . z o o m   =   o b j . l o c a t o r . m a p . g e t Z o o m ( ) ;  
                                                                 o b j . t r a c k E v e n t ( ' m a p _ c h a n g e ' ,   ' z o o m ' ,   o b j . l o c a t o r . m a p . g e t Z o o m ( ) ) ;  
                                                                 o b j . l o c a t o r . r e z o o m   =   f a l s e ;  
                                                         } ) ;  
                                                 }  
                                                 e l s e   {  
                                                         o b j . l o c a t o r . l o c a t i o n s . m a r k e r s . r e s e t ( ) ;  
                                                         / * i f   ( o b j . l o c a t o r . l o c a t i o n s . m a r k e r s . c u r r e n t ( ) . l e n g t h   = =   0   & &   o b j . l o c a t o r . r e z o o m )   {  
                                                         i f   ( o b j . l o c a t o r . z o o m   > =   1 1 )   {  
                                                         o b j . l o c a t o r . z o o m   =   o b j . l o c a t o r . z o o m   -   1 ;  
                                                         o b j . l o c a t o r . m a p . s e t Z o o m ( o b j . l o c a t o r . z o o m ) ;  
                                                         }  
                                                         } * /  
                                                 }  
                                         }  
                                         e l s e   {  
                                                 o b j . h t m l . f i n d ( ' # m a p ' ) . e m p t y ( ) ;  
                                                 o b j . h t m l . f i n d ( ' # m a p ' ) . a p p e n d ( o b j . s e t t i n g s . b a d B r o w s e r O b j ) ;  
                                         }  
                                 }  
  
                                 i f   ( ! o b j . l o c a t o r . i n i t i a l i z e d )   {  
                                         o b j . l o c a t o r . i n i t i a l i z e d   =   t r u e ;  
                                         s e t T i m e o u t ( f u n c t i o n ( )   {   o b j . l o c a t o r . r e s i z e ( ) ;   } ,   3 0 0 ) ;  
                                 }  
                         } ,  
  
                         p o p u p :   f u n c t i o n ( e l e m )   {  
  
                                 i f   ( o b j . h t m l . f i n d ( ' # p o p u p ' ) )   {  
                                         v a r   t h i s P o p u p   =   o b j . h t m l . f i n d ( ' # p o p u p ' ) ;  
                                 }  
                                 e l s e   {  
                                         v a r   t h i s P o p u p   =   $ ( ' < d i v   i d = " p o p u p " > < / d i v > ' ) ;  
                                         t h i s P o p u p . c s s ( {  
                                                 ' p o s i t i o n ' :   ' a b s o l u t e ' ,  
                                                 ' t o p ' :   0 ,   ' l e f t ' :   0  
                                         } ) ;  
                                 }  
                         } ,  
  
                         r e s i z e :   f u n c t i o n ( )   {  
                                 / / o b j . c o n s o l e ( ' F u n c t i o n :   r e s i z e ( ) ' ) ;  
                                 v a r   t o p R e s u l t s ,   t o p M a p ,   t o p T o g g l e ,   t o p F i l t e r s ;  
                                 t o p R e s u l t s   =   t o p M a p   =   t o p F i l t e r s   =   t o p T o g g l e   =   0 ;  
                                 i f   ( o b j . s e t t i n g s . s h o w S e a r c h )   {   t o p R e s u l t s   + =   o b j . e l e m . f i n d ( ' # s e a r c h ' ) . o u t e r H e i g h t ( ) ;   t o p M a p   =   t o p F i l t e r s   =   t o p T o g g l e   =   t o p R e s u l t s ;   }  
                                 i f   ( ( o b j . s e t t i n g s . s h o w M a p   & &   o b j . s e t t i n g s . s h o w R e s u l t s )   & &   o b j . s e t t i n g s . l o c a t o r V i e w   = =   ' t o g g l e ' )   {   t o p R e s u l t s   + =   o b j . e l e m . f i n d ( ' # t o g g l e ' ) . o u t e r H e i g h t ( ) ;   t o p F i l t e r s   =   t o p M a p   =   t o p R e s u l t s ;   }  
                                 i f   ( o b j . s e t t i n g s . s h o w F i l t e r s )   {   t o p R e s u l t s   + =   o b j . h t m l . f i n d ( ' # f i l t e r s   a ' ) . o u t e r H e i g h t ( )   +   1 0 ;   t o p M a p   =   t o p R e s u l t s ;   }  
                                 v a r   r e s i z e M a p   =   f a l s e ;  
                                 o b j . h t m l . f i n d ( ' # t o g g l e ' ) . c s s ( ' t o p ' ,   t o p T o g g l e ) ;  
                                 o b j . h t m l . f i n d ( ' # r e s u l t s ' ) . c s s ( ' t o p ' ,   t o p R e s u l t s ) ;  
                                 o b j . h t m l . f i n d ( ' # m a p ' ) . c s s ( ' t o p ' ,   t o p M a p ) ;  
                                 i f   ( ! o b j . h t m l . f i n d ( ' # f i l t e r s ' ) . h a s C l a s s ( ' h i d e ' )   & &   ! o b j . h t m l . f i n d ( ' # f i l t e r s ' ) . h a s C l a s s ( ' s h o w ' ) )   {  
                                         o b j . h t m l . f i n d ( ' # f i l t e r s ' ) . c s s ( ' t o p ' ,   ( t o p F i l t e r s   -   o b j . h t m l . f i n d ( ' # f i l t e r s ' ) . h e i g h t ( )   +   1 0   +   o b j . h t m l . f i n d ( ' # f i l t e r s   a ' ) . o u t e r H e i g h t ( ) ) ) ;  
                                         o b j . e l e m . f i n d ( ' # f i l t e r s ' ) . a d d C l a s s ( ' h i d e ' ) ;  
                                 }  
                                 i f   ( o b j . h t m l . f i n d ( ' # f o o t ' ) )   {  
                                         o b j . e l e m . f i n d ( ' # r e s u l t s ' ) . c s s ( ' b o t t o m ' ,   o b j . h t m l . f i n d ( ' # f o o t ' ) . o u t e r H e i g h t ( ) ) ;  
                                         o b j . e l e m . f i n d ( ' # m a p ' ) . c s s ( ' b o t t o m ' ,   o b j . h t m l . f i n d ( ' # f o o t ' ) . o u t e r H e i g h t ( ) ) ;  
                                 }  
                                 i f   ( t y p e o f   o b j . l o c a t o r . m a p   ! = =   ' u n d e f i n e d ' )   {  
                                         g o o g l e . m a p s . e v e n t . t r i g g e r ( o b j . l o c a t o r . m a p ,   ' r e s i z e ' ) ;  
                                 }  
                                 i f   ( o b j . s e t t i n g s . m o b i l e )   {  
                                         o b j . h t m l . f i n d ( ' # s e a r c h   . f i e l d ' ) . c s s ( ' w i d t h ' ,   p a r s e I n t ( o b j . h t m l . f i n d ( ' # s e a r c h   f o r m ' ) . i n n e r W i d t h ( ) )   -   2 0 ) ;  
                                         o b j . h t m l . f i n d ( ' # p r o m o t i o n s ,   # f o o t ' ) . a n i m a t e ( {   ' o p a c i t y ' :   1   } ,   {   d u r a t i o n :   1 0 0 ,   q u e u e :   f a l s e   } ) ;  
                                 }  
                                 i f   ( o b j . h t m l . f i n d ( ' # e r r o r s ' ) )   {  
                                         o b j . h t m l . f i n d ( ' # e r r o r s ' ) . c s s ( ' t o p ' ,   t o p M a p ) ;  
                                 }  
  
                                 v a r   t r i g g e r R e s i z e   =   t r u e ;  
                                 i f   ( a r g u m e n t s . l e n g t h   >   0 )   {  
                                         t r i g g e r R e s i z e   =   a r g u m e n t s [ 0 ] ;  
                                 }  
                                 i f   ( t r i g g e r R e s i z e )   {  
                                         $ ( w i n d o w ) . t r i g g e r ( ' r e s i z e ' ) ;  
                                 }  
                         } ,  
  
                         / * *    
                         *   P u b i c   O b j e c t :   l o c a t o r . w i d g e t s    
                         *   T h i s   i s   a n   o b j e c t   w h i c h   h o u s e s   a l l   t h e   l o c a t o r   s p e c i f i c   w i d g e t s .  
                         * * /  
                         w i d g e t s :   {  
                                 s e a r c h :   f u n c t i o n ( )   {  
                                         v a r   t h i s W i d g e t   =   $ ( ' < d i v   i d = " s e a r c h " > < / d i v > ' ) ;  
                                         v a r   t h i s I n s i d e   =   $ ( ' < d i v   c l a s s = " i n s i d e " > < / d i v > ' ) ;  
                                         v a r   t h i s F o r m   =   $ ( ' < f o r m > < / f o r m > ' ) ;  
                                         t h i s F o r m . s u b m i t ( f u n c t i o n ( E )   {  
                                                 E . p r e v e n t D e f a u l t ( ) ;  
                                                 o b j . t r a c k P a g e v i e w ( ' / S e a r c h / '   +   $ ( t h i s ) . f i n d ( ' i n p u t . f i e l d ' ) . v a l ( ) ) ;  
                                                 o b j . l o c a t o r . f i n d ( $ ( t h i s ) . f i n d ( ' i n p u t . f i e l d ' ) . v a l ( ) ,   t r u e ) ;  
                                         } ) ;  
                                         t h i s F o r m . a p p e n d ( ' < i n p u t   t y p e = " t e x t "   c l a s s = " f i e l d " / > ' ) ;  
                                         t h i s F o r m . a p p e n d ( ' < i n p u t   t y p e = " s u b m i t "   c l a s s = " s u b m i t "   v a l u e = " S e a r c h " / > ' ) ;  
                                         t h i s I n s i d e . a p p e n d ( t h i s F o r m ) ;  
                                         t h i s W i d g e t . a p p e n d ( t h i s I n s i d e ) ;  
  
                                         r e t u r n   t h i s W i d g e t ;  
                                 } ,  
                                 f i l t e r s :   f u n c t i o n ( )   {  
                                         i f   ( a r g u m e n t s . l e n g t h   >   0 )   {  
                                                 o b j . l o c a t o r . h t m l . f i n d ( ' # f i l t e r s   l a b e l ' ) . e a c h ( f u n c t i o n ( i n d e x ,   e l e m )   {  
                                                         v a r   m y C h e c k   =   $ ( e l e m ) . f i n d ( ' i n p u t ' ) ;  
                                                         v a r   m y N a m e   =   ' f i l t e r '   +   $ ( m y C h e c k ) . a t t r ( ' n a m e ' ) ;  
                                                         m y C h e c k [ 0 ] . c h e c k e d   =   o b j . s e t t i n g s [ m y N a m e ] . c h e c k ;  
                                                 } ) ;  
                                         }  
                                         e l s e   {  
                                                 v a r   t h i s W i d g e t   =   $ ( ' < d i v   i d = " f i l t e r s " > < / d i v > ' ) ;  
                                                 v a r   t h i s I n s i d e   =   $ ( ' < d i v   c l a s s = " i n s i d e " > < / d i v > ' ) ;  
                                                 t h i s W i d g e t . a p p e n d ( t h i s I n s i d e ) ;  
                                                 v a r   t h i s F i l t e r s   =   n e w   A r r a y ( ) ;  
  
                                                 i f   ( o b j . s e t t i n g s . f i l t e r V I O C . s h o w )   t h i s F i l t e r s . p u s h ( $ ( ' < l a b e l   c l a s s = " v i o c "   f o r = " c h e c k V I O C " > < i n p u t   t y p e = " c h e c k b o x "   i d = " c h e c k V I O C "   n a m e = " V I O C "   v a l u e = " 1 " > V a l v o l i n e   I n s t a n t   O i l   C h a n g e < / l a b e l > ' ) ) ;  
                                                 i f   ( o b j . s e t t i n g s . f i l t e r E C . s h o w )   t h i s F i l t e r s . p u s h ( $ ( ' < l a b e l   c l a s s = " e c "   f o r = " c h e c k E C " > < i n p u t   t y p e = " c h e c k b o x "   i d = " c h e c k E C "   n a m e = " E C "   v a l u e = " 1 " > E x p r e s s   C a r e < / l a b e l > ' ) ) ;  
                                                 i f   ( o b j . s e t t i n g s . f i l t e r O t h e r . s h o w )   t h i s F i l t e r s . p u s h ( $ ( ' < l a b e l   c l a s s = " o t h e r "   f o r = " c h e c k O t h e r " > < i n p u t   t y p e = " c h e c k b o x "   i d = " c h e c k O t h e r "   n a m e = " O t h e r "   v a l u e = " 1 " > O t h e r   S e r v i c e   P r o v i d e r < / l a b e l > ' ) ) ;  
                                                 i f   ( o b j . s e t t i n g s . f i l t e r R e t a i l . s h o w )   t h i s F i l t e r s . p u s h ( $ ( ' < l a b e l   c l a s s = " r e t a i l "   f o r = " c h e c k R e t a i l " > < i n p u t   t y p e = " c h e c k b o x "   i d = " c h e c k R e t a i l "   n a m e = " R e t a i l "   v a l u e = " 1 " > R e t a i l   O u t l e t < / l a b e l > ' ) ) ;  
  
                                                 $ ( t h i s F i l t e r s ) . e a c h ( f u n c t i o n ( )   {  
                                                         i f   ( o b j . s e t t i n g s [ ' f i l t e r '   +   $ ( t h i s ) . f i n d ( ' i n p u t ' ) . a t t r ( ' n a m e ' ) ] . c h e c k )   {  
                                                                 $ ( t h i s ) . f i n d ( ' i n p u t ' ) . a t t r ( ' c h e c k e d ' ,   ' c h e c k e d ' ) ;  
                                                         }  
                                                         $ ( t h i s ) . f i n d ( ' i n p u t ' ) . c h a n g e ( f u n c t i o n ( )   {  
                                                                 v a r   o n o f f   =   ' ' ;  
                                                                 i f   ( t h i s . c h e c k e d )   {  
                                                                         / / o b j . c o n s o l e ( ' C h e c k e d ' ) ;  
                                                                         o b j . s e t t i n g s [ ' f i l t e r '   +   $ ( t h i s ) . a t t r ( ' n a m e ' ) ] . c h e c k   =   t r u e ;  
                                                                         o n o f f   =   ' o n ' ;  
                                                                 }  
                                                                 e l s e   {  
                                                                         / / o b j . c o n s o l e ( ' U n c h e c k e d ' ) ;  
                                                                         o b j . s e t t i n g s [ ' f i l t e r '   +   $ ( t h i s ) . a t t r ( ' n a m e ' ) ] . c h e c k   =   f a l s e ;  
                                                                         o n o f f   =   ' o f f ' ;  
                                                                 }  
                                                                 o b j . t r a c k E v e n t ( ' f i l t e r _ c h a n g e ' ,   $ ( t h i s ) . a t t r ( ' n a m e ' ) ,   o n o f f ) ;  
                                                                 o b j . l o c a t o r . f i n d ( ) ;  
                                                         } ) ;  
                                                         $ ( t h i s ) . c l i c k ( f u n c t i o n ( )   {  
                                                                 o b j . l o c a t o r . f i n d ( ) ;  
                                                         } ) ;  
                                                         t h i s I n s i d e . a p p e n d ( t h i s ) ;  
                                                 } ) ;  
                                                 v a r   t h i s T o g g l e   =   $ ( ' < a   h r e f = " # " > S e l e c t   P r o d u c t / S e r v i c e   O p t i o n s < / a > ' ) ;  
                                                 t h i s T o g g l e . c l i c k ( f u n c t i o n ( E )   {  
                                                         E . p r e v e n t D e f a u l t ( ) ;  
                                                         v a r   m y T o p   =   0 ;  
                                                         i f   ( o b j . s e t t i n g s . s h o w S e a r c h )   {   m y T o p   + =   o b j . e l e m . f i n d ( ' # s e a r c h ' ) . o u t e r H e i g h t ( ) ;   }  
                                                         i f   ( ( o b j . s e t t i n g s . s h o w M a p   & &   o b j . s e t t i n g s . s h o w R e s u l t s )   & &   o b j . s e t t i n g s . l o c a t o r V i e w   = =   ' t o g g l e ' )   {   m y T o p   + =   o b j . e l e m . f i n d ( ' # t o g g l e ' ) . o u t e r H e i g h t ( ) ;   }  
  
                                                         i f   ( o b j . e l e m . f i n d ( ' # f i l t e r s ' ) . h a s C l a s s ( ' h i d e ' ) )   {  
                                                                 v a r   n e w T o p   =   p a r s e I n t ( t h i s W i d g e t . c s s ( ' t o p ' ) )   +   t h i s W i d g e t . h e i g h t ( )   -   1 0   -   o b j . h t m l . f i n d ( ' # f i l t e r s   a ' ) . o u t e r H e i g h t ( ) ;  
                                                                 i f   ( o b j . h t m l . f i n d ( ' # e r r o r s ' ) . l e n g t h   >   0 )   {  
                                                                         o b j . h t m l . f i n d ( ' # e r r o r s ' ) . a n i m a t e ( {   ' t o p ' :   n e w T o p   +   p a r s e I n t ( t h i s W i d g e t . h e i g h t ( ) )   } ,   5 0 0 ) ;  
                                                                 }  
                                                                 t h i s W i d g e t . a n i m a t e ( {   ' t o p ' :   n e w T o p   } ,   5 0 0 ,   f u n c t i o n ( )   {  
                                                                         t h i s W i d g e t . a d d C l a s s ( ' s h o w ' ) ;  
                                                                         t h i s W i d g e t . r e m o v e C l a s s ( ' h i d e ' ) ;  
                                                                 } ) ;  
                                                         }  
                                                         e l s e   i f   ( o b j . e l e m . f i n d ( ' # f i l t e r s ' ) . h a s C l a s s ( ' s h o w ' ) )   {  
                                                                 v a r   n e w T o p   =   p a r s e I n t ( t h i s W i d g e t . c s s ( ' t o p ' ) )   -   t h i s W i d g e t . h e i g h t ( )   +   1 0   +   o b j . h t m l . f i n d ( ' # f i l t e r s   a ' ) . o u t e r H e i g h t ( ) ;  
                                                                 i f   ( o b j . h t m l . f i n d ( ' # e r r o r s ' ) . l e n g t h   >   0 )   {  
                                                                         o b j . h t m l . f i n d ( ' # e r r o r s ' ) . a n i m a t e ( {   ' t o p ' :   n e w T o p   +   p a r s e I n t ( t h i s W i d g e t . h e i g h t ( ) )   } ,   5 0 0 ) ;  
                                                                 }  
                                                                 t h i s W i d g e t . a n i m a t e ( {   ' t o p ' :   n e w T o p   } ,   5 0 0 ,   f u n c t i o n ( )   {  
                                                                         t h i s W i d g e t . a d d C l a s s ( ' h i d e ' ) ;  
                                                                         t h i s W i d g e t . r e m o v e C l a s s ( ' s h o w ' ) ;  
                                                                 } ) ;  
                                                         }  
                                                 } ) ;  
                                                 t h i s I n s i d e . a p p e n d ( t h i s T o g g l e ) ;  
                                                 r e t u r n   t h i s W i d g e t ;  
                                         }  
                                 } ,  
                                 r e s u l t s :   f u n c t i o n ( )   {  
                                         v a r   t h i s W i d g e t   =   $ ( ' < d i v   i d = " r e s u l t s " > < d i v   c l a s s = " d e f a u l t " > E n t e r   a   c i t y ,   z i p   c o d e ,   o r   a d d r e s s   i n t o   t h e   s e a r c h   b o x   a b o v e .   W e \ ' l l   d o   t h e   r e s t . < / d i v > < / d i v > ' ) ;  
                                         t h i s W i d g e t . b i n d ( ' u p d a t e ' ,   f u n c t i o n ( )   {  
  
                                         } ) ;  
                                         r e t u r n   t h i s W i d g e t ;  
                                 } ,  
                                 r e s u l t :   f u n c t i o n ( i n f o )   {  
                                         v a r   t h i s A d d r e s s   =   i n f o . A d d r e s s . S t r e e t   +   ' < b r / > '   +   i n f o . A d d r e s s . C i t y   +   ' ,   '   +   i n f o . A d d r e s s . S t a t e   +   '   '   +   i n f o . A d d r e s s . Z i p   +   ' < b r / > ' ;  
                                         v a r   t h i s W i d g e t   =   $ . t m p l ( " r e s u l t I t e m " ,   i n f o ,   {  
                                                 n a m e :   f u n c t i o n ( )   {  
                                                         v a r   a d d A n a l y t i c s   =   ' ' ;  
                                                         i f   ( o b j . s e t t i n g s . t r a c k A n a l y t i c s )   {  
                                                                 a d d A n a l y t i c s   =   '   o n c l i c k = " t r y { _ g a q . p u s h ( [ \ ' _ t r a c k E v e n t \ ' ,   \ ' m a p _ c h a n g e \ ' ,   \ ' s h o w s t o r e \ ' ,   \ ' '   +   i n f o . I D   +   ' \ ' ] ) ; }   c a t c h ( e r r ) { } " ' ;  
                                                         }  
                                                         i f   ( o b j . b r o w s e r O k )   {  
                                                                 r e t u r n   ' < h 3 > < a   h r e f = " # "   '   +   a d d A n a l y t i c s   +   ' i d = " s h o w '   +   i n f o . I D   +   ' "   c l a s s = " m a p S h o w " > '   +   i n f o . N a m e   +   ' < / a > < / h 3 > ' ;  
                                                         }  
                                                         r e t u r n   ' < h 3 > '   +   i n f o . N a m e   +   ' < / h 3 > ' ;  
                                                 } ,  
                                                 t y p e S h o r t :   f u n c t i o n ( )   {  
                                                         s w i t c h   ( i n f o . b r a n d )   {  
                                                                 c a s e   ' A V I ' :  
                                                                         r e t u r n   ' O t h e r ' ;  
                                                                         b r e a k ;  
  
                                                                 c a s e   ' D I Y ' :  
                                                                         r e t u r n   ' R e t a i l ' ;  
                                                                         b r e a k ;  
  
                                                                 c a s e   ' E C ' :  
                                                                         r e t u r n   ' E C ' ;  
                                                                         b r e a k ;  
  
                                                                 c a s e   ' V I O C ' :  
                                                                 d e f a u l t :  
                                                                         r e t u r n   ' V I O C ' ;  
                                                         }  
                                                 } ,  
                                                 t y p e L o n g :   f u n c t i o n ( )   {  
                                                         s w i t c h   ( i n f o . b r a n d )   {  
                                                                 c a s e   ' A V I ' :  
                                                                         r e t u r n   ' O t h e r   S e r v i c e   P r o v i d e r ' ;  
                                                                         b r e a k ;  
  
                                                                 c a s e   ' D I Y ' :  
                                                                         r e t u r n   ' R e t a i l   L o c a t i o n ' ;  
                                                                         b r e a k ;  
  
                                                                 c a s e   ' E C ' :  
                                                                         r e t u r n   ' E x p r e s s   C a r e ' ;  
                                                                         b r e a k ;  
  
                                                                 c a s e   ' V I O C ' :  
                                                                 d e f a u l t :  
                                                                         r e t u r n   ' V a l v o l i n e   I n s t a n t   O i l   C h a n g e ' ;  
                                                         }  
                                                 } ,  
                                                 d i r e c t i o n s :   f u n c t i o n ( )   {  
                                                         v a r   a d d A n a l y t i c s   =   ' ' ;  
                                                         i f   ( o b j . s e t t i n g s . t r a c k A n a l y t i c s )   {  
                                                                 a d d A n a l y t i c s   =   '   o n c l i c k = " t r y { _ g a q . p u s h ( [ \ ' _ t r a c k P a g e v i e w \ ' ,   \ ' \ \ L i s t \ \ D i r e c t i o n s \ \ '   +   i n f o . I D   +   ' \ ' ] ) ; }   c a t c h ( e r r ) { } " ' ;  
                                                         }  
                                                         r e t u r n   ' < b r / > < a   h r e f = " h t t p : / / m a p s . g o o g l e . c o m / m a p s ? d a d d r = '   +   i n f o . A d d r e s s . S t r e e t   +   ' ,   '   +   i n f o . A d d r e s s . C i t y   +   ' ,   '   +   i n f o . A d d r e s s . S t a t e   +   '   '   +   i n f o . A d d r e s s . Z i p   +   ' "   '   +   a d d A n a l y t i c s   +   ' t a r g e t = " _ b l a n k " > G e t   d r i v i n g   d i r e c t i o n s < / a > ' ;  
                                                 } ,  
                                                 c a r e e r s :   f u n c t i o n ( )   {  
                                                         i f   ( t y p e o f   i n f o . C a r e e r s   = = =   ' o b j e c t ' )   {  
                                                                 v a r   m y E l e m   =   $ ( ' < s p a n / > ' ) ;  
                                                                 $ . e a c h ( i n f o . C a r e e r s ,   f u n c t i o n ( i n d e x ,   i t e m )   {  
  
                                                                         v a r   m y T i t l e   =   i t e m . T i t l e . r e p l a c e ( ' & a m p ; ' ,   ' & ' ) ;  
                                                                         v a r   m y L i   =   $ ( ' < l i > < / l i > ' ) ;  
                                                                         m y L i . a p p e n d ( ' < a   h r e f = " # "   c l a s s = " l i g h t b o x " > '   +   m y T i t l e   +   ' < / a > ' ) ;  
                                                                         m y L i . f i n d ( ' a ' ) . c l i c k ( f u n c t i o n ( )   {  
                                                                                 o b j . t r a c k P a g e v i e w ( ' / l i g h t b o x / '   +   m y T i t l e ) ;  
                                                                         } ) ;  
                                                                         v a r   m y D e s c   =   $ ( ' < s p a n   c l a s s = " d e s c r i p t i o n " > < / s p a n > ' ) ;  
                                                                         i f   ( i t e m . D e s c r i p t i o n   ! = =   u n d e f i n e d )   {  
                                                                                 m y D e s c . a p p e n d ( i t e m . D e s c r i p t i o n . r e p l a c e ( ' & a m p ; ' ,   ' & ' ) ) ;  
                                                                                 i f   ( i t e m . S t o r e D e s c r i p t i o n   ! = =   u n d e f i n e d )   {  
                                                                                         m y D e s c . a p p e n d ( i t e m . S t o r e D e s c r i p t i o n . r e p l a c e ( ' & a m p ; ' ,   ' & ' ) ) ;  
                                                                                 }  
                                                                         }  
                                                                         m y D e s c . p r e p e n d ( ' < h 3 > '   +   m y T i t l e   +   ' < / h 3 > ' ) ;  
                                                                         i f   ( t y p e o f   i t e m . L i n k   = = =   ' s t r i n g ' )   {  
                                                                                 i f   ( i t e m . L i n k . s e a r c h ( ' m a i l t o ' )   > =   0 )   {  
                                                                                         v a r   t e m p   =   i t e m . L i n k . s p l i t ( ' : ' ) ;  
                                                                                         t e m p   =   t e m p [ 1 ] . s p l i t ( ' ? ' ) ;  
                                                                                         t e m p   =   t e m p [ 0 ] ;  
                                                                                         v a r   m y L i n k   =   $ ( ' < s p a n > E m a i l   y o u r   r e s u m e   t o   < a   h r e f = " '   +   i t e m . L i n k   +   ' "   t a r g e t = " _ b l a n k " > '   +   t e m p   +   ' < / a > < / s p a n > ' ) ;  
                                                                                         m y L i n k . f i n d ( ' a ' ) . c l i c k ( f u n c t i o n ( )   {  
                                                                                                 o b j . t r a c k E v e n t ( ' C o n v e r s i o n ' ,   ' C a r e e r   A p p l y ' ,   m y T i t l e ) ;  
                                                                                         } ) ;  
                                                                                 }  
                                                                                 e l s e   i f   ( ( i t e m . L i n k . s u b s t r ( 0 ,   7 )   = =   ' h t t p : / / ' )   | |   ( i t e m . L i n k . s u b s t r ( 0 ,   8 )   = =   ' h t t p s : / / ' ) )   {  
                                                                                         v a r   m y L i n k   =   $ ( ' < a   h r e f = " '   +   i t e m . L i n k   +   ' "   t a r g e t = " _ b l a n k " > A p p l y < / a > ' ) ;  
                                                                                         m y L i n k . c l i c k ( f u n c t i o n ( )   {  
                                                                                                 o b j . t r a c k E v e n t ( ' C o n v e r s i o n ' ,   ' C a r e e r   A p p l y ' ,   m y T i t l e ) ;  
                                                                                         } ) ;  
                                                                                 }  
                                                                                 e l s e   {  
                                                                                         v a r   m y L i n k   =   $ ( ' < s p a n > '   +   i t e m . L i n k   +   ' < / s p a n > ' ) ;  
                                                                                         m y L i n k . f i n d ( ' a ' ) . c l i c k ( f u n c t i o n ( )   {  
                                                                                                 o b j . t r a c k E v e n t ( ' C o n v e r s i o n ' ,   ' C a r e e r   A p p l y ' ,   m y T i t l e ) ;  
                                                                                         } ) ;  
                                                                                 }  
                                                                                 m y D e s c . a p p e n d ( ' < b r / > ' ,   m y L i n k ) ;  
                                                                         }  
                                                                         m y L i . a p p e n d ( m y D e s c ) ;  
                                                                         m y E l e m . a p p e n d ( m y L i ) ;  
  
                                                                 } ) ;  
                                                                 r e t u r n   ' < b r / > < b r / > < b > C a r e e r s : < / b > < b r / > < u l   c l a s s = " c a r e e r s " > '   +   m y E l e m . h t m l ( )   +   ' < / u l > ' ;  
                                                         }  
                                                         r e t u r n   ' ' ;  
                                                 } ,  
                                                 a d d r e s s :   f u n c t i o n ( )   {  
                                                         r e t u r n   t h i s A d d r e s s ;  
                                                 } ,  
                                                 l i n k :   f u n c t i o n ( )   {  
                                                         i f   ( i n f o . A d d r e s s . l i n k   ! = =   n u l l )   {  
                                                                 i f   ( i n f o . A d d r e s s . l i n k   ! = =   u n d e f i n e d   & &   i n f o . A d d r e s s . l i n k   ! =   ' ' )   {  
                                                                         v a r   a d d A n a l y t i c s   =   ' ' ;  
                                                                         i f   ( o b j . s e t t i n g s . t r a c k A n a l y t i c s )   {  
                                                                                 a d d A n a l y t i c s   =   '   o n c l i c k = " t r y { _ g a q . p u s h ( [ \ ' _ t r a c k E v e n t \ ' ,   \ ' C o n v e r s i o n \ ' ,   \ ' R e s u l t s   S t o r e   C l i c k \ ' ,   \ ' '   +   i n f o . I D   +   ' \ ' ] ) ; }   c a t c h ( e r r ) { } " ' ;  
                                                                         }  
                                                                         v a r   t h i s T i t l e   =   ' V i s i t   s t o r e   s i t e ' ;  
                                                                         i f   ( a r g u m e n t s . l e n g t h   >   0 )   {  
                                                                                 t h i s T i t l e   =   ' V i s i t   s t o r e   s i t e   f o r   c o u p o n s . ' ;  
                                                                         }  
                                                                         r e t u r n   ' < a   h r e f = " '   +   i n f o . A d d r e s s . l i n k   +   ' "   '   +   a d d A n a l y t i c s   +   ' t a r g e t = " _ b l a n k " > '   +   t h i s T i t l e   +   ' < / a > ' ;  
                                                                 }  
                                                         }  
  
                                                         r e t u r n   ' ' ;  
                                                 } ,  
                                                 p h o n e :   f u n c t i o n ( )   {  
                                                         i f   ( i n f o . A d d r e s s . p h o n e   ! = =   n u l l )   {  
                                                                 i f   ( i n f o . A d d r e s s . p h o n e   ! = =   u n d e f i n e d   & &   i n f o . A d d r e s s . p h o n e   ! =   ' ' )   {  
                                                                         r e t u r n   i n f o . A d d r e s s . p h o n e ;  
                                                                 }  
                                                         }  
  
                                                         r e t u r n   ' ' ;  
                                                 } ,  
                                                 n e x t g e n :   f u n c t i o n ( )   {  
  
                                                         i f   ( i n f o . S p e c i a l S e r v i c e s . F e a t u r e s N e x t G e n   = =   ' Y ' )   {  
                                                                 r e t u r n   ' < d i v   c l a s s = " p o u r s N e x t G e n " > < / d i v > ' ;  
                                                         }  
  
                                                         r e t u r n   ' ' ;  
                                                 } ,  
                                                 h o u r s :   f u n c t i o n ( )   {  
                                                         i f   ( t y p e o f   i n f o . O p e r a t i n g H o u r s   = =   ' o b j e c t ' )   {  
                                                                 v a r   s h o w H o u r s   =   t r u e ;  
                                                                 v a r   t h i s D a y s   =   { } ;  
                                                                 v a r   t h i s T a b l e   =   $ ( ' < t a b l e / > ' ) ;  
                                                                 v a r   t h i s T i t l e s   =   $ ( ' < t r / > ' ) ;  
                                                                 v a r   t h i s V a l u e s   =   $ ( ' < t r / > ' ) ;  
                                                                 t h i s T a b l e . a p p e n d ( t h i s T i t l e s ) ;  
                                                                 t h i s T a b l e . a p p e n d ( t h i s V a l u e s ) ;  
                                                                 $ . e a c h ( i n f o . O p e r a t i n g H o u r s ,   f u n c t i o n ( t r a s h ,   d a y )   {  
                                                                         i f   ( d a y . H o u r s   ! =   n u l l )   {  
                                                                                 v a r   h o u r   =   d a y . H o u r s ;  
                                                                                 i f   ( d a y . I s C l o s e d   = =   ' Y ' )   {  
                                                                                         h o u r   =   ' C l o s e d ' ;  
                                                                                 }  
                                                                                 i f   ( h o u r   = =   ' ' )   {  
                                                                                         s h o w H o u r s   =   f a l s e ;  
                                                                                 }  
                                                                                 t h i s D a y s [ d a y . N a m e ]   =   h o u r ;  
                                                                         }  
                                                                         e l s e   {  
                                                                                 s h o w H o u r s   =   f a l s e ;  
                                                                         }  
                                                                 } ) ;  
                                                                 $ . e a c h ( o b j . s e t t i n g s . d a y O r d e r ,   f u n c t i o n ( t r a s h ,   d a y )   {  
                                                                         t h i s T i t l e s . a p p e n d ( ' < t d > '   +   d a y   +   ' < / t d > ' ) ;  
                                                                         t h i s V a l u e s . a p p e n d ( ' < t d > '   +   t h i s D a y s [ d a y ]   +   ' < / t d > ' ) ;  
                                                                 } ) ;  
                                                                 i f   ( s h o w H o u r s )   {  
                                                                         r e t u r n   ' < t a b l e   c l a s s = " h o u r s " > '   +   t h i s T a b l e . h t m l ( )   +   ' < / t a b l e > ' ;  
                                                                 }  
                                                                 r e t u r n   ' ' ;  
                                                         }  
                                                         r e t u r n   ' ' ;  
                                                 }  
                                         } ) ;  
                                         t h i s W i d g e t . f i n d ( ' . c a r e e r s   . l i g h t b o x ' ) . c l i c k ( f u n c t i o n ( e )   {  
                                                 e . p r e v e n t D e f a u l t ( ) ;  
                                                 o b j . l i g h t b o x . c r e a t e ( $ ( t h i s ) . p a r e n t ( ' l i ' ) . f i n d ( ' s p a n . d e s c r i p t i o n ' ) ) ;  
                                         } ) ;  
                                         r e t u r n   t h i s W i d g e t ;  
                                 } ,  
                                 m a p :   f u n c t i o n ( )   {  
                                         v a r   t h i s W i d g e t   =   $ ( ' < d i v   i d = " m a p " > < / d i v > ' ) ;  
                                         v a r   t h i s I n s i d e   =   $ ( ' < d i v   i d = " m a p _ d i s p l a y " > < / d i v > ' ) ;  
                                         t h i s W i d g e t . a p p e n d ( t h i s I n s i d e ) ;  
                                         r e t u r n   t h i s W i d g e t ;  
                                 } ,  
                                 f o o t e r :   f u n c t i o n ( )   {  
                                         v a r   t h i s W i d g e t   =   $ ( ' < d i v   i d = " f o o t " > < / d i v > ' ) ;  
                                         v a r   t h i s I n s i d e   =   $ ( ' < d i v   c l a s s = " i n s i d e " > < / d i v > ' ) ;  
                                         i f   ( o b j . s e t t i n g s . f o o t e r C o n t e n t   ! =   ' ' )   {  
                                                 t h i s I n s i d e . a p p e n d ( o b j . s e t t i n g s . f o o t e r C o n t e n t ) ;  
                                         }  
                                         t h i s W i d g e t . a p p e n d ( t h i s I n s i d e ) ;  
                                         r e t u r n   t h i s W i d g e t ;  
                                 } ,  
                                 m a r k e r :   f u n c t i o n ( i n f o )   {  
                                         v a r   t h i s A d d r e s s   =   i n f o . A d d r e s s . S t r e e t   +   ' < b r / > '   +   i n f o . A d d r e s s . C i t y   +   ' ,   '   +   i n f o . A d d r e s s . S t a t e   +   '   '   +   i n f o . A d d r e s s . Z i p   +   ' < b r / > ' ;  
                                         v a r   i c o n   =   o b j . s e t t i n g s . m a r k e r ( i n f o ) ;  
                                         v a r   s h a d o w   =   o b j . s e t t i n g s . m a r k e r I m a g e s . S h a d o w ;  
  
                                         v a r   t h i s T e m p   =   $ . t m p l ( " m a p I t e m " ,   i n f o ,   {  
                                                 a d d r e s s :   f u n c t i o n ( )   {  
                                                         r e t u r n   t h i s A d d r e s s ;  
                                                 } ,  
                                                 l i n k :   f u n c t i o n ( )   {  
  
                                                         i f   ( i n f o . A d d r e s s . l i n k   ! = =   n u l l )   {  
                                                                 i f   ( i n f o . A d d r e s s . l i n k   ! = =   u n d e f i n e d   & &   i n f o . A d d r e s s . l i n k   ! =   ' ' )   {  
                                                                         v a r   a d d A n a l y t i c s   =   ' ' ;  
                                                                         i f   ( o b j . s e t t i n g s . t r a c k A n a l y t i c s )   {  
                                                                                 a d d A n a l y t i c s   =   '   o n c l i c k = " t r y { _ g a q . p u s h ( [ \ ' _ t r a c k E v e n t \ ' ,   \ ' C o n v e r s i o n \ ' ,   \ ' M a p   S t o r e   C l i c k \ ' ,   \ ' '   +   i n f o . I D   +   ' \ ' ] ) ; }   c a t c h ( e r r ) { } " ' ;  
                                                                         }  
                                                                         v a r   t h i s T i t l e   =   ' V i s i t   s t o r e   s i t e ' ;  
                                                                         i f   ( a r g u m e n t s . l e n g t h   >   0 )   {  
                                                                                 t h i s T i t l e   =   ' V i s i t   s t o r e   s i t e   f o r   c o u p o n s . ' ;  
                                                                         }  
                                                                         r e t u r n   ' < a   h r e f = " '   +   i n f o . A d d r e s s . l i n k   +   ' "   '   +   a d d A n a l y t i c s   +   ' t a r g e t = " _ b l a n k " > '   +   t h i s T i t l e   +   ' < / a > < b r / > ' ;  
                                                                 }  
                                                         }  
                                                         r e t u r n   ' ' ;  
                                                 } ,  
                                                 p h o n e :   f u n c t i o n ( )   {  
                                                         i f   ( i n f o . A d d r e s s . p h o n e   ! = =   n u l l )   {  
                                                                 i f   ( i n f o . A d d r e s s . p h o n e   ! = =   u n d e f i n e d   & &   i n f o . A d d r e s s . p h o n e   ! =   ' ' )   {  
                                                                         r e t u r n   i n f o . A d d r e s s . p h o n e ;  
                                                                 }  
                                                         }  
  
                                                         r e t u r n   ' ' ;  
                                                 } ,  
                                                 c a r e e r s :   f u n c t i o n ( )   {  
                                                         i f   ( t y p e o f   i n f o . C a r e e r s   = = =   ' o b j e c t ' )   {  
                                                                 v a r   m y E l e m   =   $ ( ' < s p a n / > ' ) ;  
                                                                 $ . e a c h ( i n f o . C a r e e r s ,   f u n c t i o n ( i n d e x ,   i t e m )   {  
  
                                                                         v a r   m y T i t l e   =   i t e m . T i t l e . r e p l a c e ( ' & a m p ; ' ,   ' & ' ) ;  
                                                                         v a r   m y L i   =   $ ( ' < l i > < / l i > ' ) ;  
                                                                         m y L i . a p p e n d ( ' < a   h r e f = " # "   c l a s s = " l i g h t b o x " > '   +   m y T i t l e   +   ' < / a > ' ) ;  
                                                                         v a r   m y D e s c   =   $ ( ' < s p a n   c l a s s = " d e s c r i p t i o n " > < / s p a n > ' ) ;  
                                                                         i f   ( i t e m . D e s c r i p t i o n   ! = =   u n d e f i n e d )   {  
                                                                                 m y D e s c . a p p e n d ( i t e m . D e s c r i p t i o n . r e p l a c e ( ' & a m p ; ' ,   ' & ' ) ) ;  
                                                                                 i f   ( i t e m . S t o r e D e s c r i p t i o n   ! = =   u n d e f i n e d )   {  
                                                                                         m y D e s c . a p p e n d ( i t e m . S t o r e D e s c r i p t i o n . r e p l a c e ( ' & a m p ; ' ,   ' & ' ) ) ;  
                                                                                 }  
                                                                         }  
                                                                         m y D e s c . p r e p e n d ( ' < h 3 > '   +   m y T i t l e   +   ' < / h 3 > ' ) ;  
                                                                         i f   ( t y p e o f   i t e m . L i n k   = = =   ' s t r i n g ' )   {  
                                                                                 i f   ( i t e m . L i n k . s e a r c h ( ' m a i l t o ' )   > =   0 )   {  
                                                                                         v a r   t e m p   =   i t e m . L i n k . s p l i t ( ' : ' ) ;  
                                                                                         t e m p   =   t e m p [ 1 ] . s p l i t ( ' ? ' ) ;  
                                                                                         t e m p   =   t e m p [ 0 ] ;  
                                                                                         v a r   m y L i n k   =   $ ( ' < s p a n > E m a i l   y o u r   r e s u m e   t o   < a   h r e f = " '   +   i t e m . L i n k   +   ' "   t a r g e t = " _ b l a n k " > '   +   t e m p   +   ' < / a > < / s p a n > ' ) ;  
                                                                                 }  
                                                                                 e l s e   i f   ( ( i t e m . L i n k . s u b s t r ( 0 ,   7 )   = =   ' h t t p : / / ' )   | |   ( i t e m . L i n k . s u b s t r ( 0 ,   8 )   = =   ' h t t p s : / / ' ) )   {  
                                                                                         v a r   m y L i n k   =   $ ( ' < a   h r e f = " '   +   i t e m . L i n k   +   ' "   t a r g e t = " _ b l a n k " > A p p l y < / a > ' ) ;  
                                                                                 }  
                                                                                 e l s e   {  
                                                                                         v a r   m y L i n k   =   $ ( ' < s p a n > '   +   i t e m . L i n k   +   ' < / s p a n > ' ) ;  
                                                                                 }  
                                                                         }  
                                                                         m y D e s c . a p p e n d ( ' < b r / > ' ,   m y L i n k ) ;  
                                                                         m y L i . a p p e n d ( m y D e s c ) ;  
                                                                         m y E l e m . a p p e n d ( m y L i ) ;  
  
                                                                 } ) ;  
                                                                 r e t u r n   ' < b r / > < b r / > < b > C a r e e r s : < / b > < b r / > < u l   c l a s s = " c a r e e r s " > '   +   m y E l e m . h t m l ( )   +   ' < / u l > ' ;  
                                                         }  
                                                         r e t u r n   ' ' ;  
                                                 } ,  
                                                 n e x t g e n :   f u n c t i o n ( )   {  
  
                                                         i f   ( i n f o . S p e c i a l S e r v i c e s . F e a t u r e s N e x t G e n   = =   ' Y ' )   {  
                                                                 r e t u r n   ' < d i v   c l a s s = " p o u r s N e x t G e n " > < / d i v > ' ;  
                                                         }  
  
                                                         r e t u r n   ' ' ;  
                                                 } ,  
                                                 d i r e c t i o n s :   f u n c t i o n ( )   {  
                                                         v a r   a d d A n a l y t i c s   =   ' ' ;  
                                                         i f   ( o b j . s e t t i n g s . t r a c k A n a l y t i c s )   {  
                                                                 a d d A n a l y t i c s   =   '   o n c l i c k = " t r y { _ g a q . p u s h ( [ \ ' _ t r a c k P a g e v i e w \ ' ,   \ ' \ \ M a p \ \ D i r e c t i o n s \ \ '   +   i n f o . I D   +   ' \ ' ] ) ; }   c a t c h ( e r r ) { } " ' ;  
                                                         }  
                                                         r e t u r n   ' < b r / > < a   h r e f = " h t t p : / / m a p s . g o o g l e . c o m / m a p s ? d a d d r = '   +   i n f o . A d d r e s s . S t r e e t   +   ' ,   '   +   i n f o . A d d r e s s . C i t y   +   ' ,   '   +   i n f o . A d d r e s s . S t a t e   +   '   '   +   i n f o . A d d r e s s . Z i p   +   ' "   '   +   a d d A n a l y t i c s   +   ' t a r g e t = " _ b l a n k " > G e t   d r i v i n g   d i r e c t i o n s < / a > ' ;  
                                                 } ,  
                                                 h o u r s :   f u n c t i o n ( )   {  
  
                                                         i f   ( t y p e o f   i n f o . O p e r a t i n g H o u r s   = =   ' o b j e c t ' )   {  
                                                                 v a r   s h o w H o u r s   =   t r u e ;  
                                                                 v a r   t h i s D a y s   =   { } ;  
                                                                 v a r   t h i s T a b l e   =   $ ( ' < t a b l e / > ' ) ;  
                                                                 v a r   t h i s T i t l e s   =   $ ( ' < t r / > ' ) ;  
                                                                 v a r   t h i s V a l u e s   =   $ ( ' < t r / > ' ) ;  
                                                                 t h i s T a b l e . a p p e n d ( t h i s T i t l e s ) ;  
                                                                 t h i s T a b l e . a p p e n d ( t h i s V a l u e s ) ;  
                                                                 $ . e a c h ( i n f o . O p e r a t i n g H o u r s ,   f u n c t i o n ( t r a s h ,   d a y )   {  
                                                                         i f   ( d a y . H o u r s   ! = =   n u l l )   {  
                                                                                 v a r   h o u r   =   $ . t r i m ( d a y . H o u r s ) ;  
                                                                                 i f   ( d a y . I s C l o s e d   = =   ' Y ' )   {  
                                                                                         h o u r   =   ' C l o s e d ' ;  
                                                                                 }  
                                                                                 i f   ( h o u r   = =   ' ' )   {  
                                                                                         s h o w H o u r s   =   f a l s e ;  
                                                                                 }  
                                                                                 t h i s D a y s [ d a y . N a m e ]   =   h o u r ;  
                                                                         }  
                                                                         e l s e   {  
                                                                                 s h o w H o u r s   =   f a l s e ;  
                                                                         }  
                                                                 } ) ;  
                                                                 $ . e a c h ( o b j . s e t t i n g s . d a y O r d e r ,   f u n c t i o n ( t r a s h ,   d a y )   {  
                                                                         t h i s T i t l e s . a p p e n d ( ' < t d > '   +   d a y   +   ' < / t d > ' ) ;  
                                                                         t h i s V a l u e s . a p p e n d ( ' < t d > '   +   t h i s D a y s [ d a y ]   +   ' < / t d > ' ) ;  
                                                                 } ) ;  
                                                                 i f   ( s h o w H o u r s )   {  
                                                                         r e t u r n   ' < t a b l e   c l a s s = " h o u r s " > '   +   t h i s T a b l e . h t m l ( )   +   ' < / t a b l e > ' ;  
                                                                 }  
                                                         }  
  
                                                         r e t u r n   ' ' ;  
                                                 }  
                                         } ) ;  
  
                                         v a r   t h i s W i d g e t   =   $ ( ' < d i v   c l a s s = " m a p I n f o " / > ' ) ;  
                                         t h i s W i d g e t . a p p e n d ( t h i s T e m p ) ;  
  
                                         t h i s W i d g e t . f i n d ( ' . c a r e e r s   . l i g h t b o x ' ) . c l i c k ( f u n c t i o n ( e )   {  
                                                 e . p r e v e n t D e f a u l t ( ) ;  
                                                 o b j . l i g h t b o x . c r e a t e ( $ ( t h i s ) . p a r e n t ( ' l i ' ) . f i n d ( ' s p a n . d e s c r i p t i o n ' ) ) ;  
                                         } ) ;  
  
                                         v a r   m a r k e r   =   n e w   g o o g l e . m a p s . M a r k e r ( {   p o s i t i o n :   ( n e w   g o o g l e . m a p s . L a t L n g ( i n f o . L a t i t u d e ,   i n f o . L o n g i t u d e ) ) ,   m a p :   o b j . l o c a t o r . m a p ,   i c o n :   i c o n ,   s h a d o w :   s h a d o w ,   t i t l e :   i n f o . n a m e   } ) ;  
                                         i f   ( o b j . s e t t i n g s . s h o w M a r k e r s )   {  
                                                 m a r k e r . c o n t e n t   =   $ ( t h i s W i d g e t ) [ 0 ] ;  
                                                 g o o g l e . m a p s . e v e n t . a d d L i s t e n e r ( m a r k e r ,   ' c l i c k ' ,   f u n c t i o n ( )   {  
                                                         o b j . l o c a t o r . i n f o W i n d o w . c l o s e ( ) ;  
                                                         o b j . l o c a t o r . i n f o W i n d o w . c o n t e n t   =   m a r k e r . c o n t e n t ;  
                                                         o b j . l o c a t o r . i n f o W i n d o w . o p e n ( o b j . l o c a t o r . m a p ,   m a r k e r ) ;  
                                                         s e t T i m e o u t ( f u n c t i o n ( )   {   o b j . l o c a t o r . i n f o W i n d o w . s e t C o n t e n t ( m a r k e r . c o n t e n t ) ;   } ,   2 5 0 ) ;  
                                                 } ) ;  
                                         }  
                                         r e t u r n   m a r k e r ;  
                                 } ,  
                                 t o g g l e :   f u n c t i o n ( )   {  
                                         i f   ( a r g u m e n t s . l e n g t h   >   0 )   {  
                                                 i f   ( o b j . s e t t i n g s . l o c a t o r V i e w   = =   ' t o g g l e ' )   {  
                                                         s w i t c h   ( a r g u m e n t s [ 0 ] )   {  
                                                                 c a s e   ' m a p ' :  
                                                                         o b j . t r a c k E v e n t ( ' t o g g l e ' ,   ' m a p _ r e s u l t s ' ,   ' m a p ' ) ;  
                                                                         o b j . l o c a t o r . h t m l . r e m o v e C l a s s ( ' t o g g l e _ r e s u l t s ' ) ;  
                                                                         o b j . l o c a t o r . h t m l . a d d C l a s s ( ' t o g g l e _ m a p ' ) ;  
                                                                         o b j . h a s h . s e t ( ' t o g g l e ' ,   ' m a p ' ) ;  
                                                                         b r e a k ;  
  
                                                                 c a s e   ' r e s u l t s ' :  
                                                                         o b j . t r a c k E v e n t ( ' t o g g l e ' ,   ' m a p _ r e s u l t s ' ,   ' r e s u l t s ' ) ;  
                                                                         o b j . l o c a t o r . h t m l . r e m o v e C l a s s ( ' t o g g l e _ m a p ' ) ;  
                                                                         o b j . l o c a t o r . h t m l . a d d C l a s s ( ' t o g g l e _ r e s u l t s ' ) ;  
                                                                         o b j . h a s h . s e t ( ' t o g g l e ' ,   ' r e s u l t s ' ) ;  
                                                                         b r e a k ;  
                                                         }  
                                                 }  
                                         }  
                                         e l s e   {  
                                                 v a r   t h i s W i d g e t   =   $ ( ' < d i v   i d = " t o g g l e " > < / d i v > ' ) ;  
                                                 v a r   t h i s I n s i d e   =   $ ( ' < d i v   c l a s s = " i n s i d e " > < / d i v > ' ) ;  
                                                 v a r   t h i s T o g g l e   =   $ ( ' < a   h r e f = " # " > T o g g l e   M a p / L i s t < / a > ' ) ;  
                                                 t h i s T o g g l e . c l i c k ( f u n c t i o n ( E )   {  
                                                         E . p r e v e n t D e f a u l t ( ) ;  
                                                 } ) ;  
                                                 t h i s W i d g e t . c l i c k ( f u n c t i o n ( E )   {  
                                                         E . p r e v e n t D e f a u l t ( ) ;  
                                                         i f   ( o b j . l o c a t o r . h t m l . h a s C l a s s ( ' t o g g l e _ m a p ' ) )   {  
                                                                 o b j . l o c a t o r . w i d g e t s . t o g g l e ( ' r e s u l t s ' ) ;  
                                                         }  
                                                         e l s e   {  
                                                                 o b j . l o c a t o r . w i d g e t s . t o g g l e ( ' m a p ' ) ;  
                                                         }  
                                                         o b j . l o c a t o r . r e s i z e ( ) ;  
                                                 } ) ;  
                                                 i f   ( o b j . s e t t i n g s . m o b i l e )   {  
                                                         i f   ( o b j . s e t t i n g s . l o c a t o r V i e w   = =   ' t o g g l e ' )   {  
                                                                 t h i s W i d g e t . s w i p e ( {  
                                                                         t h r e s h o l d :   0 ,  
                                                                         s w i p e L e f t :   f u n c t i o n ( )   {   o b j . w i d g e t s . t o g g l e ( ' r e s u l t s ' )   } ,  
                                                                         s w i p e R i g h t :   f u n c t i o n ( )   {   o b j . w i d g e t s . t o g g l e ( ' m a p ' )   }  
                                                                 } ) ;  
                                                         }  
                                                 }  
                                                 t h i s I n s i d e . a p p e n d ( t h i s T o g g l e ) ;  
                                                 t h i s W i d g e t . a p p e n d ( t h i s I n s i d e ) ;  
                                                 r e t u r n   t h i s W i d g e t ;  
                                         }  
                                 }  
                         }  
                 }  
  
                 / * *    
                 *   P u b i c   O b j e c t :   c o u p o n    
                 *   T h i s   w i l l   h o u s e   t h e   i n i t a l i z a t i o n   o f   t h e   c o u p o n   o b j e c t ,   i n c l u d i n g   w i d g e t s   a n d   f u n c t i o n s   s p e c i f i c   t o   t h e   c o u p o n .  
                 * * /  
                 t h i s . c o u p o n   =   {  
                         s e t t i n g s :   {  
  
                 } ,  
  
                 / * *    
                 *   P u b i c   F u n c t i o n :   c o u p o n . i n i t   ( o b j e c t )  
                 *   T h e   p a r a m e t e r   p a s s e d   i s   a n   o b j e c t   t h a t   m e r g e s / o v e r w r i t e s   t h e   c u r r e n t   s e t t i n g s .  
                 * * /  
                 i n i t :   f u n c t i o n ( o p t i o n s )   {  
                         $ . e x t e n d ( { } ,   t h i s . s e t t i n g s ,   o p t i o n s ) ;  
                         r e t u r n   t h i s ;  
                 }  
         }  
  
         t h i s . i n i t ( o p t i o n s ) ;  
 } ;  
  
 $ . f n . V a l v o l i n e   =   f u n c t i o n ( o p t i o n s )   {  
         i f   ( t y p e o f   t h i s . v a l v o l i n e   ! = =   ' o b j e c t ' )   {  
                 t h i s . v a l v o l i n e   =   n e w   V a l v o l i n e O b j ( t h i s ,   o p t i o n s ) ;  
         }  
         e l s e   i f   ( t y p e o f   o p t i o n s   = = =   ' o b j e c t ' )   {  
                 $ . e x t e n d ( { } ,   t h i s . v a l v o l i n e . s e t t i n g s ,   o p t i o n s ) ;  
         }  
  
         r e t u r n   t h i s . v a l v o l i n e ;  
 } ;  
 } ) ( j Q u e r y ) ;  
  
 ( f u n c t i o n ( $ )   {  
         $ . f n . U R L E n c o d e   =   f u n c t i o n ( c )   {  
                 v a r   o   =   ' ' ;   v a r   x   =   0 ;   c   =   c . t o S t r i n g ( ) ;   v a r   r   =   / ( ^ [ a - z A - Z 0 - 9 _ . ] * ) / ;  
                 w h i l e   ( x   <   c . l e n g t h )   {  
                         v a r   m   =   r . e x e c ( c . s u b s t r ( x ) ) ;  
                         i f   ( m   ! =   n u l l   & &   m . l e n g t h   >   1   & &   m [ 1 ]   ! =   ' ' )   {  
                                 o   + =   m [ 1 ] ;   x   + =   m [ 1 ] . l e n g t h ;  
                         }   e l s e   {  
                                 i f   ( c [ x ]   = =   '   ' )   o   + =   ' + ' ;   e l s e   {  
                                         v a r   d   =   c . c h a r C o d e A t ( x ) ;   v a r   h   =   d . t o S t r i n g ( 1 6 ) ;  
                                         o   + =   ' % '   +   ( h . l e n g t h   <   2   ?   ' 0 '   :   ' ' )   +   h . t o U p p e r C a s e ( ) ;  
                                 }   x + + ;  
                         }  
                 }   r e t u r n   o ;  
         }  
  
         $ . f n . U R L D e c o d e   =   f u n c t i o n ( s )   {  
                 v a r   o   =   s ;   v a r   b i n V a l ,   t ;   v a r   r   =   / ( % [ ^ % ] { 2 } ) / ;  
                 w h i l e   ( ( m   =   r . e x e c ( o ) )   ! =   n u l l   & &   m . l e n g t h   >   1   & &   m [ 1 ]   ! =   ' ' )   {  
                         b   =   p a r s e I n t ( m [ 1 ] . s u b s t r ( 1 ) ,   1 6 ) ;  
                         t   =   S t r i n g . f r o m C h a r C o d e ( b ) ;   o   =   o . r e p l a c e ( m [ 1 ] ,   t ) ;  
                 }   r e t u r n   o ;  
         }  
 } ) ( j Q u e r y ) ;  
  
 j Q u e r y ( d o c u m e n t . b o d y ) . r e a d y ( f u n c t i o n ( )   {  
         j Q u e r y . a j a x T r a n s p o r t ( " + * " ,   f u n c t i o n ( o p t i o n s ,   o r i g i n a l O p t i o n s ,   j q X H R )   {  
  
                 i f   ( j Q u e r y . b r o w s e r . m s i e   & &   w i n d o w . X D o m a i n R e q u e s t )   {  
  
                         v a r   x d r ;  
  
                         r e t u r n   {  
  
                                 s e n d :   f u n c t i o n ( h e a d e r s ,   c o m p l e t e C a l l b a c k )   {  
  
                                         / /   U s e   M i c r o s o f t   X D R  
                                         x d r   =   n e w   X D o m a i n R e q u e s t ( ) ;  
  
                                         x d r . o p e n ( " g e t " ,   o p t i o n s . u r l ) ;  
  
                                         x d r . o n l o a d   =   f u n c t i o n ( )   {  
  
                                                 i f   ( t h i s . c o n t e n t T y p e . m a t c h ( / \ / x m l / ) )   {  
  
                                                         v a r   d o m   =   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 D O M " ) ;  
                                                         d o m . a s y n c   =   f a l s e ;  
                                                         d o m . l o a d X M L ( t h i s . r e s p o n s e T e x t ) ;  
                                                         c o m p l e t e C a l l b a c k ( 2 0 0 ,   " s u c c e s s " ,   [ d o m ] ) ;  
  
                                                 }   e l s e   {  
  
                                                         c o m p l e t e C a l l b a c k ( 2 0 0 ,   " s u c c e s s " ,   [ t h i s . r e s p o n s e T e x t ] ) ;  
  
                                                 }  
  
                                         } ;  
  
                                         x d r . o n t i m e o u t   =   f u n c t i o n ( )   {  
                                                 c o m p l e t e C a l l b a c k ( 4 0 8 ,   " e r r o r " ,   [ " T h e   r e q u e s t   t i m e d   o u t . " ] ) ;  
                                         } ;  
  
                                         x d r . o n e r r o r   =   f u n c t i o n ( )   {  
                                                 c o m p l e t e C a l l b a c k ( 4 0 4 ,   " e r r o r " ,   [ " T h e   r e q u e s t e d   r e s o u r c e   c o u l d   n o t   b e   f o u n d . " ] ) ;  
                                         } ;  
  
                                         x d r . s e n d ( ) ;  
                                 } ,  
                                 a b o r t :   f u n c t i o n ( )   {  
                                         i f   ( x d r )   x d r . a b o r t ( ) ;  
                                 }  
                         } ;  
                 }  
         } ) ;  
 } ) ;  
  
 / * !  
 *   g e o - l o c a t i o n - j a v a s c r i p t   v 0 . 4 . 3  
 *   h t t p : / / c o d e . g o o g l e . c o m / p / g e o - l o c a t i o n - j a v a s c r i p t /  
 *  
 *   C o p y r i g h t   ( c )   2 0 0 9   S t a n   W i e c h e r s  
 *   L i c e n s e d   u n d e r   t h e   M I T   l i c e n s e s .  
 *  
 *   R e v i s i o n :   $ R e v :   6 8   $ :    
 *   A u t h o r :   $ A u t h o r :   w h o i s s t a n   $ :  
 *   D a t e :   $ D a t e :   2 0 1 0 - 0 2 - 1 5   1 3 : 4 2 : 1 9   + 0 1 0 0   ( M o n ,   1 5   F e b   2 0 1 0 )   $ :          
 * /  
 v a r   b b _ s u c c e s s C a l l b a c k ;  
 v a r   b b _ e r r o r C a l l b a c k ;  
 v a r   b b _ b l a c k b e r r y T i m e o u t _ i d   =   - 1 ;  
  
 f u n c t i o n   h a n d l e B l a c k B e r r y L o c a t i o n T i m e o u t ( )   {  
         i f   ( b b _ b l a c k b e r r y T i m e o u t _ i d   ! =   - 1 )   {  
                 b b _ e r r o r C a l l b a c k ( {   m e s s a g e :   " T i m e o u t   e r r o r " ,   c o d e :   3   } ) ;  
         }  
 }  
 f u n c t i o n   h a n d l e B l a c k B e r r y L o c a t i o n ( )   {  
         c l e a r T i m e o u t ( b b _ b l a c k b e r r y T i m e o u t _ i d ) ;  
         b b _ b l a c k b e r r y T i m e o u t _ i d   =   - 1 ;  
         i f   ( b b _ s u c c e s s C a l l b a c k   & &   b b _ e r r o r C a l l b a c k )   {  
                 i f   ( b l a c k b e r r y . l o c a t i o n . l a t i t u d e   = =   0   & &   b l a c k b e r r y . l o c a t i o n . l o n g i t u d e   = =   0 )   {  
                         / / h t t p : / / d e v . w 3 . o r g / g e o / a p i / s p e c - s o u r c e . h t m l # p o s i t i o n _ u n a v a i l a b l e _ e r r o r  
                         / / P O S I T I O N _ U N A V A I L A B L E   ( n u m e r i c   v a l u e   2 )  
                         b b _ e r r o r C a l l b a c k ( {   m e s s a g e :   " P o s i t i o n   u n a v a i l a b l e " ,   c o d e :   2   } ) ;  
                 }  
                 e l s e   {  
                         v a r   t i m e s t a m p   =   n u l l ;  
                         / / o n l y   a v a i l a b l e   w i t h   4 . 6   a n d   l a t e r  
                         / / h t t p : / / n a . b l a c k b e r r y . c o m / e n g / d e l i v e r a b l e s / 8 8 6 1 / b l a c k b e r r y _ l o c a t i o n _ 5 6 8 4 0 4 _ 1 1 . j s p  
                         i f   ( b l a c k b e r r y . l o c a t i o n . t i m e s t a m p )   {  
                                 t i m e s t a m p   =   n e w   D a t e ( b l a c k b e r r y . l o c a t i o n . t i m e s t a m p ) ;  
                         }  
                         b b _ s u c c e s s C a l l b a c k ( {   t i m e s t a m p :   t i m e s t a m p ,   c o o r d s :   {   l a t i t u d e :   b l a c k b e r r y . l o c a t i o n . l a t i t u d e ,   l o n g i t u d e :   b l a c k b e r r y . l o c a t i o n . l o n g i t u d e }   } ) ;  
                 }  
                 / / s i n c e   b l a c k b e r r y . l o c a t i o n . r e m o v e L o c a t i o n U p d a t e ( ) ;  
                 / / i s   n o t   w o r k i n g   a s   d e s c r i b e d   h t t p : / / n a . b l a c k b e r r y . c o m / e n g / d e l i v e r a b l e s / 8 8 6 1 / b l a c k b e r r y _ l o c a t i o n _ r e m o v e L o c a t i o n U p d a t e _ 5 6 8 4 0 9 _ 1 1 . j s p  
                 / / t h e   c a l l b a c k   a r e   s e t   t o   n u l l   t o   i n d i c a t e   t h a t   t h e   j o b   i s   d o n e  
  
                 b b _ s u c c e s s C a l l b a c k   =   n u l l ;  
                 b b _ e r r o r C a l l b a c k   =   n u l l ;  
         }  
 }  
  
 v a r   g e o _ p o s i t i o n _ j s   =   f u n c t i o n ( )   {  
  
         v a r   p u b   =   { } ;  
         v a r   p r o v i d e r   =   n u l l ;  
  
         p u b . g e t C u r r e n t P o s i t i o n   =   f u n c t i o n ( s u c c e s s C a l l b a c k ,   e r r o r C a l l b a c k ,   o p t i o n s )   {  
                 p r o v i d e r . g e t C u r r e n t P o s i t i o n ( s u c c e s s C a l l b a c k ,   e r r o r C a l l b a c k ,   o p t i o n s ) ;  
         }  
  
         p u b . i n i t   =   f u n c t i o n ( )   {  
                 t r y   {  
                         i f   ( t y p e o f   ( g e o _ p o s i t i o n _ j s _ s i m u l a t o r )   ! =   " u n d e f i n e d " )   {  
                                 p r o v i d e r   =   g e o _ p o s i t i o n _ j s _ s i m u l a t o r ;  
                         }  
                         e l s e   i f   ( t y p e o f   ( b o n d i )   ! =   " u n d e f i n e d "   & &   t y p e o f   ( b o n d i . g e o l o c a t i o n )   ! =   " u n d e f i n e d " )   {  
                                 p r o v i d e r   =   b o n d i . g e o l o c a t i o n ;  
                         }  
                         e l s e   i f   ( t y p e o f   ( n a v i g a t o r . g e o l o c a t i o n )   ! =   " u n d e f i n e d " )   {  
                                 p r o v i d e r   =   n a v i g a t o r . g e o l o c a t i o n ;  
                                 p u b . g e t C u r r e n t P o s i t i o n   =   f u n c t i o n ( s u c c e s s C a l l b a c k ,   e r r o r C a l l b a c k ,   o p t i o n s )   {  
                                         f u n c t i o n   _ s u c c e s s C a l l b a c k ( p )   {  
                                                 / / f o r   m o z i l l a   g e o d e , i t   r e t u r n s   t h e   c o o r d i n a t e s   s l i g h t l y   d i f f e r e n t l y  
                                                 i f   ( t y p e o f   ( p . l a t i t u d e )   ! =   " u n d e f i n e d " )   {  
                                                         s u c c e s s C a l l b a c k ( {   t i m e s t a m p :   p . t i m e s t a m p ,   c o o r d s :   {   l a t i t u d e :   p . l a t i t u d e ,   l o n g i t u d e :   p . l o n g i t u d e }   } ) ;  
                                                 }  
                                                 e l s e   {  
                                                         s u c c e s s C a l l b a c k ( p ) ;  
                                                 }  
                                         }  
                                         p r o v i d e r . g e t C u r r e n t P o s i t i o n ( _ s u c c e s s C a l l b a c k ,   e r r o r C a l l b a c k ,   o p t i o n s ) ;  
                                 }  
                         }  
                         e l s e   i f   ( t y p e o f   ( w i n d o w . g o o g l e )   ! =   " u n d e f i n e d "   & &   t y p e o f   ( g o o g l e . g e a r s )   ! =   " u n d e f i n e d " )   {  
                                 p r o v i d e r   =   g o o g l e . g e a r s . f a c t o r y . c r e a t e ( ' b e t a . g e o l o c a t i o n ' ) ;  
                         }  
                         e l s e   i f   ( t y p e o f   ( M o j o )   ! =   " u n d e f i n e d "   & &   t y p e o f   ( M o j o . S e r v i c e . R e q u e s t )   ! =   " M o j o . S e r v i c e . R e q u e s t " )   {  
                                 p r o v i d e r   =   t r u e ;  
                                 p u b . g e t C u r r e n t P o s i t i o n   =   f u n c t i o n ( s u c c e s s C a l l b a c k ,   e r r o r C a l l b a c k ,   o p t i o n s )   {  
                                         p a r a m e t e r s   =   { } ;  
                                         i f   ( o p t i o n s )   {  
                                                 / / h t t p : / / d e v e l o p e r . p a l m . c o m / i n d e x . p h p ? o p t i o n = c o m _ c o n t e n t & v i e w = a r t i c l e & i d = 1 6 7 3 # G P S - g e t C u r r e n t P o s i t i o n  
                                                 i f   ( o p t i o n s . e n a b l e H i g h A c c u r a c y   & &   o p t i o n s . e n a b l e H i g h A c c u r a c y   = =   t r u e )   {  
                                                         p a r a m e t e r s . a c c u r a c y   =   1 ;  
                                                 }  
                                                 i f   ( o p t i o n s . m a x i m u m A g e )   {  
                                                         p a r a m e t e r s . m a x i m u m A g e   =   o p t i o n s . m a x i m u m A g e ;  
                                                 }  
                                                 i f   ( o p t i o n s . r e s p o n s e T i m e )   {  
                                                         i f   ( o p t i o n s . r e s p o n s e T i m e   <   5 )   {  
                                                                 p a r a m e t e r s . r e s p o n s e T i m e   =   1 ;  
                                                         }  
                                                         e l s e   i f   ( o p t i o n s . r e s p o n s e T i m e   <   2 0 )   {  
                                                                 p a r a m e t e r s . r e s p o n s e T i m e   =   2 ;  
                                                         }  
                                                         e l s e   {  
                                                                 p a r a m e t e r s . t i m e o u t   =   3 ;  
                                                         }  
                                                 }  
                                         }  
                                         r   =   n e w   M o j o . S e r v i c e . R e q u e s t ( ' p a l m : / / c o m . p a l m . l o c a t i o n ' ,   {  
                                                 m e t h o d :   " g e t C u r r e n t P o s i t i o n " ,  
                                                 p a r a m e t e r s :   p a r a m e t e r s ,  
                                                 o n S u c c e s s :   f u n c t i o n ( p )   {   s u c c e s s C a l l b a c k ( {   t i m e s t a m p :   p . t i m e s t a m p ,   c o o r d s :   {   l a t i t u d e :   p . l a t i t u d e ,   l o n g i t u d e :   p . l o n g i t u d e ,   h e a d i n g :   p . h e a d i n g }   } ) ;   } ,  
                                                 o n F a i l u r e :   f u n c t i o n ( e )   {  
                                                         i f   ( e . e r r o r C o d e   = =   1 )   {  
                                                                 e r r o r C a l l b a c k ( {   c o d e :   3 ,   m e s s a g e :   " T i m e o u t "   } ) ;  
                                                         }  
                                                         e l s e   i f   ( e . e r r o r C o d e   = =   2 )   {  
                                                                 e r r o r C a l l b a c k ( {   c o d e :   2 ,   m e s s a g e :   " P o s i t i o n   U n a v a i l a b l e "   } ) ;  
                                                         }  
                                                         e l s e   {  
                                                                 e r r o r C a l l b a c k ( {   c o d e :   0 ,   m e s s a g e :   " U n k n o w n   E r r o r :   w e b O S - c o d e "   +   e r r o r C o d e   } ) ;  
                                                         }  
                                                 }  
                                         } ) ;  
                                 }  
                         }  
                         e l s e   i f   ( t y p e o f   ( d e v i c e )   ! =   " u n d e f i n e d "   & &   t y p e o f   ( d e v i c e . g e t S e r v i c e O b j e c t )   ! =   " u n d e f i n e d " )   {  
                                 p r o v i d e r   =   d e v i c e . g e t S e r v i c e O b j e c t ( " S e r v i c e . L o c a t i o n " ,   " I L o c a t i o n " ) ;  
                                 / / o v e r r i d e   d e f a u l t   m e t h o d   i m p l e m e n t a t i o n  
                                 p u b . g e t C u r r e n t P o s i t i o n   =   f u n c t i o n ( s u c c e s s C a l l b a c k ,   e r r o r C a l l b a c k ,   o p t i o n s )   {  
                                         f u n c t i o n   c a l l b a c k ( t r a n s I d ,   e v e n t C o d e ,   r e s u l t )   {  
                                                 i f   ( e v e n t C o d e   = =   4 )   {  
                                                         e r r o r C a l l b a c k ( {   m e s s a g e :   " P o s i t i o n   u n a v a i l a b l e " ,   c o d e :   2   } ) ;  
                                                 }  
                                                 e l s e   {  
                                                         / / n o   t i m e s t a m p   o f   l o c a t i o n   g i v e n ?  
                                                         s u c c e s s C a l l b a c k ( {   t i m e s t a m p :   n u l l ,   c o o r d s :   {   l a t i t u d e :   r e s u l t . R e t u r n V a l u e . L a t i t u d e ,   l o n g i t u d e :   r e s u l t . R e t u r n V a l u e . L o n g i t u d e ,   a l t i t u d e :   r e s u l t . R e t u r n V a l u e . A l t i t u d e ,   h e a d i n g :   r e s u l t . R e t u r n V a l u e . H e a d i n g }   } ) ;  
                                                 }  
                                         }  
                                         / / l o c a t i o n   c r i t e r i a  
                                         v a r   c r i t e r i a   =   n e w   O b j e c t ( ) ;  
                                         c r i t e r i a . L o c a t i o n I n f o r m a t i o n C l a s s   =   " B a s i c L o c a t i o n I n f o r m a t i o n " ;  
                                         / / m a k e   t h e   c a l l  
                                         p r o v i d e r . I L o c a t i o n . G e t L o c a t i o n ( c r i t e r i a ,   c a l l b a c k ) ;  
                                 }  
                         }  
                         e l s e   i f   ( t y p e o f   ( w i n d o w . b l a c k b e r r y )   ! =   " u n d e f i n e d "   & &   b l a c k b e r r y . l o c a t i o n . G P S S u p p o r t e d )   {  
                                 / /   s e t   t o   a u t o n o m o u s   m o d e  
                                 i f   ( t y p e o f   ( b l a c k b e r r y . l o c a t i o n . s e t A i d M o d e )   = =   " u n d e f i n e d " )   {  
                                         r e t u r n   f a l s e ;  
                                 }  
                                 b l a c k b e r r y . l o c a t i o n . s e t A i d M o d e ( 2 ) ;  
                                 / / o v e r r i d e   d e f a u l t   m e t h o d   i m p l e m e n t a t i o n  
                                 p u b . g e t C u r r e n t P o s i t i o n   =   f u n c t i o n ( s u c c e s s C a l l b a c k ,   e r r o r C a l l b a c k ,   o p t i o n s )   {  
                                         / / a l e r t ( p a r s e F l o a t ( n a v i g a t o r . a p p V e r s i o n ) ) ;  
                                         / / p a s s i n g   o v e r   c a l l b a c k s   a s   p a r a m e t e r   d i d n ' t   w o r k   c o n s i s t e n t l y  
                                         / / i n   t h e   o n L o c a t i o n U p d a t e   m e t h o d ,   t h a t s   w h y   t h e y   h a v e   t o   b e   s e t  
                                         / / o u t s i d e  
                                         b b _ s u c c e s s C a l l b a c k   =   s u c c e s s C a l l b a c k ;  
                                         b b _ e r r o r C a l l b a c k   =   e r r o r C a l l b a c k ;  
                                         / / f u n c t i o n   n e e d s   t o   b e   a   s t r i n g   a c c o r d i n g   t o  
                                         / / h t t p : / / w w w . t o n y b u n c e . c o m / 2 0 0 8 / 0 5 / 0 8 / B l a c k b e r r y - B r o w s e r - A m p - G P S . a s p x  
                                         i f   ( o p t i o n s [ ' t i m e o u t ' ] )   {  
                                                 b b _ b l a c k b e r r y T i m e o u t _ i d   =   s e t T i m e o u t ( " h a n d l e B l a c k B e r r y L o c a t i o n T i m e o u t ( ) " ,   o p t i o n s [ ' t i m e o u t ' ] ) ;  
                                         }  
                                         / / d e f a u l t   t i m e o u t   w h e n   n o n e   i s   g i v e n   t o   p r e v e n t   a   h a n g i n g   s c r i p t  
                                         e l s e   {  
                                                 b b _ b l a c k b e r r y T i m e o u t _ i d   =   s e t T i m e o u t ( " h a n d l e B l a c k B e r r y L o c a t i o n T i m e o u t ( ) " ,   6 0 0 0 0 ) ;  
                                         }  
                                         b l a c k b e r r y . l o c a t i o n . o n L o c a t i o n U p d a t e ( " h a n d l e B l a c k B e r r y L o c a t i o n ( ) " ) ;  
                                         b l a c k b e r r y . l o c a t i o n . r e f r e s h L o c a t i o n ( ) ;  
                                 }  
                                 p r o v i d e r   =   b l a c k b e r r y . l o c a t i o n ;  
                         }  
                 }  
                 c a t c h   ( e )   {  
                         o b j . c o n s o l e ( e ) ;  
                         r e t u r n   f a l s e ;  
                 }  
                 r e t u r n   p r o v i d e r   ! =   n u l l ;  
         }  
         r e t u r n   p u b ;  
 }   ( ) ;  
  
 ( f u n c t i o n ( $ ,   w i n d o w ,   u n d e f i n e d )   {  
         ' $ : n o m u n g e ' ;   / /   U s e d   b y   Y U I   c o m p r e s s o r .  
  
         / /   R e u s e d   s t r i n g .  
         v a r   s t r _ h a s h c h a n g e   =   ' h a s h c h a n g e ' ,  
  
         / /   M e t h o d   /   o b j e c t   r e f e r e n c e s .  
         d o c   =   d o c u m e n t ,  
         f a k e _ o n h a s h c h a n g e ,  
         s p e c i a l   =   $ . e v e n t . s p e c i a l ,  
  
         / /   D o e s   t h e   b r o w s e r   s u p p o r t   w i n d o w . o n h a s h c h a n g e ?   N o t e   t h a t   I E 8   r u n n i n g   i n  
         / /   I E 7   c o m p a t i b i l i t y   m o d e   r e p o r t s   t r u e   f o r   ' o n h a s h c h a n g e '   i n   w i n d o w ,   e v e n  
         / /   t h o u g h   t h e   e v e n t   i s n ' t   s u p p o r t e d ,   s o   a l s o   t e s t   d o c u m e n t . d o c u m e n t M o d e .  
         d o c _ m o d e   =   d o c . d o c u m e n t M o d e ,  
         s u p p o r t s _ o n h a s h c h a n g e   =   ' o n '   +   s t r _ h a s h c h a n g e   i n   w i n d o w   & &   ( d o c _ m o d e   = = =   u n d e f i n e d   | |   d o c _ m o d e   >   7 ) ;  
  
         / /   G e t   l o c a t i o n . h a s h   ( o r   w h a t   y o u ' d   e x p e c t   l o c a t i o n . h a s h   t o   b e )   s a n s   a n y  
         / /   l e a d i n g   # .   T h a n k s   f o r   m a k i n g   t h i s   n e c e s s a r y ,   F i r e f o x !  
         f u n c t i o n   g e t _ f r a g m e n t ( u r l )   {  
                 u r l   =   u r l   | |   l o c a t i o n . h r e f ;  
                 r e t u r n   ' # '   +   u r l . r e p l a c e ( / ^ [ ^ # ] * # ? ( . * ) $ / ,   ' $ 1 ' ) ;  
         } ;  
  
         / /   M e t h o d :   j Q u e r y . f n . h a s h c h a n g e  
         / /    
         / /   B i n d   a   h a n d l e r   t o   t h e   w i n d o w . o n h a s h c h a n g e   e v e n t   o r   t r i g g e r   a l l   b o u n d  
         / /   w i n d o w . o n h a s h c h a n g e   e v e n t   h a n d l e r s .   T h i s   b e h a v i o r   i s   c o n s i s t e n t   w i t h  
         / /   j Q u e r y ' s   b u i l t - i n   e v e n t   h a n d l e r s .  
         / /    
         / /   U s a g e :  
         / /    
         / /   >   j Q u e r y ( w i n d o w ) . h a s h c h a n g e (   [   h a n d l e r   ]   ) ;  
         / /    
         / /   A r g u m e n t s :  
         / /    
         / /     h a n d l e r   -   ( F u n c t i o n )   O p t i o n a l   h a n d l e r   t o   b e   b o u n d   t o   t h e   h a s h c h a n g e  
         / /         e v e n t .   T h i s   i s   a   " s h o r t c u t "   f o r   t h e   m o r e   v e r b o s e   f o r m :  
         / /         j Q u e r y ( w i n d o w ) . b i n d (   ' h a s h c h a n g e ' ,   h a n d l e r   ) .   I f   h a n d l e r   i s   o m i t t e d ,  
         / /         a l l   b o u n d   w i n d o w . o n h a s h c h a n g e   e v e n t   h a n d l e r s   w i l l   b e   t r i g g e r e d .   T h i s  
         / /         i s   a   s h o r t c u t   f o r   t h e   m o r e   v e r b o s e  
         / /         j Q u e r y ( w i n d o w ) . t r i g g e r (   ' h a s h c h a n g e '   ) .   T h e s e   f o r m s   a r e   d e s c r i b e d   i n  
         / /         t h e   < h a s h c h a n g e   e v e n t >   s e c t i o n .  
         / /    
         / /   R e t u r n s :  
         / /    
         / /     ( j Q u e r y )   T h e   i n i t i a l   j Q u e r y   c o l l e c t i o n   o f   e l e m e n t s .  
  
         / /   A l l o w   t h e   " s h o r t c u t "   f o r m a t   $ ( e l e m ) . h a s h c h a n g e (   f n   )   f o r   b i n d i n g   a n d  
         / /   $ ( e l e m ) . h a s h c h a n g e ( )   f o r   t r i g g e r i n g ,   l i k e   j Q u e r y   d o e s   f o r   b u i l t - i n   e v e n t s .  
         $ . f n [ s t r _ h a s h c h a n g e ]   =   f u n c t i o n ( f n )   {  
                 r e t u r n   f n   ?   t h i s . b i n d ( s t r _ h a s h c h a n g e ,   f n )   :   t h i s . t r i g g e r ( s t r _ h a s h c h a n g e ) ;  
         } ;  
  
         / /   P r o p e r t y :   j Q u e r y . f n . h a s h c h a n g e . d e l a y  
         / /    
         / /   T h e   n u m e r i c   i n t e r v a l   ( i n   m i l l i s e c o n d s )   a t   w h i c h   t h e   < h a s h c h a n g e   e v e n t >  
         / /   p o l l i n g   l o o p   e x e c u t e s .   D e f a u l t s   t o   5 0 .  
  
         / /   P r o p e r t y :   j Q u e r y . f n . h a s h c h a n g e . d o m a i n  
         / /    
         / /   I f   y o u ' r e   s e t t i n g   d o c u m e n t . d o m a i n   i n   y o u r   J a v a S c r i p t ,   a n d   y o u   w a n t   h a s h  
         / /   h i s t o r y   t o   w o r k   i n   I E 6 / 7 ,   n o t   o n l y   m u s t   t h i s   p r o p e r t y   b e   s e t ,   b u t   y o u   m u s t  
         / /   a l s o   s e t   d o c u m e n t . d o m a i n   B E F O R E   j Q u e r y   i s   l o a d e d   i n t o   t h e   p a g e .   T h i s  
         / /   p r o p e r t y   i s   o n l y   a p p l i c a b l e   i f   y o u   a r e   s u p p o r t i n g   I E 6 / 7   ( o r   I E 8   o p e r a t i n g  
         / /   i n   " I E 7   c o m p a t i b i l i t y "   m o d e ) .  
         / /    
         / /   I n   a d d i t i o n ,   t h e   < j Q u e r y . f n . h a s h c h a n g e . s r c >   p r o p e r t y   m u s t   b e   s e t   t o   t h e  
         / /   p a t h   o f   t h e   i n c l u d e d   " d o c u m e n t - d o m a i n . h t m l "   f i l e ,   w h i c h   c a n   b e   r e n a m e d   o r  
         / /   m o d i f i e d   i f   n e c e s s a r y   ( n o t e   t h a t   t h e   d o c u m e n t . d o m a i n   s p e c i f i e d   m u s t   b e   t h e  
         / /   s a m e   i n   b o t h   y o u r   m a i n   J a v a S c r i p t   a s   w e l l   a s   i n   t h i s   f i l e ) .  
         / /    
         / /   U s a g e :  
         / /    
         / /   j Q u e r y . f n . h a s h c h a n g e . d o m a i n   =   d o c u m e n t . d o m a i n ;  
  
         / /   P r o p e r t y :   j Q u e r y . f n . h a s h c h a n g e . s r c  
         / /    
         / /   I f ,   f o r   s o m e   r e a s o n ,   y o u   n e e d   t o   s p e c i f y   a n   I f r a m e   s r c   f i l e   ( f o r   e x a m p l e ,  
         / /   w h e n   s e t t i n g   d o c u m e n t . d o m a i n   a s   i n   < j Q u e r y . f n . h a s h c h a n g e . d o m a i n > ) ,   y o u   c a n  
         / /   d o   s o   u s i n g   t h i s   p r o p e r t y .   N o t e   t h a t   w h e n   u s i n g   t h i s   p r o p e r t y ,   h i s t o r y  
         / /   w o n ' t   b e   r e c o r d e d   i n   I E 6 / 7   u n t i l   t h e   I f r a m e   s r c   f i l e   l o a d s .   T h i s   p r o p e r t y  
         / /   i s   o n l y   a p p l i c a b l e   i f   y o u   a r e   s u p p o r t i n g   I E 6 / 7   ( o r   I E 8   o p e r a t i n g   i n   " I E 7  
         / /   c o m p a t i b i l i t y "   m o d e ) .  
         / /    
         / /   U s a g e :  
         / /    
         / /   j Q u e r y . f n . h a s h c h a n g e . s r c   =   ' p a t h / t o / f i l e . h t m l ' ;  
  
         $ . f n [ s t r _ h a s h c h a n g e ] . d e l a y   =   5 0 ;  
         / *  
         $ . f n [   s t r _ h a s h c h a n g e   ] . d o m a i n   =   n u l l ;  
         $ . f n [   s t r _ h a s h c h a n g e   ] . s r c   =   n u l l ;  
         * /  
  
         / /   E v e n t :   h a s h c h a n g e   e v e n t  
         / /    
         / /   F i r e d   w h e n   l o c a t i o n . h a s h   c h a n g e s .   I n   b r o w s e r s   t h a t   s u p p o r t   i t ,   t h e   n a t i v e  
         / /   H T M L 5   w i n d o w . o n h a s h c h a n g e   e v e n t   i s   u s e d ,   o t h e r w i s e   a   p o l l i n g   l o o p   i s  
         / /   i n i t i a l i z e d ,   r u n n i n g   e v e r y   < j Q u e r y . f n . h a s h c h a n g e . d e l a y >   m i l l i s e c o n d s   t o  
         / /   s e e   i f   t h e   h a s h   h a s   c h a n g e d .   I n   I E 6 / 7   ( a n d   I E 8   o p e r a t i n g   i n   " I E 7  
         / /   c o m p a t i b i l i t y "   m o d e ) ,   a   h i d d e n   I f r a m e   i s   c r e a t e d   t o   a l l o w   t h e   b a c k   b u t t o n  
         / /   a n d   h a s h - b a s e d   h i s t o r y   t o   w o r k .  
         / /    
         / /   U s a g e   a s   d e s c r i b e d   i n   < j Q u e r y . f n . h a s h c h a n g e > :  
         / /    
         / /   >   / /   B i n d   a n   e v e n t   h a n d l e r .  
         / /   >   j Q u e r y ( w i n d o w ) . h a s h c h a n g e (   f u n c t i o n ( e )   {  
         / /   >       v a r   h a s h   =   l o c a t i o n . h a s h ;  
         / /   >       . . .  
         / /   >   } ) ;  
         / /   >    
         / /   >   / /   M a n u a l l y   t r i g g e r   t h e   e v e n t   h a n d l e r .  
         / /   >   j Q u e r y ( w i n d o w ) . h a s h c h a n g e ( ) ;  
         / /    
         / /   A   m o r e   v e r b o s e   u s a g e   t h a t   a l l o w s   f o r   e v e n t   n a m e s p a c i n g :  
         / /    
         / /   >   / /   B i n d   a n   e v e n t   h a n d l e r .  
         / /   >   j Q u e r y ( w i n d o w ) . b i n d (   ' h a s h c h a n g e ' ,   f u n c t i o n ( e )   {  
         / /   >       v a r   h a s h   =   l o c a t i o n . h a s h ;  
         / /   >       . . .  
         / /   >   } ) ;  
         / /   >    
         / /   >   / /   M a n u a l l y   t r i g g e r   t h e   e v e n t   h a n d l e r .  
         / /   >   j Q u e r y ( w i n d o w ) . t r i g g e r (   ' h a s h c h a n g e '   ) ;  
         / /    
         / /   A d d i t i o n a l   N o t e s :  
         / /    
         / /   *   T h e   p o l l i n g   l o o p   a n d   I f r a m e   a r e   n o t   c r e a t e d   u n t i l   a t   l e a s t   o n e   h a n d l e r  
         / /       i s   a c t u a l l y   b o u n d   t o   t h e   ' h a s h c h a n g e '   e v e n t .  
         / /   *   I f   y o u   n e e d   t h e   b o u n d   h a n d l e r ( s )   t o   e x e c u t e   i m m e d i a t e l y ,   i n   c a s e s   w h e r e  
         / /       a   l o c a t i o n . h a s h   e x i s t s   o n   p a g e   l o a d ,   v i a   b o o k m a r k   o r   p a g e   r e f r e s h   f o r  
         / /       e x a m p l e ,   u s e   j Q u e r y ( w i n d o w ) . h a s h c h a n g e ( )   o r   t h e   m o r e   v e r b o s e    
         / /       j Q u e r y ( w i n d o w ) . t r i g g e r (   ' h a s h c h a n g e '   ) .  
         / /   *   T h e   e v e n t   c a n   b e   b o u n d   b e f o r e   D O M   r e a d y ,   b u t   s i n c e   i t   w o n ' t   b e   u s a b l e  
         / /       b e f o r e   t h e n   i n   I E 6 / 7   ( d u e   t o   t h e   n e c e s s a r y   I f r a m e ) ,   r e c o m m e n d e d   u s a g e   i s  
         / /       t o   b i n d   i t   i n s i d e   a   D O M   r e a d y   h a n d l e r .  
  
         / /   O v e r r i d e   e x i s t i n g   $ . e v e n t . s p e c i a l . h a s h c h a n g e   m e t h o d s   ( a l l o w i n g   t h i s   p l u g i n  
         / /   t o   b e   d e f i n e d   a f t e r   j Q u e r y   B B Q   i n   B B Q ' s   s o u r c e   c o d e ) .  
         s p e c i a l [ s t r _ h a s h c h a n g e ]   =   $ . e x t e n d ( s p e c i a l [ s t r _ h a s h c h a n g e ] ,   {  
  
                 / /   C a l l e d   o n l y   w h e n   t h e   f i r s t   ' h a s h c h a n g e '   e v e n t   i s   b o u n d   t o   w i n d o w .  
                 s e t u p :   f u n c t i o n ( )   {  
                         / /   I f   w i n d o w . o n h a s h c h a n g e   i s   s u p p o r t e d   n a t i v e l y ,   t h e r e ' s   n o t h i n g   t o   d o . .  
                         i f   ( s u p p o r t s _ o n h a s h c h a n g e )   {   r e t u r n   f a l s e ;   }  
  
                         / /   O t h e r w i s e ,   w e   n e e d   t o   c r e a t e   o u r   o w n .   A n d   w e   d o n ' t   w a n t   t o   c a l l   t h i s  
                         / /   u n t i l   t h e   u s e r   b i n d s   t o   t h e   e v e n t ,   j u s t   i n   c a s e   t h e y   n e v e r   d o ,   s i n c e   i t  
                         / /   w i l l   c r e a t e   a   p o l l i n g   l o o p   a n d   p o s s i b l y   e v e n   a   h i d d e n   I f r a m e .  
                         $ ( f a k e _ o n h a s h c h a n g e . s t a r t ) ;  
                 } ,  
  
                 / /   C a l l e d   o n l y   w h e n   t h e   l a s t   ' h a s h c h a n g e '   e v e n t   i s   u n b o u n d   f r o m   w i n d o w .  
                 t e a r d o w n :   f u n c t i o n ( )   {  
                         / /   I f   w i n d o w . o n h a s h c h a n g e   i s   s u p p o r t e d   n a t i v e l y ,   t h e r e ' s   n o t h i n g   t o   d o . .  
                         i f   ( s u p p o r t s _ o n h a s h c h a n g e )   {   r e t u r n   f a l s e ;   }  
  
                         / /   O t h e r w i s e ,   w e   n e e d   t o   s t o p   o u r s   ( i f   p o s s i b l e ) .  
                         $ ( f a k e _ o n h a s h c h a n g e . s t o p ) ;  
                 }  
  
         } ) ;  
  
         / /   f a k e _ o n h a s h c h a n g e   d o e s   a l l   t h e   w o r k   o f   t r i g g e r i n g   t h e   w i n d o w . o n h a s h c h a n g e  
         / /   e v e n t   f o r   b r o w s e r s   t h a t   d o n ' t   n a t i v e l y   s u p p o r t   i t ,   i n c l u d i n g   c r e a t i n g   a  
         / /   p o l l i n g   l o o p   t o   w a t c h   f o r   h a s h   c h a n g e s   a n d   i n   I E   6 / 7   c r e a t i n g   a   h i d d e n  
         / /   I f r a m e   t o   e n a b l e   b a c k   a n d   f o r w a r d .  
         f a k e _ o n h a s h c h a n g e   =   ( f u n c t i o n ( )   {  
                 v a r   s e l f   =   { } ,  
             t i m e o u t _ i d ,  
  
                 / /   R e m e m b e r   t h e   i n i t i a l   h a s h   s o   i t   d o e s n ' t   g e t   t r i g g e r e d   i m m e d i a t e l y .  
             l a s t _ h a s h   =   g e t _ f r a g m e n t ( ) ,  
  
             f n _ r e t v a l   =   f u n c t i o n ( v a l )   {   r e t u r n   v a l ;   } ,  
             h i s t o r y _ s e t   =   f n _ r e t v a l ,  
             h i s t o r y _ g e t   =   f n _ r e t v a l ;  
  
                 / /   S t a r t   t h e   p o l l i n g   l o o p .  
                 s e l f . s t a r t   =   f u n c t i o n ( )   {  
                         t i m e o u t _ i d   | |   p o l l ( ) ;  
                 } ;  
  
                 / /   S t o p   t h e   p o l l i n g   l o o p .  
                 s e l f . s t o p   =   f u n c t i o n ( )   {  
                         t i m e o u t _ i d   & &   c l e a r T i m e o u t ( t i m e o u t _ i d ) ;  
                         t i m e o u t _ i d   =   u n d e f i n e d ;  
                 } ;  
  
                 / /   T h i s   p o l l i n g   l o o p   c h e c k s   e v e r y   $ . f n . h a s h c h a n g e . d e l a y   m i l l i s e c o n d s   t o   s e e  
                 / /   i f   l o c a t i o n . h a s h   h a s   c h a n g e d ,   a n d   t r i g g e r s   t h e   ' h a s h c h a n g e '   e v e n t   o n  
                 / /   w i n d o w   w h e n   n e c e s s a r y .  
                 f u n c t i o n   p o l l ( )   {  
                         v a r   h a s h   =   g e t _ f r a g m e n t ( ) ,  
                 h i s t o r y _ h a s h   =   h i s t o r y _ g e t ( l a s t _ h a s h ) ;  
  
                         i f   ( h a s h   ! = =   l a s t _ h a s h )   {  
                                 h i s t o r y _ s e t ( l a s t _ h a s h   =   h a s h ,   h i s t o r y _ h a s h ) ;  
  
                                 $ ( w i n d o w ) . t r i g g e r ( s t r _ h a s h c h a n g e ) ;  
  
                         }   e l s e   i f   ( h i s t o r y _ h a s h   ! = =   l a s t _ h a s h )   {  
                                 l o c a t i o n . h r e f   =   l o c a t i o n . h r e f . r e p l a c e ( / # . * / ,   ' ' )   +   h i s t o r y _ h a s h ;  
                         }  
  
                         t i m e o u t _ i d   =   s e t T i m e o u t ( p o l l ,   $ . f n [ s t r _ h a s h c h a n g e ] . d e l a y ) ;  
                 } ;  
  
                 / /   v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v  
                 / /   v v v v v v v v v v v v v v v v v v v   R E M O V E   I F   N O T   S U P P O R T I N G   I E 6 / 7 / 8   v v v v v v v v v v v v v v v v v v v  
                 / /   v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v v  
                 $ . b r o w s e r . m s i e   & &   ! s u p p o r t s _ o n h a s h c h a n g e   & &   ( f u n c t i o n ( )   {  
                         / /   N o t   o n l y   d o   I E 6 / 7   n e e d   t h e   " m a g i c a l "   I f r a m e   t r e a t m e n t ,   b u t   s o   d o e s   I E 8  
                         / /   w h e n   r u n n i n g   i n   " I E 7   c o m p a t i b i l i t y "   m o d e .  
  
                         v a r   i f r a m e ,  
                 i f r a m e _ s r c ;  
  
                         / /   W h e n   t h e   e v e n t   i s   b o u n d   a n d   p o l l i n g   s t a r t s   i n   I E   6 / 7 ,   c r e a t e   a   h i d d e n  
                         / /   I f r a m e   f o r   h i s t o r y   h a n d l i n g .  
                         s e l f . s t a r t   =   f u n c t i o n ( )   {  
                                 i f   ( ! i f r a m e )   {  
                                         i f r a m e _ s r c   =   $ . f n [ s t r _ h a s h c h a n g e ] . s r c ;  
                                         i f r a m e _ s r c   =   i f r a m e _ s r c   & &   i f r a m e _ s r c   +   g e t _ f r a g m e n t ( ) ;  
  
                                         / /   C r e a t e   h i d d e n   I f r a m e .   A t t e m p t   t o   m a k e   I f r a m e   a s   h i d d e n   a s   p o s s i b l e  
                                         / /   b y   u s i n g   t e c h n i q u e s   f r o m   h t t p : / / w w w . p a c i e l l o g r o u p . c o m / b l o g / ? p = 6 0 4 .  
                                         i f r a m e   =   $ ( ' < i f r a m e   t a b i n d e x = " - 1 "   t i t l e = " e m p t y " > < / d i v > ' ) . h i d e ( )  
  
                                         / /   W h e n   I f r a m e   h a s   c o m p l e t e l y   l o a d e d ,   i n i t i a l i z e   t h e   h i s t o r y   a n d  
                                         / /   s t a r t   p o l l i n g .  
                         . o n e ( ' l o a d ' ,   f u n c t i o n ( )   {  
                                 i f r a m e _ s r c   | |   h i s t o r y _ s e t ( g e t _ f r a g m e n t ( ) ) ;  
                                 p o l l ( ) ;  
                         } )  
  
                                         / /   L o a d   I f r a m e   s r c   i f   s p e c i f i e d ,   o t h e r w i s e   n o t h i n g .  
                         . a t t r ( ' s r c ' ,   i f r a m e _ s r c   | |   ' j a v a s c r i p t : 0 ' )  
  
                                         / /   A p p e n d   I f r a m e   a f t e r   t h e   e n d   o f   t h e   b o d y   t o   p r e v e n t   u n n e c e s s a r y  
                                         / /   i n i t i a l   p a g e   s c r o l l i n g   ( y e s ,   t h i s   w o r k s ) .  
                         . i n s e r t A f t e r ( ' b o d y ' ) [ 0 ] . c o n t e n t W i n d o w ;  
  
                                         / /   W h e n e v e r   ` d o c u m e n t . t i t l e `   c h a n g e s ,   u p d a t e   t h e   I f r a m e ' s   t i t l e   t o  
                                         / /   p r e t t i f y   t h e   b a c k / n e x t   h i s t o r y   m e n u   e n t r i e s .   S i n c e   I E   s o m e t i m e s  
                                         / /   e r r o r s   w i t h   " U n s p e c i f i e d   e r r o r "   t h e   v e r y   f i r s t   t i m e   t h i s   i s   s e t  
                                         / /   ( y e s ,   v e r y   u s e f u l )   w r a p   t h i s   w i t h   a   t r y / c a t c h   b l o c k .  
                                         d o c . o n p r o p e r t y c h a n g e   =   f u n c t i o n ( )   {  
                                                 t r y   {  
                                                         i f   ( e v e n t . p r o p e r t y N a m e   = = =   ' t i t l e ' )   {  
                                                                 i f r a m e . d o c u m e n t . t i t l e   =   d o c . t i t l e ;  
                                                         }  
                                                 }   c a t c h   ( e )   {   }  
                                         } ;  
  
                                 }  
                         } ;  
  
                         / /   O v e r r i d e   t h e   " s t o p "   m e t h o d   s i n c e   a n   I E 6 / 7   I f r a m e   w a s   c r e a t e d .   E v e n  
                         / /   i f   t h e r e   a r e   n o   l o n g e r   a n y   b o u n d   e v e n t   h a n d l e r s ,   t h e   p o l l i n g   l o o p  
                         / /   i s   s t i l l   n e c e s s a r y   f o r   b a c k / n e x t   t o   w o r k   a t   a l l !  
                         s e l f . s t o p   =   f n _ r e t v a l ;  
  
                         / /   G e t   h i s t o r y   b y   l o o k i n g   a t   t h e   h i d d e n   I f r a m e ' s   l o c a t i o n . h a s h .  
                         h i s t o r y _ g e t   =   f u n c t i o n ( )   {  
                                 r e t u r n   g e t _ f r a g m e n t ( i f r a m e . l o c a t i o n . h r e f ) ;  
                         } ;  
  
                         / /   S e t   a   n e w   h i s t o r y   i t e m   b y   o p e n i n g   a n d   t h e n   c l o s i n g   t h e   I f r a m e  
                         / /   d o c u m e n t ,   * t h e n *   s e t t i n g   i t s   l o c a t i o n . h a s h .   I f   d o c u m e n t . d o m a i n   h a s  
                         / /   b e e n   s e t ,   u p d a t e   t h a t   a s   w e l l .  
                         h i s t o r y _ s e t   =   f u n c t i o n ( h a s h ,   h i s t o r y _ h a s h )   {  
                                 v a r   i f r a m e _ d o c   =   i f r a m e . d o c u m e n t ,  
                     d o m a i n   =   $ . f n [ s t r _ h a s h c h a n g e ] . d o m a i n ;  
  
                                 i f   ( h a s h   ! = =   h i s t o r y _ h a s h )   {  
                                         / /   U p d a t e   I f r a m e   w i t h   a n y   i n i t i a l   ` d o c u m e n t . t i t l e `   t h a t   m i g h t   b e   s e t .  
                                         i f r a m e _ d o c . t i t l e   =   d o c . t i t l e ;  
  
                                         / /   O p e n i n g   t h e   I f r a m e ' s   d o c u m e n t   a f t e r   i t   h a s   b e e n   c l o s e d   i s   w h a t  
                                         / /   a c t u a l l y   a d d s   a   h i s t o r y   e n t r y .  
                                         i f r a m e _ d o c . o p e n ( ) ;  
  
                                         / /   S e t   d o c u m e n t . d o m a i n   f o r   t h e   I f r a m e   d o c u m e n t   a s   w e l l ,   i f   n e c e s s a r y .  
                                         d o m a i n   & &   i f r a m e _ d o c . w r i t e ( ' < s c r i p t > d o c u m e n t . d o m a i n = " '   +   d o m a i n   +   ' " < / s c r i p t > ' ) ;  
  
                                         i f r a m e _ d o c . c l o s e ( ) ;  
  
                                         / /   U p d a t e   t h e   I f r a m e ' s   h a s h ,   f o r   g r e a t   j u s t i c e .  
                                         i f r a m e . l o c a t i o n . h a s h   =   h a s h ;  
                                 }  
                         } ;  
  
                 } ) ( ) ;  
                 / /   ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^  
                 / /   ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^   R E M O V E   I F   N O T   S U P P O R T I N G   I E 6 / 7 / 8   ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^  
                 / /   ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^  
  
                 r e t u r n   s e l f ;  
         } ) ( ) ;  
  
 } ) ( j Q u e r y ,   t h i s ) ;  
  
  
  
 ( f u n c t i o n ( $ )   {  
         $ . t o J S O N   =   f u n c t i o n ( o )   {  
                 i f   ( t y p e o f   ( J S O N )   = =   ' o b j e c t '   & &   J S O N . s t r i n g i f y )  
                         r e t u r n   J S O N . s t r i n g i f y ( o ) ;   v a r   t y p e   =   t y p e o f   ( o ) ;   i f   ( o   = = =   n u l l )  
                         r e t u r n   " n u l l " ;   i f   ( t y p e   = =   " u n d e f i n e d " )  
                         r e t u r n   u n d e f i n e d ;   i f   ( t y p e   = =   " n u m b e r "   | |   t y p e   = =   " b o o l e a n " )  
                         r e t u r n   o   +   " " ;   i f   ( t y p e   = =   " s t r i n g " )  
                         r e t u r n   $ . q u o t e S t r i n g ( o ) ;   i f   ( t y p e   = =   ' o b j e c t ' )   {  
                         i f   ( t y p e o f   o . t o J S O N   = =   " f u n c t i o n " )  
                                 r e t u r n   $ . t o J S O N ( o . t o J S O N ( ) ) ;   i f   ( o . c o n s t r u c t o r   = = =   D a t e )   {  
                                 v a r   m o n t h   =   o . g e t U T C M o n t h ( )   +   1 ;   i f   ( m o n t h   <   1 0 )   m o n t h   =   ' 0 '   +   m o n t h ;   v a r   d a y   =   o . g e t U T C D a t e ( ) ;   i f   ( d a y   <   1 0 )   d a y   =   ' 0 '   +   d a y ;   v a r   y e a r   =   o . g e t U T C F u l l Y e a r ( ) ;   v a r   h o u r s   =   o . g e t U T C H o u r s ( ) ;   i f   ( h o u r s   <   1 0 )   h o u r s   =   ' 0 '   +   h o u r s ;   v a r   m i n u t e s   =   o . g e t U T C M i n u t e s ( ) ;   i f   ( m i n u t e s   <   1 0 )   m i n u t e s   =   ' 0 '   +   m i n u t e s ;   v a r   s e c o n d s   =   o . g e t U T C S e c o n d s ( ) ;   i f   ( s e c o n d s   <   1 0 )   s e c o n d s   =   ' 0 '   +   s e c o n d s ;   v a r   m i l l i   =   o . g e t U T C M i l l i s e c o n d s ( ) ;   i f   ( m i l l i   <   1 0 0 )   m i l l i   =   ' 0 '   +   m i l l i ;   i f   ( m i l l i   <   1 0 )   m i l l i   =   ' 0 '   +   m i l l i ;   r e t u r n   ' " '   +   y e a r   +   ' - '   +   m o n t h   +   ' - '   +   d a y   +   ' T '   +  
 h o u r s   +   ' : '   +   m i n u t e s   +   ' : '   +   s e c o n d s   +   ' . '   +   m i l l i   +   ' Z " ' ;  
                         }  
                         i f   ( o . c o n s t r u c t o r   = = =   A r r a y )   {  
                                 v a r   r e t   =   [ ] ;   f o r   ( v a r   i   =   0 ;   i   <   o . l e n g t h ;   i + + )  
                                         r e t . p u s h ( $ . t o J S O N ( o [ i ] )   | |   " n u l l " ) ;   r e t u r n   " [ "   +   r e t . j o i n ( " , " )   +   " ] " ;  
                         }  
                         v a r   p a i r s   =   [ ] ;   f o r   ( v a r   k   i n   o )   {  
                                 v a r   n a m e ;   v a r   t y p e   =   t y p e o f   k ;   i f   ( t y p e   = =   " n u m b e r " )  
                                         n a m e   =   ' " '   +   k   +   ' " ' ;   e l s e   i f   ( t y p e   = =   " s t r i n g " )  
                                         n a m e   =   $ . q u o t e S t r i n g ( k ) ;   e l s e  
                                         c o n t i n u e ;   i f   ( t y p e o f   o [ k ]   = =   " f u n c t i o n " )  
                                         c o n t i n u e ;   v a r   v a l   =   $ . t o J S O N ( o [ k ] ) ;   p a i r s . p u s h ( n a m e   +   " : "   +   v a l ) ;  
                         }  
                         r e t u r n   " { "   +   p a i r s . j o i n ( " ,   " )   +   " } " ;  
                 }  
         } ;   $ . e v a l J S O N   =   f u n c t i o n ( s r c )   {  
                 i f   ( t y p e o f   ( J S O N )   = =   ' o b j e c t '   & &   J S O N . p a r s e )  
                         r e t u r n   J S O N . p a r s e ( s r c ) ;   r e t u r n   e v a l ( " ( "   +   s r c   +   " ) " ) ;  
         } ;   $ . s e c u r e E v a l J S O N   =   f u n c t i o n ( s r c )   {  
                 i f   ( t y p e o f   ( J S O N )   = =   ' o b j e c t '   & &   J S O N . p a r s e )  
                         r e t u r n   J S O N . p a r s e ( s r c ) ;   v a r   f i l t e r e d   =   s r c ;   f i l t e r e d   =   f i l t e r e d . r e p l a c e ( / \ \ [ " \ \ \ / b f n r t u ] / g ,   ' @ ' ) ;   f i l t e r e d   =   f i l t e r e d . r e p l a c e ( / " [ ^ " \ \ \ n \ r ] * " | t r u e | f a l s e | n u l l | - ? \ d + ( ? : \ . \ d * ) ? ( ? : [ e E ] [ + \ - ] ? \ d + ) ? / g ,   ' ] ' ) ;   f i l t e r e d   =   f i l t e r e d . r e p l a c e ( / ( ? : ^ | : | , ) ( ? : \ s * \ [ ) + / g ,   ' ' ) ;   i f   ( / ^ [ \ ] , : { } \ s ] * $ / . t e s t ( f i l t e r e d ) )  
                         r e t u r n   e v a l ( " ( "   +   s r c   +   " ) " ) ;   e l s e  
                         t h r o w   n e w   S y n t a x E r r o r ( " E r r o r   p a r s i n g   J S O N ,   s o u r c e   i s   n o t   v a l i d . " ) ;  
         } ;   $ . q u o t e S t r i n g   =   f u n c t i o n ( s t r i n g )   {  
                 i f   ( s t r i n g . m a t c h ( _ e s c a p e a b l e ) )   {  
                         r e t u r n   ' " '   +   s t r i n g . r e p l a c e ( _ e s c a p e a b l e ,   f u n c t i o n ( a )  
                         {   v a r   c   =   _ m e t a [ a ] ;   i f   ( t y p e o f   c   = = =   ' s t r i n g ' )   r e t u r n   c ;   c   =   a . c h a r C o d e A t ( ) ;   r e t u r n   ' \ \ u 0 0 '   +   M a t h . f l o o r ( c   /   1 6 ) . t o S t r i n g ( 1 6 )   +   ( c   %   1 6 ) . t o S t r i n g ( 1 6 ) ;   } )   +   ' " ' ;  
                 }  
                 r e t u r n   ' " '   +   s t r i n g   +   ' " ' ;  
         } ;   v a r   _ e s c a p e a b l e   =   / [ " \ \ \ x 0 0 - \ x 1 f \ x 7 f - \ x 9 f ] / g ;   v a r   _ m e t a   =   {   ' \ b ' :   ' \ \ b ' ,   ' \ t ' :   ' \ \ t ' ,   ' \ n ' :   ' \ \ n ' ,   ' \ f ' :   ' \ \ f ' ,   ' \ r ' :   ' \ \ r ' ,   ' " ' :   ' \ \ " ' ,   ' \ \ ' :   ' \ \ \ \ '   } ;  
 } ) ( j Q u e r y ) ;  
  
  
 / * j s l i n t   b r o w s e r :   t r u e   * /   / * g l o b a l   j Q u e r y :   t r u e   * /  
  
 / * *  
 *   j Q u e r y   C o o k i e   p l u g i n  
 *  
 *   C o p y r i g h t   ( c )   2 0 1 0   K l a u s   H a r t l   ( s t i l b u e r o . d e )  
 *   D u a l   l i c e n s e d   u n d e r   t h e   M I T   a n d   G P L   l i c e n s e s :  
 *   h t t p : / / w w w . o p e n s o u r c e . o r g / l i c e n s e s / m i t - l i c e n s e . p h p  
 *   h t t p : / / w w w . g n u . o r g / l i c e n s e s / g p l . h t m l  
 *  
 * /  
  
 / /   T O D O   J s D o c  
  
 / * *  
 *   C r e a t e   a   c o o k i e   w i t h   t h e   g i v e n   k e y   a n d   v a l u e   a n d   o t h e r   o p t i o n a l   p a r a m e t e r s .  
 *  
 *   @ e x a m p l e   $ . c o o k i e ( ' t h e _ c o o k i e ' ,   ' t h e _ v a l u e ' ) ;  
 *   @ d e s c   S e t   t h e   v a l u e   o f   a   c o o k i e .  
 *   @ e x a m p l e   $ . c o o k i e ( ' t h e _ c o o k i e ' ,   ' t h e _ v a l u e ' ,   {   e x p i r e s :   7 ,   p a t h :   ' / ' ,   d o m a i n :   ' j q u e r y . c o m ' ,   s e c u r e :   t r u e   } ) ;  
 *   @ d e s c   C r e a t e   a   c o o k i e   w i t h   a l l   a v a i l a b l e   o p t i o n s .  
 *   @ e x a m p l e   $ . c o o k i e ( ' t h e _ c o o k i e ' ,   ' t h e _ v a l u e ' ) ;  
 *   @ d e s c   C r e a t e   a   s e s s i o n   c o o k i e .  
 *   @ e x a m p l e   $ . c o o k i e ( ' t h e _ c o o k i e ' ,   n u l l ) ;  
 *   @ d e s c   D e l e t e   a   c o o k i e   b y   p a s s i n g   n u l l   a s   v a l u e .   K e e p   i n   m i n d   t h a t   y o u   h a v e   t o   u s e   t h e   s a m e   p a t h   a n d   d o m a i n  
 *               u s e d   w h e n   t h e   c o o k i e   w a s   s e t .  
 *  
 *   @ p a r a m   S t r i n g   k e y   T h e   k e y   o f   t h e   c o o k i e .  
 *   @ p a r a m   S t r i n g   v a l u e   T h e   v a l u e   o f   t h e   c o o k i e .  
 *   @ p a r a m   O b j e c t   o p t i o n s   A n   o b j e c t   l i t e r a l   c o n t a i n i n g   k e y / v a l u e   p a i r s   t o   p r o v i d e   o p t i o n a l   c o o k i e   a t t r i b u t e s .  
 *   @ o p t i o n   N u m b e r | D a t e   e x p i r e s   E i t h e r   a n   i n t e g e r   s p e c i f y i n g   t h e   e x p i r a t i o n   d a t e   f r o m   n o w   o n   i n   d a y s   o r   a   D a t e   o b j e c t .  
 *                                                           I f   a   n e g a t i v e   v a l u e   i s   s p e c i f i e d   ( e . g .   a   d a t e   i n   t h e   p a s t ) ,   t h e   c o o k i e   w i l l   b e   d e l e t e d .  
 *                                                           I f   s e t   t o   n u l l   o r   o m i t t e d ,   t h e   c o o k i e   w i l l   b e   a   s e s s i o n   c o o k i e   a n d   w i l l   n o t   b e   r e t a i n e d  
 *                                                           w h e n   t h e   t h e   b r o w s e r   e x i t s .  
 *   @ o p t i o n   S t r i n g   p a t h   T h e   v a l u e   o f   t h e   p a t h   a t r i b u t e   o f   t h e   c o o k i e   ( d e f a u l t :   p a t h   o f   p a g e   t h a t   c r e a t e d   t h e   c o o k i e ) .  
 *   @ o p t i o n   S t r i n g   d o m a i n   T h e   v a l u e   o f   t h e   d o m a i n   a t t r i b u t e   o f   t h e   c o o k i e   ( d e f a u l t :   d o m a i n   o f   p a g e   t h a t   c r e a t e d   t h e   c o o k i e ) .  
 *   @ o p t i o n   B o o l e a n   s e c u r e   I f   t r u e ,   t h e   s e c u r e   a t t r i b u t e   o f   t h e   c o o k i e   w i l l   b e   s e t   a n d   t h e   c o o k i e   t r a n s m i s s i o n   w i l l  
 *                                                 r e q u i r e   a   s e c u r e   p r o t o c o l   ( l i k e   H T T P S ) .  
 *   @ t y p e   u n d e f i n e d  
 *  
 *   @ n a m e   $ . c o o k i e  
 *   @ c a t   P l u g i n s / C o o k i e  
 *   @ a u t h o r   K l a u s   H a r t l / k l a u s . h a r t l @ s t i l b u e r o . d e  
 * /  
  
 / * *  
 *   G e t   t h e   v a l u e   o f   a   c o o k i e   w i t h   t h e   g i v e n   k e y .  
 *  
 *   @ e x a m p l e   $ . c o o k i e ( ' t h e _ c o o k i e ' ) ;  
 *   @ d e s c   G e t   t h e   v a l u e   o f   a   c o o k i e .  
 *  
 *   @ p a r a m   S t r i n g   k e y   T h e   k e y   o f   t h e   c o o k i e .  
 *   @ r e t u r n   T h e   v a l u e   o f   t h e   c o o k i e .  
 *   @ t y p e   S t r i n g  
 *  
 *   @ n a m e   $ . c o o k i e  
 *   @ c a t   P l u g i n s / C o o k i e  
 *   @ a u t h o r   K l a u s   H a r t l / k l a u s . h a r t l @ s t i l b u e r o . d e  
 * /  
 j Q u e r y . c o o k i e   =   f u n c t i o n ( k e y ,   v a l u e ,   o p t i o n s )   {  
  
         / /   k e y   a n d   a t   l e a s t   v a l u e   g i v e n ,   s e t   c o o k i e . . .  
         i f   ( a r g u m e n t s . l e n g t h   >   1   & &   S t r i n g ( v a l u e )   ! = =   " [ o b j e c t   O b j e c t ] " )   {  
                 o p t i o n s   =   j Q u e r y . e x t e n d ( { } ,   o p t i o n s ) ;  
  
                 i f   ( v a l u e   = = =   n u l l   | |   v a l u e   = = =   u n d e f i n e d )   {  
                         o p t i o n s . e x p i r e s   =   - 1 ;  
                 }  
  
                 i f   ( t y p e o f   o p t i o n s . e x p i r e s   = = =   ' n u m b e r ' )   {  
                         v a r   d a y s   =   o p t i o n s . e x p i r e s ,   t   =   o p t i o n s . e x p i r e s   =   n e w   D a t e ( ) ;  
                         t . s e t D a t e ( t . g e t D a t e ( )   +   d a y s ) ;  
                 }  
  
                 v a l u e   =   S t r i n g ( v a l u e ) ;  
  
                 r e t u r n   ( d o c u m e n t . c o o k i e   =   [  
                         e n c o d e U R I C o m p o n e n t ( k e y ) ,   ' = ' ,  
                         o p t i o n s . r a w   ?   v a l u e   :   e n c o d e U R I C o m p o n e n t ( v a l u e ) ,  
                         o p t i o n s . e x p i r e s   ?   ' ;   e x p i r e s = '   +   o p t i o n s . e x p i r e s . t o U T C S t r i n g ( )   :   ' ' ,   / /   u s e   e x p i r e s   a t t r i b u t e ,   m a x - a g e   i s   n o t   s u p p o r t e d   b y   I E  
                         o p t i o n s . p a t h   ?   ' ;   p a t h = '   +   o p t i o n s . p a t h   :   ' ' ,  
                         o p t i o n s . d o m a i n   ?   ' ;   d o m a i n = '   +   o p t i o n s . d o m a i n   :   ' ' ,  
                         o p t i o n s . s e c u r e   ?   ' ;   s e c u r e '   :   ' '  
                 ] . j o i n ( ' ' ) ) ;  
         }  
  
         / /   k e y   a n d   p o s s i b l y   o p t i o n s   g i v e n ,   g e t   c o o k i e . . .  
         o p t i o n s   =   v a l u e   | |   { } ;  
         v a r   r e s u l t ,   d e c o d e   =   o p t i o n s . r a w   ?   f u n c t i o n ( s )   {   r e t u r n   s ;   }   :   d e c o d e U R I C o m p o n e n t ;  
         r e t u r n   ( r e s u l t   =   n e w   R e g E x p ( ' ( ? : ^ | ;   ) '   +   e n c o d e U R I C o m p o n e n t ( k e y )   +   ' = ( [ ^ ; ] * ) ' ) . e x e c ( d o c u m e n t . c o o k i e ) )   ?   d e c o d e ( r e s u l t [ 1 ] )   :   n u l l ;  
 } ;  
  
 j Q u e r y . q u e r y   =   {   n u m b e r s :   f a l s e   } ;  
  
 / * *  
 *   j Q u e r y . q u e r y   -   Q u e r y   S t r i n g   M o d i f i c a t i o n   a n d   C r e a t i o n   f o r   j Q u e r y  
 *   W r i t t e n   b y   B l a i r   M i t c h e l m o r e   ( b l a i r   D O T   m i t c h e l m o r e   A T   g m a i l   D O T   c o m )  
 *   L i c e n s e d   u n d e r   t h e   W T F P L   ( h t t p : / / s a m . z o y . o r g / w t f p l / ) .  
 *   D a t e :   2 0 0 9 / 8 / 1 3  
 *  
 *   @ a u t h o r   B l a i r   M i t c h e l m o r e  
 *   @ v e r s i o n   2 . 1 . 7  
 *  
 * * /  
 n e w   f u n c t i o n ( s e t t i n g s )   {  
         / /   V a r i o u s   S e t t i n g s  
         v a r   $ s e p a r a t o r   =   s e t t i n g s . s e p a r a t o r   | |   ' & ' ;  
         v a r   $ s p a c e s   =   s e t t i n g s . s p a c e s   = = =   f a l s e   ?   f a l s e   :   t r u e ;  
         v a r   $ s u f f i x   =   s e t t i n g s . s u f f i x   = = =   f a l s e   ?   ' '   :   ' [ ] ' ;  
         v a r   $ p r e f i x   =   s e t t i n g s . p r e f i x   = = =   f a l s e   ?   f a l s e   :   t r u e ;  
         v a r   $ h a s h   =   $ p r e f i x   ?   s e t t i n g s . h a s h   = = =   t r u e   ?   " # "   :   " ? "   :   " " ;  
         v a r   $ n u m b e r s   =   s e t t i n g s . n u m b e r s   = = =   f a l s e   ?   f a l s e   :   t r u e ;  
  
         j Q u e r y . q u e r y   =   n e w   f u n c t i o n ( )   {  
                 v a r   i s   =   f u n c t i o n ( o ,   t )   {  
                         r e t u r n   o   ! =   u n d e f i n e d   & &   o   ! = =   n u l l   & &   ( ! ! t   ?   o . c o n s t r u c t o r   = =   t   :   t r u e ) ;  
                 } ;  
                 v a r   p a r s e   =   f u n c t i o n ( p a t h )   {  
                         v a r   m ,   r x   =   / \ [ ( [ ^ [ ] * ) \ ] / g ,   m a t c h   =   / ^ ( [ ^ [ ] + ) ( \ [ . * \ ] ) ? $ / . e x e c ( p a t h ) ,   b a s e   =   m a t c h [ 1 ] ,   t o k e n s   =   [ ] ;  
                         w h i l e   ( m   =   r x . e x e c ( m a t c h [ 2 ] ) )   t o k e n s . p u s h ( m [ 1 ] ) ;  
                         r e t u r n   [ b a s e ,   t o k e n s ] ;  
                 } ;  
                 v a r   s e t   =   f u n c t i o n ( t a r g e t ,   t o k e n s ,   v a l u e )   {  
                         v a r   o ,   t o k e n   =   t o k e n s . s h i f t ( ) ;  
                         i f   ( t y p e o f   t a r g e t   ! =   ' o b j e c t ' )   t a r g e t   =   n u l l ;  
                         i f   ( t o k e n   = = =   " " )   {  
                                 i f   ( ! t a r g e t )   t a r g e t   =   [ ] ;  
                                 i f   ( i s ( t a r g e t ,   A r r a y ) )   {  
                                         t a r g e t . p u s h ( t o k e n s . l e n g t h   = =   0   ?   v a l u e   :   s e t ( n u l l ,   t o k e n s . s l i c e ( 0 ) ,   v a l u e ) ) ;  
                                 }   e l s e   i f   ( i s ( t a r g e t ,   O b j e c t ) )   {  
                                         v a r   i   =   0 ;  
                                         w h i l e   ( t a r g e t [ i + + ]   ! =   n u l l ) ;  
                                         t a r g e t [ - - i ]   =   t o k e n s . l e n g t h   = =   0   ?   v a l u e   :   s e t ( t a r g e t [ i ] ,   t o k e n s . s l i c e ( 0 ) ,   v a l u e ) ;  
                                 }   e l s e   {  
                                         t a r g e t   =   [ ] ;  
                                         t a r g e t . p u s h ( t o k e n s . l e n g t h   = =   0   ?   v a l u e   :   s e t ( n u l l ,   t o k e n s . s l i c e ( 0 ) ,   v a l u e ) ) ;  
                                 }  
                         }   e l s e   i f   ( t o k e n   & &   t o k e n . m a t c h ( / ^ \ s * [ 0 - 9 ] + \ s * $ / ) )   {  
                                 v a r   i n d e x   =   p a r s e I n t ( t o k e n ,   1 0 ) ;  
                                 i f   ( ! t a r g e t )   t a r g e t   =   [ ] ;  
                                 t a r g e t [ i n d e x ]   =   t o k e n s . l e n g t h   = =   0   ?   v a l u e   :   s e t ( t a r g e t [ i n d e x ] ,   t o k e n s . s l i c e ( 0 ) ,   v a l u e ) ;  
                         }   e l s e   i f   ( t o k e n )   {  
                                 v a r   i n d e x   =   t o k e n . r e p l a c e ( / ^ \ s * | \ s * $ / g ,   " " ) ;  
                                 i f   ( ! t a r g e t )   t a r g e t   =   { } ;  
                                 i f   ( i s ( t a r g e t ,   A r r a y ) )   {  
                                         v a r   t e m p   =   { } ;  
                                         f o r   ( v a r   i   =   0 ;   i   <   t a r g e t . l e n g t h ;   + + i )   {  
                                                 t e m p [ i ]   =   t a r g e t [ i ] ;  
                                         }  
                                         t a r g e t   =   t e m p ;  
                                 }  
                                 t a r g e t [ i n d e x ]   =   t o k e n s . l e n g t h   = =   0   ?   v a l u e   :   s e t ( t a r g e t [ i n d e x ] ,   t o k e n s . s l i c e ( 0 ) ,   v a l u e ) ;  
                         }   e l s e   {  
                                 r e t u r n   v a l u e ;  
                         }  
                         r e t u r n   t a r g e t ;  
                 } ;  
  
                 v a r   q u e r y O b j e c t   =   f u n c t i o n ( a )   {  
                         v a r   s e l f   =   t h i s ;  
                         s e l f . k e y s   =   { } ;  
  
                         i f   ( a . q u e r y O b j e c t )   {  
                                 j Q u e r y . e a c h ( a . g e t ( ) ,   f u n c t i o n ( k e y ,   v a l )   {  
                                         s e l f . S E T ( k e y ,   v a l ) ;  
                                 } ) ;  
                         }   e l s e   {  
                                 j Q u e r y . e a c h ( a r g u m e n t s ,   f u n c t i o n ( )   {  
                                         v a r   q   =   " "   +   t h i s ;  
                                         q   =   q . r e p l a c e ( / ^ [ ? # ] / ,   ' ' ) ;   / /   r e m o v e   a n y   l e a d i n g   ?   | |   #  
                                         q   =   q . r e p l a c e ( / [ ; & ] $ / ,   ' ' ) ;   / /   r e m o v e   a n y   t r a i l i n g   &   | |   ;  
                                         i f   ( $ s p a c e s )   q   =   q . r e p l a c e ( / [ + ] / g ,   '   ' ) ;   / /   r e p l a c e   + ' s   w i t h   s p a c e s  
  
                                         j Q u e r y . e a c h ( q . s p l i t ( / [ & ; ] / ) ,   f u n c t i o n ( )   {  
                                                 v a r   k e y   =   d e c o d e U R I C o m p o n e n t ( t h i s . s p l i t ( ' = ' ) [ 0 ]   | |   " " ) ;  
                                                 v a r   v a l   =   d e c o d e U R I C o m p o n e n t ( t h i s . s p l i t ( ' = ' ) [ 1 ]   | |   " " ) ;  
  
                                                 i f   ( ! k e y )   r e t u r n ;  
  
                                                 i f   ( $ n u m b e r s )   {  
                                                         i f   ( / ^ [ + - ] ? [ 0 - 9 ] + \ . [ 0 - 9 ] * $ / . t e s t ( v a l ) )   / /   s i m p l e   f l o a t   r e g e x  
                                                                 v a l   =   p a r s e F l o a t ( v a l ) ;  
                                                         e l s e   i f   ( / ^ [ + - ] ? [ 0 - 9 ] + $ / . t e s t ( v a l ) )   / /   s i m p l e   i n t   r e g e x  
                                                                 v a l   =   p a r s e I n t ( v a l ,   1 0 ) ;  
                                                 }  
  
                                                 v a l   =   ( ! v a l   & &   v a l   ! = =   0 )   ?   t r u e   :   v a l ;  
  
                                                 i f   ( v a l   ! = =   f a l s e   & &   v a l   ! = =   t r u e   & &   t y p e o f   v a l   ! =   ' n u m b e r ' )  
                                                         v a l   =   v a l ;  
  
                                                 s e l f . S E T ( k e y ,   v a l ) ;  
                                         } ) ;  
                                 } ) ;  
                         }  
                         r e t u r n   s e l f ;  
                 } ;  
  
                 q u e r y O b j e c t . p r o t o t y p e   =   {  
                         q u e r y O b j e c t :   t r u e ,  
                         h a s :   f u n c t i o n ( k e y ,   t y p e )   {  
                                 v a r   v a l u e   =   t h i s . g e t ( k e y ) ;  
                                 r e t u r n   i s ( v a l u e ,   t y p e ) ;  
                         } ,  
                         G E T :   f u n c t i o n ( k e y )   {  
                                 i f   ( ! i s ( k e y ) )   r e t u r n   t h i s . k e y s ;  
                                 v a r   p a r s e d   =   p a r s e ( k e y ) ,   b a s e   =   p a r s e d [ 0 ] ,   t o k e n s   =   p a r s e d [ 1 ] ;  
                                 v a r   t a r g e t   =   t h i s . k e y s [ b a s e ] ;  
                                 w h i l e   ( t a r g e t   ! =   n u l l   & &   t o k e n s . l e n g t h   ! =   0 )   {  
                                         t a r g e t   =   t a r g e t [ t o k e n s . s h i f t ( ) ] ;  
                                 }  
                                 r e t u r n   t y p e o f   t a r g e t   = =   ' n u m b e r '   ?   t a r g e t   :   t a r g e t   | |   " " ;  
                         } ,  
                         g e t :   f u n c t i o n ( k e y )   {  
                                 v a r   t a r g e t   =   t h i s . G E T ( k e y ) ;  
                                 i f   ( i s ( t a r g e t ,   O b j e c t ) )  
                                         r e t u r n   j Q u e r y . e x t e n d ( t r u e ,   { } ,   t a r g e t ) ;  
                                 e l s e   i f   ( i s ( t a r g e t ,   A r r a y ) )  
                                         r e t u r n   t a r g e t . s l i c e ( 0 ) ;  
                                 r e t u r n   t a r g e t ;  
                         } ,  
                         S E T :   f u n c t i o n ( k e y ,   v a l )   {  
                                 v a r   v a l u e   =   ! i s ( v a l )   ?   n u l l   :   v a l ;  
                                 v a r   p a r s e d   =   p a r s e ( k e y ) ,   b a s e   =   p a r s e d [ 0 ] ,   t o k e n s   =   p a r s e d [ 1 ] ;  
                                 v a r   t a r g e t   =   t h i s . k e y s [ b a s e ] ;  
                                 t h i s . k e y s [ b a s e ]   =   s e t ( t a r g e t ,   t o k e n s . s l i c e ( 0 ) ,   v a l u e ) ;  
                                 r e t u r n   t h i s ;  
                         } ,  
                         s e t :   f u n c t i o n ( k e y ,   v a l )   {  
                                 r e t u r n   t h i s . c o p y ( ) . S E T ( k e y ,   v a l ) ;  
                         } ,  
                         R E M O V E :   f u n c t i o n ( k e y )   {  
                                 r e t u r n   t h i s . S E T ( k e y ,   n u l l ) . C O M P A C T ( ) ;  
                         } ,  
                         r e m o v e :   f u n c t i o n ( k e y )   {  
                                 r e t u r n   t h i s . c o p y ( ) . R E M O V E ( k e y ) ;  
                         } ,  
                         E M P T Y :   f u n c t i o n ( )   {  
                                 v a r   s e l f   =   t h i s ;  
                                 j Q u e r y . e a c h ( s e l f . k e y s ,   f u n c t i o n ( k e y ,   v a l u e )   {  
                                         d e l e t e   s e l f . k e y s [ k e y ] ;  
                                 } ) ;  
                                 r e t u r n   s e l f ;  
                         } ,  
                         l o a d :   f u n c t i o n ( u r l )   {  
                                 v a r   h a s h   =   u r l . r e p l a c e ( / ^ . * ? [ # ] ( . + ? ) ( ? : \ ? . + ) ? $ / ,   " $ 1 " ) ;  
                                 v a r   s e a r c h   =   u r l . r e p l a c e ( / ^ . * ? [ ? ] ( . + ? ) ( ? : # . + ) ? $ / ,   " $ 1 " ) ;  
                                 r e t u r n   n e w   q u e r y O b j e c t ( u r l . l e n g t h   = =   s e a r c h . l e n g t h   ?   ' '   :   s e a r c h ,   u r l . l e n g t h   = =   h a s h . l e n g t h   ?   ' '   :   h a s h ) ;  
                         } ,  
                         e m p t y :   f u n c t i o n ( )   {  
                                 r e t u r n   t h i s . c o p y ( ) . E M P T Y ( ) ;  
                         } ,  
                         c o p y :   f u n c t i o n ( )   {  
                                 r e t u r n   n e w   q u e r y O b j e c t ( t h i s ) ;  
                         } ,  
                         C O M P A C T :   f u n c t i o n ( )   {  
                                 f u n c t i o n   b u i l d ( o r i g )   {  
                                         v a r   o b j   =   t y p e o f   o r i g   = =   " o b j e c t "   ?   i s ( o r i g ,   A r r a y )   ?   [ ]   :   { }   :   o r i g ;  
                                         i f   ( t y p e o f   o r i g   = =   ' o b j e c t ' )   {  
                                                 f u n c t i o n   a d d ( o ,   k e y ,   v a l u e )   {  
                                                         i f   ( i s ( o ,   A r r a y ) )  
                                                                 o . p u s h ( v a l u e ) ;  
                                                         e l s e  
                                                                 o [ k e y ]   =   v a l u e ;  
                                                 }  
                                                 j Q u e r y . e a c h ( o r i g ,   f u n c t i o n ( k e y ,   v a l u e )   {  
                                                         i f   ( ! i s ( v a l u e ) )   r e t u r n   t r u e ;  
                                                         a d d ( o b j ,   k e y ,   b u i l d ( v a l u e ) ) ;  
                                                 } ) ;  
                                         }  
                                         r e t u r n   o b j ;  
                                 }  
                                 t h i s . k e y s   =   b u i l d ( t h i s . k e y s ) ;  
                                 r e t u r n   t h i s ;  
                         } ,  
                         c o m p a c t :   f u n c t i o n ( )   {  
                                 r e t u r n   t h i s . c o p y ( ) . C O M P A C T ( ) ;  
                         } ,  
                         t o S t r i n g :   f u n c t i o n ( )   {  
                                 v a r   i   =   0 ,   q u e r y S t r i n g   =   [ ] ,   c h u n k s   =   [ ] ,   s e l f   =   t h i s ;  
                                 v a r   e n c o d e   =   f u n c t i o n ( s t r )   {  
                                         s t r   =   s t r   +   " " ;  
                                         i f   ( $ s p a c e s )   s t r   =   s t r . r e p l a c e ( /   / g ,   " + " ) ;  
                                         r e t u r n   e n c o d e U R I C o m p o n e n t ( s t r ) ;  
                                 } ;  
                                 v a r   a d d F i e l d s   =   f u n c t i o n ( a r r ,   k e y ,   v a l u e )   {  
                                         i f   ( ! i s ( v a l u e )   | |   v a l u e   = = =   f a l s e )   r e t u r n ;  
                                         v a r   o   =   [ e n c o d e ( k e y ) ] ;  
                                         i f   ( v a l u e   ! = =   t r u e )   {  
                                                 o . p u s h ( " = " ) ;  
                                                 o . p u s h ( e n c o d e ( v a l u e ) ) ;  
                                         }  
                                         a r r . p u s h ( o . j o i n ( " " ) ) ;  
                                 } ;  
                                 v a r   b u i l d   =   f u n c t i o n ( o b j ,   b a s e )   {  
                                         v a r   n e w K e y   =   f u n c t i o n ( k e y )   {  
                                                 r e t u r n   ! b a s e   | |   b a s e   = =   " "   ?   [ k e y ] . j o i n ( " " )   :   [ b a s e ,   " [ " ,   k e y ,   " ] " ] . j o i n ( " " ) ;  
                                         } ;  
                                         j Q u e r y . e a c h ( o b j ,   f u n c t i o n ( k e y ,   v a l u e )   {  
                                                 i f   ( t y p e o f   v a l u e   = =   ' o b j e c t ' )  
                                                         b u i l d ( v a l u e ,   n e w K e y ( k e y ) ) ;  
                                                 e l s e  
                                                         a d d F i e l d s ( c h u n k s ,   n e w K e y ( k e y ) ,   v a l u e ) ;  
                                         } ) ;  
                                 } ;  
  
                                 b u i l d ( t h i s . k e y s ) ;  
  
                                 i f   ( c h u n k s . l e n g t h   >   0 )   q u e r y S t r i n g . p u s h ( $ h a s h ) ;  
                                 q u e r y S t r i n g . p u s h ( c h u n k s . j o i n ( $ s e p a r a t o r ) ) ;  
  
                                 r e t u r n   q u e r y S t r i n g . j o i n ( " " ) ;  
                         }  
                 } ;  
  
                 r e t u r n   n e w   q u e r y O b j e c t ( l o c a t i o n . s e a r c h ,   l o c a t i o n . h a s h ) ;  
         } ;  
 }   ( j Q u e r y . q u e r y   | |   { } ) ;   / /   P a s s   i n   j Q u e r y . q u e r y   a s   s e t t i n g s   o b j e c t  
  
 i f   ( j Q u e r y . b r o w s e r . m s i e   & &   j Q u e r y . b r o w s e r . v e r s i o n   = =   " 7 . 0 " )   {  
         j Q u e r y . a j a x S e t u p ( {   x h r :   f u n c t i o n ( )   {  
                 r e t u r n   X M L H t t p R e q u e s t   ?   n e w   X M L H t t p R e q u e s t ( )   :   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 " ) ;  
         }  
         } ) ;  
 }  
  
 ( f u n c t i o n ( a )   {   v a r   r   =   a . f n . d o m M a n i p ,   d   =   " _ t m p l i t e m " ,   q   =   / ^ [ ^ < ] * ( < [ \ w \ W ] + > ) [ ^ > ] * $ | \ { \ { \ !   / ,   b   =   { } ,   f   =   { } ,   e ,   p   =   {   k e y :   0 ,   d a t a :   { }   } ,   h   =   0 ,   c   =   0 ,   l   =   [ ] ;   f u n c t i o n   g ( e ,   d ,   g ,   i )   {   v a r   c   =   {   d a t a :   i   | |   ( d   ?   d . d a t a   :   { } ) ,   _ w r a p :   d   ?   d . _ w r a p   :   n u l l ,   t m p l :   n u l l ,   p a r e n t :   d   | |   n u l l ,   n o d e s :   [ ] ,   c a l l s :   u ,   n e s t :   w ,   w r a p :   x ,   h t m l :   v ,   u p d a t e :   t   } ;   e   & &   a . e x t e n d ( c ,   e ,   {   n o d e s :   [ ] ,   p a r e n t :   d   } ) ;   i f   ( g )   {   c . t m p l   =   g ;   c . _ c t n t   =   c . _ c t n t   | |   c . t m p l ( a ,   c ) ;   c . k e y   =   + + h ;   ( l . l e n g t h   ?   f   :   b ) [ h ]   =   c   }   r e t u r n   c   }   a . e a c h ( {   a p p e n d T o :   " a p p e n d " ,   p r e p e n d T o :   " p r e p e n d " ,   i n s e r t B e f o r e :   " b e f o r e " ,   i n s e r t A f t e r :   " a f t e r " ,   r e p l a c e A l l :   " r e p l a c e W i t h "   } ,   f u n c t i o n ( f ,   d )   {   a . f n [ f ]   =   f u n c t i o n ( n )   {   v a r   g   =   [ ] ,   i   =   a ( n ) ,   k ,   h ,   m ,   l ,   j   =   t h i s . l e n g t h   = = =   1   & &   t h i s [ 0 ] . p a r e n t N o d e ;   e   =   b   | |   { } ;   i f   ( j   & &   j . n o d e T y p e   = = =   1 1   & &   j . c h i l d N o d e s . l e n g t h   = = =   1   & &   i . l e n g t h   = = =   1 )   {   i [ d ] ( t h i s [ 0 ] ) ;   g   =   t h i s   }   e l s e   {   f o r   ( h   =   0 ,   m   =   i . l e n g t h ;   h   <   m ;   h + + )   {   c   =   h ;   k   =   ( h   >   0   ?   t h i s . c l o n e ( t r u e )   :   t h i s ) . g e t ( ) ;   a . f n [ d ] . a p p l y ( a ( i [ h ] ) ,   k ) ;   g   =   g . c o n c a t ( k )   }   c   =   0 ;   g   =   t h i s . p u s h S t a c k ( g ,   f ,   i . s e l e c t o r )   }   l   =   e ;   e   =   n u l l ;   a . t m p l . c o m p l e t e ( l ) ;   r e t u r n   g   }   } ) ;   a . f n . e x t e n d ( {   t m p l :   f u n c t i o n ( d ,   c ,   b )   {   r e t u r n   a . t m p l ( t h i s [ 0 ] ,   d ,   c ,   b )   } ,   t m p l I t e m :   f u n c t i o n ( )   {   r e t u r n   a . t m p l I t e m ( t h i s [ 0 ] )   } ,   t e m p l a t e :   f u n c t i o n ( b )   {   r e t u r n   a . t e m p l a t e ( b ,   t h i s [ 0 ] )   } ,   d o m M a n i p :   f u n c t i o n ( d ,   l ,   j )   {   i f   ( d [ 0 ]   & &   d [ 0 ] . n o d e T y p e )   {   v a r   f   =   a . m a k e A r r a y ( a r g u m e n t s ) ,   g   =   d . l e n g t h ,   i   =   0 ,   h ;   w h i l e   ( i   <   g   & &   ! ( h   =   a . d a t a ( d [ i + + ] ,   " t m p l I t e m " ) ) ) ;   i f   ( g   >   1 )   f [ 0 ]   =   [ a . m a k e A r r a y ( d ) ] ;   i f   ( h   & &   c )   f [ 2 ]   =   f u n c t i o n ( b )   {   a . t m p l . a f t e r M a n i p ( t h i s ,   b ,   j )   } ;   r . a p p l y ( t h i s ,   f )   }   e l s e   r . a p p l y ( t h i s ,   a r g u m e n t s ) ;   c   =   0 ;   ! e   & &   a . t m p l . c o m p l e t e ( b ) ;   r e t u r n   t h i s   }   } ) ;   a . e x t e n d ( {   t m p l :   f u n c t i o n ( d ,   h ,   e ,   c )   {   v a r   j ,   k   =   ! c ;   i f   ( k )   {   c   =   p ;   d   =   a . t e m p l a t e [ d ]   | |   a . t e m p l a t e ( n u l l ,   d ) ;   f   =   { }   }   e l s e   i f   ( ! d )   {   d   =   c . t m p l ;   b [ c . k e y ]   =   c ;   c . n o d e s   =   [ ] ;   c . w r a p p e d   & &   n ( c ,   c . w r a p p e d ) ;   r e t u r n   a ( i ( c ,   n u l l ,   c . t m p l ( a ,   c ) ) )   }   i f   ( ! d )   r e t u r n   [ ] ;   i f   ( t y p e o f   h   = = =   " f u n c t i o n " )   h   =   h . c a l l ( c   | |   { } ) ;   e   & &   e . w r a p p e d   & &   n ( e ,   e . w r a p p e d ) ;   j   =   a . i s A r r a y ( h )   ?   a . m a p ( h ,   f u n c t i o n ( a )   {   r e t u r n   a   ?   g ( e ,   c ,   d ,   a )   :   n u l l   } )   :   [ g ( e ,   c ,   d ,   h ) ] ;   r e t u r n   k   ?   a ( i ( c ,   n u l l ,   j ) )   :   j   } ,   t m p l I t e m :   f u n c t i o n ( b )   {   v a r   c ;   i f   ( b   i n s t a n c e o f   a )   b   =   b [ 0 ] ;   w h i l e   ( b   & &   b . n o d e T y p e   = = =   1   & &   ! ( c   =   a . d a t a ( b ,   " t m p l I t e m " ) )   & &   ( b   =   b . p a r e n t N o d e ) ) ;   r e t u r n   c   | |   p   } ,   t e m p l a t e :   f u n c t i o n ( c ,   b )   {   i f   ( b )   {   i f   ( t y p e o f   b   = = =   " s t r i n g " )   b   =   o ( b ) ;   e l s e   i f   ( b   i n s t a n c e o f   a )   b   =   b [ 0 ]   | |   { } ;   i f   ( b . n o d e T y p e )   b   =   a . d a t a ( b ,   " t m p l " )   | |   a . d a t a ( b ,   " t m p l " ,   o ( b . i n n e r H T M L ) ) ;   r e t u r n   t y p e o f   c   = = =   " s t r i n g "   ?   ( a . t e m p l a t e [ c ]   =   b )   :   b   }   r e t u r n   c   ?   t y p e o f   c   ! = =   " s t r i n g "   ?   a . t e m p l a t e ( n u l l ,   c )   :   a . t e m p l a t e [ c ]   | |   a . t e m p l a t e ( n u l l ,   q . t e s t ( c )   ?   c   :   a ( c ) )   :   n u l l   } ,   e n c o d e :   f u n c t i o n ( a )   {   r e t u r n   ( " "   +   a ) . s p l i t ( " < " ) . j o i n ( " & l t ; " ) . s p l i t ( " > " ) . j o i n ( " & g t ; " ) . s p l i t ( ' " ' ) . j o i n ( " & # 3 4 ; " ) . s p l i t ( " ' " ) . j o i n ( " & # 3 9 ; " )   }   } ) ;   a . e x t e n d ( a . t m p l ,   {   t a g :   {   t m p l :   {   _ d e f a u l t :   {   $ 2 :   " n u l l "   } ,   o p e n :   " i f ( $ n o t n u l l _ 1 ) { _ = _ . c o n c a t ( $ i t e m . n e s t ( $ 1 , $ 2 ) ) ; } "   } ,   w r a p :   {   _ d e f a u l t :   {   $ 2 :   " n u l l "   } ,   o p e n :   " $ i t e m . c a l l s ( _ , $ 1 , $ 2 ) ; _ = [ ] ; " ,   c l o s e :   " c a l l = $ i t e m . c a l l s ( ) ; _ = c a l l . _ . c o n c a t ( $ i t e m . w r a p ( c a l l , _ ) ) ; "   } ,   e a c h :   {   _ d e f a u l t :   {   $ 2 :   " $ i n d e x ,   $ v a l u e "   } ,   o p e n :   " i f ( $ n o t n u l l _ 1 ) { $ . e a c h ( $ 1 a , f u n c t i o n ( $ 2 ) { w i t h ( t h i s ) { " ,   c l o s e :   " } } ) ; } "   } ,   " i f " :   {   o p e n :   " i f ( ( $ n o t n u l l _ 1 )   & &   $ 1 a ) { " ,   c l o s e :   " } "   } ,   " e l s e " :   {   _ d e f a u l t :   {   $ 1 :   " t r u e "   } ,   o p e n :   " } e l s e   i f ( ( $ n o t n u l l _ 1 )   & &   $ 1 a ) { "   } ,   h t m l :   {   o p e n :   " i f ( $ n o t n u l l _ 1 ) { _ . p u s h ( $ 1 a ) ; } "   } ,   " = " :   {   _ d e f a u l t :   {   $ 1 :   " $ d a t a "   } ,   o p e n :   " i f ( $ n o t n u l l _ 1 ) { _ . p u s h ( $ . e n c o d e ( $ 1 a ) ) ; } "   } ,   " ! " :   {   o p e n :   " " }   } ,   c o m p l e t e :   f u n c t i o n ( )   {   b   =   { }   } ,   a f t e r M a n i p :   f u n c t i o n ( f ,   b ,   d )   {   v a r   e   =   b . n o d e T y p e   = = =   1 1   ?   a . m a k e A r r a y ( b . c h i l d N o d e s )   :   b . n o d e T y p e   = = =   1   ?   [ b ]   :   [ ] ;   d . c a l l ( f ,   b ) ;   m ( e ) ;   c + +   }   } ) ;   f u n c t i o n   i ( e ,   g ,   f )   {   v a r   b ,   c   =   f   ?   a . m a p ( f ,   f u n c t i o n ( a )   {   r e t u r n   t y p e o f   a   = = =   " s t r i n g "   ?   e . k e y   ?   a . r e p l a c e ( / ( < \ w + ) ( ? = [ \ s > ] ) ( ? ! [ ^ > ] * _ t m p l i t e m ) ( [ ^ > ] * ) / g ,   " $ 1   "   +   d   +   ' = " '   +   e . k e y   +   ' "   $ 2 ' )   :   a   :   i ( a ,   e ,   a . _ c t n t )   } )   :   e ;   i f   ( g )   r e t u r n   c ;   c   =   c . j o i n ( " " ) ;   c . r e p l a c e ( / ^ \ s * ( [ ^ < \ s ] [ ^ < ] * ) ? ( < [ \ w \ W ] + > ) ( [ ^ > ] * [ ^ > \ s ] ) ? \ s * $ / ,   f u n c t i o n ( f ,   c ,   e ,   d )   {   b   =   a ( e ) . g e t ( ) ;   m ( b ) ;   i f   ( c )   b   =   j ( c ) . c o n c a t ( b ) ;   i f   ( d )   b   =   b . c o n c a t ( j ( d ) )   } ) ;   r e t u r n   b   ?   b   :   j ( c )   }   f u n c t i o n   j ( c )   {   v a r   b   =   d o c u m e n t . c r e a t e E l e m e n t ( " d i v " ) ;   b . i n n e r H T M L   =   c ;   r e t u r n   a . m a k e A r r a y ( b . c h i l d N o d e s )   }   f u n c t i o n   o ( b )   {   r e t u r n   n e w   F u n c t i o n ( " j Q u e r y " ,   " $ i t e m " ,   " v a r   $ = j Q u e r y , c a l l , _ = [ ] , $ d a t a = $ i t e m . d a t a ; w i t h ( $ d a t a ) { _ . p u s h ( ' "   +   a . t r i m ( b ) . r e p l a c e ( / ( [ \ \ ' ] ) / g ,   " \ \ $ 1 " ) . r e p l a c e ( / [ \ r \ t \ n ] / g ,   "   " ) . r e p l a c e ( / \ $ \ { ( [ ^ \ } ] * ) \ } / g ,   " { { =   $ 1 } } " ) . r e p l a c e ( / \ { \ { ( \ / ? ) ( \ w + | . ) ( ? : \ ( ( ( ? : [ ^ \ } ] | \ } ( ? ! \ } ) ) * ? ) ? \ ) ) ? ( ? : \ s + ( . * ? ) ? ) ? ( \ ( ( ( ? : [ ^ \ } ] | \ } ( ? ! \ } ) ) * ? ) \ ) ) ? \ s * \ } \ } / g ,   f u n c t i o n ( m ,   l ,   j ,   d ,   b ,   c ,   e )   {   v a r   i   =   a . t m p l . t a g [ j ] ,   h ,   f ,   g ;   i f   ( ! i )   t h r o w   " T e m p l a t e   c o m m a n d   n o t   f o u n d :   "   +   j ;   h   =   i . _ d e f a u l t   | |   [ ] ;   i f   ( c   & &   ! / \ w $ / . t e s t ( b ) )   {   b   + =   c ;   c   =   " "   }   i f   ( b )   {   b   =   k ( b ) ;   e   =   e   ?   " , "   +   k ( e )   +   " ) "   :   c   ?   " ) "   :   " " ;   f   =   c   ?   b . i n d e x O f ( " . " )   >   - 1   ?   b   +   c   :   " ( "   +   b   +   " ) . c a l l ( $ i t e m "   +   e   :   b ;   g   =   c   ?   f   :   " ( t y p e o f ( "   +   b   +   " ) = = = ' f u n c t i o n ' ? ( "   +   b   +   " ) . c a l l ( $ i t e m ) : ( "   +   b   +   " ) ) "   }   e l s e   g   =   f   =   h . $ 1   | |   " n u l l " ;   d   =   k ( d ) ;   r e t u r n   " ' ) ; "   +   i [ l   ?   " c l o s e "   :   " o p e n " ] . s p l i t ( " $ n o t n u l l _ 1 " ) . j o i n ( b   ?   " t y p e o f ( "   +   b   +   " ) ! = = ' u n d e f i n e d '   & &   ( "   +   b   +   " ) ! = n u l l "   :   " t r u e " ) . s p l i t ( " $ 1 a " ) . j o i n ( g ) . s p l i t ( " $ 1 " ) . j o i n ( f ) . s p l i t ( " $ 2 " ) . j o i n ( d   ?   d . r e p l a c e ( / \ s * ( [ ^ \ ( ] + ) \ s * ( \ ( ( . * ? ) \ ) ) ? / g ,   f u n c t i o n ( d ,   c ,   b ,   a )   {   a   =   a   ?   " , "   +   a   +   " ) "   :   b   ?   " ) "   :   " " ;   r e t u r n   a   ?   " ( "   +   c   +   " ) . c a l l ( $ i t e m "   +   a   :   d   } )   :   h . $ 2   | |   " " )   +   " _ . p u s h ( ' "   } )   +   " ' ) ; } r e t u r n   _ ; " )   }   f u n c t i o n   n ( c ,   b )   {   c . _ w r a p   =   i ( c ,   t r u e ,   a . i s A r r a y ( b )   ?   b   :   [ q . t e s t ( b )   ?   b   :   a ( b ) . h t m l ( ) ] ) . j o i n ( " " )   }   f u n c t i o n   k ( a )   {   r e t u r n   a   ?   a . r e p l a c e ( / \ \ ' / g ,   " ' " ) . r e p l a c e ( / \ \ \ \ / g ,   " \ \ " )   :   n u l l   }   f u n c t i o n   s ( b )   {   v a r   a   =   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 . a p p e n d C h i l d ( b . c l o n e N o d e ( t r u e ) ) ;   r e t u r n   a . i n n e r H T M L   }   f u n c t i o n   m ( o )   {   v a r   n   =   " _ "   +   c ,   k ,   j ,   l   =   { } ,   e ,   p ,   i ;   f o r   ( e   =   0 ,   p   =   o . l e n g t h ;   e   <   p ;   e + + )   {   i f   ( ( k   =   o [ e ] ) . n o d e T y p e   ! = =   1 )   c o n t i n u e ;   j   =   k . g e t E l e m e n t s B y T a g N a m e ( " * " ) ;   f o r   ( i   =   j . l e n g t h   -   1 ;   i   > =   0 ;   i - - )   m ( j [ i ] ) ;   m ( k )   }   f u n c t i o n   m ( j )   {   v a r   p ,   i   =   j ,   k ,   e ,   m ;   i f   ( m   =   j . g e t A t t r i b u t e ( d ) )   {   w h i l e   ( i . p a r e n t N o d e   & &   ( i   =   i . p a r e n t N o d e ) . n o d e T y p e   = = =   1   & &   ! ( p   =   i . g e t A t t r i b u t e ( d ) ) ) ;   i f   ( p   ! = =   m )   {   i   =   i . p a r e n t N o d e   ?   i . n o d e T y p e   = = =   1 1   ?   0   :   i . g e t A t t r i b u t e ( d )   | |   0   :   0 ;   i f   ( ! ( e   =   b [ m ] ) )   {   e   =   f [ m ] ;   e   =   g ( e ,   b [ i ]   | |   f [ i ] ,   n u l l ,   t r u e ) ;   e . k e y   =   + + h ;   b [ h ]   =   e   }   c   & &   o ( m )   }   j . r e m o v e A t t r i b u t e ( d )   }   e l s e   i f   ( c   & &   ( e   =   a . d a t a ( j ,   " t m p l I t e m " ) ) )   {   o ( e . k e y ) ;   b [ e . k e y ]   =   e ;   i   =   a . d a t a ( j . p a r e n t N o d e ,   " t m p l I t e m " ) ;   i   =   i   ?   i . k e y   :   0   }   i f   ( e )   {   k   =   e ;   w h i l e   ( k   & &   k . k e y   ! =   i )   {   k . n o d e s . p u s h ( j ) ;   k   =   k . p a r e n t   }   d e l e t e   e . _ c t n t ;   d e l e t e   e . _ w r a p ;   a . d a t a ( j ,   " t m p l I t e m " ,   e )   }   f u n c t i o n   o ( a )   {   a   =   a   +   n ;   e   =   l [ a ]   =   l [ a ]   | |   g ( e ,   b [ e . p a r e n t . k e y   +   n ]   | |   e . p a r e n t ,   n u l l ,   t r u e )   }   }   }   f u n c t i o n   u ( a ,   d ,   c ,   b )   {   i f   ( ! a )   r e t u r n   l . p o p ( ) ;   l . p u s h ( {   _ :   a ,   t m p l :   d ,   i t e m :   t h i s ,   d a t a :   c ,   o p t i o n s :   b   } )   }   f u n c t i o n   w ( d ,   c ,   b )   {   r e t u r n   a . t m p l ( a . t e m p l a t e ( d ) ,   c ,   b ,   t h i s )   }   f u n c t i o n   x ( b ,   d )   {   v a r   c   =   b . o p t i o n s   | |   { } ;   c . w r a p p e d   =   d ;   r e t u r n   a . t m p l ( a . t e m p l a t e ( b . t m p l ) ,   b . d a t a ,   c ,   b . i t e m )   }   f u n c t i o n   v ( d ,   c )   {   v a r   b   =   t h i s . _ w r a p ;   r e t u r n   a . m a p ( a ( a . i s A r r a y ( b )   ?   b . j o i n ( " " )   :   b ) . f i l t e r ( d   | |   " * " ) ,   f u n c t i o n ( a )   {   r e t u r n   c   ?   a . i n n e r T e x t   | |   a . t e x t C o n t e n t   :   a . o u t e r H T M L   | |   s ( a )   } )   }   f u n c t i o n   t ( )   {   v a r   b   =   t h i s . n o d e s ;   a . t m p l ( n u l l ,   n u l l ,   n u l l ,   t h i s ) . i n s e r t B e f o r e ( b [ 0 ] ) ;   a ( b ) . r e m o v e ( )   }   } ) ( j Q u e r y )  
  
 / *  
 # # #   j Q u e r y   X M L   t o   J S O N   P l u g i n   v 1 . 0   -   2 0 0 8 - 0 7 - 0 1   # # #  
 *   h t t p : / / w w w . f y n e w o r k s . c o m /   -   d i e g o @ f y n e w o r k s . c o m  
 *   D u a l   l i c e n s e d   u n d e r   t h e   M I T   a n d   G P L   l i c e n s e s :  
 *       h t t p : / / w w w . o p e n s o u r c e . o r g / l i c e n s e s / m i t - l i c e n s e . p h p  
 *       h t t p : / / w w w . g n u . o r g / l i c e n s e s / g p l . h t m l  
 # # #  
 W e b s i t e :   h t t p : / / w w w . f y n e w o r k s . c o m / j q u e r y / x m l - t o - j s o n /  
 * /  
 / *  
 #   I N S P I R E D   B Y :   h t t p : / / w w w . t e r r a c o d e r . c o m /  
 A N D :   h t t p : / / w w w . t h o m a s f r a n k . s e / x m l _ t o _ j s o n . h t m l  
 A N D :   h t t p : / / w w w . k a w a . n e t / w o r k s / j s / x m l / o b j t r e e - e . h t m l  
 * /  
 / *  
 T h i s   s i m p l e   s c r i p t   c o n v e r t s   X M L   ( d o c u m e n t   o f   c o d e )   i n t o   a   J S O N   o b j e c t .   I t   i s   t h e   c o m b i n a t i o n   o f   2  
 ' x m l   t o   j s o n '   g r e a t   p a r s e r s   ( s e e   b e l o w )   w h i c h   a l l o w s   f o r   b o t h   ' s i m p l e '   a n d   ' e x t e n d e d '   p a r s i n g   m o d e s .  
 * /  
 / /   A v o i d   c o l l i s i o n s  
 ;   i f   ( w i n d o w . j Q u e r y )   ( f u n c t i o n ( $ )   {  
  
         / /   A d d   f u n c t i o n   t o   j Q u e r y   n a m e s p a c e  
         $ . e x t e n d ( {  
  
                 / /   c o n v e r t s   x m l   d o c u m e n t s   a n d   x m l   t e x t   t o   j s o n   o b j e c t  
                 x m l 2 j s o n :   f u n c t i o n ( x m l ,   e x t e n d e d )   {  
                         i f   ( ! x m l )   r e t u r n   { } ;   / /   q u i c k   f a i l  
  
                         / / # # #   P A R S E R   L I B R A R Y  
                         / /   C o r e   f u n c t i o n  
                         f u n c t i o n   p a r s e X M L ( n o d e ,   s i m p l e )   {  
                                 i f   ( ! n o d e )   r e t u r n   n u l l ;  
                                 v a r   t x t   =   ' ' ,   o b j   =   n u l l ,   a t t   =   n u l l ;  
                                 v a r   n t   =   n o d e . n o d e T y p e ,   n n   =   j s V a r ( n o d e . l o c a l N a m e   | |   n o d e . n o d e N a m e ) ;  
                                 v a r   n v   =   n o d e . t e x t   | |   n o d e . n o d e V a l u e   | |   ' ' ;  
                                 / * D B G * /   / / i f ( w i n d o w . c o n s o l e )   c o n s o l e . l o g ( [ ' x 2 j ' , n n , n t , n v . l e n g t h + '   b y t e s ' ] ) ;  
                                 i f   ( n o d e . c h i l d N o d e s )   {  
                                         i f   ( n o d e . c h i l d N o d e s . l e n g t h   >   0 )   {  
                                                 / * D B G * /   / / i f ( w i n d o w . c o n s o l e )   c o n s o l e . l o g ( [ ' x 2 j ' , n n , ' C H I L D R E N ' , n o d e . c h i l d N o d e s ] ) ;  
                                                 $ . e a c h ( n o d e . c h i l d N o d e s ,   f u n c t i o n ( n ,   c n )   {  
                                                         v a r   c n t   =   c n . n o d e T y p e ,   c n n   =   j s V a r ( c n . l o c a l N a m e   | |   c n . n o d e N a m e ) ;  
                                                         v a r   c n v   =   c n . t e x t   | |   c n . n o d e V a l u e   | |   ' ' ;  
                                                         / * D B G * /   / / i f ( w i n d o w . c o n s o l e )   c o n s o l e . l o g ( [ ' x 2 j ' , n n , ' n o d e > a ' , c n n , c n t , c n v ] ) ;  
                                                         i f   ( c n t   = =   8 )   {  
                                                                 / * D B G * /   / / i f ( w i n d o w . c o n s o l e )   c o n s o l e . l o g ( [ ' x 2 j ' , n n , ' n o d e > b ' , c n n , ' C O M M E N T   ( i g n o r e ) ' ] ) ;  
                                                                 r e t u r n ;   / /   i g n o r e   c o m m e n t   n o d e  
                                                         }  
                                                         e l s e   i f   ( c n t   = =   3   | |   c n t   = =   4   | |   ! c n n )   {  
                                                                 / /   i g n o r e   w h i t e - s p a c e   i n   b e t w e e n   t a g s  
                                                                 i f   ( c n v . m a t c h ( / ^ \ s + $ / ) )   {  
                                                                         / * D B G * /   / / i f ( w i n d o w . c o n s o l e )   c o n s o l e . l o g ( [ ' x 2 j ' , n n , ' n o d e > c ' , c n n , ' W H I T E - S P A C E   ( i g n o r e ) ' ] ) ;  
                                                                         r e t u r n ;  
                                                                 } ;  
                                                                 / * D B G * /   / / i f ( w i n d o w . c o n s o l e )   c o n s o l e . l o g ( [ ' x 2 j ' , n n , ' n o d e > d ' , c n n , ' T E X T ' ] ) ;  
                                                                 t x t   + =   c n v . r e p l a c e ( / ^ \ s + / ,   ' ' ) . r e p l a c e ( / \ s + $ / ,   ' ' ) ;  
                                                                 / /   m a k e   s u r e   w e   d i t c h   t r a i l i n g   s p a c e s   f r o m   m a r k u p  
                                                         }  
                                                         e l s e   {  
                                                                 / * D B G * /   / / i f ( w i n d o w . c o n s o l e )   c o n s o l e . l o g ( [ ' x 2 j ' , n n , ' n o d e > e ' , c n n , ' O B J E C T ' ] ) ;  
                                                                 o b j   =   o b j   | |   { } ;  
                                                                 i f   ( o b j [ c n n ] )   {  
                                                                         / * D B G * /   / / i f ( w i n d o w . c o n s o l e )   c o n s o l e . l o g ( [ ' x 2 j ' , n n , ' n o d e > f ' , c n n , ' A R R A Y ' ] ) ;  
                                                                         i f   ( ! o b j [ c n n ] . l e n g t h )   o b j [ c n n ]   =   m y A r r ( o b j [ c n n ] ) ;  
                                                                         o b j [ c n n ] [ o b j [ c n n ] . l e n g t h ]   =   p a r s e X M L ( c n ,   t r u e / *   s i m p l e   * / ) ;  
                                                                         o b j [ c n n ] . l e n g t h   =   o b j [ c n n ] . l e n g t h ;  
                                                                 }  
                                                                 e l s e   {  
                                                                         / * D B G * /   / / i f ( w i n d o w . c o n s o l e )   c o n s o l e . l o g ( [ ' x 2 j ' , n n , ' n o d e > g ' , c n n , ' d i g   d e e p e r . . . ' ] ) ;  
                                                                         o b j [ c n n ]   =   p a r s e X M L ( c n ) ;  
                                                                 } ;  
                                                         } ;  
                                                 } ) ;  
                                         } ;   / / n o d e . c h i l d N o d e s . l e n g t h > 0  
                                 } ;   / / n o d e . c h i l d N o d e s  
                                 i f   ( n o d e . a t t r i b u t e s )   {  
                                         i f   ( n o d e . a t t r i b u t e s . l e n g t h   >   0 )   {  
                                                 / * D B G * /   / / i f ( w i n d o w . c o n s o l e )   c o n s o l e . l o g ( [ ' x 2 j ' , n n , ' A T T R I B U T E S ' , n o d e . a t t r i b u t e s ] )  
                                                 a t t   =   { } ;   o b j   =   o b j   | |   { } ;  
                                                 $ . e a c h ( n o d e . a t t r i b u t e s ,   f u n c t i o n ( a ,   a t )   {  
                                                         v a r   a t n   =   j s V a r ( a t . n a m e ) ,   a t v   =   a t . v a l u e ;  
                                                         a t t [ a t n ]   =   a t v ;  
                                                         i f   ( o b j [ a t n ] )   {  
                                                                 / * D B G * /   / / i f ( w i n d o w . c o n s o l e )   c o n s o l e . l o g ( [ ' x 2 j ' , n n , ' a t t r > ' , a t n , ' A R R A Y ' ] ) ;  
                                                                 i f   ( ! o b j [ a t n ] . l e n g t h )   o b j [ a t n ]   =   m y A r r ( o b j [ a t n ] ) ;   / / [   o b j [   a t n   ]   ] ;  
                                                                 o b j [ a t n ] [ o b j [ a t n ] . l e n g t h ]   =   a t v ;  
                                                                 o b j [ a t n ] . l e n g t h   =   o b j [ a t n ] . l e n g t h ;  
                                                         }  
                                                         e l s e   {  
                                                                 / * D B G * /   / / i f ( w i n d o w . c o n s o l e )   c o n s o l e . l o g ( [ ' x 2 j ' , n n , ' a t t r > ' , a t n , ' T E X T ' ] ) ;  
                                                                 o b j [ a t n ]   =   a t v ;  
                                                         } ;  
                                                 } ) ;  
                                                 / / o b j [ ' a t t r i b u t e s ' ]   =   a t t ;  
                                         } ;   / / n o d e . a t t r i b u t e s . l e n g t h > 0  
                                 } ;   / / n o d e . a t t r i b u t e s  
                                 i f   ( o b j )   {  
                                         o b j   =   $ . e x t e n d ( ( t x t   ! =   ' '   ?   n e w   S t r i n g ( t x t )   :   { } ) ,   / *   { t e x t : t x t } , * / o b j   | |   { } / * ,   a t t   | |   { } * / ) ;  
                                         t x t   =   ( o b j . t e x t )   ?   ( t y p e o f   ( o b j . t e x t )   = =   ' o b j e c t '   ?   o b j . t e x t   :   [ o b j . t e x t   | |   ' ' ] ) . c o n c a t ( [ t x t ] )   :   t x t ;  
                                         i f   ( t x t )   o b j . t e x t   =   t x t ;  
                                         t x t   =   ' ' ;  
                                 } ;  
                                 v a r   o u t   =   o b j   | |   t x t ;  
                                 / / c o n s o l e . l o g ( [ e x t e n d e d ,   s i m p l e ,   o u t ] ) ;  
                                 i f   ( e x t e n d e d )   {  
                                         i f   ( t x t )   o u t   =   { } ;   / / n e w   S t r i n g ( o u t ) ;  
                                         t x t   =   o u t . t e x t   | |   t x t   | |   ' ' ;  
                                         i f   ( t x t )   o u t . t e x t   =   t x t ;  
                                         i f   ( ! s i m p l e )   o u t   =   m y A r r ( o u t ) ;  
                                 } ;  
                                 r e t u r n   o u t ;  
                         } ;   / /   p a r s e X M L  
                         / /   C o r e   F u n c t i o n   E n d  
                         / /   U t i l i t y   f u n c t i o n s  
                         v a r   j s V a r   =   f u n c t i o n ( s )   {   r e t u r n   S t r i n g ( s   | |   ' ' ) . r e p l a c e ( / - / g ,   " _ " ) ;   } ;  
                         v a r   i s N u m   =   f u n c t i o n ( s )   {   r e t u r n   ( t y p e o f   s   = =   " n u m b e r " )   | |   S t r i n g ( ( s   & &   t y p e o f   s   = =   " s t r i n g " )   ?   s   :   ' ' ) . t e s t ( / ^ ( ( - ) ? ( [ 0 - 9 ] * ) ( ( \ . { 0 , 1 } ) ( [ 0 - 9 ] + ) ) ? $ ) / ) ;   } ;  
                         v a r   m y A r r   =   f u n c t i o n ( o )   {  
                                 i f   ( ! o . l e n g t h )   o   =   [ o ] ;   o . l e n g t h   =   o . l e n g t h ;  
                                 / /   h e r e   i s   w h e r e   y o u   c a n   a t t a c h   a d d i t i o n a l   f u n c t i o n a l i t y ,   s u c h   a s   s e a r c h i n g   a n d   s o r t i n g . . .  
                                 r e t u r n   o ;  
                         } ;  
                         / /   U t i l i t y   f u n c t i o n s   E n d  
                         / / # # #   P A R S E R   L I B R A R Y   E N D  
  
                         / /   C o n v e r t   p l a i n   t e x t   t o   x m l  
                         i f   ( t y p e o f   x m l   = =   ' s t r i n g ' )   x m l   =   $ . t e x t 2 x m l ( x m l ) ;  
  
                         / /   Q u i c k   f a i l   i f   n o t   x m l   ( o r   i f   t h i s   i s   a   n o d e )  
                         i f   ( ! x m l . n o d e T y p e )   r e t u r n ;  
                         i f   ( x m l . n o d e T y p e   = =   3   | |   x m l . n o d e T y p e   = =   4 )   r e t u r n   x m l . n o d e V a l u e ;  
  
                         / /   F i n d   x m l   r o o t   n o d e  
                         v a r   r o o t   =   ( x m l . n o d e T y p e   = =   9 )   ?   x m l . d o c u m e n t E l e m e n t   :   x m l ;  
  
                         / /   C o n v e r t   x m l   t o   j s o n  
                         v a r   o u t   =   p a r s e X M L ( r o o t ,   t r u e   / *   s i m p l e   * / ) ;  
  
                         / /   C l e a n - u p   m e m o r y  
                         x m l   =   n u l l ;   r o o t   =   n u l l ;  
  
                         / /   S e n d   o u t p u t  
                         r e t u r n   o u t ;  
                 } ,  
  
                 / /   C o n v e r t   t e x t   t o   X M L   D O M  
                 t e x t 2 x m l :   f u n c t i o n ( s t r )   {  
                         / /   N O T E :   I ' d   l i k e   t o   u s e   j Q u e r y   f o r   t h i s ,   b u t   j Q u e r y   m a k e s   a l l   t a g s   u p p e r c a s e  
                         / / r e t u r n   $ ( x m l ) [ 0 ] ;  
                         v a r   o u t ;  
                         t r y   {  
                                 v a r   x m l   =   ( $ . b r o w s e r . m s i e )   ?   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 D O M " )   :   n e w   D O M P a r s e r ( ) ;  
                                 x m l . a s y n c   =   f a l s e ;  
                         }   c a t c h   ( e )   {   t h r o w   n e w   E r r o r ( " X M L   P a r s e r   c o u l d   n o t   b e   i n s t a n t i a t e d " )   } ;  
                         t r y   {  
                                 i f   ( $ . b r o w s e r . m s i e )   o u t   =   ( x m l . l o a d X M L ( s t r ) )   ?   x m l   :   f a l s e ;  
                                 e l s e   o u t   =   x m l . p a r s e F r o m S t r i n g ( s t r ,   " t e x t / x m l " ) ;  
                         }   c a t c h   ( e )   {   t h r o w   n e w   E r r o r ( " E r r o r   p a r s i n g   X M L   s t r i n g " )   } ;  
                         r e t u r n   o u t ;  
                 }  
  
         } ) ;   / /   e x t e n d   $  
  
 } ) ( j Q u e r y ) ;  
  
 / * !  
 *   i S c r o l l   v 4 . 1 . 6   ~   C o p y r i g h t   ( c )   2 0 1 1   M a t t e o   S p i n e l l i ,   h t t p : / / c u b i q . o r g  
 *   R e l e a s e d   u n d e r   M I T   l i c e n s e ,   h t t p : / / c u b i q . o r g / l i c e n s e  
 * /  
  
 ( f u n c t i o n ( )   {  
         v a r   m   =   M a t h ,  
 	 v e n d o r   =   ( / w e b k i t / i ) . t e s t ( n a v i g a t o r . a p p V e r s i o n )   ?   ' w e b k i t '   :  
 	 	 ( / f i r e f o x / i ) . t e s t ( n a v i g a t o r . u s e r A g e n t )   ?   ' M o z '   :  
 	 	 ' o p e r a '   i n   w i n d o w   ?   ' O '   :   ' ' ,  
  
         / /   B r o w s e r   c a p a b i l i t i e s  
 	 h a s 3 d   =   ' W e b K i t C S S M a t r i x '   i n   w i n d o w   & &   ' m 1 1 '   i n   n e w   W e b K i t C S S M a t r i x ( ) ,  
 	 h a s T o u c h   =   ' o n t o u c h s t a r t '   i n   w i n d o w ,  
 	 h a s T r a n s f o r m   =   v e n d o r   +   ' T r a n s f o r m '   i n   d o c u m e n t . d o c u m e n t E l e m e n t . s t y l e ,  
 	 i s A n d r o i d   =   ( / a n d r o i d / g i ) . t e s t ( n a v i g a t o r . a p p V e r s i o n ) ,  
 	 i s I D e v i c e   =   ( / i p h o n e | i p a d / g i ) . t e s t ( n a v i g a t o r . a p p V e r s i o n ) ,  
 	 i s P l a y b o o k   =   ( / p l a y b o o k / g i ) . t e s t ( n a v i g a t o r . a p p V e r s i o n ) ,  
 	 h a s T r a n s i t i o n E n d   =   i s I D e v i c e   | |   i s P l a y b o o k ,  
 	 n e x t F r a m e   =   ( f u n c t i o n ( )   {  
 	         r e t u r n   w i n d o w . r e q u e s t A n i m a t i o n F r a m e  
 	 	 	 | |   w i n d o w . w e b k i t R e q u e s t A n i m a t i o n F r a m e  
 	 	 	 | |   w i n d o w . m o z R e q u e s t A n i m a t i o n F r a m e  
 	 	 	 | |   w i n d o w . o R e q u e s t A n i m a t i o n F r a m e  
 	 	 	 | |   w i n d o w . m s R e q u e s t A n i m a t i o n F r a m e  
 	 	 	 | |   f u n c t i o n ( c a l l b a c k )   {   r e t u r n   s e t T i m e o u t ( c a l l b a c k ,   1 7 ) ;   }  
 	 } ) ( ) ,  
 	 c a n c e l F r a m e   =   ( f u n c t i o n ( )   {  
 	         r e t u r n   w i n d o w . c a n c e l R e q u e s t A n i m a t i o n F r a m e  
 	 	 	 | |   w i n d o w . w e b k i t C a n c e l R e q u e s t A n i m a t i o n F r a m e  
 	 	 	 | |   w i n d o w . m o z C a n c e l R e q u e s t A n i m a t i o n F r a m e  
 	 	 	 | |   w i n d o w . o C a n c e l R e q u e s t A n i m a t i o n F r a m e  
 	 	 	 | |   w i n d o w . m s C a n c e l R e q u e s t A n i m a t i o n F r a m e  
 	 	 	 | |   c l e a r T i m e o u t  
 	 } ) ( ) ,  
  
         / /   E v e n t s  
 	 R E S I Z E _ E V   =   ' o n o r i e n t a t i o n c h a n g e '   i n   w i n d o w   ?   ' o r i e n t a t i o n c h a n g e '   :   ' r e s i z e ' ,  
 	 S T A R T _ E V   =   h a s T o u c h   ?   ' t o u c h s t a r t '   :   ' m o u s e d o w n ' ,  
 	 M O V E _ E V   =   h a s T o u c h   ?   ' t o u c h m o v e '   :   ' m o u s e m o v e ' ,  
 	 E N D _ E V   =   h a s T o u c h   ?   ' t o u c h e n d '   :   ' m o u s e u p ' ,  
 	 C A N C E L _ E V   =   h a s T o u c h   ?   ' t o u c h c a n c e l '   :   ' m o u s e u p ' ,  
 	 W H E E L _ E V   =   v e n d o r   = =   ' M o z '   ?   ' D O M M o u s e S c r o l l '   :   ' m o u s e w h e e l ' ,  
  
         / /   H e l p e r s  
 	 t r n O p e n   =   ' t r a n s l a t e '   +   ( h a s 3 d   ?   ' 3 d ( '   :   ' ( ' ) ,  
 	 t r n C l o s e   =   h a s 3 d   ?   ' , 0 ) '   :   ' ) ' ,  
  
         / /   C o n s t r u c t o r  
 	 i S c r o l l   =   f u n c t i o n ( e l ,   o p t i o n s )   {  
 	         v a r   t h a t   =   t h i s ,  
 	 	 	 d o c   =   d o c u m e n t ,  
 	 	 	 i ;  
  
 	         t h a t . w r a p p e r   =   t y p e o f   e l   = =   ' o b j e c t '   ?   e l   :   d o c . g e t E l e m e n t B y I d ( e l ) ;  
 	         t h a t . w r a p p e r . s t y l e . o v e r f l o w   =   ' h i d d e n ' ;  
 	         t h a t . s c r o l l e r   =   t h a t . w r a p p e r . c h i l d r e n [ 0 ] ;  
  
 	         / /   D e f a u l t   o p t i o n s  
 	         t h a t . o p t i o n s   =   {  
 	                 h S c r o l l :   t r u e ,  
 	                 v S c r o l l :   t r u e ,  
 	                 b o u n c e :   t r u e ,  
 	                 b o u n c e L o c k :   f a l s e ,  
 	                 m o m e n t u m :   t r u e ,  
 	                 l o c k D i r e c t i o n :   t r u e ,  
 	                 u s e T r a n s f o r m :   t r u e ,  
 	                 u s e T r a n s i t i o n :   f a l s e ,  
 	                 c h e c k D O M C h a n g e s :   f a l s e ,   	 / /   E x p e r i m e n t a l  
  
 	                 / /   S c r o l l b a r  
 	                 h S c r o l l b a r :   t r u e ,  
 	                 v S c r o l l b a r :   t r u e ,  
 	                 f i x e d S c r o l l b a r :   i s A n d r o i d ,  
 	                 h i d e S c r o l l b a r :   i s I D e v i c e ,  
 	                 f a d e S c r o l l b a r :   i s I D e v i c e   & &   h a s 3 d ,  
 	                 s c r o l l b a r C l a s s :   ' ' ,  
  
 	                 / /   Z o o m  
 	                 z o o m :   f a l s e ,  
 	                 z o o m M i n :   1 ,  
 	                 z o o m M a x :   4 ,  
 	                 d o u b l e T a p Z o o m :   2 ,  
 	                 w h e e l A c t i o n :   ' s c r o l l ' ,  
  
 	                 / /   S n a p  
 	                 s n a p :   f a l s e ,  
 	                 s n a p T h r e s h o l d :   1 ,  
  
 	                 / /   E v e n t s  
 	                 o n R e f r e s h :   n u l l ,  
 	                 o n B e f o r e S c r o l l S t a r t :   f u n c t i o n ( e )   {   e . p r e v e n t D e f a u l t ( ) ;   } ,  
 	                 o n S c r o l l S t a r t :   n u l l ,  
 	                 o n B e f o r e S c r o l l M o v e :   n u l l ,  
 	                 o n S c r o l l M o v e :   n u l l ,  
 	                 o n B e f o r e S c r o l l E n d :   n u l l ,  
 	                 o n S c r o l l E n d :   n u l l ,  
 	                 o n T o u c h E n d :   n u l l ,  
 	                 o n D e s t r o y :   n u l l ,  
 	                 o n Z o o m S t a r t :   n u l l ,  
 	                 o n Z o o m :   n u l l ,  
 	                 o n Z o o m E n d :   n u l l  
 	         } ;  
  
 	         / /   U s e r   d e f i n e d   o p t i o n s  
 	         f o r   ( i   i n   o p t i o n s )   t h a t . o p t i o n s [ i ]   =   o p t i o n s [ i ] ;  
  
 	         / /   N o r m a l i z e   o p t i o n s  
 	         t h a t . o p t i o n s . u s e T r a n s f o r m   =   h a s T r a n s f o r m   ?   t h a t . o p t i o n s . u s e T r a n s f o r m   :   f a l s e ;  
 	         t h a t . o p t i o n s . h S c r o l l b a r   =   t h a t . o p t i o n s . h S c r o l l   & &   t h a t . o p t i o n s . h S c r o l l b a r ;  
 	         t h a t . o p t i o n s . v S c r o l l b a r   =   t h a t . o p t i o n s . v S c r o l l   & &   t h a t . o p t i o n s . v S c r o l l b a r ;  
 	         t h a t . o p t i o n s . z o o m   =   t h a t . o p t i o n s . u s e T r a n s f o r m   & &   t h a t . o p t i o n s . z o o m ;  
 	         t h a t . o p t i o n s . u s e T r a n s i t i o n   =   h a s T r a n s i t i o n E n d   & &   t h a t . o p t i o n s . u s e T r a n s i t i o n ;  
  
 	         / /   S e t   s o m e   d e f a u l t   s t y l e s  
 	         t h a t . s c r o l l e r . s t y l e [ v e n d o r   +   ' T r a n s i t i o n P r o p e r t y ' ]   =   t h a t . o p t i o n s . u s e T r a n s f o r m   ?   ' - '   +   v e n d o r . t o L o w e r C a s e ( )   +   ' - t r a n s f o r m '   :   ' t o p   l e f t ' ;  
 	         t h a t . s c r o l l e r . s t y l e [ v e n d o r   +   ' T r a n s i t i o n D u r a t i o n ' ]   =   ' 0 ' ;  
 	         t h a t . s c r o l l e r . s t y l e [ v e n d o r   +   ' T r a n s f o r m O r i g i n ' ]   =   ' 0   0 ' ;  
 	         i f   ( t h a t . o p t i o n s . u s e T r a n s i t i o n )   t h a t . s c r o l l e r . s t y l e [ v e n d o r   +   ' T r a n s i t i o n T i m i n g F u n c t i o n ' ]   =   ' c u b i c - b e z i e r ( 0 . 3 3 , 0 . 6 6 , 0 . 6 6 , 1 ) ' ;  
  
 	         i f   ( t h a t . o p t i o n s . u s e T r a n s f o r m )   t h a t . s c r o l l e r . s t y l e [ v e n d o r   +   ' T r a n s f o r m ' ]   =   t r n O p e n   +   ' 0 , 0 '   +   t r n C l o s e ;  
 	         e l s e   t h a t . s c r o l l e r . s t y l e . c s s T e x t   + =   ' ; p o s i t i o n : a b s o l u t e ; t o p : 0 ; l e f t : 0 ' ;  
  
 	         i f   ( t h a t . o p t i o n s . u s e T r a n s i t i o n )   t h a t . o p t i o n s . f i x e d S c r o l l b a r   =   t r u e ;  
  
 	         t h a t . r e f r e s h ( ) ;  
  
 	         t h a t . _ b i n d ( R E S I Z E _ E V ,   w i n d o w ) ;  
 	         t h a t . _ b i n d ( S T A R T _ E V ) ;  
 	         i f   ( ! h a s T o u c h )   {  
 	                 t h a t . _ b i n d ( ' m o u s e o u t ' ,   t h a t . w r a p p e r ) ;  
 	                 t h a t . _ b i n d ( W H E E L _ E V ) ;  
 	         }  
  
 	         i f   ( t h a t . o p t i o n s . c h e c k D O M C h a n g e s )   t h a t . c h e c k D O M T i m e   =   s e t I n t e r v a l ( f u n c t i o n ( )   {  
 	                 t h a t . _ c h e c k D O M C h a n g e s ( ) ;  
 	         } ,   5 0 0 ) ;  
 	 } ;  
  
         / /   P r o t o t y p e  
         i S c r o l l . p r o t o t y p e   =   {  
                 e n a b l e d :   t r u e ,  
                 x :   0 ,  
                 y :   0 ,  
                 s t e p s :   [ ] ,  
                 s c a l e :   1 ,  
                 c u r r P a g e X :   0 ,   c u r r P a g e Y :   0 ,  
                 p a g e s X :   [ ] ,   p a g e s Y :   [ ] ,  
                 a n i T i m e :   n u l l ,  
  
                 h a n d l e E v e n t :   f u n c t i o n ( e )   {  
                         v a r   t h a t   =   t h i s ;  
                         s w i t c h   ( e . t y p e )   {  
                                 c a s e   S T A R T _ E V :  
                                         i f   ( ! h a s T o u c h   & &   e . b u t t o n   ! = =   0 )   r e t u r n ;  
                                         t h a t . _ s t a r t ( e ) ;  
                                         b r e a k ;  
                                 c a s e   M O V E _ E V :   t h a t . _ m o v e ( e ) ;   b r e a k ;  
                                 c a s e   E N D _ E V :  
                                 c a s e   C A N C E L _ E V :   t h a t . _ e n d ( e ) ;   b r e a k ;  
                                 c a s e   R E S I Z E _ E V :   t h a t . _ r e s i z e ( ) ;   b r e a k ;  
                                 c a s e   W H E E L _ E V :   t h a t . _ w h e e l ( e ) ;   b r e a k ;  
                                 c a s e   ' m o u s e o u t ' :   t h a t . _ m o u s e o u t ( e ) ;   b r e a k ;  
                                 c a s e   ' w e b k i t T r a n s i t i o n E n d ' :   t h a t . _ t r a n s i t i o n E n d ( e ) ;   b r e a k ;  
                         }  
                 } ,  
  
                 _ c h e c k D O M C h a n g e s :   f u n c t i o n ( )   {  
                         i f   ( t h i s . m o v e d   | |   t h i s . z o o m e d   | |   t h i s . a n i m a t i n g   | |  
 	 	 	 ( t h i s . s c r o l l e r W   = =   t h i s . s c r o l l e r . o f f s e t W i d t h   *   t h i s . s c a l e   & &   t h i s . s c r o l l e r H   = =   t h i s . s c r o l l e r . o f f s e t H e i g h t   *   t h i s . s c a l e ) )   r e t u r n ;  
  
                         t h i s . r e f r e s h ( ) ;  
                 } ,  
  
                 _ s c r o l l b a r :   f u n c t i o n ( d i r )   {  
                         v a r   t h a t   =   t h i s ,  
 	 	 	 d o c   =   d o c u m e n t ,  
 	 	 	 b a r ;  
  
                         i f   ( ! t h a t [ d i r   +   ' S c r o l l b a r ' ] )   {  
                                 i f   ( t h a t [ d i r   +   ' S c r o l l b a r W r a p p e r ' ] )   {  
                                         i f   ( h a s T r a n s f o r m )   t h a t [ d i r   +   ' S c r o l l b a r I n d i c a t o r ' ] . s t y l e [ v e n d o r   +   ' T r a n s f o r m ' ]   =   ' ' ;  
                                         t h a t [ d i r   +   ' S c r o l l b a r W r a p p e r ' ] . p a r e n t N o d e . r e m o v e C h i l d ( t h a t [ d i r   +   ' S c r o l l b a r W r a p p e r ' ] ) ;  
                                         t h a t [ d i r   +   ' S c r o l l b a r W r a p p e r ' ]   =   n u l l ;  
                                         t h a t [ d i r   +   ' S c r o l l b a r I n d i c a t o r ' ]   =   n u l l ;  
                                 }  
  
                                 r e t u r n ;  
                         }  
  
                         i f   ( ! t h a t [ d i r   +   ' S c r o l l b a r W r a p p e r ' ] )   {  
                                 / /   C r e a t e   t h e   s c r o l l b a r   w r a p p e r  
                                 b a r   =   d o c . c r e a t e E l e m e n t ( ' d i v ' ) ;  
  
                                 i f   ( t h a t . o p t i o n s . s c r o l l b a r C l a s s )   b a r . c l a s s N a m e   =   t h a t . o p t i o n s . s c r o l l b a r C l a s s   +   d i r . t o U p p e r C a s e ( ) ;  
                                 e l s e   b a r . s t y l e . c s s T e x t   =   ' p o s i t i o n : a b s o l u t e ; z - i n d e x : 1 0 0 ; '   +   ( d i r   = =   ' h '   ?   ' h e i g h t : 7 p x ; b o t t o m : 1 p x ; l e f t : 2 p x ; r i g h t : '   +   ( t h a t . v S c r o l l b a r   ?   ' 7 '   :   ' 2 ' )   +   ' p x '   :   ' w i d t h : 7 p x ; b o t t o m : '   +   ( t h a t . h S c r o l l b a r   ?   ' 7 '   :   ' 2 ' )   +   ' p x ; t o p : 2 p x ; r i g h t : 1 p x ' ) ;  
  
                                 b a r . s t y l e . c s s T e x t   + =   ' ; p o i n t e r - e v e n t s : n o n e ; - '   +   v e n d o r   +   ' - t r a n s i t i o n - p r o p e r t y : o p a c i t y ; - '   +   v e n d o r   +   ' - t r a n s i t i o n - d u r a t i o n : '   +   ( t h a t . o p t i o n s . f a d e S c r o l l b a r   ?   ' 3 5 0 m s '   :   ' 0 ' )   +   ' ; o v e r f l o w : h i d d e n ; o p a c i t y : '   +   ( t h a t . o p t i o n s . h i d e S c r o l l b a r   ?   ' 0 '   :   ' 1 ' ) ;  
  
                                 t h a t . w r a p p e r . a p p e n d C h i l d ( b a r ) ;  
                                 t h a t [ d i r   +   ' S c r o l l b a r W r a p p e r ' ]   =   b a r ;  
  
                                 / /   C r e a t e   t h e   s c r o l l b a r   i n d i c a t o r  
                                 b a r   =   d o c . c r e a t e E l e m e n t ( ' d i v ' ) ;  
                                 i f   ( ! t h a t . o p t i o n s . s c r o l l b a r C l a s s )   {  
                                         b a r . s t y l e . c s s T e x t   =   ' p o s i t i o n : a b s o l u t e ; z - i n d e x : 1 0 0 ; b a c k g r o u n d : r g b a ( 0 , 0 , 0 , 0 . 5 ) ; b o r d e r : 1 p x   s o l i d   r g b a ( 2 5 5 , 2 5 5 , 2 5 5 , 0 . 9 ) ; - '   +   v e n d o r   +   ' - b a c k g r o u n d - c l i p : p a d d i n g - b o x ; - '   +   v e n d o r   +   ' - b o x - s i z i n g : b o r d e r - b o x ; '   +   ( d i r   = =   ' h '   ?   ' h e i g h t : 1 0 0 % '   :   ' w i d t h : 1 0 0 % ' )   +   ' ; - '   +   v e n d o r   +   ' - b o r d e r - r a d i u s : 3 p x ; b o r d e r - r a d i u s : 3 p x ' ;  
                                 }  
                                 b a r . s t y l e . c s s T e x t   + =   ' ; p o i n t e r - e v e n t s : n o n e ; - '   +   v e n d o r   +   ' - t r a n s i t i o n - p r o p e r t y : - '   +   v e n d o r   +   ' - t r a n s f o r m ; - '   +   v e n d o r   +   ' - t r a n s i t i o n - t i m i n g - f u n c t i o n : c u b i c - b e z i e r ( 0 . 3 3 , 0 . 6 6 , 0 . 6 6 , 1 ) ; - '   +   v e n d o r   +   ' - t r a n s i t i o n - d u r a t i o n : 0 ; - '   +   v e n d o r   +   ' - t r a n s f o r m : '   +   t r n O p e n   +   ' 0 , 0 '   +   t r n C l o s e ;  
                                 i f   ( t h a t . o p t i o n s . u s e T r a n s i t i o n )   b a r . s t y l e . c s s T e x t   + =   ' ; - '   +   v e n d o r   +   ' - t r a n s i t i o n - t i m i n g - f u n c t i o n : c u b i c - b e z i e r ( 0 . 3 3 , 0 . 6 6 , 0 . 6 6 , 1 ) ' ;  
  
                                 t h a t [ d i r   +   ' S c r o l l b a r W r a p p e r ' ] . a p p e n d C h i l d ( b a r ) ;  
                                 t h a t [ d i r   +   ' S c r o l l b a r I n d i c a t o r ' ]   =   b a r ;  
                         }  
  
                         i f   ( d i r   = =   ' h ' )   {  
                                 t h a t . h S c r o l l b a r S i z e   =   t h a t . h S c r o l l b a r W r a p p e r . c l i e n t W i d t h ;  
                                 t h a t . h S c r o l l b a r I n d i c a t o r S i z e   =   m . m a x ( m . r o u n d ( t h a t . h S c r o l l b a r S i z e   *   t h a t . h S c r o l l b a r S i z e   /   t h a t . s c r o l l e r W ) ,   8 ) ;  
                                 t h a t . h S c r o l l b a r I n d i c a t o r . s t y l e . w i d t h   =   t h a t . h S c r o l l b a r I n d i c a t o r S i z e   +   ' p x ' ;  
                                 t h a t . h S c r o l l b a r M a x S c r o l l   =   t h a t . h S c r o l l b a r S i z e   -   t h a t . h S c r o l l b a r I n d i c a t o r S i z e ;  
                                 t h a t . h S c r o l l b a r P r o p   =   t h a t . h S c r o l l b a r M a x S c r o l l   /   t h a t . m a x S c r o l l X ;  
                         }   e l s e   {  
                                 t h a t . v S c r o l l b a r S i z e   =   t h a t . v S c r o l l b a r W r a p p e r . c l i e n t H e i g h t ;  
                                 t h a t . v S c r o l l b a r I n d i c a t o r S i z e   =   m . m a x ( m . r o u n d ( t h a t . v S c r o l l b a r S i z e   *   t h a t . v S c r o l l b a r S i z e   /   t h a t . s c r o l l e r H ) ,   8 ) ;  
                                 t h a t . v S c r o l l b a r I n d i c a t o r . s t y l e . h e i g h t   =   t h a t . v S c r o l l b a r I n d i c a t o r S i z e   +   ' p x ' ;  
                                 t h a t . v S c r o l l b a r M a x S c r o l l   =   t h a t . v S c r o l l b a r S i z e   -   t h a t . v S c r o l l b a r I n d i c a t o r S i z e ;  
                                 t h a t . v S c r o l l b a r P r o p   =   t h a t . v S c r o l l b a r M a x S c r o l l   /   t h a t . m a x S c r o l l Y ;  
                         }  
  
                         / /   R e s e t   p o s i t i o n  
                         t h a t . _ s c r o l l b a r P o s ( d i r ,   t r u e ) ;  
                 } ,  
  
                 _ r e s i z e :   f u n c t i o n ( )   {  
                         v a r   t h a t   =   t h i s ;  
                         s e t T i m e o u t ( f u n c t i o n ( )   {   t h a t . r e f r e s h ( ) ;   } ,   i s A n d r o i d   ?   2 0 0   :   0 ) ;  
                 } ,  
  
                 _ p o s :   f u n c t i o n ( x ,   y )   {  
                         x   =   t h i s . h S c r o l l   ?   x   :   0 ;  
                         y   =   t h i s . v S c r o l l   ?   y   :   0 ;  
  
                         i f   ( t h i s . o p t i o n s . u s e T r a n s f o r m )   {  
                                 t h i s . s c r o l l e r . s t y l e [ v e n d o r   +   ' T r a n s f o r m ' ]   =   t r n O p e n   +   x   +   ' p x , '   +   y   +   ' p x '   +   t r n C l o s e   +   '   s c a l e ( '   +   t h i s . s c a l e   +   ' ) ' ;  
                         }   e l s e   {  
                                 x   =   m . r o u n d ( x ) ;  
                                 y   =   m . r o u n d ( y ) ;  
                                 t h i s . s c r o l l e r . s t y l e . l e f t   =   x   +   ' p x ' ;  
                                 t h i s . s c r o l l e r . s t y l e . t o p   =   y   +   ' p x ' ;  
                         }  
  
                         t h i s . x   =   x ;  
                         t h i s . y   =   y ;  
  
                         t h i s . _ s c r o l l b a r P o s ( ' h ' ) ;  
                         t h i s . _ s c r o l l b a r P o s ( ' v ' ) ;  
                 } ,  
  
                 _ s c r o l l b a r P o s :   f u n c t i o n ( d i r ,   h i d d e n )   {  
                         v a r   t h a t   =   t h i s ,  
 	 	 	 p o s   =   d i r   = =   ' h '   ?   t h a t . x   :   t h a t . y ,  
 	 	 	 s i z e ;  
  
                         i f   ( ! t h a t [ d i r   +   ' S c r o l l b a r ' ] )   r e t u r n ;  
  
                         p o s   =   t h a t [ d i r   +   ' S c r o l l b a r P r o p ' ]   *   p o s ;  
  
                         i f   ( p o s   <   0 )   {  
                                 i f   ( ! t h a t . o p t i o n s . f i x e d S c r o l l b a r )   {  
                                         s i z e   =   t h a t [ d i r   +   ' S c r o l l b a r I n d i c a t o r S i z e ' ]   +   m . r o u n d ( p o s   *   3 ) ;  
                                         i f   ( s i z e   <   8 )   s i z e   =   8 ;  
                                         t h a t [ d i r   +   ' S c r o l l b a r I n d i c a t o r ' ] . s t y l e [ d i r   = =   ' h '   ?   ' w i d t h '   :   ' h e i g h t ' ]   =   s i z e   +   ' p x ' ;  
                                 }  
                                 p o s   =   0 ;  
                         }   e l s e   i f   ( p o s   >   t h a t [ d i r   +   ' S c r o l l b a r M a x S c r o l l ' ] )   {  
                                 i f   ( ! t h a t . o p t i o n s . f i x e d S c r o l l b a r )   {  
                                         s i z e   =   t h a t [ d i r   +   ' S c r o l l b a r I n d i c a t o r S i z e ' ]   -   m . r o u n d ( ( p o s   -   t h a t [ d i r   +   ' S c r o l l b a r M a x S c r o l l ' ] )   *   3 ) ;  
                                         i f   ( s i z e   <   8 )   s i z e   =   8 ;  
                                         t h a t [ d i r   +   ' S c r o l l b a r I n d i c a t o r ' ] . s t y l e [ d i r   = =   ' h '   ?   ' w i d t h '   :   ' h e i g h t ' ]   =   s i z e   +   ' p x ' ;  
                                         p o s   =   t h a t [ d i r   +   ' S c r o l l b a r M a x S c r o l l ' ]   +   ( t h a t [ d i r   +   ' S c r o l l b a r I n d i c a t o r S i z e ' ]   -   s i z e ) ;  
                                 }   e l s e   {  
                                         p o s   =   t h a t [ d i r   +   ' S c r o l l b a r M a x S c r o l l ' ] ;  
                                 }  
                         }  
  
                         t h a t [ d i r   +   ' S c r o l l b a r W r a p p e r ' ] . s t y l e [ v e n d o r   +   ' T r a n s i t i o n D e l a y ' ]   =   ' 0 ' ;  
                         t h a t [ d i r   +   ' S c r o l l b a r W r a p p e r ' ] . s t y l e . o p a c i t y   =   h i d d e n   & &   t h a t . o p t i o n s . h i d e S c r o l l b a r   ?   ' 0 '   :   ' 1 ' ;  
                         t h a t [ d i r   +   ' S c r o l l b a r I n d i c a t o r ' ] . s t y l e [ v e n d o r   +   ' T r a n s f o r m ' ]   =   t r n O p e n   +   ( d i r   = =   ' h '   ?   p o s   +   ' p x , 0 '   :   ' 0 , '   +   p o s   +   ' p x ' )   +   t r n C l o s e ;  
                 } ,  
  
                 _ s t a r t :   f u n c t i o n ( e )   {  
                         v a r   t h a t   =   t h i s ,  
 	 	 	 p o i n t   =   h a s T o u c h   ?   e . t o u c h e s [ 0 ]   :   e ,  
 	 	 	 m a t r i x ,   x ,   y ,  
 	 	 	 c 1 ,   c 2 ;  
  
                         i f   ( ! t h a t . e n a b l e d )   r e t u r n ;  
  
                         i f   ( t h a t . o p t i o n s . o n B e f o r e S c r o l l S t a r t )   t h a t . o p t i o n s . o n B e f o r e S c r o l l S t a r t . c a l l ( t h a t ,   e ) ;  
  
                         i f   ( t h a t . o p t i o n s . u s e T r a n s i t i o n )   t h a t . _ t r a n s i t i o n T i m e ( 0 ) ;  
  
                         t h a t . m o v e d   =   f a l s e ;  
                         t h a t . a n i m a t i n g   =   f a l s e ;  
                         t h a t . z o o m e d   =   f a l s e ;  
                         t h a t . d i s t X   =   0 ;  
                         t h a t . d i s t Y   =   0 ;  
                         t h a t . a b s D i s t X   =   0 ;  
                         t h a t . a b s D i s t Y   =   0 ;  
                         t h a t . d i r X   =   0 ;  
                         t h a t . d i r Y   =   0 ;  
  
                         / /   G e s t u r e   s t a r t  
                         i f   ( t h a t . o p t i o n s . z o o m   & &   h a s T o u c h   & &   e . t o u c h e s . l e n g t h   >   1 )   {  
                                 c 1   =   m . a b s ( e . t o u c h e s [ 0 ] . p a g e X   -   e . t o u c h e s [ 1 ] . p a g e X ) ;  
                                 c 2   =   m . a b s ( e . t o u c h e s [ 0 ] . p a g e Y   -   e . t o u c h e s [ 1 ] . p a g e Y ) ;  
                                 t h a t . t o u c h e s D i s t S t a r t   =   m . s q r t ( c 1   *   c 1   +   c 2   *   c 2 ) ;  
  
                                 t h a t . o r i g i n X   =   m . a b s ( e . t o u c h e s [ 0 ] . p a g e X   +   e . t o u c h e s [ 1 ] . p a g e X   -   t h a t . w r a p p e r O f f s e t L e f t   *   2 )   /   2   -   t h a t . x ;  
                                 t h a t . o r i g i n Y   =   m . a b s ( e . t o u c h e s [ 0 ] . p a g e Y   +   e . t o u c h e s [ 1 ] . p a g e Y   -   t h a t . w r a p p e r O f f s e t T o p   *   2 )   /   2   -   t h a t . y ;  
  
                                 i f   ( t h a t . o p t i o n s . o n Z o o m S t a r t )   t h a t . o p t i o n s . o n Z o o m S t a r t . c a l l ( t h a t ,   e ) ;  
                         }  
  
                         i f   ( t h a t . o p t i o n s . m o m e n t u m )   {  
                                 i f   ( t h a t . o p t i o n s . u s e T r a n s f o r m )   {  
                                         / /   V e r y   l a m e   g e n e r a l   p u r p o s e   a l t e r n a t i v e   t o   C S S M a t r i x  
                                         m a t r i x   =   g e t C o m p u t e d S t y l e ( t h a t . s c r o l l e r ,   n u l l ) [ v e n d o r   +   ' T r a n s f o r m ' ] . r e p l a c e ( / [ ^ 0 - 9 - . , ] / g ,   ' ' ) . s p l i t ( ' , ' ) ;  
                                         x   =   m a t r i x [ 4 ]   *   1 ;  
                                         y   =   m a t r i x [ 5 ]   *   1 ;  
                                 }   e l s e   {  
                                         x   =   g e t C o m p u t e d S t y l e ( t h a t . s c r o l l e r ,   n u l l ) . l e f t . r e p l a c e ( / [ ^ 0 - 9 - ] / g ,   ' ' )   *   1 ;  
                                         y   =   g e t C o m p u t e d S t y l e ( t h a t . s c r o l l e r ,   n u l l ) . t o p . r e p l a c e ( / [ ^ 0 - 9 - ] / g ,   ' ' )   *   1 ;  
                                 }  
  
                                 i f   ( x   ! =   t h a t . x   | |   y   ! =   t h a t . y )   {  
                                         i f   ( t h a t . o p t i o n s . u s e T r a n s i t i o n )   t h a t . _ u n b i n d ( ' w e b k i t T r a n s i t i o n E n d ' ) ;  
                                         e l s e   c a n c e l F r a m e ( t h a t . a n i T i m e ) ;  
                                         t h a t . s t e p s   =   [ ] ;  
                                         t h a t . _ p o s ( x ,   y ) ;  
                                 }  
                         }  
  
                         t h a t . a b s S t a r t X   =   t h a t . x ;   / /   N e e d e d   b y   s n a p   t h r e s h o l d  
                         t h a t . a b s S t a r t Y   =   t h a t . y ;  
  
                         t h a t . s t a r t X   =   t h a t . x ;  
                         t h a t . s t a r t Y   =   t h a t . y ;  
                         t h a t . p o i n t X   =   p o i n t . p a g e X ;  
                         t h a t . p o i n t Y   =   p o i n t . p a g e Y ;  
  
                         t h a t . s t a r t T i m e   =   e . t i m e S t a m p   | |   ( n e w   D a t e ( ) ) . g e t T i m e ( ) ;  
  
                         i f   ( t h a t . o p t i o n s . o n S c r o l l S t a r t )   t h a t . o p t i o n s . o n S c r o l l S t a r t . c a l l ( t h a t ,   e ) ;  
  
                         t h a t . _ b i n d ( M O V E _ E V ) ;  
                         t h a t . _ b i n d ( E N D _ E V ) ;  
                         t h a t . _ b i n d ( C A N C E L _ E V ) ;  
                 } ,  
  
                 _ m o v e :   f u n c t i o n ( e )   {  
                         v a r   t h a t   =   t h i s ,  
 	 	 	 p o i n t   =   h a s T o u c h   ?   e . t o u c h e s [ 0 ]   :   e ,  
 	 	 	 d e l t a X   =   p o i n t . p a g e X   -   t h a t . p o i n t X ,  
 	 	 	 d e l t a Y   =   p o i n t . p a g e Y   -   t h a t . p o i n t Y ,  
 	 	 	 n e w X   =   t h a t . x   +   d e l t a X ,  
 	 	 	 n e w Y   =   t h a t . y   +   d e l t a Y ,  
 	 	 	 c 1 ,   c 2 ,   s c a l e ,  
 	 	 	 t i m e s t a m p   =   e . t i m e S t a m p   | |   ( n e w   D a t e ( ) ) . g e t T i m e ( ) ;  
  
                         i f   ( t h a t . o p t i o n s . o n B e f o r e S c r o l l M o v e )   t h a t . o p t i o n s . o n B e f o r e S c r o l l M o v e . c a l l ( t h a t ,   e ) ;  
  
                         / /   Z o o m  
                         i f   ( t h a t . o p t i o n s . z o o m   & &   h a s T o u c h   & &   e . t o u c h e s . l e n g t h   >   1 )   {  
                                 c 1   =   m . a b s ( e . t o u c h e s [ 0 ] . p a g e X   -   e . t o u c h e s [ 1 ] . p a g e X ) ;  
                                 c 2   =   m . a b s ( e . t o u c h e s [ 0 ] . p a g e Y   -   e . t o u c h e s [ 1 ] . p a g e Y ) ;  
                                 t h a t . t o u c h e s D i s t   =   m . s q r t ( c 1   *   c 1   +   c 2   *   c 2 ) ;  
  
                                 t h a t . z o o m e d   =   t r u e ;  
  
                                 s c a l e   =   1   /   t h a t . t o u c h e s D i s t S t a r t   *   t h a t . t o u c h e s D i s t   *   t h i s . s c a l e ;  
                                 i f   ( s c a l e   <   0 . 5 )   s c a l e   =   0 . 5 ;  
                                 e l s e   i f   ( s c a l e   >   t h a t . o p t i o n s . z o o m M a x )   s c a l e   =   t h a t . o p t i o n s . z o o m M a x ;  
  
                                 / / 	 	 	 i f   ( s c a l e   <   t h a t . o p t i o n s . s c a l e M i n )   s c a l e   =   0 . 5   *   t h a t . o p t i o n s . s c a l e M i n   *   M a t h . p o w ( 2 . 0 ,   s c a l e   /   t h a t . o p t i o n s . s c a l e M i n ) ;  
                                 / / 	 	 	 e l s e   i f   ( s c a l e   >   t h a t . o p t i o n s . s c a l e M a x )   s c a l e   =   2 . 0   *   t h a t . o p t i o n s . s c a l e M a x   *   M a t h . p o w ( 0 . 5 ,   t h a t . o p t i o n s . s c a l e M a x   /   s c a l e ) ;  
  
                                 t h a t . l a s t S c a l e   =   s c a l e   /   t h i s . s c a l e ;  
  
                                 n e w X   =   t h i s . o r i g i n X   -   t h i s . o r i g i n X   *   t h a t . l a s t S c a l e   +   t h i s . x ,  
 	 	 	 n e w Y   =   t h i s . o r i g i n Y   -   t h i s . o r i g i n Y   *   t h a t . l a s t S c a l e   +   t h i s . y ;  
  
                                 t h i s . s c r o l l e r . s t y l e [ v e n d o r   +   ' T r a n s f o r m ' ]   =   t r n O p e n   +   n e w X   +   ' p x , '   +   n e w Y   +   ' p x '   +   t r n C l o s e   +   '   s c a l e ( '   +   s c a l e   +   ' ) ' ;  
  
                                 i f   ( t h a t . o p t i o n s . o n Z o o m )   t h a t . o p t i o n s . o n Z o o m . c a l l ( t h a t ,   e ) ;  
                                 r e t u r n ;  
                         }  
  
                         t h a t . p o i n t X   =   p o i n t . p a g e X ;  
                         t h a t . p o i n t Y   =   p o i n t . p a g e Y ;  
  
                         / /   S l o w   d o w n   i f   o u t s i d e   o f   t h e   b o u n d a r i e s  
                         i f   ( n e w X   >   0   | |   n e w X   <   t h a t . m a x S c r o l l X )   {  
                                 n e w X   =   t h a t . o p t i o n s . b o u n c e   ?   t h a t . x   +   ( d e l t a X   /   2 )   :   n e w X   > =   0   | |   t h a t . m a x S c r o l l X   > =   0   ?   0   :   t h a t . m a x S c r o l l X ;  
                         }  
                         i f   ( n e w Y   >   0   | |   n e w Y   <   t h a t . m a x S c r o l l Y )   {  
                                 n e w Y   =   t h a t . o p t i o n s . b o u n c e   ?   t h a t . y   +   ( d e l t a Y   /   2 )   :   n e w Y   > =   0   | |   t h a t . m a x S c r o l l Y   > =   0   ?   0   :   t h a t . m a x S c r o l l Y ;  
                         }  
  
                         i f   ( t h a t . a b s D i s t X   <   6   & &   t h a t . a b s D i s t Y   <   6 )   {  
                                 t h a t . d i s t X   + =   d e l t a X ;  
                                 t h a t . d i s t Y   + =   d e l t a Y ;  
                                 t h a t . a b s D i s t X   =   m . a b s ( t h a t . d i s t X ) ;  
                                 t h a t . a b s D i s t Y   =   m . a b s ( t h a t . d i s t Y ) ;  
  
                                 r e t u r n ;  
                         }  
  
                         / /   L o c k   d i r e c t i o n  
                         i f   ( t h a t . o p t i o n s . l o c k D i r e c t i o n )   {  
                                 i f   ( t h a t . a b s D i s t X   >   t h a t . a b s D i s t Y   +   5 )   {  
                                         n e w Y   =   t h a t . y ;  
                                         d e l t a Y   =   0 ;  
                                 }   e l s e   i f   ( t h a t . a b s D i s t Y   >   t h a t . a b s D i s t X   +   5 )   {  
                                         n e w X   =   t h a t . x ;  
                                         d e l t a X   =   0 ;  
                                 }  
                         }  
  
                         t h a t . m o v e d   =   t r u e ;  
                         t h a t . _ p o s ( n e w X ,   n e w Y ) ;  
                         t h a t . d i r X   =   d e l t a X   >   0   ?   - 1   :   d e l t a X   <   0   ?   1   :   0 ;  
                         t h a t . d i r Y   =   d e l t a Y   >   0   ?   - 1   :   d e l t a Y   <   0   ?   1   :   0 ;  
  
                         i f   ( t i m e s t a m p   -   t h a t . s t a r t T i m e   >   3 0 0 )   {  
                                 t h a t . s t a r t T i m e   =   t i m e s t a m p ;  
                                 t h a t . s t a r t X   =   t h a t . x ;  
                                 t h a t . s t a r t Y   =   t h a t . y ;  
                         }  
  
                         i f   ( t h a t . o p t i o n s . o n S c r o l l M o v e )   t h a t . o p t i o n s . o n S c r o l l M o v e . c a l l ( t h a t ,   e ) ;  
                 } ,  
  
                 _ e n d :   f u n c t i o n ( e )   {  
                         i f   ( h a s T o u c h   & &   e . t o u c h e s . l e n g t h   ! =   0 )   r e t u r n ;  
  
                         v a r   t h a t   =   t h i s ,  
 	 	 	 p o i n t   =   h a s T o u c h   ?   e . c h a n g e d T o u c h e s [ 0 ]   :   e ,  
 	 	 	 t a r g e t ,   e v ,  
 	 	 	 m o m e n t u m X   =   {   d i s t :   0 ,   t i m e :   0   } ,  
 	 	 	 m o m e n t u m Y   =   {   d i s t :   0 ,   t i m e :   0   } ,  
 	 	 	 d u r a t i o n   =   ( e . t i m e S t a m p   | |   ( n e w   D a t e ( ) ) . g e t T i m e ( ) )   -   t h a t . s t a r t T i m e ,  
 	 	 	 n e w P o s X   =   t h a t . x ,  
 	 	 	 n e w P o s Y   =   t h a t . y ,  
 	 	 	 d i s t X ,   d i s t Y ,  
 	 	 	 n e w D u r a t i o n ;  
  
                         t h a t . _ u n b i n d ( M O V E _ E V ) ;  
                         t h a t . _ u n b i n d ( E N D _ E V ) ;  
                         t h a t . _ u n b i n d ( C A N C E L _ E V ) ;  
  
                         i f   ( t h a t . o p t i o n s . o n B e f o r e S c r o l l E n d )   t h a t . o p t i o n s . o n B e f o r e S c r o l l E n d . c a l l ( t h a t ,   e ) ;  
  
                         i f   ( t h a t . z o o m e d )   {  
                                 t h a t . s c a l e   =   t h a t . s c a l e   *   t h a t . l a s t S c a l e ;  
                                 t h a t . x   =   t h a t . o r i g i n X   -   t h a t . o r i g i n X   *   t h a t . l a s t S c a l e   +   t h a t . x ;  
                                 t h a t . y   =   t h a t . o r i g i n Y   -   t h a t . o r i g i n Y   *   t h a t . l a s t S c a l e   +   t h a t . y ;  
  
                                 t h a t . s c r o l l e r . s t y l e . w e b k i t T r a n s f o r m   =   t r n O p e n   +   t h a t . x   +   ' p x , '   +   t h a t . y   +   ' p x '   +   t r n C l o s e   +   '   s c a l e ( '   +   t h a t . s c a l e   +   ' ) ' ;  
  
                                 t h a t . r e f r e s h ( ) ;  
  
                                 i f   ( t h a t . o p t i o n s . o n Z o o m E n d )   t h a t . o p t i o n s . o n Z o o m E n d . c a l l ( t h a t ,   e ) ;  
                                 r e t u r n ;  
                         }  
  
                         i f   ( ! t h a t . m o v e d )   {  
                                 i f   ( h a s T o u c h )   {  
                                         i f   ( t h a t . d o u b l e T a p T i m e r   & &   t h a t . o p t i o n s . z o o m )   {  
                                                 / /   D o u b l e   t a p p e d  
                                                 c l e a r T i m e o u t ( t h a t . d o u b l e T a p T i m e r ) ;  
                                                 t h a t . d o u b l e T a p T i m e r   =   n u l l ;  
                                                 t h a t . z o o m ( t h a t . p o i n t X ,   t h a t . p o i n t Y ,   t h a t . s c a l e   = =   1   ?   t h a t . o p t i o n s . d o u b l e T a p Z o o m   :   1 ) ;  
                                         }   e l s e   {  
                                                 t h a t . d o u b l e T a p T i m e r   =   s e t T i m e o u t ( f u n c t i o n ( )   {  
                                                         t h a t . d o u b l e T a p T i m e r   =   n u l l ;  
  
                                                         / /   F i n d   t h e   l a s t   t o u c h e d   e l e m e n t  
                                                         t a r g e t   =   p o i n t . t a r g e t ;  
                                                         w h i l e   ( t a r g e t . n o d e T y p e   ! =   1 )   t a r g e t   =   t a r g e t . p a r e n t N o d e ;  
  
                                                         i f   ( t a r g e t . t a g N a m e   ! =   ' S E L E C T '   & &   t a r g e t . t a g N a m e   ! =   ' I N P U T '   & &   t a r g e t . t a g N a m e   ! =   ' T E X T A R E A ' )   {  
                                                                 e v   =   d o c u m e n t . c r e a t e E v e n t ( ' M o u s e E v e n t s ' ) ;  
                                                                 e v . i n i t M o u s e E v e n t ( ' c l i c k ' ,   t r u e ,   t r u e ,   e . v i e w ,   1 ,  
 	 	 	 	 	 	 	 	 p o i n t . s c r e e n X ,   p o i n t . s c r e e n Y ,   p o i n t . c l i e n t X ,   p o i n t . c l i e n t Y ,  
 	 	 	 	 	 	 	 	 e . c t r l K e y ,   e . a l t K e y ,   e . s h i f t K e y ,   e . m e t a K e y ,  
 	 	 	 	 	 	 	 	 0 ,   n u l l ) ;  
                                                                 e v . _ f a k e   =   t r u e ;  
                                                                 t a r g e t . d i s p a t c h E v e n t ( e v ) ;  
                                                         }  
                                                 } ,   t h a t . o p t i o n s . z o o m   ?   2 5 0   :   0 ) ;  
                                         }  
                                 }  
  
                                 t h a t . _ r e s e t P o s ( 2 0 0 ) ;  
  
                                 i f   ( t h a t . o p t i o n s . o n T o u c h E n d )   t h a t . o p t i o n s . o n T o u c h E n d . c a l l ( t h a t ,   e ) ;  
                                 r e t u r n ;  
                         }  
  
                         i f   ( d u r a t i o n   <   3 0 0   & &   t h a t . o p t i o n s . m o m e n t u m )   {  
                                 m o m e n t u m X   =   n e w P o s X   ?   t h a t . _ m o m e n t u m ( n e w P o s X   -   t h a t . s t a r t X ,   d u r a t i o n ,   - t h a t . x ,   t h a t . s c r o l l e r W   -   t h a t . w r a p p e r W   +   t h a t . x ,   t h a t . o p t i o n s . b o u n c e   ?   t h a t . w r a p p e r W   :   0 )   :   m o m e n t u m X ;  
                                 m o m e n t u m Y   =   n e w P o s Y   ?   t h a t . _ m o m e n t u m ( n e w P o s Y   -   t h a t . s t a r t Y ,   d u r a t i o n ,   - t h a t . y ,   ( t h a t . m a x S c r o l l Y   <   0   ?   t h a t . s c r o l l e r H   -   t h a t . w r a p p e r H   +   t h a t . y   :   0 ) ,   t h a t . o p t i o n s . b o u n c e   ?   t h a t . w r a p p e r H   :   0 )   :   m o m e n t u m Y ;  
  
                                 n e w P o s X   =   t h a t . x   +   m o m e n t u m X . d i s t ;  
                                 n e w P o s Y   =   t h a t . y   +   m o m e n t u m Y . d i s t ;  
  
                                 i f   ( ( t h a t . x   >   0   & &   n e w P o s X   >   0 )   | |   ( t h a t . x   <   t h a t . m a x S c r o l l X   & &   n e w P o s X   <   t h a t . m a x S c r o l l X ) )   m o m e n t u m X   =   {   d i s t :   0 ,   t i m e :   0   } ;  
                                 i f   ( ( t h a t . y   >   0   & &   n e w P o s Y   >   0 )   | |   ( t h a t . y   <   t h a t . m a x S c r o l l Y   & &   n e w P o s Y   <   t h a t . m a x S c r o l l Y ) )   m o m e n t u m Y   =   {   d i s t :   0 ,   t i m e :   0   } ;  
                         }  
  
                         i f   ( m o m e n t u m X . d i s t   | |   m o m e n t u m Y . d i s t )   {  
                                 n e w D u r a t i o n   =   m . m a x ( m . m a x ( m o m e n t u m X . t i m e ,   m o m e n t u m Y . t i m e ) ,   1 0 ) ;  
  
                                 / /   D o   w e   n e e d   t o   s n a p ?  
                                 i f   ( t h a t . o p t i o n s . s n a p )   {  
                                         d i s t X   =   n e w P o s X   -   t h a t . a b s S t a r t X ;  
                                         d i s t Y   =   n e w P o s Y   -   t h a t . a b s S t a r t Y ;  
                                         i f   ( m . a b s ( d i s t X )   <   t h a t . o p t i o n s . s n a p T h r e s h o l d   & &   m . a b s ( d i s t Y )   <   t h a t . o p t i o n s . s n a p T h r e s h o l d )   {   t h a t . s c r o l l T o ( t h a t . a b s S t a r t X ,   t h a t . a b s S t a r t Y ,   2 0 0 ) ;   }  
                                         e l s e   {  
                                                 s n a p   =   t h a t . _ s n a p ( n e w P o s X ,   n e w P o s Y ) ;  
                                                 n e w P o s X   =   s n a p . x ;  
                                                 n e w P o s Y   =   s n a p . y ;  
                                                 n e w D u r a t i o n   =   m . m a x ( s n a p . t i m e ,   n e w D u r a t i o n ) ;  
                                         }  
                                 }  
  
                                 t h a t . s c r o l l T o ( n e w P o s X ,   n e w P o s Y ,   n e w D u r a t i o n ) ;  
  
                                 i f   ( t h a t . o p t i o n s . o n T o u c h E n d )   t h a t . o p t i o n s . o n T o u c h E n d . c a l l ( t h a t ,   e ) ;  
                                 r e t u r n ;  
                         }  
  
                         / /   D o   w e   n e e d   t o   s n a p ?  
                         i f   ( t h a t . o p t i o n s . s n a p )   {  
                                 d i s t X   =   n e w P o s X   -   t h a t . a b s S t a r t X ;  
                                 d i s t Y   =   n e w P o s Y   -   t h a t . a b s S t a r t Y ;  
                                 i f   ( m . a b s ( d i s t X )   <   t h a t . o p t i o n s . s n a p T h r e s h o l d   & &   m . a b s ( d i s t Y )   <   t h a t . o p t i o n s . s n a p T h r e s h o l d )   t h a t . s c r o l l T o ( t h a t . a b s S t a r t X ,   t h a t . a b s S t a r t Y ,   2 0 0 ) ;  
                                 e l s e   {  
                                         s n a p   =   t h a t . _ s n a p ( t h a t . x ,   t h a t . y ) ;  
                                         i f   ( s n a p . x   ! =   t h a t . x   | |   s n a p . y   ! =   t h a t . y )   t h a t . s c r o l l T o ( s n a p . x ,   s n a p . y ,   s n a p . t i m e ) ;  
                                 }  
  
                                 i f   ( t h a t . o p t i o n s . o n T o u c h E n d )   t h a t . o p t i o n s . o n T o u c h E n d . c a l l ( t h a t ,   e ) ;  
                                 r e t u r n ;  
                         }  
  
                         t h a t . _ r e s e t P o s ( 2 0 0 ) ;  
                         i f   ( t h a t . o p t i o n s . o n T o u c h E n d )   t h a t . o p t i o n s . o n T o u c h E n d . c a l l ( t h a t ,   e ) ;  
                 } ,  
  
                 _ r e s e t P o s :   f u n c t i o n ( t i m e )   {  
                         v a r   t h a t   =   t h i s ,  
 	 	 	 r e s e t X   =   t h a t . x   > =   0   ?   0   :   t h a t . x   <   t h a t . m a x S c r o l l X   ?   t h a t . m a x S c r o l l X   :   t h a t . x ,  
 	 	 	 r e s e t Y   =   t h a t . y   > =   0   | |   t h a t . m a x S c r o l l Y   >   0   ?   0   :   t h a t . y   <   t h a t . m a x S c r o l l Y   ?   t h a t . m a x S c r o l l Y   :   t h a t . y ;  
  
                         i f   ( r e s e t X   = =   t h a t . x   & &   r e s e t Y   = =   t h a t . y )   {  
                                 i f   ( t h a t . m o v e d )   {  
                                         t h a t . m o v e d   =   f a l s e ;  
                                         i f   ( t h a t . o p t i o n s . o n S c r o l l E n d )   t h a t . o p t i o n s . o n S c r o l l E n d . c a l l ( t h a t ) ;   	 / /   E x e c u t e   c u s t o m   c o d e   o n   s c r o l l   e n d  
                                 }  
  
                                 i f   ( t h a t . h S c r o l l b a r   & &   t h a t . o p t i o n s . h i d e S c r o l l b a r )   {  
                                         i f   ( v e n d o r   = =   ' w e b k i t ' )   t h a t . h S c r o l l b a r W r a p p e r . s t y l e [ v e n d o r   +   ' T r a n s i t i o n D e l a y ' ]   =   ' 3 0 0 m s ' ;  
                                         t h a t . h S c r o l l b a r W r a p p e r . s t y l e . o p a c i t y   =   ' 0 ' ;  
                                 }  
                                 i f   ( t h a t . v S c r o l l b a r   & &   t h a t . o p t i o n s . h i d e S c r o l l b a r )   {  
                                         i f   ( v e n d o r   = =   ' w e b k i t ' )   t h a t . v S c r o l l b a r W r a p p e r . s t y l e [ v e n d o r   +   ' T r a n s i t i o n D e l a y ' ]   =   ' 3 0 0 m s ' ;  
                                         t h a t . v S c r o l l b a r W r a p p e r . s t y l e . o p a c i t y   =   ' 0 ' ;  
                                 }  
  
                                 r e t u r n ;  
                         }  
  
                         t h a t . s c r o l l T o ( r e s e t X ,   r e s e t Y ,   t i m e   | |   0 ) ;  
                 } ,  
  
                 _ w h e e l :   f u n c t i o n ( e )   {  
                         v a r   t h a t   =   t h i s ,  
 	 	 	 d e l t a X ,   d e l t a Y ,  
 	 	 	 d e l t a S c a l e ;  
  
                         i f   ( t h a t . o p t i o n s . w h e e l A c t i o n   = =   ' z o o m ' )   {  
                                 d e l t a Y   =   ' w h e e l D e l t a '   i n   e   ?   e . w h e e l D e l t a   :   ' d e t a i l '   i n   e   ?   e . d e t a i l   :   0 ;  
                                 d e l t a S c a l e   =   t h a t . s c a l e   *   M a t h . p o w ( 2 ,   1   /   3   *   ( d e l t a Y   ?   d e l t a Y   /   M a t h . a b s ( d e l t a Y )   :   0 ) ) ;  
                                 i f   ( d e l t a S c a l e   <   t h a t . o p t i o n s . z o o m M i n )   d e l t a S c a l e   =   t h a t . o p t i o n s . z o o m M i n ;  
                                 i f   ( d e l t a S c a l e   >   t h a t . o p t i o n s . z o o m M a x )   d e l t a S c a l e   =   t h a t . o p t i o n s . z o o m M a x ;  
                                 t h a t . z o o m ( e . p a g e X ,   e . p a g e Y ,   d e l t a S c a l e ,   4 0 0 ) ;  
  
                                 r e t u r n ;  
                         }  
  
                         i f   ( ' w h e e l D e l t a X '   i n   e )   {  
                                 d e l t a X   =   t h a t . x   +   e . w h e e l D e l t a X   /   1 2 ,  
 	 	 	 d e l t a Y   =   t h a t . y   +   e . w h e e l D e l t a Y   /   1 2 ;  
                         }   e l s e   i f   ( ' d e t a i l '   i n   e )   {  
                                 d e l t a X   =   t h a t . x   -   e . d e t a i l   *   3 ,  
 	 	 	 d e l t a Y   =   t h a t . y   -   e . d e t a i l   *   3 ;  
                         }   e l s e   {  
                                 d e l t a X   =   t h a t . x   -   e . w h e e l D e l t a ,  
 	 	 	 d e l t a Y   =   t h a t . y   -   e . w h e e l D e l t a ;  
                         }  
  
                         i f   ( d e l t a X   >   0 )   d e l t a X   =   0 ;  
                         e l s e   i f   ( d e l t a X   <   t h a t . m a x S c r o l l X )   d e l t a X   =   t h a t . m a x S c r o l l X ;  
  
                         i f   ( d e l t a Y   >   0 )   d e l t a Y   =   0 ;  
                         e l s e   i f   ( d e l t a Y   <   t h a t . m a x S c r o l l Y )   d e l t a Y   =   t h a t . m a x S c r o l l Y ;  
  
                         t h a t . s c r o l l T o ( d e l t a X ,   d e l t a Y ,   0 ) ;  
                 } ,  
  
                 _ m o u s e o u t :   f u n c t i o n ( e )   {  
                         v a r   t   =   e . r e l a t e d T a r g e t ;  
  
                         i f   ( ! t )   {  
                                 t h i s . _ e n d ( e ) ;  
                                 r e t u r n ;  
                         }  
  
                         w h i l e   ( t   =   t . p a r e n t N o d e )   i f   ( t   = =   t h i s . w r a p p e r )   r e t u r n ;  
  
                         t h i s . _ e n d ( e ) ;  
                 } ,  
  
                 _ t r a n s i t i o n E n d :   f u n c t i o n ( e )   {  
                         v a r   t h a t   =   t h i s ;  
  
                         i f   ( e . t a r g e t   ! =   t h a t . s c r o l l e r )   r e t u r n ;  
  
                         t h a t . _ u n b i n d ( ' w e b k i t T r a n s i t i o n E n d ' ) ;  
  
                         t h a t . _ s t a r t A n i ( ) ;  
                 } ,  
  
  
                 / * *  
                 *  
                 *   U t i l i t i e s  
                 *  
                 * /  
                 _ s t a r t A n i :   f u n c t i o n ( )   {  
                         v a r   t h a t   =   t h i s ,  
 	 	 	 s t a r t X   =   t h a t . x ,   s t a r t Y   =   t h a t . y ,  
 	 	 	 s t a r t T i m e   =   ( n e w   D a t e ) . g e t T i m e ( ) ,  
 	 	 	 s t e p ,   e a s e O u t ;  
  
                         i f   ( t h a t . a n i m a t i n g )   r e t u r n ;  
  
                         i f   ( ! t h a t . s t e p s . l e n g t h )   {  
                                 t h a t . _ r e s e t P o s ( 4 0 0 ) ;  
                                 r e t u r n ;  
                         }  
  
                         s t e p   =   t h a t . s t e p s . s h i f t ( ) ;  
  
                         i f   ( s t e p . x   = =   s t a r t X   & &   s t e p . y   = =   s t a r t Y )   s t e p . t i m e   =   0 ;  
  
                         t h a t . a n i m a t i n g   =   t r u e ;  
                         t h a t . m o v e d   =   t r u e ;  
  
                         i f   ( t h a t . o p t i o n s . u s e T r a n s i t i o n )   {  
                                 t h a t . _ t r a n s i t i o n T i m e ( s t e p . t i m e ) ;  
                                 t h a t . _ p o s ( s t e p . x ,   s t e p . y ) ;  
                                 t h a t . a n i m a t i n g   =   f a l s e ;  
                                 i f   ( s t e p . t i m e )   t h a t . _ b i n d ( ' w e b k i t T r a n s i t i o n E n d ' ) ;  
                                 e l s e   t h a t . _ r e s e t P o s ( 0 ) ;  
                                 r e t u r n ;  
                         }  
  
                         ( f u n c t i o n   a n i m a t e ( )   {  
                                 v a r   n o w   =   ( n e w   D a t e ) . g e t T i m e ( ) ,  
 	 	 	 	 n e w X ,   n e w Y ;  
  
                                 i f   ( n o w   > =   s t a r t T i m e   +   s t e p . t i m e )   {  
                                         t h a t . _ p o s ( s t e p . x ,   s t e p . y ) ;  
                                         t h a t . a n i m a t i n g   =   f a l s e ;  
                                         i f   ( t h a t . o p t i o n s . o n A n i m a t i o n E n d )   t h a t . o p t i o n s . o n A n i m a t i o n E n d . c a l l ( t h a t ) ;   	 	 / /   E x e c u t e   c u s t o m   c o d e   o n   a n i m a t i o n   e n d  
                                         t h a t . _ s t a r t A n i ( ) ;  
                                         r e t u r n ;  
                                 }  
  
                                 n o w   =   ( n o w   -   s t a r t T i m e )   /   s t e p . t i m e   -   1 ;  
                                 e a s e O u t   =   m . s q r t ( 1   -   n o w   *   n o w ) ;  
                                 n e w X   =   ( s t e p . x   -   s t a r t X )   *   e a s e O u t   +   s t a r t X ;  
                                 n e w Y   =   ( s t e p . y   -   s t a r t Y )   *   e a s e O u t   +   s t a r t Y ;  
                                 t h a t . _ p o s ( n e w X ,   n e w Y ) ;  
                                 i f   ( t h a t . a n i m a t i n g )   t h a t . a n i T i m e   =   n e x t F r a m e ( a n i m a t e ) ;  
                         } ) ( ) ;  
                 } ,  
  
                 _ t r a n s i t i o n T i m e :   f u n c t i o n ( t i m e )   {  
                         t i m e   + =   ' m s ' ;  
                         t h i s . s c r o l l e r . s t y l e [ v e n d o r   +   ' T r a n s i t i o n D u r a t i o n ' ]   =   t i m e ;  
                         i f   ( t h i s . h S c r o l l b a r )   t h i s . h S c r o l l b a r I n d i c a t o r . s t y l e [ v e n d o r   +   ' T r a n s i t i o n D u r a t i o n ' ]   =   t i m e ;  
                         i f   ( t h i s . v S c r o l l b a r )   t h i s . v S c r o l l b a r I n d i c a t o r . s t y l e [ v e n d o r   +   ' T r a n s i t i o n D u r a t i o n ' ]   =   t i m e ;  
                 } ,  
  
                 _ m o m e n t u m :   f u n c t i o n ( d i s t ,   t i m e ,   m a x D i s t U p p e r ,   m a x D i s t L o w e r ,   s i z e )   {  
                         v a r   d e c e l e r a t i o n   =   0 . 0 0 0 6 ,  
 	 	 	 s p e e d   =   m . a b s ( d i s t )   /   t i m e ,  
 	 	 	 n e w D i s t   =   ( s p e e d   *   s p e e d )   /   ( 2   *   d e c e l e r a t i o n ) ,  
 	 	 	 n e w T i m e   =   0 ,   o u t s i d e D i s t   =   0 ;  
  
                         / /   P r o p o r t i n a l l y   r e d u c e   s p e e d   i f   w e   a r e   o u t s i d e   o f   t h e   b o u n d a r i e s    
                         i f   ( d i s t   >   0   & &   n e w D i s t   >   m a x D i s t U p p e r )   {  
                                 o u t s i d e D i s t   =   s i z e   /   ( 6   /   ( n e w D i s t   /   s p e e d   *   d e c e l e r a t i o n ) ) ;  
                                 m a x D i s t U p p e r   =   m a x D i s t U p p e r   +   o u t s i d e D i s t ;  
                                 s p e e d   =   s p e e d   *   m a x D i s t U p p e r   /   n e w D i s t ;  
                                 n e w D i s t   =   m a x D i s t U p p e r ;  
                         }   e l s e   i f   ( d i s t   <   0   & &   n e w D i s t   >   m a x D i s t L o w e r )   {  
                                 o u t s i d e D i s t   =   s i z e   /   ( 6   /   ( n e w D i s t   /   s p e e d   *   d e c e l e r a t i o n ) ) ;  
                                 m a x D i s t L o w e r   =   m a x D i s t L o w e r   +   o u t s i d e D i s t ;  
                                 s p e e d   =   s p e e d   *   m a x D i s t L o w e r   /   n e w D i s t ;  
                                 n e w D i s t   =   m a x D i s t L o w e r ;  
                         }  
  
                         n e w D i s t   =   n e w D i s t   *   ( d i s t   <   0   ?   - 1   :   1 ) ;  
                         n e w T i m e   =   s p e e d   /   d e c e l e r a t i o n ;  
  
                         r e t u r n   {   d i s t :   n e w D i s t ,   t i m e :   m . r o u n d ( n e w T i m e )   } ;  
                 } ,  
  
                 _ o f f s e t :   f u n c t i o n ( e l )   {  
                         v a r   l e f t   =   - e l . o f f s e t L e f t ,  
 	 	 	 t o p   =   - e l . o f f s e t T o p ;  
  
                         w h i l e   ( e l   =   e l . o f f s e t P a r e n t )   {  
                                 l e f t   - =   e l . o f f s e t L e f t ;  
                                 t o p   - =   e l . o f f s e t T o p ;  
                         }  
  
                         i f   ( e l   ! =   t h i s . w r a p p e r )   {  
                                 l e f t   * =   t h i s . s c a l e ;  
                                 t o p   * =   t h i s . s c a l e ;  
                         }  
  
                         r e t u r n   {   l e f t :   l e f t ,   t o p :   t o p   } ;  
                 } ,  
  
                 _ s n a p :   f u n c t i o n ( x ,   y )   {  
                         v a r   t h a t   =   t h i s ,  
 	 	 	 i ,   l ,  
 	 	 	 p a g e ,   t i m e ,  
 	 	 	 s i z e X ,   s i z e Y ;  
  
                         / /   C h e c k   p a g e   X  
                         p a g e   =   t h a t . p a g e s X . l e n g t h   -   1 ;  
                         f o r   ( i   =   0 ,   l   =   t h a t . p a g e s X . l e n g t h ;   i   <   l ;   i + + )   {  
                                 i f   ( x   > =   t h a t . p a g e s X [ i ] )   {  
                                         p a g e   =   i ;  
                                         b r e a k ;  
                                 }  
                         }  
                         i f   ( p a g e   = =   t h a t . c u r r P a g e X   & &   p a g e   >   0   & &   t h a t . d i r X   <   0 )   p a g e - - ;  
                         x   =   t h a t . p a g e s X [ p a g e ] ;  
                         s i z e X   =   m . a b s ( x   -   t h a t . p a g e s X [ t h a t . c u r r P a g e X ] ) ;  
                         s i z e X   =   s i z e X   ?   m . a b s ( t h a t . x   -   x )   /   s i z e X   *   5 0 0   :   0 ;  
                         t h a t . c u r r P a g e X   =   p a g e ;  
  
                         / /   C h e c k   p a g e   Y  
                         p a g e   =   t h a t . p a g e s Y . l e n g t h   -   1 ;  
                         f o r   ( i   =   0 ;   i   <   p a g e ;   i + + )   {  
                                 i f   ( y   > =   t h a t . p a g e s Y [ i ] )   {  
                                         p a g e   =   i ;  
                                         b r e a k ;  
                                 }  
                         }  
                         i f   ( p a g e   = =   t h a t . c u r r P a g e Y   & &   p a g e   >   0   & &   t h a t . d i r Y   <   0 )   p a g e - - ;  
                         y   =   t h a t . p a g e s Y [ p a g e ] ;  
                         s i z e Y   =   m . a b s ( y   -   t h a t . p a g e s Y [ t h a t . c u r r P a g e Y ] ) ;  
                         s i z e Y   =   s i z e Y   ?   m . a b s ( t h a t . y   -   y )   /   s i z e Y   *   5 0 0   :   0 ;  
                         t h a t . c u r r P a g e Y   =   p a g e ;  
  
                         / /   S n a p   w i t h   c o n s t a n t   s p e e d   ( p r o p o r t i o n a l   d u r a t i o n )  
                         t i m e   =   m . r o u n d ( m . m a x ( s i z e X ,   s i z e Y ) )   | |   2 0 0 ;  
  
                         r e t u r n   {   x :   x ,   y :   y ,   t i m e :   t i m e   } ;  
                 } ,  
  
                 _ b i n d :   f u n c t i o n ( t y p e ,   e l ,   b u b b l e )   {  
                         ( e l   | |   t h i s . s c r o l l e r ) . a d d E v e n t L i s t e n e r ( t y p e ,   t h i s ,   ! ! b u b b l e ) ;  
                 } ,  
  
                 _ u n b i n d :   f u n c t i o n ( t y p e ,   e l ,   b u b b l e )   {  
                         ( e l   | |   t h i s . s c r o l l e r ) . r e m o v e E v e n t L i s t e n e r ( t y p e ,   t h i s ,   ! ! b u b b l e ) ;  
                 } ,  
  
  
                 / * *  
                 *  
                 *   P u b l i c   m e t h o d s  
                 *  
                 * /  
                 d e s t r o y :   f u n c t i o n ( )   {  
                         v a r   t h a t   =   t h i s ;  
  
                         t h a t . s c r o l l e r . s t y l e [ v e n d o r   +   ' T r a n s f o r m ' ]   =   ' ' ;  
  
                         / /   R e m o v e   t h e   s c r o l l b a r s  
                         t h a t . h S c r o l l b a r   =   f a l s e ;  
                         t h a t . v S c r o l l b a r   =   f a l s e ;  
                         t h a t . _ s c r o l l b a r ( ' h ' ) ;  
                         t h a t . _ s c r o l l b a r ( ' v ' ) ;  
  
                         / /   R e m o v e   t h e   e v e n t   l i s t e n e r s  
                         t h a t . _ u n b i n d ( R E S I Z E _ E V ,   w i n d o w ) ;  
                         t h a t . _ u n b i n d ( S T A R T _ E V ) ;  
                         t h a t . _ u n b i n d ( M O V E _ E V ) ;  
                         t h a t . _ u n b i n d ( E N D _ E V ) ;  
                         t h a t . _ u n b i n d ( C A N C E L _ E V ) ;  
  
                         i f   ( t h a t . o p t i o n s . h a s T o u c h )   {  
                                 t h a t . _ u n b i n d ( ' m o u s e o u t ' ,   t h a t . w r a p p e r ) ;  
                                 t h a t . _ u n b i n d ( W H E E L _ E V ) ;  
                         }  
  
                         i f   ( t h a t . o p t i o n s . u s e T r a n s i t i o n )   t h a t . _ u n b i n d ( ' w e b k i t T r a n s i t i o n E n d ' ) ;  
  
                         i f   ( t h a t . o p t i o n s . c h e c k D O M C h a n g e s )   c l e a r I n t e r v a l ( t h a t . c h e c k D O M T i m e ) ;  
  
                         i f   ( t h a t . o p t i o n s . o n D e s t r o y )   t h a t . o p t i o n s . o n D e s t r o y . c a l l ( t h a t ) ;  
                 } ,  
  
                 r e f r e s h :   f u n c t i o n ( )   {  
                         v a r   t h a t   =   t h i s ,  
 	 	 	 o f f s e t ,  
 	 	 	 p o s   =   0 ,  
 	 	 	 p a g e   =   0 ;  
  
                         i f   ( t h a t . s c a l e   <   t h a t . o p t i o n s . z o o m M i n )   t h a t . s c a l e   =   t h a t . o p t i o n s . z o o m M i n ;  
                         t h a t . w r a p p e r W   =   t h a t . w r a p p e r . c l i e n t W i d t h   | |   1 ;  
                         t h a t . w r a p p e r H   =   t h a t . w r a p p e r . c l i e n t H e i g h t   | |   1 ;  
  
                         t h a t . s c r o l l e r W   =   m . r o u n d ( t h a t . s c r o l l e r . o f f s e t W i d t h   *   t h a t . s c a l e ) ;  
                         t h a t . s c r o l l e r H   =   m . r o u n d ( t h a t . s c r o l l e r . o f f s e t H e i g h t   *   t h a t . s c a l e ) ;  
                         t h a t . m a x S c r o l l X   =   t h a t . w r a p p e r W   -   t h a t . s c r o l l e r W ;  
                         t h a t . m a x S c r o l l Y   =   t h a t . w r a p p e r H   -   t h a t . s c r o l l e r H ;  
                         t h a t . d i r X   =   0 ;  
                         t h a t . d i r Y   =   0 ;  
  
                         t h a t . h S c r o l l   =   t h a t . o p t i o n s . h S c r o l l   & &   t h a t . m a x S c r o l l X   <   0 ;  
                         t h a t . v S c r o l l   =   t h a t . o p t i o n s . v S c r o l l   & &   ( ! t h a t . o p t i o n s . b o u n c e L o c k   & &   ! t h a t . h S c r o l l   | |   t h a t . s c r o l l e r H   >   t h a t . w r a p p e r H ) ;  
  
                         t h a t . h S c r o l l b a r   =   t h a t . h S c r o l l   & &   t h a t . o p t i o n s . h S c r o l l b a r ;  
                         t h a t . v S c r o l l b a r   =   t h a t . v S c r o l l   & &   t h a t . o p t i o n s . v S c r o l l b a r   & &   t h a t . s c r o l l e r H   >   t h a t . w r a p p e r H ;  
  
                         o f f s e t   =   t h a t . _ o f f s e t ( t h a t . w r a p p e r ) ;  
                         t h a t . w r a p p e r O f f s e t L e f t   =   - o f f s e t . l e f t ;  
                         t h a t . w r a p p e r O f f s e t T o p   =   - o f f s e t . t o p ;  
  
                         / /   P r e p a r e   s n a p  
                         i f   ( t y p e o f   t h a t . o p t i o n s . s n a p   = =   ' s t r i n g ' )   {  
                                 t h a t . p a g e s X   =   [ ] ;  
                                 t h a t . p a g e s Y   =   [ ] ;  
                                 e l s   =   t h a t . s c r o l l e r . q u e r y S e l e c t o r A l l ( t h a t . o p t i o n s . s n a p ) ;  
                                 f o r   ( i   =   0 ,   l   =   e l s . l e n g t h ;   i   <   l ;   i + + )   {  
                                         p o s   =   t h a t . _ o f f s e t ( e l s [ i ] ) ;  
                                         p o s . l e f t   + =   t h a t . w r a p p e r O f f s e t L e f t ;  
                                         p o s . t o p   + =   t h a t . w r a p p e r O f f s e t T o p ;  
                                         t h a t . p a g e s X [ i ]   =   p o s . l e f t   <   t h a t . m a x S c r o l l X   ?   t h a t . m a x S c r o l l X   :   p o s . l e f t   *   t h a t . s c a l e ;  
                                         t h a t . p a g e s Y [ i ]   =   p o s . t o p   <   t h a t . m a x S c r o l l Y   ?   t h a t . m a x S c r o l l Y   :   p o s . t o p   *   t h a t . s c a l e ;  
                                 }  
                         }   e l s e   i f   ( t h a t . o p t i o n s . s n a p )   {  
                                 t h a t . p a g e s X   =   [ ] ;  
                                 w h i l e   ( p o s   > =   t h a t . m a x S c r o l l X )   {  
                                         t h a t . p a g e s X [ p a g e ]   =   p o s ;  
                                         p o s   =   p o s   -   t h a t . w r a p p e r W ;  
                                         p a g e + + ;  
                                 }  
                                 i f   ( t h a t . m a x S c r o l l X   %   t h a t . w r a p p e r W )   t h a t . p a g e s X [ t h a t . p a g e s X . l e n g t h ]   =   t h a t . m a x S c r o l l X   -   t h a t . p a g e s X [ t h a t . p a g e s X . l e n g t h   -   1 ]   +   t h a t . p a g e s X [ t h a t . p a g e s X . l e n g t h   -   1 ] ;  
  
                                 p o s   =   0 ;  
                                 p a g e   =   0 ;  
                                 t h a t . p a g e s Y   =   [ ] ;  
                                 w h i l e   ( p o s   > =   t h a t . m a x S c r o l l Y )   {  
                                         t h a t . p a g e s Y [ p a g e ]   =   p o s ;  
                                         p o s   =   p o s   -   t h a t . w r a p p e r H ;  
                                         p a g e + + ;  
                                 }  
                                 i f   ( t h a t . m a x S c r o l l Y   %   t h a t . w r a p p e r H )   t h a t . p a g e s Y [ t h a t . p a g e s Y . l e n g t h ]   =   t h a t . m a x S c r o l l Y   -   t h a t . p a g e s Y [ t h a t . p a g e s Y . l e n g t h   -   1 ]   +   t h a t . p a g e s Y [ t h a t . p a g e s Y . l e n g t h   -   1 ] ;  
                         }  
  
                         / /   P r e p a r e   t h e   s c r o l l b a r s  
                         t h a t . _ s c r o l l b a r ( ' h ' ) ;  
                         t h a t . _ s c r o l l b a r ( ' v ' ) ;  
  
                         t h a t . s c r o l l e r . s t y l e [ v e n d o r   +   ' T r a n s i t i o n D u r a t i o n ' ]   =   ' 0 ' ;  
  
                         t h a t . _ r e s e t P o s ( 2 0 0 ) ;  
                 } ,  
  
                 s c r o l l T o :   f u n c t i o n ( x ,   y ,   t i m e ,   r e l a t i v e )   {  
                         v a r   t h a t   =   t h i s ,  
 	 	 	 s t e p   =   x ,  
 	 	 	 i ,   l ;  
  
                         t h a t . s t o p ( ) ;  
  
                         i f   ( ! s t e p . l e n g t h )   s t e p   =   [ {   x :   x ,   y :   y ,   t i m e :   t i m e ,   r e l a t i v e :   r e l a t i v e } ] ;  
  
                         f o r   ( i   =   0 ,   l   =   s t e p . l e n g t h ;   i   <   l ;   i + + )   {  
                                 i f   ( s t e p [ i ] . r e l a t i v e )   {   s t e p [ i ] . x   =   t h a t . x   -   s t e p [ i ] . x ;   s t e p [ i ] . y   =   t h a t . y   -   s t e p [ i ] . y ;   }  
                                 t h a t . s t e p s . p u s h ( {   x :   s t e p [ i ] . x ,   y :   s t e p [ i ] . y ,   t i m e :   s t e p [ i ] . t i m e   | |   0   } ) ;  
                         }  
  
                         t h a t . _ s t a r t A n i ( ) ;  
                 } ,  
  
                 s c r o l l T o E l e m e n t :   f u n c t i o n ( e l ,   t i m e )   {  
                         v a r   t h a t   =   t h i s ,   p o s ;  
                         e l   =   e l . n o d e T y p e   ?   e l   :   t h a t . s c r o l l e r . q u e r y S e l e c t o r ( e l ) ;  
                         i f   ( ! e l )   r e t u r n ;  
  
                         p o s   =   t h a t . _ o f f s e t ( e l ) ;  
                         p o s . l e f t   + =   t h a t . w r a p p e r O f f s e t L e f t ;  
                         p o s . t o p   + =   t h a t . w r a p p e r O f f s e t T o p ;  
  
                         p o s . l e f t   =   p o s . l e f t   >   0   ?   0   :   p o s . l e f t   <   t h a t . m a x S c r o l l X   ?   t h a t . m a x S c r o l l X   :   p o s . l e f t ;  
                         p o s . t o p   =   p o s . t o p   >   0   ?   0   :   p o s . t o p   <   t h a t . m a x S c r o l l Y   ?   t h a t . m a x S c r o l l Y   :   p o s . t o p ;  
                         t i m e   =   t i m e   = = =   u n d e f i n e d   ?   m . m a x ( m . a b s ( p o s . l e f t )   *   2 ,   m . a b s ( p o s . t o p )   *   2 )   :   t i m e ;  
  
                         t h a t . s c r o l l T o ( p o s . l e f t ,   p o s . t o p ,   t i m e ) ;  
                 } ,  
  
                 s c r o l l T o P a g e :   f u n c t i o n ( p a g e X ,   p a g e Y ,   t i m e )   {  
                         v a r   t h a t   =   t h i s ,   x ,   y ;  
  
                         i f   ( t h a t . o p t i o n s . s n a p )   {  
                                 p a g e X   =   p a g e X   = =   ' n e x t '   ?   t h a t . c u r r P a g e X   +   1   :   p a g e X   = =   ' p r e v '   ?   t h a t . c u r r P a g e X   -   1   :   p a g e X ;  
                                 p a g e Y   =   p a g e Y   = =   ' n e x t '   ?   t h a t . c u r r P a g e Y   +   1   :   p a g e Y   = =   ' p r e v '   ?   t h a t . c u r r P a g e Y   -   1   :   p a g e Y ;  
  
                                 p a g e X   =   p a g e X   <   0   ?   0   :   p a g e X   >   t h a t . p a g e s X . l e n g t h   -   1   ?   t h a t . p a g e s X . l e n g t h   -   1   :   p a g e X ;  
                                 p a g e Y   =   p a g e Y   <   0   ?   0   :   p a g e Y   >   t h a t . p a g e s Y . l e n g t h   -   1   ?   t h a t . p a g e s Y . l e n g t h   -   1   :   p a g e Y ;  
  
                                 t h a t . c u r r P a g e X   =   p a g e X ;  
                                 t h a t . c u r r P a g e Y   =   p a g e Y ;  
                                 x   =   t h a t . p a g e s X [ p a g e X ] ;  
                                 y   =   t h a t . p a g e s Y [ p a g e Y ] ;  
                         }   e l s e   {  
                                 x   =   - t h a t . w r a p p e r W   *   p a g e X ;  
                                 y   =   - t h a t . w r a p p e r H   *   p a g e Y ;  
                                 i f   ( x   <   t h a t . m a x S c r o l l X )   x   =   t h a t . m a x S c r o l l X ;  
                                 i f   ( y   <   t h a t . m a x S c r o l l Y )   y   =   t h a t . m a x S c r o l l Y ;  
                         }  
  
                         t h a t . s c r o l l T o ( x ,   y ,   t i m e   | |   4 0 0 ) ;  
                 } ,  
  
                 d i s a b l e :   f u n c t i o n ( )   {  
                         t h i s . s t o p ( ) ;  
                         t h i s . _ r e s e t P o s ( 0 ) ;  
                         t h i s . e n a b l e d   =   f a l s e ;  
  
                         / /   I f   d i s a b l e d   a f t e r   t o u c h s t a r t   w e   m a k e   s u r e   t h a t   t h e r e   a r e   n o   l e f t   o v e r   e v e n t s  
                         t h i s . _ u n b i n d ( M O V E _ E V ) ;  
                         t h i s . _ u n b i n d ( E N D _ E V ) ;  
                         t h i s . _ u n b i n d ( C A N C E L _ E V ) ;  
                 } ,  
  
                 e n a b l e :   f u n c t i o n ( )   {  
                         t h i s . e n a b l e d   =   t r u e ;  
                 } ,  
  
                 s t o p :   f u n c t i o n ( )   {  
                         i f   ( t h i s . o p t i o n s . u s e T r a n s i t i o n )   t h i s . _ u n b i n d ( ' w e b k i t T r a n s i t i o n E n d ' ) ;  
                         e l s e   c a n c e l F r a m e ( t h i s . a n i T i m e ) ;  
                         t h i s . s t e p s   =   [ ] ;  
                         t h i s . m o v e d   =   f a l s e ;  
                         t h i s . a n i m a t i n g   =   f a l s e ;  
                 } ,  
  
                 z o o m :   f u n c t i o n ( x ,   y ,   s c a l e ,   t i m e )   {  
                         v a r   t h a t   =   t h i s ,  
 	 	 	 r e l S c a l e   =   s c a l e   /   t h a t . s c a l e ;  
  
                         i f   ( ! t h a t . o p t i o n s . u s e T r a n s f o r m )   r e t u r n ;  
  
                         t i m e   =   ( t i m e   | |   2 0 0 )   +   ' m s '  
                         x   =   x   -   t h a t . w r a p p e r O f f s e t L e f t   -   t h a t . x ;  
                         y   =   y   -   t h a t . w r a p p e r O f f s e t T o p   -   t h a t . y ;  
                         t h a t . x   =   x   -   x   *   r e l S c a l e   +   t h a t . x ;  
                         t h a t . y   =   y   -   y   *   r e l S c a l e   +   t h a t . y ;  
  
                         t h a t . s c a l e   =   s c a l e ;  
  
                         t h a t . s c r o l l e r . s t y l e [ v e n d o r   +   ' T r a n s i t i o n D u r a t i o n ' ]   =   t i m e ;  
                         t h a t . s c r o l l e r . s t y l e [ v e n d o r   +   ' T r a n s f o r m ' ]   =   t r n O p e n   +   t h a t . x   +   ' p x , '   +   t h a t . y   +   ' p x '   +   t r n C l o s e   +   '   s c a l e ( '   +   s c a l e   +   ' ) ' ;  
  
                         t h a t . r e f r e s h ( ) ;  
                 } ,  
  
                 i s R e a d y :   f u n c t i o n ( )   {  
                         r e t u r n   ! t h i s . m o v e d   & &   ! t h i s . z o o m e d   & &   ! t h i s . a n i m a t i n g ;  
                 }  
         } ;  
  
         i f   ( t y p e o f   e x p o r t s   ! = =   ' u n d e f i n e d ' )   e x p o r t s . i S c r o l l   =   i S c r o l l ;  
         e l s e   w i n d o w . i S c r o l l   =   i S c r o l l ;  
  
 } ) ( ) ;  
  
 / *  
 *   i s c r o l l - w r a p p e r   f o r   j Q q u e r y .  
 *   h t t p : / / s a n r a u l . c o m / p r o j e c t s / j q l o a d e r /  
 *    
 *   C o p y r i g h t   ( c )   2 0 1 1   R a u l   S a n c h e z   ( h t t p : / / w w w . s a n r a u l . c o m )  
 *    
 *   D u a l   l i c e n s e d   u n d e r   t h e   M I T   a n d   G P L   l i c e n s e s :  
 *   h t t p : / / w w w . o p e n s o u r c e . o r g / l i c e n s e s / m i t - l i c e n s e . p h p  
 *   h t t p : / / w w w . g n u . o r g / l i c e n s e s / g p l . h t m l  
 * /  
  
 ( f u n c t i o n ( $ )   {  
         $ . f n . i s c r o l l   =   f u n c t i o n ( o p t i o n s )   {  
                 i f   ( t h i s . d a t a ( ' i S c r o l l R e a d y ' )   = =   n u l l )   {  
                         v a r   t h a t   =   t h i s ;  
                         v a r   o p t i o n s   =   $ . e x t e n d ( { } ,   o p t i o n s ) ;  
                         o p t i o n s . o n S c r o l l E n d   =   f u n c t i o n ( )   {  
                                 t h a t . t r i g g e r H a n d l e r ( ' o n S c r o l l E n d ' ,   [ t h i s ] ) ;  
                         } ;  
                         a r g u m e n t s . c a l l e e . o b j e c t   =   n e w   i S c r o l l ( t h i s . g e t ( 0 ) ,   o p t i o n s ) ;  
                         / /   N O T E :   f o r   s o m e   r e a s o n   i n   a   c o m p l e x   p a g e   t h e   p l u g i n   d o e s   n o t   r e g i s t e r  
                         / /   t h e   s i z e   o f   t h e   e l e m e n t .   T h i s   w i l l   f i x   t h a t   i n   t h e   m e a n t i m e .  
                         s e t T i m e o u t ( f u n c t i o n ( s c r o l l e r )   {  
                                 s c r o l l e r . r e f r e s h ( ) ;  
                         } ,   1 0 0 0 ,   a r g u m e n t s . c a l l e e . o b j e c t ) ;  
                         t h i s . d a t a ( ' i S c r o l l R e a d y ' ,   t r u e ) ;  
                 }   e l s e   {  
                         a r g u m e n t s . c a l l e e . o b j e c t . r e f r e s h ( ) ;  
                 }  
                 r e t u r n   a r g u m e n t s . c a l l e e . o b j e c t ;  
         } ;  
 } ) ( j Q u e r y ) ;  
  
 / /   j q u e r y . j s o n p   2 . 1 . 4   ( c ) 2 0 1 0   J u l i a n   A u b o u r g   |   M I T   L i c e n s e  
 / /   h t t p : / / c o d e . g o o g l e . c o m / p / j q u e r y - j s o n p /  
 ( f u n c t i o n ( e ,   b )   {   f u n c t i o n   d ( )   {   }   f u n c t i o n   t ( C )   {   c   =   [ C ]   }   f u n c t i o n   m ( C )   {   f . i n s e r t B e f o r e ( C ,   f . f i r s t C h i l d )   }   f u n c t i o n   l ( E ,   C ,   D )   {   r e t u r n   E   & &   E . a p p l y ( C . c o n t e x t   | |   C ,   D )   }   f u n c t i o n   k ( C )   {   r e t u r n   / \ ? / . t e s t ( C )   ?   " & "   :   " ? "   }   v a r   n   =   " a s y n c " ,   s   =   " c h a r s e t " ,   q   =   " " ,   A   =   " e r r o r " ,   r   =   " _ j q j s p " ,   w   =   " o n " ,   o   =   w   +   " c l i c k " ,   p   =   w   +   A ,   a   =   w   +   " l o a d " ,   i   =   w   +   " r e a d y s t a t e c h a n g e " ,   z   =   " r e m o v e C h i l d " ,   g   =   " < s c r i p t / > " ,   v   =   " s u c c e s s " ,   y   =   " t i m e o u t " ,   x   =   e . b r o w s e r ,   f   =   e ( " h e a d " ) [ 0 ]   | |   d o c u m e n t . d o c u m e n t E l e m e n t ,   u   =   { } ,   j   =   0 ,   c ,   h   =   {   c a l l b a c k :   r ,   u r l :   l o c a t i o n . h r e f   } ;   f u n c t i o n   B ( C )   {   C   =   e . e x t e n d ( { } ,   h ,   C ) ;   v a r   Q   =   C . c o m p l e t e ,   E   =   C . d a t a F i l t e r ,   M   =   C . c a l l b a c k P a r a m e t e r ,   R   =   C . c a l l b a c k ,   G   =   C . c a c h e ,   J   =   C . p a g e C a c h e ,   I   =   C . c h a r s e t ,   D   =   C . u r l ,   L   =   C . d a t a ,   P   =   C . t i m e o u t ,   O ,   K   =   0 ,   H   =   d ;   C . a b o r t   =   f u n c t i o n ( )   {   ! K + +   & &   H ( )   } ;   i f   ( l ( C . b e f o r e S e n d ,   C ,   [ C ] )   = = =   f a l s e   | |   K )   {   r e t u r n   C   }   D   =   D   | |   q ;   L   =   L   ?   ( ( t y p e o f   L )   = =   " s t r i n g "   ?   L   :   e . p a r a m ( L ,   C . t r a d i t i o n a l ) )   :   q ;   D   + =   L   ?   ( k ( D )   +   L )   :   q ;   M   & &   ( D   + =   k ( D )   +   e n c o d e U R I C o m p o n e n t ( M )   +   " = ? " ) ;   ! G   & &   ! J   & &   ( D   + =   k ( D )   +   " _ "   +   ( n e w   D a t e ( ) ) . g e t T i m e ( )   +   " = " ) ;   D   =   D . r e p l a c e ( / = \ ? ( & | $ ) / ,   " = "   +   R   +   " $ 1 " ) ;   f u n c t i o n   N ( S )   {   ! K + +   & &   b ( f u n c t i o n ( )   {   H ( ) ;   J   & &   ( u [ D ]   =   {   s :   [ S ]   } ) ;   E   & &   ( S   =   E . a p p l y ( C ,   [ S ] ) ) ;   l ( C . s u c c e s s ,   C ,   [ S ,   v ] ) ;   l ( Q ,   C ,   [ C ,   v ] )   } ,   0 )   }   f u n c t i o n   F ( S )   {   ! K + +   & &   b ( f u n c t i o n ( )   {   H ( ) ;   J   & &   S   ! =   y   & &   ( u [ D ]   =   S ) ;   l ( C . e r r o r ,   C ,   [ C ,   S ] ) ;   l ( Q ,   C ,   [ C ,   S ] )   } ,   0 )   }   J   & &   ( O   =   u [ D ] )   ?   ( O . s   ?   N ( O . s [ 0 ] )   :   F ( O ) )   :   b ( f u n c t i o n ( T ,   S ,   U )   {   i f   ( ! K )   {   U   =   P   >   0   & &   b ( f u n c t i o n ( )   {   F ( y )   } ,   P ) ;   H   =   f u n c t i o n ( )   {   U   & &   c l e a r T i m e o u t ( U ) ;   T [ i ]   =   T [ o ]   =   T [ a ]   =   T [ p ]   =   n u l l ;   f [ z ] ( T ) ;   S   & &   f [ z ] ( S )   } ;   w i n d o w [ R ]   =   t ;   T   =   e ( g ) [ 0 ] ;   T . i d   =   r   +   j + + ;   i f   ( I )   {   T [ s ]   =   I   }   f u n c t i o n   V ( W )   {   ( T [ o ]   | |   d ) ( ) ;   W   =   c ;   c   =   u n d e f i n e d ;   W   ?   N ( W [ 0 ] )   :   F ( A )   }   i f   ( x . m s i e )   {   T . e v e n t   =   o ;   T . h t m l F o r   =   T . i d ;   T [ i ]   =   f u n c t i o n ( )   {   / l o a d e d | c o m p l e t e / . t e s t ( T . r e a d y S t a t e )   & &   V ( )   }   }   e l s e   {   T [ p ]   =   T [ a ]   =   V ;   x . o p e r a   ?   ( ( S   =   e ( g ) [ 0 ] ) . t e x t   =   " j Q u e r y ( ' # "   +   T . i d   +   " ' ) [ 0 ] . "   +   p   +   " ( ) " )   :   T [ n ]   =   n   }   T . s r c   =   D ;   m ( T ) ;   S   & &   m ( S )   }   } ,   0 ) ;   r e t u r n   C   }   B . s e t u p   =   f u n c t i o n ( C )   {   e . e x t e n d ( h ,   C )   } ;   e . j s o n p   =   B   } ) ( j Q u e r y ,   s e t T i m e o u t ) ;  
  
 / *  
 *   t o u c h S w i p e   -   j Q u e r y   P l u g i n  
 *   h t t p : / / p l u g i n s . j q u e r y . c o m / p r o j e c t / t o u c h S w i p e  
 *   h t t p : / / l a b s . s k i n k e r s . c o m / t o u c h S w i p e /  
 *  
 *   C o p y r i g h t   ( c )   2 0 1 0   M a t t   B r y s o n   ( w w w . s k i n k e r s . c o m )  
 *   D u a l   l i c e n s e d   u n d e r   t h e   M I T   o r   G P L   V e r s i o n   2   l i c e n s e s .  
 *  
 *   $ v e r s i o n :   1 . 2 . 3  
 *  
 *   C h a n g e l o g  
 *   $ D a t e :   2 0 1 0 - 1 2 - 1 2   ( W e d ,   1 2   D e c   2 0 1 0 )   $  
 *   $ v e r s i o n :   1 . 0 . 0    
 *   $ v e r s i o n :   1 . 0 . 1   -   r e m o v e d   m u l t i b y t e   c o m m e n t s  
 *  
 *   $ D a t e :   2 0 1 1 - 2 1 - 0 2   ( M o n ,   2 1   F e b   2 0 1 1 )   $  
 *   $ v e r s i o n :   1 . 1 . 0   	 -   a d d e d   a l l o w P a g e S c r o l l   p r o p e r t y   t o   a l l o w   s w i p i n g   a n d   s c r o l l i n g   o f   p a g e  
 * 	 	 	 	 	 -   c h a n g e d   h a n d l e r   s i g n a t u r e s   s o   o n e   h a n d l e r   c a n   b e   u s e d   f o r   m u l t i p l e   e v e n t s  
 *   $ D a t e :   2 0 1 1 - 2 3 - 0 2   ( W e d ,   2 3   F e b   2 0 1 1 )   $  
 *   $ v e r s i o n :   1 . 2 . 0   	 -   a d d e d   c l i c k   h a n d l e r .   T h i s   i s   f i r e d   i f   t h e   u s e r   s i m p l y   c l i c k s   a n d   d o e s   n o t   s w i p e .   T h e   e v e n t   o b j e c t   a n d   c l i c k   t a r g e t   a r e   p a s s e d   t o   h a n d l e r .  
 * 	 	 	 	 	 -   I f   y o u   u s e   t h e   h t t p : / / c o d e . g o o g l e . c o m / p / j q u e r y - u i - f o r - i p a d - a n d - i p h o n e /   p l u g i n ,   y o u   c a n   a l s o   a s s i g n   j Q u e r y   m o u s e   e v e n t s   t o   c h i l d r e n   o f   a   t o u c h S w i p e   o b j e c t .  
 *   $ v e r s i o n :   1 . 2 . 1   	 -   r e m o v e d   c o n s o l e   l o g !  
 *  
 *   $ v e r s i o n :   1 . 2 . 2   	 -   F i x e d   b u g   w h e r e   s c o p e   w a s   n o t   p r e s e r v e d   i n   c a l l b a c k   m e t h o d s .    
 *  
 *   $ D a t e :   2 0 1 1 - 2 8 - 0 4   ( T h u r s ,   2 8   A p r i l   2 0 1 1 )   $  
 *   $ v e r s i o n :   1 . 2 . 4   	 -   C h a n g e d   l i c e n c e   t e r m s   t o   b e   M I T   o r   G P L   i n l i n e   w i t h   j Q u e r y .   A d d e d   c h e c k   f o r   s u p p o r t   o f   t o u c h   e v e n t s   t o   s t o p   n o n   c o m p a t i b l e   b r o w s e r s   e r r o r i n g .  
 *  
 *   A   j Q u e r y   p l u g i n   t o   c a p t u r e   l e f t ,   r i g h t ,   u p   a n d   d o w n   s w i p e s   o n   t o u c h   d e v i c e s .  
 *   Y o u   c a n   c a p t u r e   2   f i n g e r   o r   1   f i n g e r   s w i p e s ,   s e t   t h e   t h r e s h o l d   a n d   d e f i n e   e i t h e r   a   c a t c h   a l l   h a n d l e r ,   o r   i n d i v i d u a l   d i r e c t i o n   h a n d l e r s .  
 *   O p t i o n s :  
 *   	 	 s w i p e   	 	 F u n c t i o n   	 A   c a t c h   a l l   h a n d l e r   t h a t   i s   t r i g g e r e d   f o r   a l l   s w i p e   d i r e c t i o n s .   H a n d l e r   i s   p a s s e d   3   a r g u m e n t s ,   t h e   o r i g i n a l   e v e n t   o b j e c t ,   t h e   d i r e c t i o n   o f   t h e   s w i p e   :   " l e f t " ,   " r i g h t " ,   " u p " ,   " d o w n "   a n d   t h e   d i s t a n c e   o f   t h e   s w i p e .  
 *   	 	 s w i p e L e f t 	 F u n c t i o n   	 A   h a n d l e r   t h a t   i s   t r i g g e r e d   f o r   " l e f t "   s w i p e s .   H a n d l e r   i s   p a s s e d   3   a r g u m e n t s ,   t h e   o r i g i n a l   e v e n t   o b j e c t ,   t h e   d i r e c t i o n   o f   t h e   s w i p e   :   " l e f t " ,   " r i g h t " ,   " u p " ,   " d o w n "   a n d   t h e   d i s t a n c e   o f   t h e   s w i p e .  
 *   	 	 s w i p e R i g h t 	 F u n c t i o n   	 A   h a n d l e r   t h a t   i s   t r i g g e r e d   f o r   " r i g h t "   s w i p e s .   H a n d l e r   i s   p a s s e d   3   a r g u m e n t s ,   t h e   o r i g i n a l   e v e n t   o b j e c t ,   t h e   d i r e c t i o n   o f   t h e   s w i p e   :   " l e f t " ,   " r i g h t " ,   " u p " ,   " d o w n "   a n d   t h e   d i s t a n c e   o f   t h e   s w i p e .  
 *   	 	 s w i p e U p 	 	 F u n c t i o n   	 A   h a n d l e r   t h a t   i s   t r i g g e r e d   f o r   " u p "   s w i p e s .   H a n d l e r   i s   p a s s e d   3   a r g u m e n t s ,   t h e   o r i g i n a l   e v e n t   o b j e c t ,   t h e   d i r e c t i o n   o f   t h e   s w i p e   :   " l e f t " ,   " r i g h t " ,   " u p " ,   " d o w n "   a n d   t h e   d i s t a n c e   o f   t h e   s w i p e .  
 *   	 	 s w i p e D o w n 	 F u n c t i o n   	 A   h a n d l e r   t h a t   i s   t r i g g e r e d   f o r   " d o w n "   s w i p e s .   H a n d l e r   i s   p a s s e d   3   a r g u m e n t s ,   t h e   o r i g i n a l   e v e n t   o b j e c t ,   t h e   d i r e c t i o n   o f   t h e   s w i p e   :   " l e f t " ,   " r i g h t " ,   " u p " ,   " d o w n "   a n d   t h e   d i s t a n c e   o f   t h e   s w i p e .  
 * 	 	 s w i p e S t a t u s   F u n c t i o n   	 A   h a n d l e r   t r i g g e r e d   f o r   e v e r y   p h a s e   o f   t h e   s w i p e .   H a n d l e r   i s   p a s s e d   4   a r g u m e n t s :   e v e n t   :   T h e   o r i g i n a l   e v e n t   o b j e c t ,   p h a s e : T h e   c u r r e n t   s w i p e   f a c e ,   e i t h e r   " s t a r t ýÿ,   " m o v e ýÿ,   " e n d ýÿ  o r   " c a n c e l ýÿ.   d i r e c t i o n   :   T h e   s w i p e   d i r e c t i o n ,   e i t h e r   " u p ýÿ,   " d o w n ýÿ,   " l e f t   "   o r   " r i g h t ýÿ. d i s t a n c e   :   T h e   d i s t a n c e   o f   t h e   s w i p e .  
 * 	 	 c l i c k 	 	 F u n c t i o n 	 A   h a n d l e r   t r i g g e r e d   w h e n   a   u s e r   j u s t   c l i c k s   o n   t h e   i t e m ,   r a t h e r   t h a n   s w i p e s   i t .   I f   t h e y   d o   n o t   m o v e ,   c l i c k   i s   t r i g g e r e d ,   i f   t h e y   d o   m o v e ,   i t   i s   n o t .  
 *  
 *   	 	 f i n g e r s   	 i n t   	 	 D e f a u l t   1 .   	 T h e   n u m b e r   o f   f i n g e r s   t o   t r i g g e r   t h e   s w i p e ,   1   o r   2 .  
 *   	 	 t h r e s h o l d   	 i n t     	 	 D e f a u l t   7 5 . 	 T h e   n u m b e r   o f   p i x e l s   t h a t   t h e   u s e r   m u s t   m o v e   t h e i r   f i n g e r   b y   b e f o r e   i t   i s   c o n s i d e r e d   a   s w i p e .  
 * 	 	 t r i g g e r O n T o u c h E n d   B o o l e a n   D e f a u l t   t r u e   I f   t r u e ,   t h e   s w i p e   e v e n t s   a r e   t r i g g e r e d   w h e n   t h e   t o u c h   e n d   e v e n t   i s   r e c e i v e d   ( u s e r   r e l e a s e s   f i n g e r ) .     I f   f a l s e ,   i t   w i l l   b e   t r i g g e r e d   o n   r e a c h i n g   t h e   t h r e s h o l d ,   a n d   t h e n   c a n c e l   t h e   t o u c h   e v e n t   a u t o m a t i c a l l y .  
 * 	 	 a l l o w P a g e S c r o l l   S t r i n g   D e f a u l t   " a u t o " .   H o w   t h e   b r o w s e r   h a n d l e s   p a g e   s c r o l l s   w h e n   t h e   u s e r   i s   s w i p i n g   o n   a   t o u c h S w i p e   o b j e c t .    
 * 	 	 	 	 	 	 	 	 	 	 " a u t o "   :   a l l   u n d e f i n e d   s w i p e s   w i l l   c a u s e   t h e   p a g e   t o   s c r o l l   i n   t h a t   d i r e c t i o n .  
 * 	 	 	 	 	 	 	 	 	 	 " n o n e "   :   t h e   p a g e   w i l l   n o t   s c r o l l   w h e n   u s e r   s w i p e s .  
 * 	 	 	 	 	 	 	 	 	 	 " h o r i z o n t a l "   :   w i l l   f o r c e   p a g e   t o   s c r o l l   o n   h o r i z o n t a l   s w i p e s .  
 * 	 	 	 	 	 	 	 	 	 	 " v e r t i c a l "   :   w i l l   f o r c e   p a g e   t o   s c r o l l   o n   v e r t i c a l   s w i p e s .  
 *  
 *   T h i s   j Q u e r y   p l u g i n   w i l l   o n l y   r u n   o n   d e v i c e s   r u n n i n g   M o b i l e   W e b k i t   b a s e d   b r o w s e r s   ( i O S   2 . 0 + ,   a n d r o i d   2 . 2 + )  
 * /  
 ( f u n c t i o n ( $ )   {  
  
  
  
         $ . f n . s w i p e   =   f u n c t i o n ( o p t i o n s )   {  
                 i f   ( ! t h i s )   r e t u r n   f a l s e ;  
  
                 / /   D e f a u l t   t h r e s h o l d s   &   s w i p e   f u n c t i o n s  
                 v a r   d e f a u l t s   =   {  
  
                         f i n g e r s :   1 ,   	 	 	 	 	 	 	 / /   i n t   -   T h e   n u m b e r   o f   f i n g e r s   t o   t r i g g e r   t h e   s w i p e ,   1   o r   2 .   D e f a u l t   i s   1 .  
                         t h r e s h o l d :   7 5 ,   	 	 	 	 	 	 	 / /   i n t   -   T h e   n u m b e r   o f   p i x e l s   t h a t   t h e   u s e r   m u s t   m o v e   t h e i r   f i n g e r   b y   b e f o r e   i t   i s   c o n s i d e r e d   a   s w i p e .   D e f a u l t   i s   7 5 .  
  
                         s w i p e :   n u l l ,   	 / /   F u n c t i o n   -   A   c a t c h   a l l   h a n d l e r   t h a t   i s   t r i g g e r e d   f o r   a l l   s w i p e   d i r e c t i o n s .   A c c e p t s   2   a r g u m e n t s ,   t h e   o r i g i n a l   e v e n t   o b j e c t   a n d   t h e   d i r e c t i o n   o f   t h e   s w i p e   :   " l e f t " ,   " r i g h t " ,   " u p " ,   " d o w n " .  
                         s w i p e L e f t :   n u l l ,   	 / /   F u n c t i o n   -   A   h a n d l e r   t h a t   i s   t r i g g e r e d   f o r   " l e f t "   s w i p e s .   A c c e p t s   3   a r g u m e n t s ,   t h e   o r i g i n a l   e v e n t   o b j e c t ,   t h e   d i r e c t i o n   o f   t h e   s w i p e   :   " l e f t " ,   " r i g h t " ,   " u p " ,   " d o w n "   a n d   t h e   d i s t a n c e   o f   t h e   s w i p e .  
                         s w i p e R i g h t :   n u l l ,   	 / /   F u n c t i o n   -   A   h a n d l e r   t h a t   i s   t r i g g e r e d   f o r   " r i g h t "   s w i p e s .   A c c e p t s   3   a r g u m e n t s ,   t h e   o r i g i n a l   e v e n t   o b j e c t ,   t h e   d i r e c t i o n   o f   t h e   s w i p e   :   " l e f t " ,   " r i g h t " ,   " u p " ,   " d o w n "   a n d   t h e   d i s t a n c e   o f   t h e   s w i p e .  
                         s w i p e U p :   n u l l ,   	 / /   F u n c t i o n   -   A   h a n d l e r   t h a t   i s   t r i g g e r e d   f o r   " u p "   s w i p e s .   A c c e p t s   3   a r g u m e n t s ,   t h e   o r i g i n a l   e v e n t   o b j e c t ,   t h e   d i r e c t i o n   o f   t h e   s w i p e   :   " l e f t " ,   " r i g h t " ,   " u p " ,   " d o w n "   a n d   t h e   d i s t a n c e   o f   t h e   s w i p e .  
                         s w i p e D o w n :   n u l l ,   	 / /   F u n c t i o n   -   A   h a n d l e r   t h a t   i s   t r i g g e r e d   f o r   " d o w n "   s w i p e s .   A c c e p t s   3   a r g u m e n t s ,   t h e   o r i g i n a l   e v e n t   o b j e c t ,   t h e   d i r e c t i o n   o f   t h e   s w i p e   :   " l e f t " ,   " r i g h t " ,   " u p " ,   " d o w n "   a n d   t h e   d i s t a n c e   o f   t h e   s w i p e .  
                         s w i p e S t a t u s :   n u l l ,   	 / /   F u n c t i o n   -   A   h a n d l e r   t r i g g e r e d   f o r   e v e r y   p h a s e   o f   t h e   s w i p e .   H a n d l e r   i s   p a s s e d   4   a r g u m e n t s :   e v e n t   :   T h e   o r i g i n a l   e v e n t   o b j e c t ,   p h a s e : T h e   c u r r e n t   s w i p e   f a c e ,   e i t h e r   " s t a r t ýÿ,   " m o v e ýÿ,   " e n d ýÿ  o r   " c a n c e l ýÿ.   d i r e c t i o n   :   T h e   s w i p e   d i r e c t i o n ,   e i t h e r   " u p ýÿ,   " d o w n ýÿ,   " l e f t   "   o r   " r i g h t ýÿ. d i s t a n c e   :   T h e   d i s t a n c e   o f   t h e   s w i p e .  
                         c l i c k :   n u l l ,   	 / /   F u n c t i o n 	 -   A   h a n d l e r   t r i g g e r e d   w h e n   a   u s e r   j u s t   c l i c k s   o n   t h e   i t e m ,   r a t h e r   t h a n   s w i p e s   i t .   I f   t h e y   d o   n o t   m o v e ,   c l i c k   i s   t r i g g e r e d ,   i f   t h e y   d o   m o v e ,   i t   i s   n o t .  
  
                         t r i g g e r O n T o u c h E n d :   t r u e ,   / /   B o o l e a n ,   i f   t r u e ,   t h e   s w i p e   e v e n t s   a r e   t r i g g e r e d   w h e n   t h e   t o u c h   e n d   e v e n t   i s   r e c e i v e d   ( u s e r   r e l e a s e s   f i n g e r ) .     I f   f a l s e ,   i t   w i l l   b e   t r i g g e r e d   o n   r e a c h i n g   t h e   t h r e s h o l d ,   a n d   t h e n   c a n c e l   t h e   t o u c h   e v e n t   a u t o m a t i c a l l y .  
                         a l l o w P a g e S c r o l l :   " a u t o "   	 / *   H o w   t h e   b r o w s e r   h a n d l e s   p a g e   s c r o l l s   w h e n   t h e   u s e r   i s   s w i p i n g   o n   a   t o u c h S w i p e   o b j e c t .    
 	 	 	 	 	 	 	 	 	 	 	 " a u t o "   :   a l l   u n d e f i n e d   s w i p e s   w i l l   c a u s e   t h e   p a g e   t o   s c r o l l   i n   t h a t   d i r e c t i o n .  
   	 	 	 	 	 	 	 	 	 	 	 " n o n e "   :   t h e   p a g e   w i l l   n o t   s c r o l l   w h e n   u s e r   s w i p e s .  
   	 	 	 	 	 	 	 	 	 	 	 " h o r i z o n t a l "   :   w i l l   f o r c e   p a g e   t o   s c r o l l   o n   h o r i z o n t a l   s w i p e s .  
   	 	 	 	 	 	 	 	 	 	 	 " v e r t i c a l "   :   w i l l   f o r c e   p a g e   t o   s c r o l l   o n   v e r t i c a l   s w i p e s .  
 	 	 	 	 	 	 	 	 	 	 * /  
                 } ;  
  
  
                 / / C o n s t a n t s  
                 v a r   L E F T   =   " l e f t " ;  
                 v a r   R I G H T   =   " r i g h t " ;  
                 v a r   U P   =   " u p " ;  
                 v a r   D O W N   =   " d o w n " ;  
                 v a r   N O N E   =   " n o n e " ;  
                 v a r   H O R I Z O N T A L   =   " h o r i z o n t a l " ;  
                 v a r   V E R T I C A L   =   " v e r t i c a l " ;  
                 v a r   A U T O   =   " a u t o " ;  
  
                 v a r   P H A S E _ S T A R T   =   " s t a r t " ;  
                 v a r   P H A S E _ M O V E   =   " m o v e " ;  
                 v a r   P H A S E _ E N D   =   " e n d " ;  
                 v a r   P H A S E _ C A N C E L   =   " c a n c e l " ;  
  
  
  
                 v a r   p h a s e   =   " s t a r t " ;  
  
                 i f   ( o p t i o n s . a l l o w P a g e S c r o l l   = =   u n d e f i n e d   & &   ( o p t i o n s . s w i p e   ! =   u n d e f i n e d   | |   o p t i o n s . s w i p e S t a t u s   ! =   u n d e f i n e d ) )  
                         o p t i o n s . a l l o w P a g e S c r o l l   =   N O N E ;  
  
                 i f   ( o p t i o n s )  
                         $ . e x t e n d ( d e f a u l t s ,   o p t i o n s ) ;  
  
  
                 / * *  
                 *   S e t u p   e a c h   o b j e c t   t o   d e t e c t   s w i p e   g e s t u r e s  
                 * /  
                 r e t u r n   t h i s . e a c h ( f u n c t i o n ( )   {  
                         v a r   $ t h i s   =   $ ( t h i s ) ;  
  
                         v a r   t r i g g e r E l e m e n t I D   =   n u l l ;   	 / /   t h i s   v a r i a b l e   i s   u s e d   t o   i d e n t i t y   t h e   t r i g g e r i n g   e l e m e n t  
                         v a r   f i n g e r C o u n t   =   0 ;   	 	 / /   t h e   c u r r e n t   n u m b e r   o f   f i n g e r s   b e i n g   u s e d . 	  
  
                         / / t r a c k   m o u s e   p o i n t s   /   d e l t a  
                         v a r   s t a r t   =   {   x :   0 ,   y :   0   } ;  
                         v a r   e n d   =   {   x :   0 ,   y :   0   } ;  
                         v a r   d e l t a   =   {   x :   0 ,   y :   0   } ;  
  
  
                         / * *  
                         *   E v e n t   h a n d l e r   f o r   a   t o u c h   s t a r t   e v e n t .    
                         *   S t o p s   t h e   d e f a u l t   c l i c k   e v e n t   f r o m   t r i g g e r i n g   a n d   s t o r e s   w h e r e   w e   t o u c h e d  
                         * /  
                         f u n c t i o n   t o u c h S t a r t ( e v e n t )   {  
                                 p h a s e   =   P H A S E _ S T A R T ;  
  
                                 / /   g e t   t h e   t o t a l   n u m b e r   o f   f i n g e r s   t o u c h i n g   t h e   s c r e e n  
                                 f i n g e r C o u n t   =   e v e n t . t o u c h e s . l e n g t h ;  
  
                                 / / c l e a r   v a r s . .  
                                 d i s t a n c e   =   0 ;  
                                 d i r e c t i o n   =   n u l l ;  
  
                                 / /   c h e c k   t h e   n u m b e r   o f   f i n g e r s   i s   w h a t   w e   a r e   l o o k i n g   f o r  
                                 i f   ( f i n g e r C o u n t   = =   d e f a u l t s . f i n g e r s )   {  
                                         / /   g e t   t h e   c o o r d i n a t e s   o f   t h e   t o u c h  
                                         s t a r t . x   =   e n d . x   =   e v e n t . t o u c h e s [ 0 ] . p a g e X ;  
                                         s t a r t . y   =   e n d . y   =   e v e n t . t o u c h e s [ 0 ] . p a g e Y ;  
  
                                         i f   ( d e f a u l t s . s w i p e S t a t u s )  
                                                 t r i g g e r H a n d l e r ( e v e n t ,   p h a s e ) ;  
                                 }  
                                 e l s e   {  
                                         / / t o u c h   w i t h   m o r e / l e s s   t h a n   t h e   f i n g e r s   w e   a r e   l o o k i n g   f o r  
                                         t o u c h C a n c e l ( e v e n t ) ;  
                                 }  
                         }  
  
                         / * *  
                         *   E v e n t   h a n d l e r   f o r   a   t o u c h   m o v e   e v e n t .    
                         *   I f   w e   c h a n g e   f i n g e r s   d u r i n g   m o v e ,   t h e n   c a n c e l   t h e   e v e n t  
                         * /  
                         f u n c t i o n   t o u c h M o v e ( e v e n t )   {  
                                 i f   ( p h a s e   = =   P H A S E _ E N D   | |   p h a s e   = =   P H A S E _ C A N C E L )  
                                         r e t u r n ;  
  
                                 e n d . x   =   e v e n t . t o u c h e s [ 0 ] . p a g e X ;  
                                 e n d . y   =   e v e n t . t o u c h e s [ 0 ] . p a g e Y ;  
  
                                 d i r e c t i o n   =   c a l u c u l a t e D i r e c t i o n ( ) ;  
                                 f i n g e r C o u n t   =   e v e n t . t o u c h e s . l e n g t h ;  
  
                                 p h a s e   =   P H A S E _ M O V E  
  
                                 / / C h e c k   i f   w e   n e e d   t o   p r e v e n t   d e f a u l t   e v n e t   ( p a g e   s c r o l l )   o r   n o t  
                                 v a l i d a t e D e f a u l t E v e n t ( e v e n t ,   d i r e c t i o n ) ;  
  
                                 i f   ( f i n g e r C o u n t   = =   d e f a u l t s . f i n g e r s )   {  
                                         d i s t a n c e   =   c a l u c u l a t e D i s t a n c e ( ) ;  
  
                                         i f   ( d e f a u l t s . s w i p e S t a t u s )  
                                                 t r i g g e r H a n d l e r ( e v e n t ,   p h a s e ,   d i r e c t i o n ,   d i s t a n c e ) ;  
  
                                         / / I f   w e   t r i g g e r   w h i l s t   d r a g g i n g ,   n o t   o n   t o u c h   e n d ,   t h e n   c a l c u l a t e   n o w . . .  
                                         i f   ( ! d e f a u l t s . t r i g g e r O n T o u c h E n d )   {  
                                                 / /   i f   t h e   u s e r   s w i p e d   m o r e   t h a n   t h e   m i n i m u m   l e n g t h ,   p e r f o r m   t h e   a p p r o p r i a t e   a c t i o n  
                                                 i f   ( d i s t a n c e   > =   d e f a u l t s . t h r e s h o l d )   {  
                                                         p h a s e   =   P H A S E _ E N D ;  
                                                         t r i g g e r H a n d l e r ( e v e n t ,   p h a s e ) ;  
                                                         t o u c h C a n c e l ( e v e n t ) ;   / /   r e s e t   t h e   v a r i a b l e s  
                                                 }  
                                         }  
                                 }  
                                 e l s e   {  
                                         p h a s e   =   P H A S E _ C A N C E L ;  
                                         t r i g g e r H a n d l e r ( e v e n t ,   p h a s e ) ;  
                                         t o u c h C a n c e l ( e v e n t ) ;  
                                 }  
                         }  
  
                         / * *  
                         *   E v e n t   h a n d l e r   f o r   a   t o u c h   e n d   e v e n t .    
                         *   C a l c u l a t e   t h e   d i r e c t i o n   a n d   t r i g g e r   e v e n t s  
                         * /  
                         f u n c t i o n   t o u c h E n d ( e v e n t )   {  
                                 e v e n t . p r e v e n t D e f a u l t ( ) ;  
  
                                 d i s t a n c e   =   c a l u c u l a t e D i s t a n c e ( ) ;  
                                 d i r e c t i o n   =   c a l u c u l a t e D i r e c t i o n ( ) ;  
  
                                 i f   ( d e f a u l t s . t r i g g e r O n T o u c h E n d )   {  
                                         p h a s e   =   P H A S E _ E N D ;  
                                         / /   c h e c k   t o   s e e   i f   m o r e   t h a n   o n e   f i n g e r   w a s   u s e d   a n d   t h a t   t h e r e   i s   a n   e n d i n g   c o o r d i n a t e  
                                         i f   ( f i n g e r C o u n t   = =   d e f a u l t s . f i n g e r s   & &   e n d . x   ! =   0 )   {  
                                                 / /   i f   t h e   u s e r   s w i p e d   m o r e   t h a n   t h e   m i n i m u m   l e n g t h ,   p e r f o r m   t h e   a p p r o p r i a t e   a c t i o n  
                                                 i f   ( d i s t a n c e   > =   d e f a u l t s . t h r e s h o l d )   {  
                                                         t r i g g e r H a n d l e r ( e v e n t ,   p h a s e ) ;  
                                                         t o u c h C a n c e l ( e v e n t ) ;   / /   r e s e t   t h e   v a r i a b l e s  
                                                 }  
                                                 e l s e   {  
                                                         p h a s e   =   P H A S E _ C A N C E L ;  
                                                         t r i g g e r H a n d l e r ( e v e n t ,   p h a s e ) ;  
                                                         t o u c h C a n c e l ( e v e n t ) ;  
                                                 }  
                                         }  
                                         e l s e   {  
                                                 p h a s e   =   P H A S E _ C A N C E L ;  
                                                 t r i g g e r H a n d l e r ( e v e n t ,   p h a s e ) ;  
                                                 t o u c h C a n c e l ( e v e n t ) ;  
                                         }  
                                 }  
                                 e l s e   i f   ( p h a s e   = =   P H A S E _ M O V E )   {  
                                         p h a s e   =   P H A S E _ C A N C E L ;  
                                         t r i g g e r H a n d l e r ( e v e n t ,   p h a s e ) ;  
                                         t o u c h C a n c e l ( e v e n t ) ;  
                                 }  
                         }  
  
                         / * *  
                         *   E v e n t   h a n d l e r   f o r   a   t o u c h   c a n c e l   e v e n t .    
                         *   C l e a r s   c u r r e n t   v a r s  
                         * /  
                         f u n c t i o n   t o u c h C a n c e l ( e v e n t )   {  
                                 / /   r e s e t   t h e   v a r i a b l e s   b a c k   t o   d e f a u l t   v a l u e s  
                                 f i n g e r C o u n t   =   0 ;  
  
                                 s t a r t . x   =   0 ;  
                                 s t a r t . y   =   0 ;  
                                 e n d . x   =   0 ;  
                                 e n d . y   =   0 ;  
                                 d e l t a . x   =   0 ;  
                                 d e l t a . y   =   0 ;  
                         }  
  
  
                         / * *  
                         *   T r i g g e r   t h e   r e l e v a n t   e v e n t   h a n d l e r  
                         *   T h e   h a n d l e r s   a r e   p a s s e d   t h e   o r i g i n a l   e v e n t ,   t h e   e l e m e n t   t h a t   w a s   s w i p e d ,   a n d   i n   t h e   c a s e   o f   t h e   c a t c h   a l l   h a n d l e r ,   t h e   d i r e c t i o n   t h a t   w a s   s w i p e d ,   " l e f t " ,   " r i g h t " ,   " u p " ,   o r   " d o w n "  
                         * /  
                         f u n c t i o n   t r i g g e r H a n d l e r ( e v e n t ,   p h a s e )   {  
                                 / / u p d a t e   s t a t u s  
                                 i f   ( d e f a u l t s . s w i p e S t a t u s )  
                                         d e f a u l t s . s w i p e S t a t u s . c a l l ( $ t h i s ,   e v e n t ,   p h a s e ,   d i r e c t i o n   | |   n u l l ,   d i s t a n c e   | |   0 ) ;  
  
  
                                 i f   ( p h a s e   = =   P H A S E _ C A N C E L )   {  
                                         i f   ( d e f a u l t s . c l i c k   & &   f i n g e r C o u n t   = =   1   & &   ( i s N a N ( d i s t a n c e )   | |   d i s t a n c e   = =   0 ) )  
                                                 d e f a u l t s . c l i c k . c a l l ( $ t h i s ,   e v e n t ,   e v e n t . t a r g e t ) ;  
                                 }  
  
                                 i f   ( p h a s e   = =   P H A S E _ E N D )   {  
                                         / / t r i g g e r   c a t c h   a l l   e v e n t   h a n d l e r  
                                         i f   ( d e f a u l t s . s w i p e )   {  
  
                                                 d e f a u l t s . s w i p e . c a l l ( $ t h i s ,   e v e n t ,   d i r e c t i o n ,   d i s t a n c e ) ;  
  
                                         }  
                                         / / t r i g g e r   d i r e c t i o n   s p e c i f i c   e v e n t   h a n d l e r s 	  
                                         s w i t c h   ( d i r e c t i o n )   {  
                                                 c a s e   L E F T :  
                                                         i f   ( d e f a u l t s . s w i p e L e f t )  
                                                                 d e f a u l t s . s w i p e L e f t . c a l l ( $ t h i s ,   e v e n t ,   d i r e c t i o n ,   d i s t a n c e ) ;  
                                                         b r e a k ;  
  
                                                 c a s e   R I G H T :  
                                                         i f   ( d e f a u l t s . s w i p e R i g h t )  
                                                                 d e f a u l t s . s w i p e R i g h t . c a l l ( $ t h i s ,   e v e n t ,   d i r e c t i o n ,   d i s t a n c e ) ;  
                                                         b r e a k ;  
  
                                                 c a s e   U P :  
                                                         i f   ( d e f a u l t s . s w i p e U p )  
                                                                 d e f a u l t s . s w i p e U p . c a l l ( $ t h i s ,   e v e n t ,   d i r e c t i o n ,   d i s t a n c e ) ;  
                                                         b r e a k ;  
  
                                                 c a s e   D O W N :  
                                                         i f   ( d e f a u l t s . s w i p e D o w n )  
                                                                 d e f a u l t s . s w i p e D o w n . c a l l ( $ t h i s ,   e v e n t ,   d i r e c t i o n ,   d i s t a n c e ) ;  
                                                         b r e a k ;  
                                         }  
                                 }  
                         }  
  
  
                         / * *  
                         *   C h e c k s   d i r e c t i o n   o f   t h e   s w i p e   a n d   t h e   v a l u e   a l l o w P a g e S c r o l l   t o   s e e   i f   w e   s h o u l d   a l l o w   o r   p r e v e n t   t h e   d e f a u l t   b e h a v i o u r   f r o m   o c c u r r i n g .  
                         *   T h i s   w i l l   e s s e n t i a l l y   a l l o w   p a g e   s c r o l l i n g   o r   n o t   w h e n   t h e   u s e r   i s   s w i p i n g   o n   a   t o u c h S w i p e   o b j e c t .  
                         * /  
                         f u n c t i o n   v a l i d a t e D e f a u l t E v e n t ( e v e n t ,   d i r e c t i o n )   {  
                                 i f   ( d e f a u l t s . a l l o w P a g e S c r o l l   = =   N O N E )   {  
                                         e v e n t . p r e v e n t D e f a u l t ( ) ;  
                                 }  
                                 e l s e   {  
                                         v a r   a u t o   =   d e f a u l t s . a l l o w P a g e S c r o l l   = =   A U T O ;  
  
                                         s w i t c h   ( d i r e c t i o n )   {  
                                                 c a s e   L E F T :  
                                                         i f   ( ( d e f a u l t s . s w i p e L e f t   & &   a u t o )   | |   ( ! a u t o   & &   d e f a u l t s . a l l o w P a g e S c r o l l   ! =   H O R I Z O N T A L ) )  
                                                                 e v e n t . p r e v e n t D e f a u l t ( ) ;  
                                                         b r e a k ;  
  
                                                 c a s e   R I G H T :  
                                                         i f   ( ( d e f a u l t s . s w i p e R i g h t   & &   a u t o )   | |   ( ! a u t o   & &   d e f a u l t s . a l l o w P a g e S c r o l l   ! =   H O R I Z O N T A L ) )  
                                                                 e v e n t . p r e v e n t D e f a u l t ( ) ;  
                                                         b r e a k ;  
  
                                                 c a s e   U P :  
                                                         i f   ( ( d e f a u l t s . s w i p e U p   & &   a u t o )   | |   ( ! a u t o   & &   d e f a u l t s . a l l o w P a g e S c r o l l   ! =   V E R T I C A L ) )  
                                                                 e v e n t . p r e v e n t D e f a u l t ( ) ;  
                                                         b r e a k ;  
  
                                                 c a s e   D O W N :  
                                                         i f   ( ( d e f a u l t s . s w i p e D o w n   & &   a u t o )   | |   ( ! a u t o   & &   d e f a u l t s . a l l o w P a g e S c r o l l   ! =   V E R T I C A L ) )  
                                                                 e v e n t . p r e v e n t D e f a u l t ( ) ;  
                                                         b r e a k ;  
                                         }  
                                 }  
  
                         }  
  
  
  
                         / * *  
                         *   C a l c u a l t e   t h e   l e n g t h   /   d i s t a n c e   o f   t h e   s w i p e  
                         * /  
                         f u n c t i o n   c a l u c u l a t e D i s t a n c e ( )   {  
                                 r e t u r n   M a t h . r o u n d ( M a t h . s q r t ( M a t h . p o w ( e n d . x   -   s t a r t . x ,   2 )   +   M a t h . p o w ( e n d . y   -   s t a r t . y ,   2 ) ) ) ;  
                         }  
  
                         / * *  
                         *   C a l c u a l t e   t h e   a n g l e   o f   t h e   s w i p e  
                         * /  
                         f u n c t i o n   c a l u c u l a t e A n g l e ( )   {  
                                 v a r   X   =   s t a r t . x   -   e n d . x ;  
                                 v a r   Y   =   e n d . y   -   s t a r t . y ;  
                                 v a r   r   =   M a t h . a t a n 2 ( Y ,   X ) ;   / / r a d i a n s  
                                 v a r   a n g l e   =   M a t h . r o u n d ( r   *   1 8 0   /   M a t h . P I ) ;   / / d e g r e e s  
  
                                 / / e n s u r e   v a l u e   i s   p o s i t i v e  
                                 i f   ( a n g l e   <   0 )  
                                         a n g l e   =   3 6 0   -   M a t h . a b s ( a n g l e ) ;  
  
                                 r e t u r n   a n g l e ;  
                         }  
  
                         / * *  
                         *   C a l c u a l t e   t h e   d i r e c t i o n   o f   t h e   s w i p e  
                         *   T h i s   w i l l   a l s o   c a l l   c a l u c u l a t e A n g l e   t o   g e t   t h e   l a t e s t   a n g l e   o f   s w i p e  
                         * /  
                         f u n c t i o n   c a l u c u l a t e D i r e c t i o n ( )   {  
                                 v a r   a n g l e   =   c a l u c u l a t e A n g l e ( ) ;  
  
                                 i f   ( ( a n g l e   < =   4 5 )   & &   ( a n g l e   > =   0 ) )  
                                         r e t u r n   L E F T ;  
  
                                 e l s e   i f   ( ( a n g l e   < =   3 6 0 )   & &   ( a n g l e   > =   3 1 5 ) )  
                                         r e t u r n   L E F T ;  
  
                                 e l s e   i f   ( ( a n g l e   > =   1 3 5 )   & &   ( a n g l e   < =   2 2 5 ) )  
                                         r e t u r n   R I G H T ;  
  
                                 e l s e   i f   ( ( a n g l e   >   4 5 )   & &   ( a n g l e   <   1 3 5 ) )  
                                         r e t u r n   D O W N ;  
  
                                 e l s e  
                                         r e t u r n   U P ;  
                         }  
  
  
  
                         / /   A d d   g e s t u r e s   t o   a l l   s w i p a b l e   a r e a s   i f   s u p p o r t e d  
                         t r y   {  
                                 t h i s . a d d E v e n t L i s t e n e r ( " t o u c h s t a r t " ,   t o u c h S t a r t ,   f a l s e ) ;  
                                 t h i s . a d d E v e n t L i s t e n e r ( " t o u c h m o v e " ,   t o u c h M o v e ,   f a l s e ) ;  
                                 t h i s . a d d E v e n t L i s t e n e r ( " t o u c h e n d " ,   t o u c h E n d ,   f a l s e ) ;  
                                 t h i s . a d d E v e n t L i s t e n e r ( " t o u c h c a n c e l " ,   t o u c h C a n c e l ,   f a l s e ) ;  
                         }  
                         c a t c h   ( e )   {  
                                 / / t o u c h   n o t   s u p p o r t e d  
                         }  
  
                 } ) ;  
         } ;  
  
 } ) ( j Q u e r y ) ;  
  
 ( f u n c t i o n ( $ )   {  
         $ . f n . t i p s y   =   f u n c t i o n ( o p t i o n s )   {  
  
                 o p t i o n s   =   $ . e x t e n d ( { } ,   $ . f n . t i p s y . d e f a u l t s ,   o p t i o n s ) ;  
  
                 r e t u r n   t h i s . e a c h ( f u n c t i o n ( )   {  
  
                         v a r   o p t s   =   $ . f n . t i p s y . e l e m e n t O p t i o n s ( t h i s ,   o p t i o n s ) ;  
  
                         $ ( t h i s ) . h o v e r ( f u n c t i o n ( )   {  
  
                                 $ . d a t a ( t h i s ,   ' c a n c e l . t i p s y ' ,   t r u e ) ;  
  
                                 v a r   t i p   =   $ . d a t a ( t h i s ,   ' a c t i v e . t i p s y ' ) ;  
                                 i f   ( ! t i p )   {  
                                         t i p   =   $ ( ' < d i v   c l a s s = " t i p s y " > < d i v   c l a s s = " t i p s y - i n n e r " / > < / d i v > ' ) ;  
                                         t i p . c s s ( {   p o s i t i o n :   ' a b s o l u t e ' ,   z I n d e x :   1 0 0 0 0 0   } ) ;  
                                         $ . d a t a ( t h i s ,   ' a c t i v e . t i p s y ' ,   t i p ) ;  
                                 }  
  
                                 i f   ( $ ( t h i s ) . a t t r ( ' t i t l e ' )   | |   t y p e o f   ( $ ( t h i s ) . a t t r ( ' o r i g i n a l - t i t l e ' ) )   ! =   ' s t r i n g ' )   {  
                                         $ ( t h i s ) . a t t r ( ' o r i g i n a l - t i t l e ' ,   $ ( t h i s ) . a t t r ( ' t i t l e ' )   | |   ' ' ) . r e m o v e A t t r ( ' t i t l e ' ) ;  
                                 }  
  
                                 v a r   t i t l e ;  
                                 i f   ( t y p e o f   o p t s . t i t l e   = =   ' s t r i n g ' )   {  
                                         t i t l e   =   $ ( t h i s ) . a t t r ( o p t s . t i t l e   = =   ' t i t l e '   ?   ' o r i g i n a l - t i t l e '   :   o p t s . t i t l e ) ;  
                                 }   e l s e   i f   ( t y p e o f   o p t s . t i t l e   = =   ' f u n c t i o n ' )   {  
                                         t i t l e   =   o p t s . t i t l e . c a l l ( t h i s ) ;  
                                 }  
  
                                 t i p . f i n d ( ' . t i p s y - i n n e r ' ) [ o p t s . h t m l   ?   ' h t m l '   :   ' t e x t ' ] ( t i t l e   | |   o p t s . f a l l b a c k ) ;  
  
                                 v a r   p o s   =   $ . e x t e n d ( { } ,   $ ( t h i s ) . o f f s e t ( ) ,   {   w i d t h :   t h i s . o f f s e t W i d t h ,   h e i g h t :   t h i s . o f f s e t H e i g h t   } ) ;  
                                 t i p . g e t ( 0 ) . c l a s s N a m e   =   ' t i p s y ' ;   / /   r e s e t   c l a s s n a m e   i n   c a s e   o f   d y n a m i c   g r a v i t y  
                                 t i p . r e m o v e ( ) . c s s ( {   t o p :   0 ,   l e f t :   0 ,   v i s i b i l i t y :   ' h i d d e n ' ,   d i s p l a y :   ' b l o c k '   } ) . a p p e n d T o ( d o c u m e n t . b o d y ) ;  
                                 v a r   a c t u a l W i d t h   =   t i p [ 0 ] . o f f s e t W i d t h ,   a c t u a l H e i g h t   =   t i p [ 0 ] . o f f s e t H e i g h t ;  
                                 v a r   g r a v i t y   =   ( t y p e o f   o p t s . g r a v i t y   = =   ' f u n c t i o n ' )   ?   o p t s . g r a v i t y . c a l l ( t h i s )   :   o p t s . g r a v i t y ;  
  
                                 s w i t c h   ( g r a v i t y . c h a r A t ( 0 ) )   {  
                                         c a s e   ' n ' :  
                                                 t i p . c s s ( {   t o p :   p o s . t o p   +   p o s . h e i g h t ,   l e f t :   p o s . l e f t   +   p o s . w i d t h   /   2   -   a c t u a l W i d t h   /   2   } ) . a d d C l a s s ( ' t i p s y - n o r t h ' ) ;  
                                                 b r e a k ;  
                                         c a s e   ' s ' :  
                                                 t i p . c s s ( {   t o p :   p o s . t o p   -   a c t u a l H e i g h t ,   l e f t :   p o s . l e f t   +   p o s . w i d t h   /   2   -   a c t u a l W i d t h   /   2   } ) . a d d C l a s s ( ' t i p s y - s o u t h ' ) ;  
                                                 b r e a k ;  
                                         c a s e   ' e ' :  
                                                 t i p . c s s ( {   t o p :   p o s . t o p   +   p o s . h e i g h t   /   2   -   a c t u a l H e i g h t   /   2 ,   l e f t :   p o s . l e f t   -   a c t u a l W i d t h   } ) . a d d C l a s s ( ' t i p s y - e a s t ' ) ;  
                                                 b r e a k ;  
                                         c a s e   ' w ' :  
                                                 t i p . c s s ( {   t o p :   p o s . t o p   +   p o s . h e i g h t   /   2   -   a c t u a l H e i g h t   /   2 ,   l e f t :   p o s . l e f t   +   p o s . w i d t h   } ) . a d d C l a s s ( ' t i p s y - w e s t ' ) ;  
                                                 b r e a k ;  
                                 }  
  
                                 i f   ( o p t s . f a d e )   {  
                                         t i p . c s s ( {   o p a c i t y :   0 ,   d i s p l a y :   ' b l o c k ' ,   v i s i b i l i t y :   ' v i s i b l e '   } ) . a n i m a t e ( {   o p a c i t y :   0 . 8   } ) ;  
                                 }   e l s e   {  
                                         t i p . c s s ( {   v i s i b i l i t y :   ' v i s i b l e '   } ) ;  
                                 }  
  
                         } ,   f u n c t i o n ( )   {  
                                 $ . d a t a ( t h i s ,   ' c a n c e l . t i p s y ' ,   f a l s e ) ;  
                                 v a r   s e l f   =   t h i s ;  
                                 s e t T i m e o u t ( f u n c t i o n ( )   {  
                                         i f   ( $ . d a t a ( t h i s ,   ' c a n c e l . t i p s y ' ) )   r e t u r n ;  
                                         v a r   t i p   =   $ . d a t a ( s e l f ,   ' a c t i v e . t i p s y ' ) ;  
                                         i f   ( o p t s . f a d e )   {  
                                                 t i p . s t o p ( ) . f a d e O u t ( f u n c t i o n ( )   {   $ ( t h i s ) . r e m o v e ( ) ;   } ) ;  
                                         }   e l s e   {  
                                                 t i p . r e m o v e ( ) ;  
                                         }  
                                 } ,   1 0 0 ) ;  
  
                         } ) ;  
  
                 } ) ;  
  
         } ;  
  
         / /   O v e r w r i t e   t h i s   m e t h o d   t o   p r o v i d e   o p t i o n s   o n   a   p e r - e l e m e n t   b a s i s .  
         / /   F o r   e x a m p l e ,   y o u   c o u l d   s t o r e   t h e   g r a v i t y   i n   a   ' t i p s y - g r a v i t y '   a t t r i b u t e :  
         / /   r e t u r n   $ . e x t e n d ( { } ,   o p t i o n s ,   { g r a v i t y :   $ ( e l e ) . a t t r ( ' t i p s y - g r a v i t y ' )   | |   ' n '   } ) ;  
         / /   ( r e m e m b e r   -   d o   n o t   m o d i f y   ' o p t i o n s '   i n   p l a c e ! )  
         $ . f n . t i p s y . e l e m e n t O p t i o n s   =   f u n c t i o n ( e l e ,   o p t i o n s )   {  
                 r e t u r n   $ . m e t a d a t a   ?   $ . e x t e n d ( { } ,   o p t i o n s ,   $ ( e l e ) . m e t a d a t a ( ) )   :   o p t i o n s ;  
         } ;  
  
         $ . f n . t i p s y . d e f a u l t s   =   {  
                 f a d e :   f a l s e ,  
                 f a l l b a c k :   ' ' ,  
                 g r a v i t y :   ' n ' ,  
                 h t m l :   f a l s e ,  
                 t i t l e :   ' t i t l e '  
         } ;  
  
         $ . f n . t i p s y . a u t o N S   =   f u n c t i o n ( )   {  
                 r e t u r n   $ ( t h i s ) . o f f s e t ( ) . t o p   >   ( $ ( d o c u m e n t ) . s c r o l l T o p ( )   +   $ ( w i n d o w ) . h e i g h t ( )   /   2 )   ?   ' s '   :   ' n ' ;  
         } ;  
  
         $ . f n . t i p s y . a u t o W E   =   f u n c t i o n ( )   {  
                 r e t u r n   $ ( t h i s ) . o f f s e t ( ) . l e f t   >   ( $ ( d o c u m e n t ) . s c r o l l L e f t ( )   +   $ ( w i n d o w ) . w i d t h ( )   /   2 )   ?   ' e '   :   ' w ' ;  
         } ;  
  
 } ) ( j Q u e r y ) ;  
  
 v a r   u s e r A g e n t   =   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 ( ) ;  
 j Q u e r y . b r o w s e r . c h r o m e   =   / c h r o m e / . t e s t ( 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 f   ( j Q u e r y . b r o w s e r . c h r o m e )   {  
         j Q u e r y . b r o w s e r . s a f a r i   =   f a l s e ;  
 } 
