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