ÿþf u n c t i o n   a d d R o l l o v e r ( i m g ,   r o l l o v e r U R L )   {  
         i f   ( t y p e o f   i m g   = =   " s t r i n g " )   {     / /   I f   i m g   i s   a   s t r i n g ,  
                 v a r   i d   =   i m g ;                         / /   i t   i s   a n   i d ,   n o t   a n   i m a g e  
                 i m g   =   n u l l ;                             / /   a n d   w e   d o n ' t   h a v e   a n   i m a g e   y e t .  
  
                 / / F i r s t   t r y   l o o k i n g   t h e   i m a g e   u p   b y   a n   i d  
                 i f   ( d o c u m e n t . g e t E l e m e n t B y I d )   i m g   =   d o c u m e n t . g e t E l e m e n t B y I d ( i d ) ;  
                 e l s e   i f   ( d o c u m e n t . a l l )   i m g   =   d o c u m e n t . a l l [ i d ]  
  
                 / / i f   n o t   f o u n d   b y   i d ,   t r y   l o o k i n g   t h e   i m a g e   u p   b y   n a m e  
                 i f   ( ! i m g )   i m g   =   d o c u m e n t . i m a g e s [ i d ] ;  
  
                 / / i f   w e   c o u l d n ' t   f i n d   t h e   i m a g e ,   d o   n o t h i n g   a n d   f a i l   s i l e n t l y  
                 i f   ( ! i m g )   r e t u r n ;  
  
         }  
  
         / /   i f   w e   f o u n d   a n   e l e m e n t   b u t   i t   i s   n o t   a n   < i m g >   t a g ,   w e   a l s o   f a i l  
         i f   ( i m g . t a g N a m e . t o L o w e r C a s e ( )   ! =   " i m g " )   r e t u r n ;  
  
         / / R e m e m b e r   t h e   o r i g i n a l   U R L   o f   t h e   i m a g e  
         v a r   b a s e U R L   =   i m g . s r c ;  
  
         / / P r e l o a d   t h e   r o l l o v e r   i m a g e   i n t o   t h e   b r o w s e r ' s   c a c h e  
         v a r   r o l l O v e r o b j   =   n e w   I m a g e ( ) ;    
         r o l l O v e r o b j . s r c   =   r o l l o v e r U R L ;  
  
         i m g . o n m o u s e o v e r   =   f u n c t i o n ( )   {   i m g . s r c   =   r o l l O v e r o b j . s r c ;   }  
         i m g . o n m o u s e o u t   =   f u n c t i o n ( )   {   i m g . s r c   =   b a s e U R L ;   }  
 }  
  
 f u n c t i o n   i n i t R o l l o v e r s ( )   {  
         v a r   i m a g e s   =   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 ( " i m g " ) ;  
         f o r   ( v a r   i   =   0 ;   i   <   i m a g e s . l e n g t h ;   i + + )   {  
                 v a r   i m a g e   =   i m a g e s [ i ] ;  
                 v a r   r o l l o v e r U R L   =   i m a g e . g e t A t t r i b u t e ( " r o l l o v e r " ) ;  
                 i f   ( r o l l o v e r U R L )   a d d R o l l o v e r ( i m a g e ,   r o l l o v e r U R L ) ;  
         }  
 } 
