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