ÿþ/ / / < r e f e r e n c e   p a t h = " . . / U t i l . j s "   / >  
 / * *  
   *   A d v e r t S c r o l l B T D  
   *    
   *   @ 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 :   A d v e r t S c r o l l B T D . j s ,   v 2 . 0   2 0 0 7 / 1 0 / 3  
   * /  
  
 v a r   A d v e r t S c r o l l B T D   =  
 {  
 	 c o u n t e r P l u s :   1 0 ,  
 	 t i m e r :   n u l l ,  
 	 e l C o n t a i n e r L e f t :   n u l l ,  
 	 e l C o n t a i n e r R i g h t :   n u l l ,  
 	 t o t a l W i d t h :   2 4 0 ,  
 	 r e s o l u t i o n W i d t h :   1 0 0 0 ,  
 	 i s S t o p :   f a l s e ,  
 	 i s H a s C h i l d L e f t :   f a l s e ,  
 	 i s H a s C h i l d R i g h t :   f a l s e ,  
 	 c o u n t S i n :   0 . 0 ,  
 	 p o s D i v :   0 ,  
 	 p o s N e e d :   0 ,  
 	 i s R u n n i n g :   f a l s e ,  
 	 i s F i x :   f a l s e ,  
 	 i s I n i t :   f a l s e ,  
  
 	 r e t u r n S c r o l l T o p :   f u n c t i o n   ( )   {  
 	 	 / / /   < r e t u r n s   t y p e = " N u m b e r "   / >  
 	 	 r e t u r n   u t i l O b j . g e t D o c u m e n t S c r o l l ( ) . s c r o l l T o p ;  
 	 } ,  
  
 	 c r e a t e C o n t a i n e r L e f t :   f u n c t i o n   ( )   {  
 	 	 t h i s . e l C o n t a i n e r L e f t   =   u t i l O b j . c r e a t e E l ( " D I V " ) ;  
 	 	 t h i s . e l C o n t a i n e r L e f t . s t y l e . p o s i t i o n   =   " a b s o l u t e " ;  
 	 	 t h i s . e l C o n t a i n e r L e f t . s t y l e . d i s p l a y   =   " b l o c k " ;  
 	 	 u t i l O b j . a d d C h i l d T o B o d y ( t h i s . e l C o n t a i n e r L e f t ) ;  
 	 } ,  
  
 	 c r e a t e C o n t a i n e r R i g h t :   f u n c t i o n   ( )   {  
 	 	 t h i s . e l C o n t a i n e r R i g h t   =   d o c u m e n t . c r e a t e E l e m e n t ( " D I V " ) ;  
 	 	 t h i s . e l C o n t a i n e r R i g h t . s t y l e . p o s i t i o n   =   " a b s o l u t e " ;  
 	 	 t h i s . e l C o n t a i n e r R i g h t . s t y l e . d i s p l a y   =   " b l o c k " ;  
 	 	 u t i l O b j . a d d C h i l d T o B o d y ( t h i s . e l C o n t a i n e r R i g h t ) ;  
 	 } ,  
  
 	 i n i t :   f u n c t i o n   ( )   {  
 	 	 / / /   < s u m m a r y > K h ßi   t ¡o   q u £n g   c á o   t h a n h   c u Ùn   ( p h £i   ·t   t r o n g   o n l o a d   c ça   w i n d o w ) . < / s u m m a r y >  
 	 	 i f   ( t h i s . i s I n i t )   r e t u r n ;  
 	 	 t h i s . c r e a t e C o n t a i n e r L e f t ( ) ;  
 	 	 t h i s . c r e a t e C o n t a i n e r R i g h t ( ) ;  
 	 	 t h i s . o n R e s i z e ( ) ;  
 	 	 v a r   s e l f   =   t h i s ;  
 	 	 u t i l O b j . a d d E v e n t ( u t i l O b j . w d ,   " r e s i z e " ,   f u n c t i o n   ( e )   {   s e l f . o n R e s i z e ( ) ;   } ) ;  
 	 	 u t i l O b j . a d d E v e n t ( w i n d o w ,   " s c r o l l " ,   f u n c t i o n   ( e )   {   s e l f . o n S c r o l l ( ) ;   } ) ;  
 	 	 t h i s . i s I n i t   =   t r u e ;  
 	 } ,  
  
 	 s e t F i x :   f u n c t i o n   ( )   {  
 	 	 / / /   < s u m m a r y > L à m   f i x   q u £n g   c á o . < / s u m m a r y >  
 	 	 t h i s . i n i t ( ) ;  
 	 	 i f   ( ! t h i s . i s F i x )   {  
 	 	 	 t h i s . i s F i x   =   t r u e ;  
 	 	 	 t h i s . e l C o n t a i n e r L e f t . s t y l e . p o s i t i o n   =  
 	 	 	 t h i s . e l C o n t a i n e r R i g h t . s t y l e . p o s i t i o n   =   " f i x e d " ;  
 	 	 	 t h i s . e l C o n t a i n e r L e f t . s t y l e . t o p   =  
 	 	 	 t h i s . e l C o n t a i n e r R i g h t . s t y l e . t o p   =  
 	 	 	 t h i s . e l C o n t a i n e r L e f t . s t y l e . l e f t   =  
 	 	 	 t h i s . e l C o n t a i n e r R i g h t . s t y l e . r i g h t   =   " 0 p x " ;  
 	 	 	 t h i s . e l C o n t a i n e r L e f t . s t y l e . o v e r f l o w   =  
 	 	 	 t h i s . e l C o n t a i n e r R i g h t . s t y l e . o v e r f l o w   =   " h i d d e n " ;  
 	 	 }  
 	 	 v a r   c l i e n t S i z e   =   u t i l O b j . g e t D o c u m e n t ( ) ;  
 	 	 t h i s . e l C o n t a i n e r L e f t . s t y l e . h e i g h t   =  
 	 	 t h i s . e l C o n t a i n e r R i g h t . s t y l e . h e i g h t   =   c l i e n t S i z e . c l i e n t H e i g h t   +   " p x " ;  
 	 	 v a r   w   =   ( c l i e n t S i z e . c l i e n t W i d t h   -   t h i s . r e s o l u t i o n W i d t h   -   1 6 )   /   2 ;  
 	 	 i f   ( w   <   0 )   w   =   0 ;  
 	 	 t h i s . e l C o n t a i n e r L e f t . s t y l e . w i d t h   =  
 	 	 t h i s . e l C o n t a i n e r R i g h t . s t y l e . w i d t h   =   w   +   " p x " ;  
 	 } ,  
  
 	 c l e a r A l l L e f t :   f u n c t i o n   ( )   {  
 	 	 t h i s . e l C o n t a i n e r L e f t . i n n e r H T M L   =   " " ;  
 	 } ,  
  
 	 a d d A d v e r t i s e L e f t :   f u n c t i o n   ( e l )   {  
 	 	 / / /   < s u m m a r y > N h ­p   q u £n g   c á o   b ê n   t r á i . < / s u m m a r y >  
 	 	 / / /   < p a r a m   n a m e = " e l " > L à   E l e m e n t   c ça   w i n d o w ,   h o ·c   l à   I D   c ça   E l e m e n t   ó . < / p a r a m >  
 	 	 t h i s . i s H a s C h i l d L e f t   =   t r u e ;  
 	 	 e l   =   t y p e o f   ( e l )   = =   " s t r i n g "   ?   d o c u m e n t . g e t E l e m e n t B y I d ( e l )   :   e l ;  
 	 	 e l . s t y l e . d i s p l a y   =   " " ;  
 	 	 i f   ( t h i s . i s F i x )   {  
 	 	 	 i f   ( e l . s t y l e . c s s F l o a t   ! =   n u l l )   {  
 	 	 	 	 e l . s t y l e . c s s F l o a t   =   " r i g h t " ;  
 	 	 	 }  
 	 	 	 e l s e   {  
 	 	 	 	 e l . s t y l e . s t y l e F l o a t   =   " r i g h t " ;  
 	 	 	 }  
 	 	 }  
 	 	 i f   ( t h i s . e l C o n t a i n e r L e f t   ! =   n u l l   & &   e l   ! =   n u l l )   {  
 	 	 	 t h i s . e l C o n t a i n e r L e f t . a p p e n d C h i l d ( e l ) ;  
 	 	 	 t h i s . o n S c r o l l ( ) ;  
 	 	 }  
 	 } ,  
  
 	 a d d A d v e r t i s e R i g h t :   f u n c t i o n   ( e l )   {  
 	 	 / / /   < s u m m a r y > N h ­p   q u £n g   c á o   b ê n   p h £i . < / s u m m a r y >  
 	 	 / / /   < p a r a m   n a m e = " e l " > L à   E l e m e n t   c ça   w i n d o w ,   h o ·c   l à   I D   c ça   E l e m e n t   ó . < / p a r a m >  
 	 	 t h i s . i s H a s C h i l d R i g h t   =   t r u e ;  
 	 	 e l   =   t y p e o f   ( e l )   = =   " s t r i n g "   ?   d o c u m e n t . g e t E l e m e n t B y I d ( e l )   :   e l ;  
 	 	 e l . s t y l e . d i s p l a y   =   " " ;  
 	 	 i f   ( t h i s . i s F i x )   {  
 	 	 	 i f   ( e l . s t y l e . c s s F l o a t   ! =   n u l l )   {  
 	 	 	 	 e l . s t y l e . c s s F l o a t   =   " l e f t " ;  
 	 	 	 }  
 	 	 	 e l s e   {  
 	 	 	 	 e l . s t y l e . s t y l e F l o a t   =   " l e f t " ;  
 	 	 	 }  
 	 	 }  
 	 	 i f   ( t h i s . e l C o n t a i n e r R i g h t   ! =   n u l l   & &   e l   ! =   n u l l )   {  
 	 	 	 t h i s . e l C o n t a i n e r R i g h t . a p p e n d C h i l d ( e l ) ;  
 	 	 	 t h i s . o n S c r o l l ( ) ;  
 	 	 }  
 	 } ,  
  
 	 c h a n g e P o s i t i o n :   f u n c t i o n   ( )   {  
 	 	 v a r   m a x   =   M a t h . P I   /   2 ;  
 	 	 i f   ( t h i s . c o u n t S i n   >   m a x   | |   t h i s . i s S t o p )   {  
 	 	 	 t h i s . c o u n t S i n   =   0 . 0 ;  
 	 	 	 t h i s . i s R u n n i n g   =   f a l s e ;  
 	 	 	 w i n d o w . c l e a r T i m e o u t ( t h i s . t i m e r ) ;  
 	 	 	 r e t u r n ;  
 	 	 }  
 	 	 t h i s . c o u n t S i n   + =   0 . 0 3 ;  
 	 	 v a r   p o s   =   t h i s . p o s D i v   +   ( M a t h . s i n ( t h i s . c o u n t S i n )   *   ( t h i s . p o s N e e d   -   t h i s . p o s D i v ) ) ;  
 	 	 t h i s . i s R u n n i n g   =   t r u e ;  
 	 	 t h i s . e l C o n t a i n e r L e f t . s t y l e . t o p   =  
 	 	 t h i s . e l C o n t a i n e r R i g h t . s t y l e . t o p   =   p o s   +   " p x " ;  
 	 	 v a r   s e l f   =   t h i s ;  
 	 	 t h i s . t i m e r   =   w i n d o w . s e t T i m e o u t ( f u n c t i o n   ( )   {   s e l f . c h a n g e P o s i t i o n ( ) ;   } ,   1 0 ) ;  
 	 } ,  
  
 	 o n S c r o l l :   f u n c t i o n   ( )   {  
 	 	 i f   ( ! t h i s . i s H a s C h i l d L e f t   & &   ! t h i s . i s H a s C h i l d R i g h t   | |   t h i s . i s F i x )   r e t u r n ;  
 	 	 t h i s . p o s N e e d   =   t h i s . r e t u r n S c r o l l T o p ( ) ;  
 	 	 v a r   p o s D i v   =   t h i s . i s H a s C h i l d L e f t   ?   p a r s e I n t ( t h i s . e l C o n t a i n e r L e f t . s t y l e . t o p )   :   p a r s e I n t ( t h i s . e l C o n t a i n e r R i g h t . s t y l e . t o p ) ;  
  
 	 	 v a r   s i z e D i v   =   t h i s . i s H a s C h i l d L e f t   ?   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 L e f t )   :   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 R i g h t ) ;  
 	 	 i f   ( p o s D i v   <   t h i s . p o s N e e d   -   s i z e D i v . h e i g h t )   {  
 	 	 	 p o s D i v   =   t h i s . p o s N e e d   -   s i z e D i v . h e i g h t ;  
 	 	 	 t h i s . e l C o n t a i n e r L e f t . s t y l e . t o p   =  
 	 	 	 t h i s . e l C o n t a i n e r R i g h t . s t y l e . t o p   =   p o s D i v   +   " p x " ;  
 	 	 }  
 	 	 e l s e   i f   ( p o s D i v   >   u t i l O b j . g e t D o c u m e n t ( ) . c l i e n t H e i g h t   +   t h i s . p o s N e e d )   {  
 	 	 	 p o s D i v   =   u t i l O b j . g e t D o c u m e n t ( ) . c l i e n t H e i g h t   +   t h i s . p o s N e e d ;  
 	 	 	 t h i s . e l C o n t a i n e r L e f t . s t y l e . t o p   =  
 	 	 	 t h i s . e l C o n t a i n e r R i g h t . s t y l e . t o p   =   p o s D i v   +   " p x " ;  
 	 	 }  
 	 	 t h i s . c o u n t S i n   =   0 . 0 ;  
 	 	 t h i s . p o s D i v   =   p o s D i v ;  
  
 	 	 i f   ( ! t h i s . i s R u n n i n g )   {  
 	 	 	 t h i s . c h a n g e P o s i t i o n ( ) ;  
 	 	 }  
 	 } ,  
  
 	 o n R e s i z e :   f u n c t i o n   ( )   {  
 	 	 v a r   i s R e s i z e   =   f a l s e ;  
 	 	 v a r   c l i e n t 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   d e l t a   =   ( u t i l O b j . i s F F   | |   u t i l O b j . i s S a f a r i   ?   0   :   ( u t i l O b j . i s I E   ?   4   :   1 ) ) ;  
 	 	 i f   ( c l i e n t S i z e . c l i e n t W i d t h   > =   t h i s . r e s o l u t i o n W i d t h   +   t h i s . t o t a l W i d t h   -   1 6 )   {  
 	 	 	 i s R e s i z e   =   t r u e ;  
 	 	 }  
 	 	 i f   ( ! i s R e s i z e )   {  
 	 	 	 t h i s . i s S t o p   =   t r u e ;  
 	 	 	 i f   ( t h i s . e l C o n t a i n e r L e f t   ! =   n u l l )   {  
 	 	 	 	 t h i s . e l C o n t a i n e r L e f t . s t y l e . d i s p l a y   =   " n o n e " ;  
 	 	 	 }  
 	 	 	 i f   ( t h i s . e l C o n t a i n e r R i g h t   ! =   n u l l )   {  
 	 	 	 	 t h i s . e l C o n t a i n e r R i g h t . s t y l e . d i s p l a y   =   " n o n e " ;  
 	 	 	 }  
 	 	 }  
 	 	 e l s e   {  
 	 	 	 t h i s . i s S t o p   =   f a l s e ;  
 	 	 	 t h i s . e l C o n t a i n e r L e f t . s t y l e . d i s p l a y   =   " b l o c k " ;  
 	 	 	 t h i s . e l C o n t a i n e r R i g h t . s t y l e . d i s p l a y   =   " b l o c k " ;  
 	 	 	 i f   ( t h i s . i s F i x )   {  
 	 	 	 	 t h i s . s e t F i x ( ) ;  
 	 	 	 }  
 	 	 	 e l s e   {  
 	 	 	 	 t h i s . e l C o n t a i n e r L e f t . s t y l e . p o s i t i o n   =  
 	 	 	 	 t h i s . e l C o n t a i n e r R i g h t . s t y l e . p o s i t i o n   =   " a b s o l u t e " ;  
 	 	 	 	 t h i s . e l C o n t a i n e r L e f t . s t y l e . l e f t   =   ( ( c l i e n t S i z e . c l i e n t W i d t h   /   2 )   -   ( t h i s . r e s o l u t i o n W i d t h   /   2 )   -   ( t h i s . t o t a l W i d t h   /   2 )   -   5 )   +   " p x " ;  
 	 	 	 	 t h i s . e l C o n t a i n e r R i g h t . s t y l e . l e f t   =   ( ( c l i e n t S i z e . c l i e n t W i d t h   /   2 )   +   ( t h i s . r e s o l u t i o n W i d t h   /   2 )   +   5 )   +   " p x " ;  
  
 	 	 	 	 v a r   p o s D i v   =   p a r s e I n t ( t h i s . e l C o n t a i n e r L e f t . s t y l e . t o p ) ;  
 	 	 	 	 i f   ( i s N a N ( p o s D i v )   | |   t h i s . i s F i x )   p o s D i v   =   0 ;  
  
 	 	 	 	 t h i s . e l C o n t a i n e r L e f t . s t y l e . t o p   =   t h i s . e l C o n t a i n e r R i g h t . s t y l e . t o p   =   p o s D i v   +   " p x " ;  
 	 	 	 	 t h i s . o n S c r o l l ( ) ;  
 	 	 	 }  
 	 	 }  
 	 }  
 } ;  
  
 
