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