ÿþf u n c t i o n   c h e c k J S ( )   {  
         a l e r t ( " s d f " ) ;  
 }  
 / / t h i s   f u n c t i o n   w i l l   s a v e   v a l u e   i n   c o o k i e   i f   y o u   c l i c k   t h e   t a b  
 f u n c t i o n   l o a d T a b ( ) {  
 	 i f ( g e t C o o k i e ( ' T a b ' ) = = " " ) / / t h i s   c a s e   b e g i n   l o a d   p a g e  
 	 	 c h a n g e T a b ( 1 , 4 ) ;  
 	 e l s e  
 	 	 c h a n g e T a b ( g e t C o o k i e ( ' T a b ' ) , 4 ) ;  
 }  
 f u n c t i o n   g e t _ r a n d o m ( r a n k )   {  
         v a r   r a n N u m   =   M a t h . f l o o r ( M a t h . r a n d o m ( )   *   r a n k ) ;  
         r e t u r n   r a n N u m ;  
 }  
  
  
 w i n d o w . o n l o a d   = l o a d T a b ;  
 f u n c t i o n   c h a n g e T a b ( n , t )   {  
 	 	 f o r   ( v a r   i   = 1 ;   i   < =   t ;   i   + + )   {  
 	 	 	 i f   ( i   = =   n )   {  
 	 	 	 	 i f ( d o c u m e n t . g e t E l e m e n t B y I d ( ' t a b ' + i ) ! = n u l l ) / / t h i s   c a s e   i s   o r t h e r   t h e   p a g e  
 	 	 	 	 { d o c u m e n t . g e t E l e m e n t B y I d ( ' t a b ' + i ) . c l a s s N a m e   =   ' c u r r e n t ' ;  
 	 	 	 	 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 e n t d s _ ' + i ) . s t y l e . d i s p l a y   =   ' b l o c k ' ;  
 	 	 	 	 s e t C o o k i e ( ' T a b ' , i ) ;  
 	 	 	 	 }  
 	 	 	 }   e l s e   {  
 	 	 	 	 i f ( d o c u m e n t . g e t E l e m e n t B y I d ( ' t a b ' + i ) ! = n u l l )  
 	 	 	 	 {  
 	 	 	 	 d o c u m e n t . g e t E l e m e n t B y I d ( ' t a b ' + i ) . c l a s s N a m e   =   ' ' ; 	  
 	 	 	 	 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 e n t d s _ ' + i ) . s t y l e . d i s p l a y   =   ' n o n e ' ;  
 	 	 	 	 }  
 	 	 	 } 	 	 	  
 	 	 }  
 	 	 / / r e t u r n   f a l s e ;  
 }  
 f u n c t i o n   c h a n g e T a b 2 ( n ,   t )   {  
         f o r   ( v a r   i   =   1 ;   i   < =   t ;   i + + )   {  
                 i f   ( i   = =   n )   {  
                         i f   ( d o c u m e n t . g e t E l e m e n t B y I d ( ' t a b 2 '   +   i )   ! =   n u l l ) / / t h i s   c a s e   i s   o r t h e r   t h e   p a g e  
                         {  
                                 d o c u m e n t . g e t E l e m e n t B y I d ( ' t a b 2 '   +   i ) . c l a s s N a m e   =   ' c u r r e n t ' ;  
                                 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 e n t d s 2 _ '   +   i ) . s t y l e . d i s p l a y   =   ' b l o c k ' ;  
                                 s e t C o o k i e ( ' T a b ' ,   i ) ;  
                         }  
                 }   e l s e   {  
                         i f   ( d o c u m e n t . g e t E l e m e n t B y I d ( ' t a b 2 '   +   i )   ! =   n u l l )   {  
                                 d o c u m e n t . g e t E l e m e n t B y I d ( ' t a b 2 '   +   i ) . c l a s s N a m e   =   ' ' ;  
                                 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 e n t d s 2 _ '   +   i ) . s t y l e . d i s p l a y   =   ' n o n e ' ;  
                         }  
                 }  
         }  
         / / r e t u r n   f a l s e ; 	 	  
 }  
 f u n c t i o n   g e t C o o k i e ( N a m e ) {    
 v a r   r e = n e w   R e g E x p ( N a m e + " = [ ^ ; ] + " ,   " i " ) ;   / / c o n s t r u c t   R E   t o   s e a r c h   f o r   t a r g e t   n a m e / v a l u e   p a i r  
 i f   ( d o c u m e n t . c o o k i e . m a t c h ( r e ) )   / / i f   c o o k i e   f o u n d  
 r e t u r n   d o c u m e n t . c o o k i e . m a t c h ( r e ) [ 0 ] . s p l i t ( " = " ) [ 1 ]   / / r e t u r n   i t s   v a l u e  
 r e t u r n   " "  
 }  
  
 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 ) {  
 d o c u m e n t . c o o k i e   =   n a m e + " = " + v a l u e   / / c o o k i e   v a l u e   i s   d o m a i n   w i d e   ( p a t h = / )  
 } 	  
 f u n c t i o n   e r r o r H a n d l e r ( m s g , u r l , l i n e ) {  
   s t r E r r   =   " I N T E R N A L   E R R O R   : "  
   s t r E r r   + =   " \ n "   +   m s g  
   s t r E r r   + =   " \ n   I N   L I N E = "   +   l i n e   +   " . " ;  
     a l e r t ( s t r E r r ) ;  
 r e t u r n   t r u e ;    
 }  
 w i n d o w . o n e r r o r   =   e r r o r H a n d l e r ;  
  
 v a r   l o a d e d   =   n e w   A r r a y ( ) ;  
  
 f u n c t i o n   F _ l o a d R o l l o v e r ( i m a g e , i m a g e N a m e )   { 	  
       i f   ( i m a g e   & &   i m a g e . s r c   & &  
         ( n u l l   = =   i m a g e . o u t   | |   t y p e o f ( i m a g e . o u t )   = =   t y p e o f ( v o i d ( 0 ) ) ) )   {  
             s   =   i m a g e . s r c ;  
             i m a g e . o u t   =   n e w   I m a g e ( ) ;  
             i m a g e . o u t . s r c   =   s ;  
             i m a g e . o v e r   =   n e w   I m a g e ( ) ;  
             i f   ( i m a g e N a m e . l a s t I n d e x O f ( ' / ' )   > =   0   | |   i m a g e N a m e . l a s t I n d e x O f ( ' \ \ ' )   > = 0 )   {  
                   s   =   i m a g e N a m e ;  
             }   e l s e   {  
                   i   =   s . l a s t I n d e x O f ( ' / ' ) ;  
                   i f   ( i < 0 )   i   =   s . l a s t I n d e x O f ( ' \ \ ' ) ;  
                   i f   ( i < 0 )   {   s   =   i m a g e N a m e ;   }  
                   e l s e           {   s   =   s . s u b s t r i n g ( 0 , i + 1 )   +   i m a g e N a m e ;   }  
             }  
             i m a g e . o v e r . s r c   =   s ;  
             l o a d e d [ i m a g e . n a m e ]   =   i m a g e ;  
       }  
 }  
  
 f u n c t i o n   F _ r o l l ( i m a g e N a m e ,   o v e r )   {  
 	 v a r   i n d e x ,   t m p I t e m ;  
 	  
 	  
 	 i f   ( d o c u m e n t . i m a g e s )   {  
 	 	 i f   ( o v e r )   {    
 	 	 	 i m a g e O b j e c t   =   " o v e r " ;    
 	 	 	  
 	 	 	 i f   ( i m a g e N a m e . i n d e x O f ( ' p r o d ' )   ! =   - 1 ) {  
 	 	 	 	 f o r ( i n d e x = 0 ;   i n d e x < p r o d u c t A r r a y . l e n g t h ;   i n d e x + + ) {  
 	 	 	 	 	 t m p I t e m = p r o d u c t A r r a y [ i n d e x ] ;  
 	 	 	 	 	  
 	 	 	 	 	 i f   ( t m p I t e m . g e t P r o d I D ( )   = =   i m a g e N a m e   & &   t m p I t e m . g e t I s O v e r ( )   = =   1 ) {  
 	 	 	 	 	 	 d o c u m e n t . i m a g e s [ " p r o d I m g " ] . s r c   =   t m p I t e m . g e t O v e r I m a g e ( ) ;  
 	 	 	 	 	 	 b r e a k ;  
 	 	 	 	 	 }  
 	 	 	 	 }  
 	 	 	 }  
 	 	 }  
 	 	 e l s e   {   i m a g e O b j e c t   =   " o u t " ;   }  
       i m a g e   =   l o a d e d [ i m a g e N a m e ] ;  
       i f   ( i m a g e )   {  
               r e f   =   e v a l ( " i m a g e . " + i m a g e O b j e c t ) ;  
               i f   ( r e f )   i m a g e . s r c   =   e v a l ( " i m a g e . " + i m a g e O b j e c t + " . s r c " ) ;  
       }  
       i f   ( w i n d o w . e v e n t )  
             w i n d o w . e v e n t . c a n c e l B u b b l e   =   t r u e ;  
       }  
 }  
  
 f u n c t i o n   c h e c k D a t e ( t m p D a t e ) {  
 	 v a r   t m p   =   t m p D a t e ;  
 	  
 	 w h e r e = t m p . i n d e x O f ( " / " )  
 	 m o n t h   =   t m p . s u b s t r i n g ( 0 ,   w h e r e ) ;  
 	 y e a r   =   t m p . s u b s t r i n g ( w h e r e   +   1 , t m p . l e n g t h ) ;  
 	  
 	 i f ( ( w h e r e < 0 ) | | ( w h e r e ! = 2 ) | | ( m o n t h . l e n g t h > 2 ) | | ( p a r s e I n t ( m o n t h ) > 1 2 ) | | ( p a r s e I n t ( m o n t h ) < 1 ) | | ( y e a r . l e n g t h ! = 2   & &   y e a r . l e n g t h ! = 4 ) )  
 	 	 r e t u r n   f a l s e ;  
 	 e l s e  
 	 	 r e t u r n   t r u e ;  
 }  
  
 f u n c t i o n   c h e c k E m a i l ( s t r ) {  
 	 i f   ( s t r . i n d e x O f ( " @ " ) = = - 1   | |   s t r . c h a r A t ( 0 ) = = " @ "   | |   s t r . i n d e x O f ( " . " ) = = - 1   | |   s t r . c h a r A t ( 0 ) = = " . "   | |   s t r . c h a r A t ( s t r . i n d e x O f ( " @ " ) + 1 ) = = " . "   )  
 	 	 r e t u r n   0 ;  
 	 e l s e  
 	 	 r e t u r n   1 ; 	 	  
 }  
  
 f u n c t i o n   e m a i l C h e c k   ( e m a i l S t r )   {  
 	 v a r   e m a i l P a t = / ^ ( . + ) @ ( . + ) $ / ;  
 	 v a r   s p e c i a l C h a r s = " \ \ ( \ \ ) < > @ , ; : \ \ \ \ \ \ \ " \ \ . \ \ [ \ \ ] " ;  
 	 v a r   v a l i d C h a r s = " \ [ ^ \ \ s "   +   s p e c i a l C h a r s   +   " \ ] " ;  
 	 v a r   q u o t e d U s e r = " ( \ " [ ^ \ " ] * \ " ) " ;  
 	 v a r   i p D o m a i n P a t = / ^ \ [ ( \ d { 1 , 3 } ) \ . ( \ d { 1 , 3 } ) \ . ( \ d { 1 , 3 } ) \ . ( \ d { 1 , 3 } ) \ ] $ / ;  
 	 v a r   a t o m = v a l i d C h a r s   +   ' + ' ;  
 	 v a r   w o r d = " ( "   +   a t o m   +   " | "   +   q u o t e d U s e r   +   " ) " ;  
 	 v a r   u s e r P a t = n e w   R e g E x p ( " ^ "   +   w o r d   +   " ( \ \ . "   +   w o r d   +   " ) * $ " ) ;  
 	 v a r   d o m a i n P a t = n e w   R e g E x p ( " ^ "   +   a t o m   +   " ( \ \ . "   +   a t o m   + " ) * $ " ) ;  
 	 v a r   m a t c h A r r a y = e m a i l S t r . m a t c h ( e m a i l P a t ) ;  
 	  
 	 i f   ( m a t c h A r r a y = = n u l l )   {  
 	 	 r e t u r n   f a l s e ;  
 	 }  
 	  
 	 v a r   u s e r = m a t c h A r r a y [ 1 ] ;  
 	 v a r   d o m a i n = m a t c h A r r a y [ 2 ] ;  
  
 	 i f   ( u s e r . m a t c h ( u s e r P a t ) = = n u l l )   {  
 	 	 r e t u r n   f a l s e ;  
 	 }  
  
 	 v a r   I P A r r a y = d o m a i n . m a t c h ( i p D o m a i n P a t ) ;  
 	  
 	 i f   ( I P A r r a y ! = n u l l )   {  
 	 	 f o r   ( v a r   i = 1 ; i < = 4 ; i + + )   {  
 	 	         i f   ( I P A r r a y [ i ] > 2 5 5 )   {  
 	 	 	 	 r e t u r n   f a l s e ;  
 	 	 	 }  
 	 	 }  
 	 	 r e t u r n   t r u e ;  
 	 }  
  
 	 v a r   d o m a i n A r r a y = d o m a i n . m a t c h ( d o m a i n P a t ) ;  
 	 i f   ( d o m a i n A r r a y = = n u l l )   {  
 	         r e t u r n   f a l s e ;  
 	 }  
  
 	 v a r   a t o m P a t = n e w   R e g E x p ( a t o m , " g " ) ;  
 	 v a r   d o m A r r = d o m a i n . m a t c h ( a t o m P a t ) ;  
 	 v a r   l e n = d o m A r r . l e n g t h ;  
 	 i f   ( d o m A r r [ d o m A r r . l e n g t h - 1 ] . l e n g t h < 2   | |    
 	 	 d o m A r r [ d o m A r r . l e n g t h - 1 ] . l e n g t h > 3 )   {  
 	 	 r e t u r n   f a l s e ;  
 	 }  
  
 	 i f   ( l e n < 2 )   {  
 	 	 v a r   e r r S t r = " T h i s   a d d r e s s   i s   m i s s i n g   a   h o s t n a m e ! " ;  
 	 	 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   I s N u m e r i c ( c h ) {  
  
 	 i f   ( c h = = " 0 " | | c h = = " 1 " | | c h = = " 2 " | | c h = = " 3 " | | c h = = " 4 " | | c h = = " 5 " | | c h = = " 6 " | | c h = = " 7 " | | c h = = " 8 " | | c h = = " 9 " )  
 	 	 r e t u r n   1 ;  
 	 e l s e  
 	 	 r e t u r n   0 ;  
 }  
  
 f u n c t i o n   I s N u m b e r ( s t r ) {  
 	 v a r   i ,   c h ;  
 	  
 	 f o r   ( i = 0 ;   i < s t r . l e n g t h ;   i + + ) {  
 	  
 	 	 c h   =   s t r . s u b s t r i n g ( i , i + 1 ) ;  
 	 	 i f   ( ! I s N u m e r i c ( c h ) ) {  
 	 	 	 r e t u r n   0 ;  
 	 	 } 	  
 	 }  
 	 r e t u r n   1 ;  
 }  
  
 f u n c t i o n   I s N u m e r i c 1 ( c h ) {  
  
 	 i f   ( c h = = " 0 " | | c h = = " 1 " | | c h = = " 2 " | | c h = = " 3 " | | c h = = " 4 " | | c h = = " 5 " | | c h = = " 6 " | | c h = = " 7 " | | c h = = " 8 " | | c h = = " 9 " | | c h = = " . " | | c h = = " , " )  
 	 	 r e t u r n   1 ;  
 	 e l s e  
 	 	 r e t u r n   0 ;  
 }  
  
 f u n c t i o n   I s F l o a t ( s t r ) {  
 	 v a r   i ,   c h ;  
 	  
 	 f o r   ( i = 0 ;   i < s t r . l e n g t h ;   i + + ) {  
 	  
 	 	 c h   =   s t r . s u b s t r i n g ( i , i + 1 ) ;  
 	 	 i f   ( ! I s N u m e r i c 1 ( c h ) ) {  
 	 	 	 r e t u r n   0 ;  
 	 	 } 	  
 	 }  
 	 r e t u r n   1 ;  
 }  
 f u n c t i o n   i s I n t e g e r ( S )   {  
         v a r   L   =   S . l e n g t h ;  
         i f   ( S   = =   0 )   {  
                 a l e r t ( " V u i   l ò n g   n h ­p   s Ñ  l °ãn g   c h o   s £n   p h ©m ! " ) ;   / / b a t   b u o c   p h a i   n h a n   v a o    
                 r e t u r n   f a l s e ;  
         }  
         f o r   ( v a r   i   =   0 ;   i   <   L ;   + + i )  
                 i f   ( S . c h a r A t ( i )   <   ' 0 '   | |   S . c h a r A t ( i )   >   ' 9 ' )   {  
                 a l e r t ( " S Ñ  l °¡n g   b u Ùc   p h £i   l à   s Ñ  n g u y ê n   k h ô n g   â m   v à   l Ûn   h ¡n   k h ô n g ! " ) ;   / / o   n a y   b a t   b u o c   p h a i   n h a p   v o i   m o t   c o n   s o   n g u y e n  
                 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   p o p u p ( u r l ,   e x t _ u r l ,   w ,   h ,   s c r o l l a b l e ) {  
 	 v a r   p o p u p ,   l e f t ,   t o p ,   s e t t i n g ;  
 	 l e f t = s c r e e n . w i d t h ? ( s c r e e n . w i d t h - w ) / 2 : 0 ;  
 	 t o p = s c r e e n . w i d t h ? ( s c r e e n . h e i g h t - h ) / 2 : 0 ;  
  
 	 s e t t i n g   =   " w i d t h = "   +   w   +   " , h e i g h t = "   +   h   +   " ,   s c r o l l b a r s = "   +   s c r o l l a b l e   +   " ,   d e p e n d e n t = y e s ,   "   +   " t o p = "   +   t o p   +   " , l e f t = "   +   l e f t   +   " ' " ;  
 	 p o p u p   =   w i n d o w . o p e n ( " " , " t e s t " , s e t t i n g ) ;  
         p o p u p . l o c a t i o n . h r e f = u r l   +   e x t _ u r l ;  
 / / 	 i f   ( p o p u p . o p e n e r   = =   n u l l )   {    
 / /       	 	 p o p u p . o p e n e r   =   s e l f ;    
 / / 	 }  
 	  
 }  
 f u n c t i o n   c h e c k V a l i d D a t e ( d a t e S t r )   {  
         / /   d a t e S t r   m u s t   b e   o f   f o r m a t   m o n t h   d a y   y e a r   w i t h   e i t h e r   s l a s h e s  
         / /   o r   d a s h e s   s e p a r a t i n g   t h e   p a r t s .   S o m e   m i n o r   c h a n g e s   w o u l d   h a v e  
         / /   t o   b e   m a d e   t o   u s e   d a y   m o n t h   y e a r   o r   a n o t h e r   f o r m a t .  
         / /   T h i s   f u n c t i o n   r e t u r n s   T r u e   i f   t h e   d a t e   i s   v a l i d .  
         v a r   s l a s h 1   =   d a t e S t r . i n d e x O f ( " / " ) ;  
         i f   ( s l a s h 1   = =   - 1 )   {   s l a s h 1   =   d a t e S t r . i n d e x O f ( " - " ) ;   }  
         / /   i f   n o   s l a s h e s   o r   d a s h e s ,   i n v a l i d   d a t e  
         i f   ( s l a s h 1   = =   - 1 )   {   r e t u r n   f a l s e ;   }  
         v a r   d a t e M o n t h   =   d a t e S t r . s u b s t r i n g ( 0 ,   s l a s h 1 )  
         v a r   d a t e M o n t h A n d Y e a r   =   d a t e S t r . s u b s t r i n g ( s l a s h 1 + 1 ,   d a t e S t r . l e n g t h ) ;  
         v a r   s l a s h 2   =   d a t e M o n t h A n d Y e a r . i n d e x O f ( " / " ) ;  
         i f   ( s l a s h 2   = =   - 1 )   {   s l a s h 2   =   d a t e M o n t h A n d Y e a r . i n d e x O f ( " - " ) ;   }  
         / /   i f   n o t   a   s e c o n d   s l a s h   o r   d a s h ,   i n v a l i d   d a t e  
         i f   ( s l a s h 2   = =   - 1 )   {   r e t u r n   f a l s e ;   }  
         v a r   d a t e D a y   =   d a t e M o n t h A n d Y e a r . s u b s t r i n g ( 0 ,   s l a s h 2 ) ;  
         v a r   d a t e Y e a r   =   d a t e M o n t h A n d Y e a r . s u b s t r i n g ( s l a s h 2 + 1 ,   d a t e M o n t h A n d Y e a r . l e n g t h ) ;  
         i f   (   ( d a t e M o n t h   = =   " " )   | |   ( d a t e D a y   = =   " " )   | |   ( d a t e Y e a r   = =   " " )   )   {   r e t u r n   f a l s e ;   }  
         / /   i f   a n y   n o n - d i g i t s   i n   t h e   m o n t h ,   i n v a l i d   d a t e  
         f o r   ( v a r   x = 0 ;   x   <   d a t e M o n t h . l e n g t h ;   x + + )   {  
                 v a r   d i g i t   =   d a t e M o n t h . s u b s t r i n g ( x ,   x + 1 ) ;  
                 i f   ( ( d i g i t   <   " 0 " )   | |   ( d i g i t   >   " 9 " ) )   {   r e t u r n   f a l s e ;   }  
         }  
         / /   c o n v e r t   t h e   t e x t   m o n t h   t o   a   n u m b e r  
         v a r   n u m M o n t h   =   0 ;  
         f o r   ( v a r   x = 0 ;   x   <   d a t e M o n t h . l e n g t h ;   x + + )   {  
                 d i g i t   =   d a t e M o n t h . s u b s t r i n g ( x ,   x + 1 ) ;  
                 n u m M o n t h   * =   1 0 ;  
                 n u m M o n t h   + =   p a r s e I n t ( d i g i t ) ;  
         }  
         i f   ( ( n u m M o n t h   < =   0 )   | |   ( n u m M o n t h   >   1 2 ) )   {   r e t u r n   f a l s e ;   }  
         / /   i f   a n y   n o n - d i g i t s   i n   t h e   d a y ,   i n v a l i d   d a t e  
         f o r   ( v a r   x = 0 ;   x   <   d a t e D a y . l e n g t h ;   x + + )   {  
                 d i g i t   =   d a t e D a y . s u b s t r i n g ( x ,   x + 1 ) ;  
                 i f   ( ( d i g i t   <   " 0 " )   | |   ( d i g i t   >   " 9 " ) )   {   r e t u r n   f a l s e ;   }  
         }  
         / /   c o n v e r t   t h e   t e x t   d a y   t o   a   n u m b e r  
         v a r   n u m D a y   =   0 ;  
         f o r   ( v a r   x = 0 ;   x   <   d a t e D a y . l e n g t h ;   x + + )   {  
                 d i g i t   =   d a t e D a y . s u b s t r i n g ( x ,   x + 1 ) ;  
                 n u m D a y   * =   1 0 ;  
                 n u m D a y   + =   p a r s e I n t ( d i g i t ) ;  
         }  
         i f   ( ( n u m D a y   < =   0 )   | |   ( n u m D a y   >   3 1 ) )   {   r e t u r n   f a l s e ;   }  
         / /   F e b r u a r y   c a n ' t   b e   g r e a t e r   t h a n   2 9   ( l e a p   y e a r   c a l c u l a t i o n   c o m e s   l a t e r )  
         i f   ( ( n u m M o n t h   = =   2 )   & &   ( n u m D a y   >   2 9 ) )   {   r e t u r n   f a l s e ;   }  
         / /   c h e c k   f o r   m o n t h s   w i t h   o n l y   3 0   d a y s  
         i f   ( ( n u m M o n t h   = =   4 )   | |   ( n u m M o n t h   = =   6 )   | |   ( n u m M o n t h   = =   9 )   | |   ( n u m M o n t h   = =   1 1 ) )   {    
                 i f   ( n u m D a y   >   3 0 )   {   r e t u r n   f a l s e ;   }    
         }  
         / /   i f   a n y   n o n - d i g i t s   i n   t h e   y e a r ,   i n v a l i d   d a t e  
         f o r   ( v a r   x = 0 ;   x   <   d a t e Y e a r . l e n g t h ;   x + + )   {  
                 d i g i t   =   d a t e Y e a r . s u b s t r i n g ( x ,   x + 1 ) ;  
                 i f   ( ( d i g i t   <   " 0 " )   | |   ( d i g i t   >   " 9 " ) )   {   r e t u r n   f a l s e ;   }  
         }  
         / /   c o n v e r t   t h e   t e x t   y e a r   t o   a   n u m b e r  
         v a r   n u m Y e a r   =   0 ;  
         f o r   ( v a r   x = 0 ;   x   <   d a t e Y e a r . l e n g t h ;   x + + )   {  
                 d i g i t   =   d a t e Y e a r . s u b s t r i n g ( x ,   x + 1 ) ;  
                 n u m Y e a r   * =   1 0 ;  
                 n u m Y e a r   + =   p a r s e I n t ( d i g i t ) ;  
         }  
         / /   Y e a r   m u s t   b e   a   2 - d i g i t   y e a r   o r   a   4 - d i g i t   y e a r  
         i f   (   ( d a t e Y e a r . l e n g t h   ! =   2 )   & &   ( d a t e Y e a r . l e n g t h   ! =   4 )   )   {   r e t u r n   f a l s e ;   }  
         / /   i f   2 - d i g i t   y e a r ,   u s e   5 0   a s   a   p i v o t   d a t e  
         i f   (   ( n u m Y e a r   <   5 0 )   & &   ( d a t e Y e a r . l e n g t h   = =   2 )   )   {   n u m Y e a r   + =   2 0 0 0 ;   }  
         i f   (   ( n u m Y e a r   <   1 0 0 )   & &   ( d a t e Y e a r . l e n g t h   = =   2 )   )   {   n u m Y e a r   + =   1 9 0 0 ;   }  
         i f   ( ( n u m Y e a r   < =   0 )   | |   ( n u m Y e a r   >   9 9 9 9 ) )   {   r e t u r n   f a l s e ;   }  
         / /   c h e c k   f o r   l e a p   y e a r   i f   t h e   m o n t h   a n d   d a y   i s   F e b   2 9  
         i f   ( ( n u m M o n t h   = =   2 )   & &   ( n u m D a y   = =   2 9 ) )   {  
                 v a r   d i v 4   =   n u m Y e a r   %   4 ;  
                 v a r   d i v 1 0 0   =   n u m Y e a r   %   1 0 0 ;  
                 v a r   d i v 4 0 0   =   n u m Y e a r   %   4 0 0 ;  
                 / /   i f   n o t   d i v i s i b l e   b y   4 ,   t h e n   n o t   a   l e a p   y e a r   s o   F e b   2 9   i s   i n v a l i d  
                 i f   ( d i v 4   ! =   0 )   {   r e t u r n   f a l s e ;   }  
                 / /   a t   t h i s   p o i n t ,   y e a r   i s   d i v i s i b l e   b y   4 .   S o   i f   y e a r   i s   d i v i s i b l e   b y  
                 / /   1 0 0   a n d   n o t   4 0 0 ,   t h e n   i t ' s   n o t   a   l e a p   y e a r   s o   F e b   2 9   i s   i n v a l i d  
                 i f   ( ( d i v 1 0 0   = =   0 )   & &   ( d i v 4 0 0   ! =   0 ) )   {   r e t u r n   f a l s e ;   }  
         }  
         / /   d a t e   i s   v a l i d  
         r e t u r n   t r u e ;  
 }  
 f u n c t i o n   G e t D a y ( s t r D a t e )  
 {  
         v a r   s l a s h = s t r D a t e . i n d e x O f ( " / " ) ;  
         v a r   d a t e D a y = s t r D a t e . s u b s t r i n g ( 0 , s l a s h ) ;  
         / /   c o n v e r t   t h e   t e x t   d a y   t o   a   n u m b e r  
         v a r   n u m D a y   =   0 ;  
         f o r   ( v a r   x = 0 ;   x   <   d a t e D a y . l e n g t h ;   x + + )   {  
                 v a r   d i g i t   =   d a t e D a y . s u b s t r i n g ( x ,   x + 1 ) ;  
                 n u m D a y   * =   1 0 ;  
                 n u m D a y   + =   p a r s e I n t ( d i g i t ) ;  
         }  
         r e t u r n   n u m D a y ;  
 }  
 f u n c t i o n   G e t M o n t h ( s t r D a t e )  
 {  
         v a r   s l a s h = s t r D a t e . i n d e x O f ( " / " ) ;  
         v a r   d a t e M o n t h A n d Y e a r   =   s t r D a t e . s u b s t r i n g ( s l a s h + 1 ,   s t r D a t e . l e n g t h ) ;  
         v a r   s l a s h 2   =   d a t e M o n t h A n d Y e a r . i n d e x O f ( " / " ) ;  
         v a r   d a t e M o n t h   =   d a t e M o n t h A n d Y e a r . s u b s t r i n g ( 0 ,   s l a s h 2 ) ;  
         v a r   n u m M o n t h   =   0 ;  
         f o r   ( v a r   x = 0 ;   x   <   d a t e M o n t h . l e n g t h ;   x + + )   {  
                 v a r   d i g i t   =   d a t e M o n t h . s u b s t r i n g ( x ,   x + 1 ) ;  
                 n u m M o n t h   * =   1 0 ;  
                 n u m M o n t h   + =   p a r s e I n t ( d i g i t ) ;  
         }  
         r e t u r n   n u m M o n t h ;  
 }  
 f u n c t i o n   G e t Y e a r ( s t r D a t e )  
 {  
         v a r   s l a s h = s t r D a t e . i n d e x O f ( " / " ) ;  
         v a r   d a t e M o n t h A n d Y e a r   =   s t r D a t e . s u b s t r i n g ( s l a s h + 1 ,   s t r D a t e . l e n g t h ) ;  
         v a r   s l a s h 2   =   d a t e M o n t h A n d Y e a r . i n d e x O f ( " / " ) ;  
         v a r   d a t e Y e a r   =   d a t e M o n t h A n d Y e a r . s u b s t r i n g ( s l a s h 2 + 1 ,   d a t e M o n t h A n d Y e a r . l e n g t h ) ;  
         v a r   n u m Y e a r   =   0 ;  
         f o r   ( v a r   x = 0 ;   x   <   d a t e Y e a r . l e n g t h ;   x + + )   {  
                 d i g i t   =   d a t e Y e a r . s u b s t r i n g ( x ,   x + 1 ) ;  
                 n u m Y e a r   * =   1 0 ;  
                 n u m Y e a r   + =   p a r s e I n t ( d i g i t ) ;  
         }  
         r e t u r n   n u m Y e a r ;  
 }  
 / /   i f ( ( G e t D a y ( s t r F r o m D a t e ) + G e t M o n t h ( s t r F r o m D a t e ) + G e t Y e a r ( s t r F r o m D a t e ) )   >   ( G e t D a y ( s t r T o D a t e )   +   G e t M o n t h ( s t r T o D a t e )   +   G e t Y e a r ( s t r T o D a t e ) ) )  
 f u n c t i o n   c l o s e A l l ( ) {  
         v a r   l s t S t a t i s t i c = d o c u m e n t . g e t E l e m e n t B y I d ( " l s t S t a t i s t i c " ) ;  
         v a r   s t r o n g   =   l s t S t a t i s t i c . g e t E l e m e n t s B y T a g N a m e ( " S T R O N G " ) ;  
         v a r   u l   =   l s t S t a t i s t i c . g e t E l e m e n t s B y T a g N a m e ( " U L " ) ;                  
         f o r ( v a r   i   = 0 ;   i < u l . l e n g t h ; i + + )    
                 u l [ i ] . s t y l e . d i s p l a y = " n o n e " ;  
           f o r ( v a r   i   = 0 ;   i < s t r o n g . l e n g t h ; i + + )    
                 s t r o n g [ i ] . s t y l e . d i s p l a y = " n o n e " ;                          
 }  
 f u n c t i o n   v i e w A l l ( o b j ) {  
         v a r   v i e w a l l   =   o b j . p a r e n t N o d e ;  
         v i e w a l l . s t y l e . d i s p l a y = " n o n e " ;  
         v a r   m o r e   =   v i e w a l l . p a r e n t N o d e . g e t E l e m e n t s B y T a g N a m e ( " U L " ) [ 1 ] ;  
         m o r e . s t y l e . d i s p l a y = " b l o c k " ;  
          
 }  
 f u n c t i o n   g e t C o o k i e ( c _ n a m e )  
 {  
         i f   ( d o c u m e n t . c o o k i e . l e n g t h > 0 )  
             {  
             c _ s t a r t = d o c u m e n t . c o o k i e . i n d e x O f ( c _ n a m e   +   " = " ) ;  
             i f   ( c _ s t a r t ! = - 1 )  
                 {    
                 c _ s t a r t = c _ s t a r t   +   c _ n a m e . l e n g t h + 1 ;    
                 c _ e n d = d o c u m e n t . c o o k i e . i n d e x O f ( " ; " , c _ s t a r t ) ;  
                 i f   ( c _ e n d = = - 1 )   c _ e n d = d o c u m e n t . c o o k i e . l e n g t h ;  
                 r e t u r n   u n e s c a p e ( d o c u m e n t . c o o k i e . s u b s t r i n g ( c _ s t a r t , c _ e n d ) ) ;  
                 }    
             }  
         r e t u r n   " " ;  
 }  
 f u n c t i o n   s e t C o o k i e ( c _ n a m e , v a l u e , e x p i r e d a y s )  
 {  
         v a r   e x d a t e = n e w   D a t e ( ) ; e x d a t e . s e t D a t e ( e x d a t e . g e t D a t e ( ) + e x p i r e d a y s ) ;  
         d o c u m e n t . c o o k i e = c _ n a m e +   " = "   + e s c a p e ( v a l u e ) +  
         ( ( e x p i r e d a y s = = n u l l )   ?   " "   :   " ; e x p i r e s = " + e x d a t e . t o G M T S t r i n g ( ) ) ;  
 }  
  
 f u n c t i o n   l o a d P a g e ( ) {  
 / /         i f ( g e t C o o k i e ( ' c u r I t e m ' ) ! = n u l l )  
 / /                 v i e w I t e m s ( g e t C o o k i e ( ' c u r I t e m ' ) ) ;  
  
 / /         v a r   s e s s i o n F i e l d   =   d o c u m e n t . g e t E l e m e n t B y I d ( " s e s s i o n F i e l d " ) ;  
 / /         v a r   s e s s i o n V a l u e   =   s e s s i o n F i e l d . v a l u e ;  
 / /         i f   ( s e s s i o n V a l u e   = =   " " )   {  
 / /           a l e r t ( " S t o r i n g   n e w   s e s s i o n   v a l u e " ) ;  
 / /           s e s s i o n F i e l d . v a l u e   =   " H e l l o   W o r l d " ;  
 / /             a l e r t ( s e s s i o n F i e l d . v a l u e ) ;  
 / /         }  
 / /         e l s e   {  
 / /           a l e r t ( " O l d   s e s s i o n   v a l u e :   "   +   s e s s i o n V a l u e ) ;  
 / /         }    
        
       }  
 f u n c t i o n   c h e c k I m a g e F i l e ( i m a g e N a m e ) {  
 	 s u b s r c   =   i m a g e N a m e . s u b s t r i n g ( i m a g e N a m e . l a s t I n d e x O f ( " . " )   +   1 ,   i m a g e N a m e . l e n g t h ) ;  
 	 s u b s r c   =   s u b s r c . t o L o w e r C a s e ( ) ;  
 	 	 	 	 	 	  
 	 i f   ( ( s u b s r c   ! =   " " )   & &   ( s u b s r c   ! =   " g i f " )   & &   ( s u b s r c   ! =   " j p g " )   & &   ( s u b s r c   ! =   " j p e g " ) )  
 	 	 r e t u r n   f a l s e ; 	 	 	  
 	 e l s e  
 	 	 r e t u r n   t r u e ;  
 }  
 f u n c t i o n   o p e n W i n d o w ( f i l e ,   w i d t h ,   h e i g h t )   {  
         j a v a s c r i p t :   w i n d o w . s h o w M o d a l D i a l o g ( f i l e ,   ' ' ,   ' d i a l o g H e i g h t : '   +   h e i g h t   +   ' p x ; d i a l o g W i d t h : '   +   w i d t h   +   ' p x ; c e n t e r : Y e s ; h e l p : N o ; s c r o l l : N o ; r e s i z a b l e : N o ; s t a t u s : N o ; c l o s e : N o ' )  
         r e t u r n   f a l s e ;  
 }  
  
  
  
 f u n c t i o n   s h o w u p ( i d _ o f _ l i n k ,   i d _ o f _ t a b ,   i d _ o f _ l i n k _ t i m e o u t ,   i d _ o f _ t a b _ t i m e o u t )   {  
         d o c u m e n t . g e t E l e m e n t B y I d ( ' s e c o n d l e v e l _ o n e ' ) . s t y l e . d i s p l a y   =   ' n o n e ' ;  
         d o c u m e n t . g e t E l e m e n t B y I d ( ' s e c o n d l e v e l _ t w o ' ) . s t y l e . d i s p l a y   =   ' n o n e ' ;  
         d o c u m e n t . g e t E l e m e n t B y I d ( ' s e c o n d l e v e l _ t h r e e ' ) . s t y l e . d i s p l a y   =   ' n o n e ' ;  
  
  
  
  
         d o c u m e n t . g e t E l e m e n t B y I d ( i d _ o f _ l i n k ) . s t y l e . d i s p l a y   =   ' b l o c k ' ;  
         d o c u m e n t . g e t E l e m e n t B y I d ( ' m a i n l v l _ o n e ' ) . c l a s s N a m e   =   ' e m p t y ' ;  
         d o c u m e n t . g e t E l e m e n t B y I d ( ' m a i n l v l _ t w o ' ) . c l a s s N a m e   =   ' e m p t y ' ;  
         d o c u m e n t . g e t E l e m e n t B y I d ( ' m a i n l v l _ t h r e e ' ) . c l a s s N a m e   =   ' e m p t y ' ;  
  
  
  
         d o c u m e n t . g e t E l e m e n t B y I d ( i d _ o f _ t a b ) . c l a s s N a m e   =   ' s e l e c t e d ' ;  
  
 }  
  
  
  
 / / K i e m   t r a   d u   l i e u   n g a y  
 f u n c t i o n   C h e c k D a t e ( f i e l d )   {  
         v a r   c h e c k s t r   =   " 0 1 2 3 4 5 6 7 8 9 " ;  
         v a r   D a t e F i e l d   =   f i e l d ;  
         v a r   D a t e v a l u e   =   " " ;  
         v a r   D a t e T e m p   =   " " ;  
         v a r   s e p e r a t o r   =   " / " ;  
         v a r   d a y ;  
         v a r   m o n t h ;  
         v a r   y e a r ;  
         v a r   l e a p   =   0 ;  
         v a r   e r r   =   0 ;  
         v a r   i ;  
         e r r   =   0 ;  
         D a t e V a l u e   =   D a t e F i e l d . v a l u e ;  
         / *   D e l e t e   a l l   c h a r s   e x c e p t   0 . . 9   * /  
         f o r   ( i   =   0 ;   i   <   D a t e V a l u e . l e n g t h ;   i + + )   {  
                 i f   ( c h e c k s t r . i n d e x O f ( D a t e V a l u e . s u b s t r ( i ,   1 ) )   > =   0 )   {  
                         D a t e T e m p   =   D a t e T e m p   +   D a t e V a l u e . s u b s t r ( i ,   1 ) ;  
                 }  
         }  
         D a t e V a l u e   =   D a t e T e m p ;  
         / *   A l w a y s   c h a n g e   d a t e   t o   8   d i g i t s   -   s t r i n g * /  
         / *   i f   y e a r   i s   e n t e r e d   a s   2 - d i g i t   /   a l w a y s   a s s u m e   2 0 x x    
         H u n g D D   e d i t   :   i f   y e a r   i s   e n t e r e d   a s   2 - d i g i t   /   i f   2   d i g i t s   o f   y e a r   = <   7 0   a s s u m e   2 0 x x   /   e l s e   a s s u m e   1 9 x x  
         * /  
         i f   ( D a t e V a l u e . l e n g t h   = =   6 )   {  
                 v a r   s t r   =   D a t e V a l u e . s u b s t r ( 4 ,   2 ) ;  
                 / / a l e r t ( " s t r   :   "   +   s t r ) ;  
                 v a r   y   =   0 ;  
                 i f   ( s t r   = =   " 0 8 " )   y   =   8 ;  
                 e l s e   i f   ( s t r   = =   " 0 9 " )   y   =   9 ;  
                 e l s e  
                         y   =   p a r s e I n t ( s t r ) ;  
                 / / a l e r t ( " y   :   "   +   y ) ;  
  
                 v a r   s t r Y e a r   =   y   <   1 0   ?   " 0 "   +   y   :   " "   +   y ;  
  
                 / / a l e r t ( " s t r Y e a r   :   "   +   s t r Y e a r ) ;  
                 i f   ( y   >   7 0 )  
                         D a t e V a l u e   =   D a t e V a l u e . s u b s t r ( 0 ,   4 )   +   ' 1 9 '   +   s t r Y e a r ;  
                 e l s e  
                         D a t e V a l u e   =   D a t e V a l u e . s u b s t r ( 0 ,   4 )   +   ' 2 0 '   +   s t r Y e a r ;  
         }  
  
         i f   ( D a t e V a l u e . l e n g t h   ! =   8 )   {  
                 / / h u n g d d   e d i t   0 5 / 0 5 / 2 0 0 9  
                 / * r e p l a c e   ' / '   &   ' - '   &   ' . '   t o   ' / '   * /  
                 v a r   s t r D a t e   =   D a t e F i e l d . v a l u e ;  
                 v a r   c u r r e n t D a t e   =   n e w   D a t e ( ) ;  
                 v a r   r e g   =   / \ d / ;  
                 v a r   p a t t e r n   =   / \ / { 1 , } / g ;  
                 i f   ( s t r D a t e . i n d e x O f ( " . " )   >   - 1   | |   s t r D a t e . i n d e x O f ( " - " )   >   - 1 )   {  
                         s t r D a t e   =   s t r D a t e . r e p l a c e ( / \ . / g ,   " / " ) ;  
                         s t r D a t e   =   s t r D a t e . r e p l a c e ( / - / g ,   " / " ) ;  
                         s t r D a t e   =   s t r D a t e . r e p l a c e ( p a t t e r n ,   " / " ) ;  
                         v a r   s D a t e   =   s t r D a t e . s u b s t r i n g ( 0 ,   s t r D a t e . i n d e x O f ( " / " ) ) ;  
                         s t r D a t e   =   s t r D a t e . r e p l a c e ( s D a t e   +   " / " ,   " " ) ;  
                         v a r   s M o n t h   =   s t r D a t e . s u b s t r i n g ( 0 ,   s t r D a t e . i n d e x O f ( " / " ) ) ;  
                         s t r D a t e   =   s t r D a t e . r e p l a c e ( s M o n t h   +   " / " ,   " " ) ;  
                         v a r   s Y e a r   =   s t r D a t e . s u b s t r i n g ( s t r D a t e . l e n g t h   -   2 ,   s t r D a t e ) ;  
                         i f   ( s M o n t h   = =   n u l l   | |   s M o n t h   = =   " " )   {  
                                 s M o n t h   =   s Y e a r ;  
                                 s Y e a r   =   c u r r e n t D a t e . g e t F u l l Y e a r ( ) ;  
                         }  
                         / / a l e r t ( s D a t e   +   " ; "   +   s M o n t h   +   " ; "   +   s Y e a r ) ;  
                         i f   ( r e g . t e s t ( s D a t e )   = =   t r u e   & &   r e g . t e s t ( s M o n t h )   = =   t r u e   & &   r e g . t e s t ( s Y e a r )   = =   t r u e )   {  
                                 / * C o m p i l e   t o   D a t e T i m e   s t r i n g * /  
                                 s D a t e   =   s D a t e . l e n g t h   = =   1   ?   " 0 "   +   s D a t e   :   s D a t e ;  
                                 s M o n t h   =   s M o n t h . l e n g t h   = =   1   ?   " 0 "   +   s M o n t h   :   s M o n t h ;  
                                 v a r   i n t Y e a r   =   p a r s e I n t ( s Y e a r ) ;  
                                 s w i t c h   ( s Y e a r . l e n g t h )   {  
                                         c a s e   1 :  
                                                 s Y e a r   =   " 2 0 0 "   +   s Y e a r ;  
                                                 b r e a k ;  
                                         c a s e   2 :  
                                                 s Y e a r   =   i n t Y e a r   < =   7 0   ?   " 2 0 "   +   s Y e a r   :   " 1 9 "   +   s Y e a r ;  
                                                 b r e a k ;  
                                 }  
                                 / / a l e r t ( d a t e   +   " ; "   +   m o n t h   +   " ; "   +   y e a r ) ;  
                                 D a t e V a l u e   =   s D a t e   +   s M o n t h   +   s Y e a r ;  
                         }  
                         e l s e  
                                 e r r   =   1 9 ;  
                 }  
                 / / e n d   :   h u n g d d   e d i t   0 5 / 0 5 / 2 0 0 9  
                 e l s e   {  
                         i f   ( r e g . t e s t ( s t r D a t e )   = =   t r u e )   {  
                                 v a r   i n t D a t e   =   p a r s e I n t ( s t r D a t e ) ;  
                                 v a r   m y D a t e   =   n e w   D a t e ( ) ;  
                                 m y D a t e . s e t F u l l Y e a r ( c u r r e n t D a t e . g e t F u l l Y e a r ( ) ,   c u r r e n t D a t e . g e t M o n t h ( )   +   1 ,   1 ) ;  
                                 m y D a t e . s e t D a t e ( m y D a t e . g e t D a t e ( )   -   1 ) ;  
                                 i f   ( i n t D a t e   >   m y D a t e . g e t D a t e ( )   | |   i n t D a t e   < =   0 )  
                                         e r r   =   2 5 ;  
                                 e l s e   {  
                                         D a t e V a l u e   =   i n t D a t e   <   1 0   ?   " 0 "   +   s t r D a t e   :   s t r D a t e ;  
                                         v a r   m o n t h _   =   c u r r e n t D a t e . g e t M o n t h ( )   +   1 ;  
                                         D a t e V a l u e   + =   m o n t h _   <   1 0   ?   " 0 "   +   m o n t h _   :   " "   +   m o n t h _ ;  
                                         D a t e V a l u e   + =   c u r r e n t D a t e . g e t F u l l Y e a r ( ) ;  
                                 }  
                         }  
                         e l s e  
                                 e r r   =   1 9 ;  
                 }  
         }  
         / / e n d   H u n g D D   e d i t    
         / *   y e a r   i s   w r o n g   i f   y e a r   =   0 0 0 0   * /  
         y e a r   =   D a t e V a l u e . s u b s t r ( 4 ,   4 ) ;  
         i f   ( y e a r   = =   0 )   {  
                 e r r   =   2 0 ;  
         }  
         / *   V a l i d a t i o n   o f   m o n t h * /  
         m o n t h   =   D a t e V a l u e . s u b s t r ( 2 ,   2 ) ;  
         i f   ( ( m o n t h   <   1 )   | |   ( m o n t h   >   1 2 ) )   {  
                 e r r   =   2 1 ;  
         }  
         / *   V a l i d a t i o n   o f   d a y * /  
         d a y   =   D a t e V a l u e . s u b s t r ( 0 ,   2 ) ;  
  
         i f   ( y e a r   < =   1 9 0 0 )   {  
                 e r r   =   1 8 ;  
         }  
         i f   ( d a y   <   1 )   {  
                 e r r   =   2 2 ;  
         }  
         / *   V a l i d a t i o n   l e a p - y e a r   /   f e b r u a r y   /   d a y   * /  
         i f   ( ( y e a r   %   4   = =   0 )   | |   ( y e a r   %   1 0 0   = =   0 )   | |   ( y e a r   %   4 0 0   = =   0 ) )   {  
                 l e a p   =   1 ;  
         }  
         i f   ( ( m o n t h   = =   2 )   & &   ( l e a p   = =   1 )   & &   ( d a y   >   2 9 ) )   {  
                 e r r   =   2 3 ;  
         }  
         i f   ( ( m o n t h   = =   2 )   & &   ( l e a p   ! =   1 )   & &   ( d a y   >   2 8 ) )   {  
                 e r r   =   2 4 ;  
         }  
         / *   V a l i d a t i o n   o f   o t h e r   m o n t h s   * /  
         i f   ( ( d a y   >   3 1 )   & &   ( ( m o n t h   = =   " 0 1 " )   | |   ( m o n t h   = =   " 0 3 " )   | |   ( m o n t h   = =   " 0 5 " )   | |   ( m o n t h   = =   " 0 7 " )   | |   ( m o n t h   = =   " 0 8 " )   | |   ( m o n t h   = =   " 1 0 " )   | |   ( m o n t h   = =   " 1 2 " ) ) )   {  
                 e r r   =   2 5 ;  
         }  
         i f   ( ( d a y   >   3 0 )   & &   ( ( m o n t h   = =   " 0 4 " )   | |   ( m o n t h   = =   " 0 6 " )   | |   ( m o n t h   = =   " 0 9 " )   | |   ( m o n t h   = =   " 1 1 " ) ) )   {  
                 e r r   =   2 6 ;  
         }  
         / *   i f   0 0   i s t   e n t e r e d ,   n o   e r r o r ,   d e l e t i n g   t h e   e n t r y   * /  
         i f   ( ( d a y   = =   0 )   & &   ( m o n t h   = =   0 )   & &   ( y e a r   = =   0 0 ) )   {  
                 e r r   =   0 ;   d a y   =   " " ;   m o n t h   =   " " ;   y e a r   =   " " ;   s e p e r a t o r   =   " " ;  
         }  
         / *   i f   n o   e r r o r ,   w r i t e   t h e   c o m p l e t e d   d a t e   t o   I n p u t - F i e l d   ( e . g .   1 3 . 1 2 . 2 0 0 1 )   * /  
         i f   ( e r r   = =   0 )   {  
                 D a t e F i e l d . v a l u e   =   d a y   +   s e p e r a t o r   +   m o n t h   +   s e p e r a t o r   +   y e a r ;  
                 r e t u r n   t r u e ;  
         }  
         e l s e   i f   ( e r r   =   1 8 ) / *   E r r o r - m e s s a g e   i f   e r r   ! =   0   * /  
         {  
                 D a t e F i e l d . v a l u e   =   " " ;  
                 D a t e F i e l d . f o c u s ( ) ;  
                 / / G e t A l e r t E r r o r ( i T o t a l ,   D S A l e r t ,   " 0 0 3 0 " ) ;  
                 a l e r t ( " N g à y   n h ­p   k h ô n g   ú n g " ) ;  
                 r e t u r n   f a l s e ;  
         }  
         e l s e   {  
                 D a t e F i e l d . v a l u e   =   " " ;  
                 D a t e F i e l d . f o c u s ( ) ;  
                 / / G e t A l e r t E r r o r ( i T o t a l ,   D S A l e r t ,   " 0 0 3 1 " ) ;  
                 a l e r t ( " N g à y   n h ­p   k h ô n g   ú n g " ) ;  
                 r e t u r n   f a l s e ;  
         }  
 }  
 / / l o a i   b o   k h o a n g   t r a n g  
 f u n c t i o n   t r i m ( t x t )   {  
         t x t   =   t x t . r e p l a c e ( / ^ ( \ s ) + / ,   ' ' ) ;  
         t x t   =   t x t . r e p l a c e ( / ( \ s ) + $ / ,   ' ' ) ;  
         r e t u r n   t x t ;  
 }  
 / / k i e m   t r a   d u   l i e u   p h a i   l a   s o  
 f u n c t i o n   c h e c k N u m e r i c ( f i e l d )   {  
         v a r   r e ;  
         r e   =   / , / g ;  
         v a r   v a l u e   =   f i e l d . v a l u e . r e p l a c e ( r e ,   ' ' ) ;  
        
         i f   ( t r i m ( f i e l d . v a l u e )   = =   " " )   {  
                 f i e l d . v a l u e   =   " " ;  
                 r e t u r n   f a l s e ;  
         }  
         i f   ( i s N a N ( v a l u e ) )   {  
                 / / G e t A l e r t E r r o r ( i T o t a l ,   D S A l e r t ,   " 0 0 1 3 " ) ;  
                 a l e r t ( " D ï  l i Çu   p h £i   l à   s Ñ" ) ;  
                 f i e l d . v a l u e   =   " " ;  
                 f i e l d . f o c u s ( ) ;  
                 r e t u r n   f a l s e ;  
       }  
         i f   ( v a l u e   <   0 )   {  
                 / / a l e r t ( " M u s t   n o t   a   n e g a t i v e   n u m e r i c   o r   z e r o ! " ) ;  
                 / / G e t A l e r t E r r o r ( i T o t a l ,   D S A l e r t ,   " 0 0 1 2 " ) ;  
                 a l e r t ( " D ï  l i Çu   b u Ùc   p h £i   l à   s Ñ  v à   k h ô n g   °ãc   l à   s Ñ  0 " ) ;  
                 f i e l d . v a l u e   =   " " ;  
                 f i e l d . f o c u s ( ) ;  
                 r e t u r n   f a l s e ;  
         }  
         F o r m a t N u m e r i c W i t h S e p a r a t e ( f i e l d ) ;  
 }  
 / / d i n h   s o   t h a n g   c h u o i   c o   d a u   ,   V D   2 0 0 0 0 0   -   >   2 0 0 , 0 0 0    
 f u n c t i o n   F o r m a t N u m e r i c W i t h S e p a r a t e ( f i e l d )   {  
         v a r   D e c i m a l N u m b e r   =   2 ;  
         v a r   D e c i m a l C h a r   =   " . " ;  
         v a r   S e p e r a t e C h a r   =   " , " ;  
         v a r   V a l u e S t r i n g   =   f i e l d . v a l u e ;  
         v a r   V a l u e S t r i n g A f t e r D e c i m a l   =   " " ;  
         v a r   V a l u e S t r i n g N e w   =   " " ;  
         i f   ( f i e l d . v a l u e   <   0 )  
                 V a l u e S t r i n g   =   V a l u e S t r i n g . s u b s t r i n g ( 1 ,   V a l u e S t r i n g . l e n g t h ) ;   / / B o   d a u   t r u  
         i f   ( V a l u e S t r i n g . i n d e x O f ( D e c i m a l C h a r )   ! =   - 1 )   {  
                 V a l u e S t r i n g A f t e r D e c i m a l   =   V a l u e S t r i n g . s u b s t r i n g ( V a l u e S t r i n g . i n d e x O f ( D e c i m a l C h a r ) ,   V a l u e S t r i n g . i n d e x O f ( D e c i m a l C h a r )   +   1   +   D e c i m a l N u m b e r )   / /   T i n h   l u o n   d a u   c h a m  
                 V a l u e S t r i n g   =   V a l u e S t r i n g . s u b s t r i n g ( 0 ,   V a l u e S t r i n g . i n d e x O f ( D e c i m a l C h a r ) )  
         }  
  
         i f   ( V a l u e S t r i n g A f t e r D e c i m a l . i n d e x O f ( S e p e r a t e C h a r )   ! =   - 1 )   {  
                 a l e r t ( " K h ô n g   p h £i   l à   d ï  l i Çu   s Ñ! " ) ;  
                 f i e l d . v a l u e   =   " " ;  
                 f i e l d . f o c u s ( ) ;  
                 r e t u r n ;  
         }  
         V a l u e S t r i n g   =   V a l u e S t r i n g . r e p l a c e ( / , / g ,   ' ' ) ;  
         V a l u e S t r i n g N e w   =   " " ;  
         w h i l e   ( V a l u e S t r i n g . l e n g t h   >   3 )   {  
                 V a l u e S t r i n g N e w   =   S e p e r a t e C h a r   +   V a l u e S t r i n g . s u b s t r i n g ( V a l u e S t r i n g . l e n g t h   -   3 ,   V a l u e S t r i n g . l e n g t h )   +   V a l u e S t r i n g N e w ;  
                 V a l u e S t r i n g   =   V a l u e S t r i n g . s u b s t r i n g ( 0 ,   V a l u e S t r i n g . l e n g t h   -   3 ) ;  
         }  
         i f   ( D e c i m a l N u m b e r   ! =   0 )  
                 V a l u e S t r i n g N e w   =   V a l u e S t r i n g   +   V a l u e S t r i n g N e w   +   V a l u e S t r i n g A f t e r D e c i m a l ;  
         e l s e  
                 V a l u e S t r i n g N e w   =   V a l u e S t r i n g   +   V a l u e S t r i n g N e w ;  
  
         i f   ( f i e l d . v a l u e   <   0 )  
                 V a l u e S t r i n g N e w   =   " -   "   +   V a l u e S t r i n g N e w ;  
  
         f i e l d . v a l u e   =   V a l u e S t r i n g N e w ;  
 }  
 f u n c t i o n   c h e c k I n t e g e r ( f i e l d )   {  
         v a r   v a l u e   =   f i e l d . v a l u e ;  
         i f   ( i s N a N ( v a l u e ) )   {  
  
                 a l e r t ( " S Ñ  k h ô n g   h ãp   l Ç! " ) ;  
                 f i e l d . f o c u s ( ) ;  
                 f i e l d . v a l u e   =   " " ;  
                 r e t u r n   f a l s e ;  
         }  
         e l s e   {  
                 i f   ( v a l u e   <   0 )   {  
                         a l e r t ( " S Ñ  k h ô n g   °ãc   l à   s Ñ  â m ! " ) ;  
                         f i e l d . f o c u s ( ) ;  
                         f i e l d . v a l u e   =   " " ;  
                         r e t u r n   f a l s e ;  
                 }  
                 e l s e   {  
                         f i e l d . v a l u e   =   M a t h . r o u n d ( f i e l d . v a l u e ) ;  
                         r e t u r n   t r u e ;  
                 }  
         }  
 }  
 / / r a n g   b u o c   p h a i   n h a p   t r o n g   k h o a n g   t u   b a o   n h i e u   d e n   b a o   n h i e u  
 f u n c t i o n   c h e c k I n p u t I n M o n t h ( f i e l d ,   f r o m ,   t o )   {  
         i f   ( c h e c k I n t e g e r ( f i e l d ) )   {  
                 v a r   v a l u e   =   f i e l d . v a l u e ;  
                 i f   ( p a r s e I n t ( v a l u e )   <   f r o m   | |   p a r s e I n t ( v a l u e )   >   t o ) {  
                         a l e r t ( " D ï  l i Çu   s Ñ  p h £i   n ±m   t r o n g   k h o £n g   "   +   f r o m   +   "   ¿n   "   +   t o ) ;  
                         f i e l d . f o c u s ( ) ;  
                         f i e l d . v a l u e   =   " " ;  
                         r e t u r n   f a l s e ;  
                 }  
       }  
       / / r e t u r n   t r u e ;  
  }  
  
 / / c h o n   d a u   c h e c k   t a t   c a  
 f u n c t i o n   C h e c k A l l ( C t l ,   G r i d N a m e ,   B e g i n I n d e x ,   E n d I n d e x E x t ,   G r i d C t l )   {  
         v a r   v a l u e   =   d o c u m e n t . g e t E l e m e n t B y I d ( C t l ) . c h e c k e d ;  
         v a r   i ;  
         c o u n t   =   d o c u m e n t . g e t E l e m e n t B y I d ( G r i d N a m e ) . r o w s . l e n g t h ;  
         i f   ( c o u n t   >   1 )   {  
                 f o r   ( i   =   B e g i n I n d e x ;   i   <   d o c u m e n t . g e t E l e m e n t B y I d ( G r i d N a m e ) . r o w s . l e n g t h   +   E n d I n d e x E x t ;   i + + )   {  
                         i f   ( i   < =   9 )   {  
                                 d o c u m e n t . g e t E l e m e n t B y I d ( G r i d N a m e   +   " _ c t l 0 "   +   i   +   " _ "   +   G r i d C t l ) . c h e c k e d   =   v a l u e ;  
                         }  
                         e l s e   {  
                                 d o c u m e n t . g e t E l e m e n t B y I d ( G r i d N a m e   +   " _ c t l "   +   i   +   " _ "   +   G r i d C t l ) . c h e c k e d   =   v a l u e ;  
                         }  
                 }  
         }  
 } 
