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