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