ÿþf u n c t i o n   g e t _ x m l h t t p ( )   / / H à m   n à y   Ã  t ¡o   r a   Ñi   t °ãn g   X M L H T T P R e q u e s t   m a   c a c   t r i n h   d u y e t   h o   t r o   t r o n g   k ÷  t h åâ t   a j a x .  
 {      
             x m l = n u l l ;  
                 t r y  
                 {  
                 	 x m l = n e w   X M L H t t p R e q u e s t ( ) ;  
 	                 r e t u r n   x m l ;  
                 }  
                 c a t c h ( e r r )  
                 {  
                 	 t r y  
 	 	 {  
 	 	 	 x m l = n e w   A c t i v e X O b j e c t ( " M i c r o s o f t . X M L H T T P " ) ;  
 	 	 	 r e t u r n   x m l ;  
 	 	 }  
  
 	 c a t c h ( e r r 1 )  
 	 	  
 	 	 {  
 	 	 	 t r y  
 	 	 	 	 {  
 	 	 	 	 	 x m l =   n e w   A c t i v e X O b j e c t ( " M s x m l 2 . X M L H T T P " ) ;  
 	 	 	   	 	 r e t u r n   x m l ;  
 	 	 	 	 }  
  
 	 	 	 c a t c h ( e r r 2 )  
  
 	 	 	 	 {  
 	 	 	 	 	 a l e r t ( ' B r o w s e r   c a n   n o t   i n i t i a l i z e   X M L H t t p R e q u e s t   o b j e c t ' ) ;  
 	 	 	 	 	 r e t u r n   x m l ;  
 	 	 	 	 }  
  
 	 	 } 	 	  
                 }  
                
       r e t u r n   x m l ;  
 }    
  
 f u n c t i o n   p r o c e s s _ a j a x _ d a t a ( d a t a _ g u i , u r l _ x u l y , i d _ p h a n t u _ b i e u d i e n _ d u l i e u )   / / H à m   n à y   Ã  l ¥y   d ï  l i Çu   t ë  Ñi   t °ãn g   X M L H T T P   v à   h i Ãn   t h Ë  t r ê n   t r ì n h   d u y Çt .  
 {  
                 x m l r e s u l t = g e t _ x m l h t t p ( ) ; 	  
                 i f ( x m l r e s u l t   ! =   n u l l )  
                 {  
                         u r l = u r l _ x u l y ;  
                         x m l r e s u l t . o p e n ( " P O S T " , u r l , t r u e ) ; / /   D ù n g   k i Ãu   g íi   d a t a   t h e o   p h °¡n g   t h éc   p o s t   Ã  a n   t o à n   v à   g íi   n h i Áu   d a t a   m Ùt   l ú c . 	  
 	                 x m l r e s u l t . s e t R e q u e s t H e a d e r ( ' C o n t e n t - t y p e ' ,   ' a p p l i c a t i o n / x - w w w - f o r m - u r l e n c o d e d ; c h a r s e t = U T F - 8 ; ' ) ;      
                         x m l r e s u l t . o n r e a d y s t a t e c h a n g e   =   f u n c t i o n   ( )  
                                 {  
                                         i f   ( x m l r e s u l t . r e a d y S t a t e   = =   4   & &   x m l r e s u l t . s t a t u s   = =   2 0 0 )   / /   K i Ãm   t r a   c o   d a t a   t r a   v e   v a   k h o n g   c o   l o i .  
                                         {                                                  
                                                 d o c u m e n t . g e t E l e m e n t B y I d ( i d _ p h a n t u _ b i e u d i e n _ d u l i e u ) . i n n e r H T M L = x m l r e s u l t . r e s p o n s e T e x t ; / / T r ì n h   d i Ån   d a t a   t r £  v Á  t ¡i   c l i e n t   t r ê n   m Ùt   p h §n   t í  n h °  t h »  < d i v >   h a y   < s p a n > . . .   c ó   i d   °ãc   t r u y Án   v à o .  
  
 	 	                                 / / e s c a p e ( d a t a   g íi   t h e o   u r l   c §n   m ã   h ó a ) ; - - - - > H a m   n a y   m a   h o a   c a c   k y   t u   v a   t r a   v e   c h u o i   t h e o   k i e u   g i o n g   n h u   u r l   d e   g u i   d i   c ù n g   u r l .  
                                         }    
                                 }  
                       x m l r e s u l t . s e n d ( d a t a _ g u i ) ; / / H à m   g íi   d a t a   i .  
                 }  
                 / / e l s e  
                         / / a l e r t ( ' Y o u r   b r o w s e r   n e e d   t o   s u p p o r t   A j a x   t o   u s e   t h i s   p a g e   b e s t . ' ) ;  
 }  
  
 / /   p r o c e s s   p r e s s   e n t e r k e y   o n   t e x t b o x  
 f u n c t i o n   p r e s s _ e n t e r k e y L o n g ( e , b u t t o n i d )  
 {      
       v a r   e v t   =   e   ?   e   :   w i n d o w . e v e n t ;          
       v a r   b t   =   d o c u m e n t . g e t E l e m e n t B y I d ( b u t t o n i d ) ;      
       i f   ( b t )  
             {        
               i f   ( e v t . k e y C o d e   = =   1 3 )  
                     {            
                         b t . c l i c k ( ) ;        
                         r e t u r n   f a l s e ;            
                     }        
             }    
 }  
  
 / / f o r   p a g i n g   _ o l d  
 f u n c t i o n   i d p a g e L o n g _ o l d ( k e y s t r , v a l u e s t r )  
   	   {  
   	       v a r   Q S t r i n g =   u n e s c a p e ( l o c a t i o n . s e a r c h ) ;  
 	       v a r   v i t r i = Q S t r i n g . i n d e x O f ( k e y s t r )  
 	   	   i f   ( v i t r i ! = - 1 )   Q S t r i n g = Q S t r i n g . s u b s t r i n g ( 0 , v i t r i - 1 ) ;  
 	   	   i f   ( Q S t r i n g ! = ' ' )   Q S t r i n g + = ' & ' ;  
 	   	   e l s e   Q S t r i n g = ' ? ' + Q S t r i n g ;  
   	       l o c a t i o n . h r e f = Q S t r i n g + k e y s t r + ' = ' + v a l u e s t r ;  
   	   }  
 / / f o r   f i x   i m a g e s   o n   p a g e  
 v a r   m a x w i d t h i m g s n e e d f i x L ;  
 v a r   m a x h e i g h t i m g s n e e d i x L ;  
 v a r   n a m e i m g s n e e d f i x L ; / / c h i   t r u y e n   v a o   c h o   h a m   f i x   c a c   i m a g e s   t r e n   t r a n g   m o t   p h a n   t e n   g i o n g   n h a u   c u a   t h u o c   t i n h   n a m e   c h o   a l l   i m a g e s  
 f u n c t i o n   s t a r f i x i m a g e s L o n g ( m a x w i d t h , m a x h e i g h t , n a m e i m g 9 l e t t e r )  
 {  
         m a x w i d t h i m g s n e e d f i x L   =   m a x w i d t h ;  
         m a x h e i g h t i m g s n e e d i x L   =   m a x h e i g h t ;  
         n a m e i m g s n e e d f i x L   =   n a m e i m g 9 l e t t e r ;  
         f i x i m a g e s L o n g ( ) ;          
 }  
 f u n c t i o n   f i x i m a g e s L o n g ( )    
 {  
         v a r   w ;  
         v a r   h ;  
         v a r   w G o c ;  
         v a r   h G o c ;  
         w G o c   =   m a x w i d t h i m g s n e e d f i x L ;  
         h G o c   =   m a x h e i g h t i m g s n e e d i x L ;  
         v a r   p i x   =   d o c u m e n t . i m a g e s ;  
         v a r   i ;  
         v a r   r a t i o ;          
         f o r   ( i = 0 ;   i < p i x . l e n g t h ;   i + + )    
         {  
                         v a r   i m I d = p i x [ i ] . n a m e ;  
                         i f   ( i m I d . s u b s t r i n g ( 0 , 9 )   = =   n a m e i m g s n e e d f i x L )  
                                 {                              
                                         p i x [ i ] . r e m o v e A t t r i b u t e ( " w i d t h " ) ;  
                                         p i x [ i ] . r e m o v e A t t r i b u t e ( " h e i g h t " ) ;                          
                                         w = p i x [ i ] . w i d t h ;  
                                         h = p i x [ i ] . h e i g h t ;                              
                                         i f ( h / w   = =   h G o c / w G o c )  
                                                 {  
                                                         p i x [ i ] . w i d t h = w G o c ;  
                                                         p i x [ i ] . h e i g h t = h G o c ;  
                                                 }  
                                                     e l s e  
                                                 {  
                                                                     i f ( h   > =   w   & &   h   > =   h G o c )  
                                                                         {  
                                                                             r a t i o   =   h / w ;      
                                                                             p i x [ i ] . w i d t h = ( h G o c / r a t i o ) ;  
                                                                             p i x [ i ] . h e i g h t = h G o c ;  
                                                                         }  
                                                                       i f ( h   < w   & &   h   > =   h G o c )  
                                                                         {  
                                                                                 r a t i o   =   ( w / h ) ;  
                                                                                 p i x [ i ] . w i d t h = w G o c ;  
                                                                                 p i x [ i ] . h e i g h t = w G o c / r a t i o ;                                                                            
                                                                         }    
                                                                         i f ( h   <   w   & &   w   >   w G o c )  
                                                                         {  
                                                                                   r a t i o   =   ( w / h ) ;  
                                                                                 p i x [ i ] . w i d t h = w G o c ;  
                                                                                 p i x [ i ] . h e i g h t = w G o c / r a t i o ;  
                                                                         }  
  
                                                 }                  
                         }  
           }  
               t i m e r u n a g a i n f i x L   =   s e t T i m e o u t ( ' f i x i m a g e s L o n g ( ) ' , 2 0 0 0 ) ;  
               i f ( t i m e r u n a g a i n f i x L   ! = n u l l )  
               {  
                   s e t T i m e o u t ( ' c l e a r T i m e o u t ( t i m e r u n a g a i n f i x L ) ; t i m e r u n a g a i n f i x L   =   n u l l ' , 5 0 0 0 ) ;  
               }  
                
 }  
 / /   e n d   f i x i m a g e  
  
 / / H a m   c h u y e n   d o i   n g o n   n g u  
 f u n c t i o n   c o n v e r t _ l a n g u a g e s ( s t r )  
 {  
   	       v a r   Q S t r i n g =   u n e s c a p e ( l o c a t i o n . s e a r c h ) ;  
 	       v a r   v i t r i = Q S t r i n g . i n d e x O f ( " l a n g " )  
 	         i f   ( v i t r i ! = - 1 )   Q S t r i n g = Q S t r i n g . s u b s t r i n g ( 0 , v i t r i - 1 ) ;  
 	   	 i f   ( Q S t r i n g ! = ' ' )   Q S t r i n g + = ' & ' ;  
 	   	 e l s e   Q S t r i n g = ' ? ' + Q S t r i n g ;  
   	       l o c a t i o n . h r e f = Q S t r i n g + ' l a n g = ' + s t r ;  
 }  
   	    
   / / H a m   m o   f u l l   w i n d o w   m o i 	  
 f u n c t i o n   o p e n _ f u l l n e w w i n d o w ( u r l , w i d t h , h e i g h t )  
 {  
                 v a r   t o p , l e f t , w i d t h W , h e i g h t W ;  
                 w i d t h W   =   w i d t h ;  
                 h e i g h t W   =   h e i g h t ;  
                 i f ( w i d t h W   > =   w i n d o w . s c r e e n . a v a i l W i d t h )  
                 {  
                         w i d t h W = ( w i n d o w . s c r e e n . a v a i l W i d t h - 8 ) ;                        
                         l e f t   =   0 ;  
 	 	 }  
 	 	 e l s e  
 	 	 {  
 	 	       l e f t   =   w i n d o w . s c r e e n . a v a i l W i d t h   -   w i d t h W   -   M a t h . r o u n d ( ( ( w i n d o w . s c r e e n . a v a i l W i d t h   -   w i d t h W ) / 2 ) ) ;    
 	 	 }  
 	 	 i f ( h e i g h t W   > =   w i n d o w . s c r e e n . a v a i l H e i g h t )  
                 {  
 	 	         h e i g h t W   = ( w i n d o w . s c r e e n . a v a i l H e i g h t - 1 0 6 ) ;  
 	 	         t o p   =   0 ;  
                 }  
 	 	 e l s e  
 	 	 {  
 	 	       t o p   =   w i n d o w . s c r e e n . a v a i l H e i g h t   -   h e i g h t W   -   M a t h . r o u n d ( ( ( w i n d o w . s c r e e n . a v a i l H e i g h t   -   h e i g h t W ) / 2 ) ) ;  
 	 	 } 	 	 	  
 	 	 v a r   w i n D e f   =   ' s t a t u s = y e s , r e s i z a b l e = y e s , s c r o l l b a r s = y e s , t o o l b a r = y e s , l o c a t i o n = y e s , m e n u b a r = y e s , d i r e c t o r i e s = n o , t i t l e b a r = y e s , t o p = ' + t o p + ' , l e f t = ' + l e f t + ' , h e i g h t = '   + h e i g h t W + '   , w i d t h = ' + w i d t h W ; 	 	  
 	 	 v a r   n e w w i n   = w i n d o w . o p e n ( u r l ,   ' _ b l a n k ' ,   w i n D e f ) ;  
 }  
 / /   h a m   m o   w i n d o w   g i o i   h a n  
 f u n c t i o n   o p e n _ m i s s i n g n e w w i n d o w ( u r l , w i d t h , h e i g h t )  
 {  
                 v a r   t o p , l e f t , w i d t h W , h e i g h t W ;  
                 w i d t h W   =   w i d t h ;  
                 h e i g h t W   =   h e i g h t ;  
                 i f ( w i d t h W   > =   w i n d o w . s c r e e n . a v a i l W i d t h )  
                 {  
                         w i d t h W = ( w i n d o w . s c r e e n . a v a i l W i d t h - 8 ) ;                        
                         l e f t   =   0 ;  
 	 	 }  
 	 	 e l s e  
 	 	 {  
 	 	       l e f t   =   w i n d o w . s c r e e n . a v a i l W i d t h   -   w i d t h W   -   M a t h . r o u n d ( ( ( w i n d o w . s c r e e n . a v a i l W i d t h   -   w i d t h W ) / 2 ) ) ;    
 	 	 }  
 	 	 i f ( h e i g h t W   > =   w i n d o w . s c r e e n . a v a i l H e i g h t )  
                 {  
 	 	         h e i g h t W   = ( w i n d o w . s c r e e n . a v a i l H e i g h t - 1 0 6 ) ;  
 	 	         t o p   =   0 ;  
                 }  
 	 	 e l s e  
 	 	 {  
 	 	       t o p   =   w i n d o w . s c r e e n . a v a i l H e i g h t   -   h e i g h t W   -   M a t h . r o u n d ( ( ( w i n d o w . s c r e e n . a v a i l H e i g h t   -   h e i g h t W ) / 2 ) ) ;  
 	 	 } 	 	 	  
 	 	 v a r   w i n D e f   =   ' s t a t u s = n o , r e s i z a b l e = n o , s c r o l l b a r s = n o , t o o l b a r = n o , l o c a t i o n = n o , m e n u b a r = n o , d i r e c t o r i e s = n o , t i t l e b a r = n o , t o p = ' + t o p + ' , l e f t = ' + l e f t + ' , h e i g h t = '   + h e i g h t W + '   , w i d t h = ' + w i d t h W ; 	 	  
 	 	 v a r   n e w w i n   = w i n d o w . o p e n ( u r l ,   ' _ b l a n k ' ,   w i n D e f ) ;  
 }  
 / /   f o r   p a g i n g _ n e w  
 f u n c t i o n   i d p a g e L o n g ( k e y s t r , v a l u e s t r )  
 {  
   	 v a r   Q S t r i n g   =   u n e s c a p e ( l o c a t i o n . s e a r c h ) ; 	  
 	 v a r   Q S t r i n g 1   =   Q S t r i n g . s u b s t r i n g ( 1 , Q S t r i n g . l e n g t h ) ; 	  
         v a r   m a n g t h a m s o   =   n e w   A r r a y ( ) ;  
 	 v a r   c h u o i d a b i e n d o i   =   ' ? '   ;  
 	 v a r   i   =   0 ;  
       i f (   Q S t r i n g 1   = =   ' '   )  
         {  
 	         c h u o i d a b i e n d o i   + =   k e y s t r   + ' = ' +   v a l u e s t r   ;  
         }  
         e l s e  
         {  
 	     m a n g t h a m s o   =   Q S t r i n g 1 . s p l i t (   ' & '   ) ; 	    
 	     v a r   v i t r i p h a n t u   =   - 1   ;  
 	 	 f o r (   i   =   0 ;   i   <   m a n g t h a m s o . l e n g t h ;   i + + )  
 	 	 {  
 	 	 	 i f ( v i t r i p h a n t u   = =   - 1 )  
 	 	 	 {  
 	 	 	 	 v i t r i p h a n t u   =   m a n g t h a m s o [ i ] . s u b s t r i n g (   0 , ( k e y s t r . l e n g t h ) ) . i n d e x O f ( k e y s t r ) ;  
 	 	 	 }  
 	 	 	 i f ( m a n g t h a m s o [ i ] . s u b s t r i n g (   0 , ( k e y s t r . l e n g t h )   )   = =   k e y s t r )  
 	 	 	 {  
 	 	 	 	 m a n g t h a m s o [ i ]   =     k e y s t r   +   ' = '   +   v a l u e s t r   ; 	 	 	  
 	 	 	 } 	 	 	  
 	 	 	 i f   ( i   = =   0   )  
 	 	 	 {  
 	 	 	 	 c h u o i d a b i e n d o i   + =   m a n g t h a m s o [ i ] ;  
 	 	 	 }  
 	 	 	 e l s e  
 	 	 	 {  
 	 	 	 	 c h u o i d a b i e n d o i     + = ' & ' +   m a n g t h a m s o [ i ]     ;  
 	 	 	 }  
 	 	 } 	 	  
 	 	 i f (   v i t r i p h a n t u   = =   - 1 )  
 	 	 {  
 	 	 	 c h u o i d a b i e n d o i     + = ' & '   + k e y s t r   +   ' = '   +   v a l u e s t r   ;  
 	 	 }  
         } 	      
   	       l o c a t i o n . h r e f   =   c h u o i d a b i e n d o i ;  
   }  
 / / l a y   t h o i   g i a n   h i e n   t a i  
 f u n c t i o n   g e t c u r r e n t d a t e l o n g ( e n _ o r _ v n , c o n t a i n e r i d , l o n g _ o r _ s o r t _ o n l y n u m b e r )  
 {  
   v a r   n e w d a t e   =   n e w   D a t e ( ) ;  
   v a r   w e e k d a y s   =   n e w d a t e . g e t D a y ( ) ;    
   v a r   m o n t h d a y s   =   n e w d a t e . g e t D a t e ( ) ;  
   v a r   m o n t h   =   n e w d a t e . g e t M o n t h ( ) ;  
   v a r   y e a r   =   n e w d a t e . g e t F u l l Y e a r ( ) ;  
   v a r   n a m e m o n t h ;  
   v a r   n a m e w e e k d a y ;  
   v a r   c o n t a i n e r   =   d o c u m e n t . g e t E l e m e n t B y I d ( c o n t a i n e r i d ) ;  
                 i f ( e n _ o r _ v n   = =   ' e n ' )  
                 {  
                         i f ( m o n t h   = =   0 ) { n a m e m o n t h   =   " J a n u a r y " }  
                         i f ( m o n t h   = =   1 ) { n a m e m o n t h   =   " F e b r u a r y " }  
                         i f ( m o n t h   = =   2 ) { n a m e m o n t h   =   " M a r c h " }  
                         i f ( m o n t h   = =   3 ) { n a m e m o n t h   =   " A p r i l " }  
                         i f ( m o n t h   = =   4 ) { n a m e m o n t h   =   " M a y " }  
                         i f ( m o n t h   = =   5 ) { n a m e m o n t h   =   " J u n e " }  
                         i f ( m o n t h   = =   6 ) { n a m e m o n t h   =   " J u l y " }  
                         i f ( m o n t h   = =   7 ) { n a m e m o n t h   =   " A u g u s t " }  
                         i f ( m o n t h   = =   8 ) { n a m e m o n t h   =   " S e p t e m b e r " }  
                         i f ( m o n t h   = =   9 ) { n a m e m o n t h   =   " O c t o b e r " }  
                         i f ( m o n t h   = =   1 0 ) { n a m e m o n t h   =   " N o v e m b e r " }  
                         i f ( m o n t h   = =   1 1 ) { n a m e m o n t h   =   " D e c e m b e r " }  
                          
                         i f ( w e e k d a y s   = =   0 ) { n a m e w e e k d a y   =   " S u n d a y " }      
                         i f ( w e e k d a y s   = =   1 ) { n a m e w e e k d a y   =   " M o n d a y " }    
                         i f ( w e e k d a y s   = =   2 ) { n a m e w e e k d a y   =   " T u e s d a y " }    
                         i f ( w e e k d a y s   = =   3 ) { n a m e w e e k d a y   =   " W e d n e s d a y " }    
                         i f ( w e e k d a y s   = =   4 ) { n a m e w e e k d a y   =   " T h u r s d a y " }    
                         i f ( w e e k d a y s   = =   5 ) { n a m e w e e k d a y   =   " F r i d a y " }    
                         i f ( w e e k d a y s   = =   6 ) { n a m e w e e k d a y   =   " S a t u r d a y " }              
                         i f ( l o n g _ o r _ s o r t _ o n l y n u m b e r   = =   ' l o n g ' )  
                                 {  
                                         c o n t a i n e r . i n n e r H T M L   =   n a m e w e e k d a y + ' ,   ' + n a m e m o n t h + '   ' + m o n t h d a y s + ' ,   ' + y e a r ;  
                                 }  
                         i f ( l o n g _ o r _ s o r t _ o n l y n u m b e r   = =   ' o n l y n u m b e r ' )  
                                 {  
                                         c o n t a i n e r . i n n e r H T M L   =   ( m o n t h + 1 ) + ' / ' + m o n t h d a y s + ' / ' + y e a r ;  
                                 }  
                         e l s e  
                                 {  
                                         c o n t a i n e r . i n n e r H T M L   =   n a m e m o n t h + '   ' + m o n t h d a y s + ' ,   ' + y e a r ;                                      
                                 }  
                 }  
                   e l s e  
                 {  
                                                                                  
                                         i f ( w e e k d a y s   = =   0 ) { n a m e w e e k d a y   =   " C h ç  n h ­t " }      
                                         i f ( w e e k d a y s   = =   1 ) { n a m e w e e k d a y   =   " T h é  h a i " }    
                                         i f ( w e e k d a y s   = =   2 ) { n a m e w e e k d a y   =   " T h é  b a " }    
                                         i f ( w e e k d a y s   = =   3 ) { n a m e w e e k d a y   =   " T h é  t °" }    
                                         i f ( w e e k d a y s   = =   4 ) { n a m e w e e k d a y   =   " T h é  n m " }    
                                         i f ( w e e k d a y s   = =   5 ) { n a m e w e e k d a y   =   " T h é  s á u " }    
                                         i f ( w e e k d a y s   = =   6 ) { n a m e w e e k d a y   =   " T h é  b £y " }              
                                         i f ( l o n g _ o r _ s o r t _ o n l y n u m b e r   = =   ' l o n g ' )  
                                         {  
                                                         c o n t a i n e r . i n n e r H T M L   =   n a m e w e e k d a y + ' ,   n g à y   ' + m o n t h d a y s + '   t h á n g   ' + ( m o n t h + 1 ) + '   n m   ' + y e a r ;  
                                         }  
                                         i f ( l o n g _ o r _ s o r t _ o n l y n u m b e r   = =   ' o n l y n u m b e r ' )  
                                         {  
                                                         c o n t a i n e r . i n n e r H T M L   =   m o n t h d a y s + ' / ' + ( m o n t h + 1 ) + ' / ' + y e a r ;  
                                         }  
                                         e l s e  
                                         {  
                                                         c o n t a i n e r . i n n e r H T M L   =   ' N g à y   ' + m o n t h d a y s + '   t h á n g   ' + ( m o n t h + 1 ) + '   n m   ' + y e a r ;  
                                         }  
                 }  
  
 }  
  
 
