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