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