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