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