ÿþ
 / / S t a r t   H o v e r I n t e n t 
 
 / * * 
 *   h o v e r I n t e n t   i s   s i m i l a r   t o   j Q u e r y ' s   b u i l t - i n   " h o v e r "   f u n c t i o n   e x c e p t   t h a t 
 *   i n s t e a d   o f   f i r i n g   t h e   o n M o u s e O v e r   e v e n t   i m m e d i a t e l y ,   h o v e r I n t e n t   c h e c k s 
 *   t o   s e e   i f   t h e   u s e r ' s   m o u s e   h a s   s l o w e d   d o w n   ( b e n e a t h   t h e   s e n s i t i v i t y 
 *   t h r e s h o l d )   b e f o r e   f i r i n g   t h e   o n M o u s e O v e r   e v e n t . 
 *   
 *   h o v e r I n t e n t   r 5   / /   2 0 0 7 . 0 3 . 2 7   / /   j Q u e r y   1 . 1 . 2 
 *   < h t t p : / / c h e r n e . n e t / b r i a n / r e s o u r c e s / j q u e r y . h o v e r I n t e n t . h t m l > 
 *   
 *   h o v e r I n t e n t   i s   c u r r e n t l y   a v a i l a b l e   f o r   u s e   i n   a l l   p e r s o n a l   o r   c o m m e r c i a l   
 *   p r o j e c t s   u n d e r   b o t h   M I T   a n d   G P L   l i c e n s e s .   T h i s   m e a n s   t h a t   y o u   c a n   c h o o s e   
 *   t h e   l i c e n s e   t h a t   b e s t   s u i t s   y o u r   p r o j e c t ,   a n d   u s e   i t   a c c o r d i n g l y . 
 *   
 *   / /   b a s i c   u s a g e   ( j u s t   l i k e   . h o v e r )   r e c e i v e s   o n M o u s e O v e r   a n d   o n M o u s e O u t   f u n c t i o n s 
 *   $ ( " u l   l i " ) . h o v e r I n t e n t (   s h o w N a v   ,   h i d e N a v   ) ; 
 *   
 *   / /   a d v a n c e d   u s a g e   r e c e i v e s   c o n f i g u r a t i o n   o b j e c t   o n l y 
 *   $ ( " u l   l i " ) . h o v e r I n t e n t ( { 
 * 	 s e n s i t i v i t y :   2 ,   / /   n u m b e r   =   s e n s i t i v i t y   t h r e s h o l d   ( m u s t   b e   1   o r   h i g h e r ) 
 * 	 i n t e r v a l :   5 0 ,       / /   n u m b e r   =   m i l l i s e c o n d s   o f   p o l l i n g   i n t e r v a l 
 * 	 o v e r :   s h o w N a v ,     / /   f u n c t i o n   =   o n M o u s e O v e r   c a l l b a c k   ( r e q u i r e d ) 
 * 	 t i m e o u t :   1 0 0 ,       / /   n u m b e r   =   m i l l i s e c o n d s   d e l a y   b e f o r e   o n M o u s e O u t   f u n c t i o n   c a l l 
 * 	 o u t :   h i d e N a v         / /   f u n c t i o n   =   o n M o u s e O u t   c a l l b a c k   ( r e q u i r e d ) 
 *   } ) ; 
 *   
 *   @ p a r a m     f     o n M o u s e O v e r   f u n c t i o n   | |   A n   o b j e c t   w i t h   c o n f i g u r a t i o n   o p t i o n s 
 *   @ p a r a m     g     o n M o u s e O u t   f u n c t i o n     | |   N o t h i n g   ( u s e   c o n f i g u r a t i o n   o p t i o n s   o b j e c t ) 
 *   @ r e t u r n         T h e   o b j e c t   ( a k a   " t h i s " )   t h a t   c a l l e d   h o v e r I n t e n t ,   a n d   t h e   e v e n t   o b j e c t 
 *   @ a u t h o r         B r i a n   C h e r n e   < b r i a n @ c h e r n e . n e t > 
 * / 
 ( f u n c t i o n ( $ )   { 
 	 $ . f n . h o v e r I n t e n t   =   f u n c t i o n ( f , g )   { 
 	 	 / /   d e f a u l t   c o n f i g u r a t i o n   o p t i o n s 
 	 	 v a r   c f g   =   { 
 	 	 	 s e n s i t i v i t y :   7 , 
 	 	 	 i n t e r v a l :   1 0 0 , 
 	 	 	 t i m e o u t :   0 
 	 	 } ; 
 	 	 / /   o v e r r i d e   c o n f i g u r a t i o n   o p t i o n s   w i t h   u s e r   s u p p l i e d   o b j e c t 
 	 	 c f g   =   $ . e x t e n d ( c f g ,   g   ?   {   o v e r :   f ,   o u t :   g   }   :   f   ) ; 
 
 	 	 / /   i n s t a n t i a t e   v a r i a b l e s 
 	 	 / /   c X ,   c Y   =   c u r r e n t   X   a n d   Y   p o s i t i o n   o f   m o u s e ,   u p d a t e d   b y   m o u s e m o v e   e v e n t 
 	 	 / /   p X ,   p Y   =   p r e v i o u s   X   a n d   Y   p o s i t i o n   o f   m o u s e ,   s e t   b y   m o u s e o v e r   a n d   p o l l i n g   i n t e r v a l 
 	 	 v a r   c X ,   c Y ,   p X ,   p Y ; 
 
 	 	 / /   A   p r i v a t e   f u n c t i o n   f o r   g e t t i n g   m o u s e   p o s i t i o n 
 	 	 v a r   t r a c k   =   f u n c t i o n ( e v )   { 
 	 	 	 c X   =   e v . p a g e X ; 
 	 	 	 c Y   =   e v . p a g e Y ; 
 	 	 } ; 
 
 	 	 / /   A   p r i v a t e   f u n c t i o n   f o r   c o m p a r i n g   c u r r e n t   a n d   p r e v i o u s   m o u s e   p o s i t i o n 
 	 	 v a r   c o m p a r e   =   f u n c t i o n ( e v , o b )   { 
 	 	 	 o b . h o v e r I n t e n t _ t   =   c l e a r T i m e o u t ( o b . h o v e r I n t e n t _ t ) ; 
 	 	 	 / /   c o m p a r e   m o u s e   p o s i t i o n s   t o   s e e   i f   t h e y ' v e   c r o s s e d   t h e   t h r e s h o l d 
 	 	 	 i f   (   (   M a t h . a b s ( p X - c X )   +   M a t h . a b s ( p Y - c Y )   )   <   c f g . s e n s i t i v i t y   )   { 
 	 	 	 	 $ ( o b ) . u n b i n d ( " m o u s e m o v e " , t r a c k ) ; 
 	 	 	 	 / /   s e t   h o v e r I n t e n t   s t a t e   t o   t r u e   ( s o   m o u s e O u t   c a n   b e   c a l l e d ) 
 	 	 	 	 o b . h o v e r I n t e n t _ s   =   1 ; 
 	 	 	 	 r e t u r n   c f g . o v e r . a p p l y ( o b , [ e v ] ) ; 
 	 	 	 }   e l s e   { 
 	 	 	 	 / /   s e t   p r e v i o u s   c o o r d i n a t e s   f o r   n e x t   t i m e 
 	 	 	 	 p X   =   c X ;   p Y   =   c Y ; 
 	 	 	 	 / /   u s e   s e l f - c a l l i n g   t i m e o u t ,   g u a r a n t e e s   i n t e r v a l s   a r e   s p a c e d   o u t   p r o p e r l y   ( a v o i d s   J a v a S c r i p t   t i m e r   b u g s ) 
 	 	 	 	 o b . h o v e r I n t e n t _ t   =   s e t T i m e o u t (   f u n c t i o n ( ) { c o m p a r e ( e v ,   o b ) ; }   ,   c f g . i n t e r v a l   ) ; 
 	 	 	 } 
 	 	 } ; 
 
 	 	 / /   A   p r i v a t e   f u n c t i o n   f o r   d e l a y i n g   t h e   m o u s e O u t   f u n c t i o n 
 	 	 v a r   d e l a y   =   f u n c t i o n ( e v , o b )   { 
 	 	 	 o b . h o v e r I n t e n t _ t   =   c l e a r T i m e o u t ( o b . h o v e r I n t e n t _ t ) ; 
 	 	 	 o b . h o v e r I n t e n t _ s   =   0 ; 
 	 	 	 r e t u r n   c f g . o u t . a p p l y ( o b , [ e v ] ) ; 
 	 	 } ; 
 
 	 	 / /   A   p r i v a t e   f u n c t i o n   f o r   h a n d l i n g   m o u s e   ' h o v e r i n g ' 
 	 	 v a r   h a n d l e H o v e r   =   f u n c t i o n ( e )   { 
 	 	 	 / /   n e x t   t h r e e   l i n e s   c o p i e d   f r o m   j Q u e r y . h o v e r ,   i g n o r e   c h i l d r e n   o n M o u s e O v e r / o n M o u s e O u t 
 	 	 	 v a r   p   =   ( e . t y p e   = =   " m o u s e o v e r "   ?   e . f r o m E l e m e n t   :   e . t o E l e m e n t )   | |   e . r e l a t e d T a r g e t ; 
 	 	 	 w h i l e   (   p   & &   p   ! =   t h i s   )   {   t r y   {   p   =   p . p a r e n t N o d e ;   }   c a t c h ( e )   {   p   =   t h i s ;   }   } 
 	 	 	 i f   (   p   = =   t h i s   )   {   r e t u r n   f a l s e ;   } 
 
 	 	 	 / /   c o p y   o b j e c t s   t o   b e   p a s s e d   i n t o   t   ( r e q u i r e d   f o r   e v e n t   o b j e c t   t o   b e   p a s s e d   i n   I E ) 
 	 	 	 v a r   e v   =   j Q u e r y . e x t e n d ( { } , e ) ; 
 	 	 	 v a r   o b   =   t h i s ; 
 
 	 	 	 / /   c a n c e l   h o v e r I n t e n t   t i m e r   i f   i t   e x i s t s 
 	 	 	 i f   ( o b . h o v e r I n t e n t _ t )   {   o b . h o v e r I n t e n t _ t   =   c l e a r T i m e o u t ( o b . h o v e r I n t e n t _ t ) ;   } 
 
 	 	 	 / /   e l s e   e . t y p e   = =   " o n m o u s e o v e r " 
 	 	 	 i f   ( e . t y p e   = =   " m o u s e o v e r " )   { 
 	 	 	 	 / /   s e t   " p r e v i o u s "   X   a n d   Y   p o s i t i o n   b a s e d   o n   i n i t i a l   e n t r y   p o i n t 
 	 	 	 	 p X   =   e v . p a g e X ;   p Y   =   e v . p a g e Y ; 
 	 	 	 	 / /   u p d a t e   " c u r r e n t "   X   a n d   Y   p o s i t i o n   b a s e d   o n   m o u s e m o v e 
 	 	 	 	 $ ( o b ) . b i n d ( " m o u s e m o v e " , t r a c k ) ; 
 	 	 	 	 / /   s t a r t   p o l l i n g   i n t e r v a l   ( s e l f - c a l l i n g   t i m e o u t )   t o   c o m p a r e   m o u s e   c o o r d i n a t e s   o v e r   t i m e 
 	 	 	 	 i f   ( o b . h o v e r I n t e n t _ s   ! =   1 )   {   o b . h o v e r I n t e n t _ t   =   s e t T i m e o u t (   f u n c t i o n ( ) { c o m p a r e ( e v , o b ) ; }   ,   c f g . i n t e r v a l   ) ; } 
 
 	 	 	 / /   e l s e   e . t y p e   = =   " o n m o u s e o u t " 
 	 	 	 }   e l s e   { 
 	 	 	 	 / /   u n b i n d   e x p e n s i v e   m o u s e m o v e   e v e n t 
 	 	 	 	 $ ( o b ) . u n b i n d ( " m o u s e m o v e " , t r a c k ) ; 
 	 	 	 	 / /   i f   h o v e r I n t e n t   s t a t e   i s   t r u e ,   t h e n   c a l l   t h e   m o u s e O u t   f u n c t i o n   a f t e r   t h e   s p e c i f i e d   d e l a y 
 	 	 	 	 i f   ( o b . h o v e r I n t e n t _ s   = =   1 )   {   o b . h o v e r I n t e n t _ t   =   s e t T i m e o u t (   f u n c t i o n ( ) { d e l a y ( e v , o b ) ; }   ,   c f g . t i m e o u t   ) ; } 
 	 	 	 } 
 	 	 } ; 
 
 	 	 / /   b i n d   t h e   f u n c t i o n   t o   t h e   t w o   e v e n t   l i s t e n e r s 
 	 	 r e t u r n   t h i s . m o u s e o v e r ( h a n d l e H o v e r ) . m o u s e o u t ( h a n d l e H o v e r ) ; 
 	 } ; 
 } ) ( j Q u e r y ) ; 
 
 / / E n d   H o v e r I n t e n t 
 
 / / S t a r t   C l u e T i p 
 
 / * 
   *   j Q u e r y   c l u e T i p   p l u g i n 
   *   V e r s i o n   0 . 9 . 8     ( 0 5 / 2 2 / 2 0 0 8 ) 
   *   @ r e q u i r e s   j Q u e r y   v 1 . 1 . 4 + 
   *   @ r e q u i r e s   D i m e n s i o n s   p l u g i n   ( f o r   j Q u e r y   v e r s i o n s   <   1 . 2 . 5 ) 
   * 
   *   D u a l   l i c e n s e d   u n d e r   t h e   M I T   a n d   G P L   l i c e n s e s : 
   *   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 
   *   h t t p : / / w w w . g n u . o r g / l i c e n s e s / g p l . h t m l 
   * 
   * / 
 ; ( f u n c t i o n ( $ )   {   
 / * 
   *   @ n a m e   c l u e T i p 
   *   @ t y p e   j Q u e r y 
   *   @ c a t   P l u g i n s / t o o l t i p 
   *   @ r e t u r n   j Q u e r y 
   *   @ a u t h o r   K a r l   S w e d b e r g 
   * 
   *   @ c r e d i t   I n s p i r e d   b y   C o d y   L i n d l e y ' s   j T i p   ( h t t p : / / w w w . c o d y l i n d l e y . c o m ) 
   *   @ c r e d i t   T h a n k s   t o   t h e   f o l l o w i n g   p e o p l e   f o r   t h e i r   m a n y   a n d   v a r i e d   c o n t r i b u t i o n s : 
             S h e l a n e   E n o s ,   G l e n   L i p k a ,   H e c t o r   S a n t o s ,   T o r b e n   S c h r e i t e r ,   D a n   G .   S w i t z e r ,   J ar n   Z a e f f e r e r   
   *   @ c r e d i t   T h a n k s   t o   J o n a t h a n   C h a f f e r ,   a s   a l w a y s ,   f o r   h e l p   w i t h   t h e   h a r d   p a r t s .   : - ) 
   * / 
 
   / * * 
   *   
   *   D i s p l a y s   a   h i g h l y   c u s t o m i z a b l e   t o o l t i p   w h e n   t h e   u s e r   h o v e r s   ( d e f a u l t )   o r   c l i c k s   ( o p t i o n a l )   t h e   m a t c h e d   e l e m e n t .   
   *   B y   d e f a u l t ,   t h e   c l u e T i p   p l u g i n   l o a d s   a   p a g e   i n d i c a t e d   b y   t h e   " r e l "   a t t r i b u t e   v i a   a j a x   a n d   d i s p l a y s   i t s   c o n t e n t s . 
   *   I f   a   " t i t l e "   a t t r i b u t e   i s   s p e c i f i e d ,   i t s   v a l u e   i s   u s e d   a s   t h e   c l u e T i p ' s   h e a d i n g . 
   *   T h e   a t t r i b u t e   t o   b e   u s e d   f o r   b o t h   t h e   b o d y   a n d   t h e   h e a d i n g   o f   t h e   c l u e T i p   i s   u s e r - c o n f i g u r a b l e .   
   *   O p t i o n a l l y ,   t h e   c l u e T i p ' s   b o d y   c a n   d i s p l a y   c o n t e n t   f r o m   a n   e l e m e n t   o n   t h e   s a m e   p a g e . 
   *   *   J u s t   i n d i c a t e   t h e   e l e m e n t ' s   i d   ( e . g .   " # s o m e - i d " )   i n   t h e   r e l   a t t r i b u t e . 
   *   O p t i o n a l l y ,   t h e   c l u e T i p ' s   b o d y   c a n   d i s p l a y   c o n t e n t   f r o m   t h e   t i t l e   a t t r i b u t e ,   w h e n   a   d e l i m i t e r   i s   i n d i c a t e d .   
   *   *   T h e   s t r i n g   b e f o r e   t h e   f i r s t   i n s t a n c e   o f   t h e   d e l i m i t e r   i s   s e t   a s   t h e   c l u e T i p ' s   h e a d i n g . 
   *   *   A l l   s u b s e q u e n t   s t r i n g s   a r e   w r a p p e d   i n   s e p a r a t e   D I V s   a n d   p l a c e d   i n   t h e   c l u e T i p ' s   b o d y . 
   *   T h e   c l u e T i p   p l u g i n   a l l o w s   f o r   m a n y ,   m a n y   m o r e   o p t i o n s .   P l e a s e e   s e e   t h e   e x a m p l e s   a n d   t h e   o p t i o n   d e s c r i p t i o n s   b e l o w . . . 
   *   
   *   
   *   @ e x a m p l e   $ ( ' # t i p ) . c l u e t i p ( ) ; 
   *   @ d e s c   T h i s   i s   t h e   m o s t   b a s i c   c l u e T i p .   I t   d i s p l a y s   a   2 7 5 p x - w i d e   c l u e T i p   o n   m o u s e o v e r   o f   t h e   e l e m e n t   w i t h   a n   I D   o f   " t i p . "   O n   m o u s e o u t   o f   t h e   e l e m e n t ,   t h e   c l u e T i p   i s   h i d d e n . 
   * 
   * 
   *   @ e x a m p l e   $ ( ' a . c l u e ' ) . c l u e t i p ( { 
   *     h o v e r C l a s s :   ' h i g h l i g h t ' , 
   *     s t i c k y :   t r u e , 
   *     c l o s e P o s i t i o n :   ' b o t t o m ' , 
   *     c l o s e T e x t :   ' < i m g   s r c = " c r o s s . p n g "   a l t = " c l o s e "   / > ' , 
   *     t r u n c a t e :   6 0 , 
   *     a j a x S e t t i n g s :   { 
   *         t y p e :   ' P O S T ' 
   *     } 
   *   } ) ; 
   *   @ d e s c   D i s p l a y s   a   c l u e T i p   o n   m o u s e o v e r   o f   a l l   < a >   e l e m e n t s   w i t h   c l a s s = " c l u e " .   T h e   h o v e r e d   e l e m e n t   g e t s   a   c l a s s   o f   " h i g h l i g h t "   a d d e d   t o   i t   ( s o   t h a t   i t   c a n   b e   s t y l e d   a p p r o p r i a t e l y .   T h i s   i s   e s p .   u s e f u l   f o r   n o n - a n c h o r   e l e m e n t s . ) .   T h e   c l u e T i p   i s   " s t i c k y , "   w h i c h   m e a n s   t h a t   i t   w i l l   n o t   b e   h i d d e n   u n t i l   t h e   u s e r   e i t h e r   c l i c k s   o n   i t s   " c l o s e "   t e x t / g r a p h i c   o r   d i s p l a y s   a n o t h e r   c l u e T i p .   T h e   " c l o s e "   t e x t / g r a p h i c   i s   s e t   t o   d i p l a y   a t   t h e   b o t t o m   o f   t h e   c l u e T i p   ( d e f a u l t   i s   t o p )   a n d   d i s p l a y   a n   i m a g e   r a t h e r   t h a n   t h e   d e f a u l t   " C l o s e "   t e x t .   M o r e o v e r ,   t h e   b o d y   o f   t h e   c l u e T i p   i s   t r u n c a t e d   t o   t h e   f i r s t   6 0   c h a r a c t e r s ,   w h i c h   a r e   f o l l o w e d   b y   a n   e l l i p s i s   ( . . . ) .   F i n a l l y ,   t h e   c l u e T i p   r e t r i e v e s   t h e   c o n t e n t   u s i n g   P O S T   r a t h e r   t h a n   t h e   $ . a j a x   m e t h o d ' s   d e f a u l t   " G E T . " 
   *   
   *   M o r e   e x a m p l e s   c a n   b e   f o u n d   a t   h t t p : / / p l u g i n s . l e a r n i n g j q u e r y . c o m / c l u e t i p / d e m o / 
   *   
   *   F u l l   l i s t   o f   o p t i o n s / s e t t i n g s   c a n   b e   f o u n d   a t   t h e   b o t t o m   o f   t h i s   f i l e   a n d   a t   h t t p : / / p l u g i n s . l e a r n i n g j q u e r y . c o m / c l u e t i p / 
   * / 
 
     v a r   $ c l u e t i p ,   $ c l u e t i p I n n e r ,   $ c l u e t i p O u t e r ,   $ c l u e t i p T i t l e ,   $ c l u e t i p A r r o w s ,   $ d r o p S h a d o w ,   i m g C o u n t ; 
     $ . f n . c l u e t i p   =   f u n c t i o n ( j s ,   o p t i o n s )   { 
         i f   ( t y p e o f   j s   = =   ' o b j e c t ' )   { 
             o p t i o n s   =   j s ; 
             j s   =   n u l l ; 
         } 
         r e t u r n   t h i s . e a c h ( f u n c t i o n ( i n d e x )   { 
             v a r   $ t h i s   =   $ ( t h i s ) ;             
             
             / /   s u p p o r t   m e t a d a t a   p l u g i n   ( v 1 . 0   a n d   2 . 0 ) 
             v a r   o p t s   =   $ . e x t e n d ( f a l s e ,   { } ,   $ . f n . c l u e t i p . d e f a u l t s ,   o p t i o n s   | |   { } ,   $ . m e t a d a t a   ?   $ t h i s . m e t a d a t a ( )   :   $ . m e t a   ?   $ t h i s . d a t a ( )   :   { } ) ; 
 
             / /   s t a r t   o u t   w i t h   n o   c o n t e n t s   ( f o r   a j a x   a c t i v a t i o n ) 
             v a r   c l u e t i p C o n t e n t s   =   f a l s e ; 
             v a r   c l u e z I n d e x   =   p a r s e I n t ( o p t s . c l u e z I n d e x ,   1 0 ) - 1 ; 
             v a r   i s A c t i v e   =   f a l s e ,   c l o s e O n D e l a y   =   0 ; 
 
             / /   c r e a t e   t h e   c l u e t i p   d i v s 
             i f   ( ! $ ( ' # c l u e t i p ' ) . l e n g t h )   { 
                 $ c l u e t i p I n n e r   =   $ ( ' < d i v   i d = " c l u e t i p - i n n e r " > < / d i v > ' ) ; 
                 $ c l u e t i p T i t l e   =   $ ( ' < h 3   i d = " c l u e t i p - t i t l e " > < / h 3 > ' ) ;                 
                 $ c l u e t i p O u t e r   =   $ ( ' < d i v   i d = " c l u e t i p - o u t e r " > < / d i v > ' ) . a p p e n d ( $ c l u e t i p I n n e r ) . p r e p e n d ( $ c l u e t i p T i t l e ) ; 
                 $ c l u e t i p   =   $ ( ' < d i v   i d = " c l u e t i p " > < / d i v > ' ) . c s s ( { z I n d e x :   o p t s . c l u e z I n d e x } ) 
                 . a p p e n d ( $ c l u e t i p O u t e r ) . a p p e n d ( ' < d i v   i d = " c l u e t i p - e x t r a " > < / d i v > ' ) [ i n s e r t i o n T y p e ] ( i n s e r t i o n E l e m e n t ) . h i d e ( ) ; 
                 $ ( ' < d i v   i d = " c l u e t i p - w a i t i m a g e " > < / d i v > ' ) . c s s ( { p o s i t i o n :   ' a b s o l u t e ' ,   z I n d e x :   c l u e z I n d e x - 1 } ) 
                 . i n s e r t B e f o r e ( ' # c l u e t i p ' ) . h i d e ( ) ; 
                 $ c l u e t i p . c s s ( { p o s i t i o n :   ' a b s o l u t e ' ,   z I n d e x :   c l u e z I n d e x } ) ; 
                 $ c l u e t i p O u t e r . c s s ( { p o s i t i o n :   ' r e l a t i v e ' ,   z I n d e x :   c l u e z I n d e x + 1 } ) ; 
                 $ c l u e t i p A r r o w s   =   $ ( ' < d i v   i d = " c l u e t i p - a r r o w s "   c l a s s = " c l u e t i p - a r r o w s " > < / d i v > ' ) . c s s ( { z I n d e x :   c l u e z I n d e x + 1 } ) . a p p e n d T o ( ' # c l u e t i p ' ) ; 
             } 
             v a r   d r o p S h a d o w S t e p s   =   ( o p t s . d r o p S h a d o w )   ?   + o p t s . d r o p S h a d o w S t e p s   :   0 ; 
             i f   ( ! $ d r o p S h a d o w )   { 
                 $ d r o p S h a d o w   =   $ ( [ ] ) ; 
                 f o r   ( v a r   i = 0 ;   i   <   d r o p S h a d o w S t e p s ;   i + + )   { 
                     $ d r o p S h a d o w   =   $ d r o p S h a d o w . a d d ( $ ( ' < d i v > < / d i v > ' ) . c s s ( { z I n d e x :   c l u e z I n d e x - i - 1 ,   o p a c i t y : . 1 ,   t o p :   1 + i ,   l e f t :   1 + i } ) ) ; 
                 } ; 
                 $ d r o p S h a d o w . c s s ( { p o s i t i o n :   ' a b s o l u t e ' ,   b a c k g r o u n d C o l o r :   ' # 0 0 0 ' } ) 
                 . p r e p e n d T o ( $ c l u e t i p ) ; 
             } 
             v a r   t i p A t t r i b u t e   =   $ t h i s . a t t r ( o p t s . a t t r i b u t e ) ,   c t C l a s s   =   o p t s . c l u e t i p C l a s s ; 
             i f   ( ! t i p A t t r i b u t e   & &   ! o p t s . s p l i t T i t l e   & &   ! j s )   r e t u r n   t r u e ; 
             / /   i f   h i d e L o c a l   i s   s e t   t o   t r u e ,   o n   D O M   r e a d y   h i d e   t h e   l o c a l   c o n t e n t   t h a t   w i l l   b e   d i s p l a y e d   i n   t h e   c l u e T i p             
             i f   ( o p t s . l o c a l   & &   o p t s . h i d e L o c a l )   {   $ ( t i p A t t r i b u t e   +   ' : f i r s t ' ) . h i d e ( ) ;   } 
             v a r   t O f f s e t   =   p a r s e I n t ( o p t s . t o p O f f s e t ,   1 0 ) ,   l O f f s e t   =   p a r s e I n t ( o p t s . l e f t O f f s e t ,   1 0 ) ; 
             / /   v e r t i c a l   m e a s u r e m e n t   v a r i a b l e s 
             v a r   t i p H e i g h t ,   w H e i g h t ; 
             v a r   d e f H e i g h t   =   i s N a N ( p a r s e I n t ( o p t s . h e i g h t ,   1 0 ) )   ?   ' a u t o '   :   ( / \ D / g ) . t e s t ( o p t s . h e i g h t )   ?   o p t s . h e i g h t   :   o p t s . h e i g h t   +   ' p x ' ; 
             v a r   s T o p ,   l i n k T o p ,   p o s Y ,   t i p Y ,   m o u s e Y ,   b a s e l i n e ; 
             / /   h o r i z o n t a l   m e a s u r e m e n t   v a r i a b l e s 
             v a r   t i p I n n e r W i d t h   =   i s N a N ( p a r s e I n t ( o p t s . w i d t h ,   1 0 ) )   ?   2 7 5   :   p a r s e I n t ( o p t s . w i d t h ,   1 0 ) ; 
             v a r   t i p W i d t h   =   t i p I n n e r W i d t h   +   ( p a r s e I n t ( $ c l u e t i p . c s s ( ' p a d d i n g L e f t ' ) ) | | 0 )   +   ( p a r s e I n t ( $ c l u e t i p . c s s ( ' p a d d i n g R i g h t ' ) ) | | 0 )   +   d r o p S h a d o w S t e p s ; 
             v a r   l i n k W i d t h   =   t h i s . o f f s e t W i d t h ; 
             v a r   l i n k L e f t ,   p o s X ,   t i p X ,   m o u s e X ,   w i n W i d t h ; 
                         
             / /   p a r s e   t h e   t i t l e 
             v a r   t i p P a r t s ; 
             v a r   t i p T i t l e   =   ( o p t s . a t t r i b u t e   ! =   ' t i t l e ' )   ?   $ t h i s . a t t r ( o p t s . t i t l e A t t r i b u t e )   :   ' ' ; 
             i f   ( o p t s . s p l i t T i t l e )   { 
                 i f ( t i p T i t l e   = =   u n d e f i n e d )   { t i p T i t l e   =   ' ' ; } 
                 t i p P a r t s   =   t i p T i t l e . s p l i t ( o p t s . s p l i t T i t l e ) ; 
                 t i p T i t l e   =   t i p P a r t s . s h i f t ( ) ; 
             } 
             v a r   l o c a l C o n t e n t ; 
 
 / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *             
 *   A C T I V A T I O N 
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / 
         
 / / a c t i v a t e   c l u e T i p 
         v a r   a c t i v a t e   =   f u n c t i o n ( e v e n t )   { 
             i f   ( ! o p t s . o n A c t i v a t e ( $ t h i s ) )   { 
                 r e t u r n   f a l s e ; 
             } 
             i s A c t i v e   =   t r u e ; 
             $ c l u e t i p . r e m o v e C l a s s ( ) . c s s ( { w i d t h :   t i p I n n e r W i d t h } ) ; 
             i f   ( t i p A t t r i b u t e   = =   $ t h i s . a t t r ( ' h r e f ' ) )   { 
                 $ t h i s . c s s ( ' c u r s o r ' ,   o p t s . c u r s o r ) ; 
             } 
             $ t h i s . a t t r ( ' t i t l e ' , ' ' ) ; 
             i f   ( o p t s . h o v e r C l a s s )   { 
                 $ t h i s . a d d C l a s s ( o p t s . h o v e r C l a s s ) ; 
             } 
             l i n k T o p   =   p o s Y   =   $ t h i s . o f f s e t ( ) . t o p ; 
             l i n k L e f t   =   $ t h i s . o f f s e t ( ) . l e f t ; 
             m o u s e X   =   e v e n t . p a g e X ; 
             m o u s e Y   =   e v e n t . p a g e Y ; 
             i f   ( $ t h i s [ 0 ] . t a g N a m e . t o L o w e r C a s e ( )   ! =   ' a r e a ' )   { 
                 s T o p   =   $ ( d o c u m e n t ) . s c r o l l T o p ( ) ; 
                 w i n W i d t h   =   $ ( w i n d o w ) . w i d t h ( ) ; 
             } 
 / /   p o s i t i o n   c l u e T i p   h o r i z o n t a l l y 
             i f   ( o p t s . p o s i t i o n B y   = =   ' f i x e d ' )   { 
                 p o s X   =   l i n k W i d t h   +   l i n k L e f t   +   l O f f s e t ; 
                 $ c l u e t i p . c s s ( { l e f t :   p o s X } ) ; 
             }   e l s e   { 
                 p o s X   =   ( l i n k W i d t h   >   l i n k L e f t   & &   l i n k L e f t   >   t i p W i d t h ) 
                     | |   l i n k L e f t   +   l i n k W i d t h   +   t i p W i d t h   +   l O f f s e t   >   w i n W i d t h   
                     ?   l i n k L e f t   -   t i p W i d t h   -   l O f f s e t   
                     :   l i n k W i d t h   +   l i n k L e f t   +   l O f f s e t ; 
                 i f   ( $ t h i s [ 0 ] . t a g N a m e . t o L o w e r C a s e ( )   = =   ' a r e a '   | |   o p t s . p o s i t i o n B y   = =   ' m o u s e '   | |   l i n k W i d t h   +   t i p W i d t h   >   w i n W i d t h )   {   / /   p o s i t i o n   b y   m o u s e 
                     i f   ( m o u s e X   +   2 0   +   t i p W i d t h   >   w i n W i d t h )   {     
                         $ c l u e t i p . a d d C l a s s ( '   c l u e t i p - '   +   c t C l a s s ) ; 
                         p o s X   =   ( m o u s e X   -   t i p W i d t h   -   l O f f s e t )   > =   0   ?   m o u s e X   -   t i p W i d t h   -   l O f f s e t   -   p a r s e I n t ( $ c l u e t i p . c s s ( ' m a r g i n L e f t ' ) , 1 0 )   +   p a r s e I n t ( $ c l u e t i p I n n e r . c s s ( ' m a r g i n R i g h t ' ) , 1 0 )   :     m o u s e X   -   ( t i p W i d t h / 2 ) ; 
                     }   e l s e   { 
                         p o s X   =   m o u s e X   +   l O f f s e t ; 
                     } 
                 } 
                 v a r   p Y   =   p o s X   <   0   ?   e v e n t . p a g e Y   +   t O f f s e t   :   e v e n t . p a g e Y ; 
                 $ c l u e t i p . c s s ( { l e f t :   ( p o s X   >   0   & &   o p t s . p o s i t i o n B y   ! =   ' b o t t o m T o p ' )   ?   p o s X   :   ( m o u s e X   +   ( t i p W i d t h / 2 )   >   w i n W i d t h )   ?   w i n W i d t h / 2   -   t i p W i d t h / 2   :   M a t h . m a x ( m o u s e X   -   ( t i p W i d t h / 2 ) , 0 ) } ) ; 
             } 
                 w H e i g h t   =   $ ( w i n d o w ) . h e i g h t ( ) ; 
 
 / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
 *   l o a d   a   s t r i n g   f r o m   c l u e t i p   m e t h o d ' s   f i r s t   a r g u m e n t 
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / 
             i f   ( j s )   { 
                 $ c l u e t i p I n n e r . h t m l ( j s ) ; 
                 c l u e t i p S h o w ( p Y ) ; 
             } 
 / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
 *   l o a d   t h e   t i t l e   a t t r i b u t e   o n l y   ( o r   u s e r - s e l e c t e d   a t t r i b u t e ) .   
 *   c l u e T i p   t i t l e   i s   t h e   s t r i n g   b e f o r e   t h e   f i r s t   d e l i m i t e r 
 *   s u b s e q u e n t   d e l i m i t e r s   p l a c e   c l u e T i p   b o d y   t e x t   o n   s e p a r a t e   l i n e s 
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / 
 
             e l s e   i f   ( t i p P a r t s )   { 
                 v a r   t p l   =   t i p P a r t s . l e n g t h ; 
                 f o r   ( v a r   i = 0 ;   i   <   t p l ;   i + + ) { 
                     i f   ( i   = =   0 )   { 
                         $ c l u e t i p I n n e r . h t m l ( t i p P a r t s [ i ] ) ; 
                     }   e l s e   {   
                         $ c l u e t i p I n n e r . a p p e n d ( ' < d i v   c l a s s = " s p l i t - b o d y " > '   +   t i p P a r t s [ i ]   +   ' < / d i v > ' ) ; 
                     }                         
                 } ; 
                 c l u e t i p S h o w ( p Y ) ; 
             } 
 / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
 *   l o a d   e x t e r n a l   f i l e   v i a   a j a x                     
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / 
 
             e l s e   i f   ( ! o p t s . l o c a l   & &   t i p A t t r i b u t e . i n d e x O f ( ' # ' )   ! =   0 )   { 
                 i f   ( c l u e t i p C o n t e n t s   & &   o p t s . a j a x C a c h e )   { 
                     $ c l u e t i p I n n e r . h t m l ( c l u e t i p C o n t e n t s ) ; 
                     c l u e t i p S h o w ( p Y ) ; 
                 } 
                 e l s e   { 
                     v a r   a j a x S e t t i n g s   =   o p t s . a j a x S e t t i n g s ; 
                     a j a x S e t t i n g s . u r l   =   t i p A t t r i b u t e ; 
                     a j a x S e t t i n g s . b e f o r e S e n d   =   f u n c t i o n ( )   { 
                         $ c l u e t i p O u t e r . c h i l d r e n ( ) . e m p t y ( ) ; 
                         i f   ( o p t s . w a i t I m a g e )   { 
                             $ ( ' # c l u e t i p - w a i t i m a g e ' ) 
                             . c s s ( { t o p :   m o u s e Y + 2 0 ,   l e f t :   m o u s e X + 2 0 } ) 
                             . s h o w ( ) ; 
                         } 
                     } ; 
                   a j a x S e t t i n g s . e r r o r   =   f u n c t i o n ( )   { 
                         i f   ( i s A c t i v e )   { 
                             $ c l u e t i p I n n e r . h t m l ( ' < i > s o r r y ,   t h e   c o n t e n t s   c o u l d   n o t   b e   l o a d e d < / i > ' ) ; 
                         } 
                     } ; 
                     a j a x S e t t i n g s . s u c c e s s   =   f u n c t i o n ( d a t a )   { 
                         c l u e t i p C o n t e n t s   =   o p t s . a j a x P r o c e s s ( d a t a ) ; 
                         i f   ( i s A c t i v e )   { 
                             $ c l u e t i p I n n e r . h t m l ( c l u e t i p C o n t e n t s ) ; 
                         } 
                     } ; 
                     a j a x S e t t i n g s . c o m p l e t e   =   f u n c t i o n ( )   { 
                     	 i m g C o u n t   =   $ ( ' # c l u e t i p - i n n e r   i m g ' ) . l e n g t h ; 
                 	 	 i f   ( i m g C o u n t   & &   ! $ . b r o w s e r . o p e r a )   { 
                 	 	     $ ( ' # c l u e t i p - i n n e r   i m g ' ) . l o a d ( f u n c t i o n ( )   { 
                     	 	 	 i m g C o u n t - - ; 
                     	 	 	 i f   ( i m g C o u n t < 1 )   { 
                     	 	 	 	 $ ( ' # c l u e t i p - w a i t i m a g e ' ) . h i d e ( ) ; 
                     	 	 	     i f   ( i s A c t i v e )   c l u e t i p S h o w ( p Y ) ; 
                     	 	 	 } 
                 	 	     } ) ;   
                 	 	 }   e l s e   { 
             	 	 	 	 $ ( ' # c l u e t i p - w a i t i m a g e ' ) . h i d e ( ) ; 
                 	 	     i f   ( i s A c t i v e )   c l u e t i p S h o w ( p Y ) ;         
                 	 	 }   
                     } ; 
                     $ . a j a x ( a j a x S e t t i n g s ) ; 
                 } 
 
 / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
 *   l o a d   a n   e l e m e n t   f r o m   t h e   s a m e   p a g e 
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / 
             }   e l s e   i f   ( o p t s . l o c a l ) { 
                 v a r   $ l o c a l C o n t e n t   =   $ ( t i p A t t r i b u t e   +   ' : f i r s t ' ) ; 
                 v a r   l o c a l C l u e t i p   =   $ . f n . w r a p I n n e r   ?   $ l o c a l C o n t e n t . w r a p I n n e r ( ' < d i v > < / d i v > ' ) . c h i l d r e n ( ) . c l o n e ( t r u e )   :   $ l o c a l C o n t e n t . h t m l ( ) ; 
                 $ . f n . w r a p I n n e r   ?   $ c l u e t i p I n n e r . e m p t y ( ) . a p p e n d ( l o c a l C l u e t i p )   :   $ c l u e t i p I n n e r . h t m l ( l o c a l C l u e t i p ) ; 
                 c l u e t i p S h o w ( p Y ) ; 
             } 
         } ; 
 
 / /   g e t   d i m e n s i o n s   a n d   o p t i o n s   f o r   c l u e t i p   a n d   p r e p a r e   i t   t o   b e   s h o w n 
         v a r   c l u e t i p S h o w   =   f u n c t i o n ( b p Y )   { 
             $ c l u e t i p . a d d C l a s s ( ' c l u e t i p - '   +   c t C l a s s ) ; 
             
             i f   ( o p t s . t r u n c a t e )   {   
                 v a r   $ t r u n c l o a d e d   =   $ c l u e t i p I n n e r . t e x t ( ) . s l i c e ( 0 , o p t s . t r u n c a t e )   +   ' . . . ' ; 
                 $ c l u e t i p I n n e r . h t m l ( $ t r u n c l o a d e d ) ; 
             } 
             f u n c t i o n   d o N o t h i n g ( )   { } ;   / / e m p t y   f u n c t i o n 
             t i p T i t l e   ?   $ c l u e t i p T i t l e . s h o w ( ) . h t m l ( t i p T i t l e )   :   ( o p t s . s h o w T i t l e )   ?   $ c l u e t i p T i t l e . s h o w ( ) . h t m l ( ' & n b s p ; ' )   :   $ c l u e t i p T i t l e . h i d e ( ) ; 
             i f   ( o p t s . s t i c k y )   { 
                 v a r   $ c l o s e L i n k   =   $ ( ' < d i v   i d = " c l u e t i p - c l o s e " > < a   h r e f = " # " > '   +   o p t s . c l o s e T e x t   +   ' < / a > < / d i v > ' ) ; 
                 ( o p t s . c l o s e P o s i t i o n   = =   ' b o t t o m ' )   ?   $ c l o s e L i n k . a p p e n d T o ( $ c l u e t i p I n n e r )   :   ( o p t s . c l o s e P o s i t i o n   = =   ' t i t l e ' )   ?   $ c l o s e L i n k . p r e p e n d T o ( $ c l u e t i p T i t l e )   :   $ c l o s e L i n k . p r e p e n d T o ( $ c l u e t i p I n n e r ) ; 
                 $ c l o s e L i n k . c l i c k ( f u n c t i o n ( )   { 
                     c l u e t i p C l o s e ( ) ; 
                     r e t u r n   f a l s e ; 
                 } ) ; 
                 i f   ( o p t s . m o u s e O u t C l o s e )   { 
                     i f   ( $ . f n . h o v e r I n t e n t   & &   o p t s . h o v e r I n t e n t )   {   
                         $ c l u e t i p . h o v e r I n t e n t ( { 
                             o v e r :   d o N o t h i n g ,   
                             t i m e o u t :   o p t s . h o v e r I n t e n t . t i m e o u t ,     
                             o u t :   f u n c t i o n ( )   {   $ c l o s e L i n k . t r i g g e r ( ' c l i c k ' ) ;   } 
                         } ) ; 
                     }   e l s e   { 
                         $ c l u e t i p . h o v e r ( d o N o t h i n g ,   
                         f u n c t i o n ( )   { $ c l o s e L i n k . t r i g g e r ( ' c l i c k ' ) ;   } ) ; 
                     } 
                 }   e l s e   { 
                     $ c l u e t i p . u n b i n d ( ' m o u s e o u t ' ) ; 
                 } 
             } 
 / /   n o w   t h a t   c o n t e n t   i s   l o a d e d ,   f i n i s h   t h e   p o s i t i o n i n g   
             v a r   d i r e c t i o n   =   ' ' ; 
             $ c l u e t i p O u t e r . c s s ( { o v e r f l o w :   d e f H e i g h t   = =   ' a u t o '   ?   ' v i s i b l e '   :   ' a u t o ' ,   h e i g h t :   d e f H e i g h t } ) ; 
             t i p H e i g h t   =   d e f H e i g h t   = =   ' a u t o '   ?   M a t h . m a x ( $ c l u e t i p . o u t e r H e i g h t ( ) , $ c l u e t i p . h e i g h t ( ) )   :   p a r s e I n t ( d e f H e i g h t , 1 0 ) ;       
             t i p Y   =   p o s Y ; 
             b a s e l i n e   =   s T o p   +   w H e i g h t ; 
             i f   ( o p t s . p o s i t i o n B y   = =   ' f i x e d ' )   { 
                 t i p Y   =   p o s Y   -   o p t s . d r o p S h a d o w S t e p s   +   t O f f s e t ; 
             }   e l s e   i f   (   ( p o s X   <   m o u s e X   & &   M a t h . m a x ( p o s X ,   0 )   +   t i p W i d t h   >   m o u s e X )   | |   o p t s . p o s i t i o n B y   = =   ' b o t t o m T o p ' )   { 
                 i f   ( p o s Y   +   t i p H e i g h t   +   t O f f s e t   >   b a s e l i n e   & &   m o u s e Y   -   s T o p   >   t i p H e i g h t   +   t O f f s e t )   {   
                     t i p Y   =   m o u s e Y   -   t i p H e i g h t   -   t O f f s e t ; 
                     d i r e c t i o n   =   ' t o p ' ; 
                 }   e l s e   {   
                     t i p Y   =   m o u s e Y   +   t O f f s e t ; 
                     d i r e c t i o n   =   ' b o t t o m ' ; 
                 } 
             }   e l s e   i f   (   p o s Y   +   t i p H e i g h t   +   t O f f s e t   >   b a s e l i n e   )   { 
                 t i p Y   =   ( t i p H e i g h t   > =   w H e i g h t )   ?   s T o p   :   b a s e l i n e   -   t i p H e i g h t   -   t O f f s e t ; 
             }   e l s e   i f   ( $ t h i s . c s s ( ' d i s p l a y ' )   = =   ' b l o c k '   | |   $ t h i s [ 0 ] . t a g N a m e . t o L o w e r C a s e ( )   = =   ' a r e a '   | |   o p t s . p o s i t i o n B y   = =   " m o u s e " )   { 
                 t i p Y   =   b p Y   -   t O f f s e t ; 
             }   e l s e   { 
                 t i p Y   =   p o s Y   -   o p t s . d r o p S h a d o w S t e p s ; 
             } 
             i f   ( d i r e c t i o n   = =   ' ' )   { 
                 p o s X   <   l i n k L e f t   ?   d i r e c t i o n   =   ' l e f t '   :   d i r e c t i o n   =   ' r i g h t ' ; 
             } 
             $ c l u e t i p . c s s ( { t o p :   t i p Y   +   ' p x ' } ) . r e m o v e C l a s s ( ) . a d d C l a s s ( ' c l u e - '   +   d i r e c t i o n   +   ' - '   +   c t C l a s s ) . a d d C l a s s ( '   c l u e t i p - '   +   c t C l a s s ) ; 
             i f   ( o p t s . a r r o w s )   {   / /   s e t   u p   a r r o w   p o s i t i o n i n g   t o   a l i g n   w i t h   e l e m e n t 
                 v a r   b g Y   =   ( p o s Y   -   t i p Y   -   o p t s . d r o p S h a d o w S t e p s ) ; 
                 $ c l u e t i p A r r o w s . c s s ( { t o p :   ( / ( l e f t | r i g h t ) / . t e s t ( d i r e c t i o n )   & &   p o s X   > = 0   & &   b g Y   >   0 )   ?   b g Y   +   ' p x '   :   / ( l e f t | r i g h t ) / . t e s t ( d i r e c t i o n )   ?   0   :   ' ' } ) . s h o w ( ) ; 
             }   e l s e   { 
                 $ c l u e t i p A r r o w s . h i d e ( ) ; 
             } 
 
 / /   ( f i r s t   h i d e ,   t h e n )   * * * S H O W   T H E   C L U E T I P * * * 
             $ d r o p S h a d o w . h i d e ( ) ; 
             $ c l u e t i p . h i d e ( ) [ o p t s . f x . o p e n ] ( o p t s . f x . o p e n   ! =   ' s h o w '   & &   o p t s . f x . o p e n S p e e d ) ; 
             i f   ( o p t s . d r o p S h a d o w )   $ d r o p S h a d o w . c s s ( { h e i g h t :   t i p H e i g h t ,   w i d t h :   t i p I n n e r W i d t h } ) . s h o w ( ) ; 
             i f   ( $ . f n . b g i f r a m e )   {   $ c l u e t i p . b g i f r a m e ( ) ;   } 
             / /   t r i g g e r   t h e   o p t i o n a l   o n S h o w   f u n c t i o n 
             i f   ( o p t s . d e l a y e d C l o s e   >   0 )   { 
                 c l o s e O n D e l a y   =   s e t T i m e o u t ( c l u e t i p C l o s e ,   o p t s . d e l a y e d C l o s e ) ; 
             } 
             o p t s . o n S h o w ( $ c l u e t i p ,   $ c l u e t i p I n n e r ) ; 
             
         } ; 
 
 / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
       = I N A C T I V A T I O N 
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   * / 
         v a r   i n a c t i v a t e   =   f u n c t i o n ( )   { 
             i s A c t i v e   =   f a l s e ; 
             $ ( ' # c l u e t i p - w a i t i m a g e ' ) . h i d e ( ) ; 
             i f   ( ! o p t s . s t i c k y   | |   ( / c l i c k | t o g g l e / ) . t e s t ( o p t s . a c t i v a t i o n )   )   { 
                 c l u e t i p C l o s e ( ) ; 
 c l e a r T i m e o u t ( c l o s e O n D e l a y ) ;                 
             } ; 
             i f   ( o p t s . h o v e r C l a s s )   { 
                 $ t h i s . r e m o v e C l a s s ( o p t s . h o v e r C l a s s ) ; 
             } 
             $ ( ' . c l u e t i p - c l i c k e d ' ) . r e m o v e C l a s s ( ' c l u e t i p - c l i c k e d ' ) ; 
         } ; 
 / /   c l o s e   c l u e t i p   a n d   r e s e t   s o m e   t h i n g s 
         v a r   c l u e t i p C l o s e   =   f u n c t i o n ( )   { 
             $ c l u e t i p O u t e r   
             . p a r e n t ( ) . h i d e ( ) . r e m o v e C l a s s ( ) . e n d ( ) 
             . c h i l d r e n ( ) . e m p t y ( ) ; 
             i f   ( t i p T i t l e )   { 
                 $ t h i s . a t t r ( o p t s . t i t l e A t t r i b u t e ,   t i p T i t l e ) ; 
             } 
             $ t h i s . c s s ( ' c u r s o r ' , ' ' ) ; 
             i f   ( o p t s . a r r o w s )   $ c l u e t i p A r r o w s . c s s ( { t o p :   ' ' } ) ; 
         } ; 
 
 / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
       = B I N D   E V E N T S 
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   * / 
     / /   a c t i v a t e   b y   c l i c k 
             i f   (   ( / c l i c k | t o g g l e / ) . t e s t ( o p t s . a c t i v a t i o n )   )   { 
                 $ t h i s . c l i c k ( f u n c t i o n ( e v e n t )   { 
                     i f   ( $ c l u e t i p . i s ( ' : h i d d e n ' )   | |   ! $ t h i s . i s ( ' . c l u e t i p - c l i c k e d ' ) )   { 
                         a c t i v a t e ( e v e n t ) ; 
                         $ ( ' . c l u e t i p - c l i c k e d ' ) . r e m o v e C l a s s ( ' c l u e t i p - c l i c k e d ' ) ; 
                         $ t h i s . a d d C l a s s ( ' c l u e t i p - c l i c k e d ' ) ; 
 
                     }   e l s e   { 
                         i n a c t i v a t e ( e v e n t ) ; 
 
                     } 
                     t h i s . b l u r ( ) ; 
                     r e t u r n   f a l s e ; 
                 } ) ; 
     / /   a c t i v a t e   b y   f o c u s ;   i n a c t i v a t e   b y   b l u r         
             }   e l s e   i f   ( o p t s . a c t i v a t i o n   = =   ' f o c u s ' )   { 
                 $ t h i s . f o c u s ( f u n c t i o n ( e v e n t )   { 
                     a c t i v a t e ( e v e n t ) ; 
                 } ) ; 
                 $ t h i s . b l u r ( f u n c t i o n ( e v e n t )   { 
                     i n a c t i v a t e ( e v e n t ) ; 
                 } ) ; 
     / /   a c t i v a t e   b y   h o v e r 
         / /   c l i c k i n g   i s   r e t u r n e d   f a l s e   i f   c l u e t i p   u r l   i s   s a m e   a s   h r e f   u r l 
             }   e l s e   { 
                 $ t h i s . c l i c k ( f u n c t i o n ( )   { 
                     i f   ( $ t h i s . a t t r ( ' h r e f ' )   & &   $ t h i s . a t t r ( ' h r e f ' )   = =   t i p A t t r i b u t e   & &   ! o p t s . c l i c k T h r o u g h )   { 
                         r e t u r n   f a l s e ; 
                     } 
                 } ) ; 
                 / / s e t   u p   m o u s e   t r a c k i n g 
                 v a r   m o u s e T r a c k s   =   f u n c t i o n ( e v t )   { 
                     i f   ( o p t s . t r a c k i n g   = =   t r u e )   { 
                         v a r   t r a c k X   =   p o s X   -   e v t . p a g e X ; 
                         v a r   t r a c k Y   =   t i p Y   ?   t i p Y   -   e v t . p a g e Y   :   p o s Y   -   e v t . p a g e Y ; 
                         $ t h i s . m o u s e m o v e ( f u n c t i o n ( e v t )   { 
                             $ c l u e t i p . c s s ( { l e f t :   e v t . p a g e X   +   t r a c k X ,   t o p :   e v t . p a g e Y   +   t r a c k Y   } ) ; 
                         } ) ; 
                     } 
                 } ; 
                 i f   ( $ . f n . h o v e r I n t e n t   & &   o p t s . h o v e r I n t e n t )   { 
                     $ t h i s . m o u s e o v e r ( f u n c t i o n ( )   { $ t h i s . a t t r ( ' t i t l e ' , ' ' ) ;   } ) 
                     . h o v e r I n t e n t ( { 
                         s e n s i t i v i t y :   o p t s . h o v e r I n t e n t . s e n s i t i v i t y , 
                         i n t e r v a l :   o p t s . h o v e r I n t e n t . i n t e r v a l ,     
                         o v e r :   f u n c t i o n ( e v e n t )   { 
                             a c t i v a t e ( e v e n t ) ; 
                             m o u s e T r a c k s ( e v e n t ) ; 
                         } ,   
                         t i m e o u t :   o p t s . h o v e r I n t e n t . t i m e o u t ,     
                         o u t :   f u n c t i o n ( e v e n t )   { i n a c t i v a t e ( e v e n t ) ;   $ t h i s . u n b i n d ( ' m o u s e m o v e ' ) ; } 
                     } ) ;                       
                 }   e l s e   { 
                     $ t h i s . h o v e r ( f u n c t i o n ( e v e n t )   { 
                         a c t i v a t e ( e v e n t ) ; 
                         m o u s e T r a c k s ( e v e n t ) ; 
                     } ,   f u n c t i o n ( e v e n t )   { 
                         i n a c t i v a t e ( e v e n t ) ; 
                         $ t h i s . u n b i n d ( ' m o u s e m o v e ' ) ; 
                     } ) ; 
                 } 
             } 
         } ) ; 
     } ; 
     
 / * 
   *   o p t i o n s   f o r   c l u e T i p 
   * 
   *   e a c h   o n e   c a n   b e   e x p l i c i t l y   o v e r r i d d e n   b y   c h a n g i n g   i t s   v a l u e .   
   *   f o r   e x a m p l e :   $ . f n . c l u e t i p . d e f a u l t s . w i d t h   =   2 0 0 ;   
   *   w o u l d   c h a n g e   t h e   d e f a u l t   w i d t h   f o r   a l l   c l u e T i p s   t o   2 0 0 .   
   * 
   *   e a c h   o n e   c a n   a l s o   b e   o v e r r i d d e n   b y   p a s s i n g   a n   o p t i o n s   m a p   t o   t h e   c l u e t i p   m e t h o d . 
   *   f o r   e x a m p l e :   $ ( ' a . e x a m p l e ' ) . c l u e t i p ( { w i d t h :   2 0 0 } ) ;   
   *   w o u l d   c h a n g e   t h e   d e f a u l t   w i d t h   t o   2 0 0   f o r   c l u e T i p s   i n v o k e d   b y   a   l i n k   w i t h   c l a s s   o f   " e x a m p l e " 
   * 
   * / 
     
     $ . f n . c l u e t i p . d e f a u l t s   =   {     / /   s e t   u p   d e f a u l t   o p t i o n s 
         w i d t h :                         2 7 5 ,             / /   T h e   w i d t h   o f   t h e   c l u e T i p 
         h e i g h t :                       ' a u t o ' ,       / /   T h e   h e i g h t   o f   t h e   c l u e T i p 
         c l u e z I n d e x :               9 7 ,               / /   S e t s   t h e   z - i n d e x   s t y l e   p r o p e r t y   o f   t h e   c l u e T i p 
         p o s i t i o n B y :               ' a u t o ' ,       / /   S e t s   t h e   t y p e   o f   p o s i t i o n i n g :   ' a u t o ' ,   ' m o u s e ' , ' b o t t o m T o p ' ,   ' f i x e d ' 
         t o p O f f s e t :                 1 5 ,               / /   N u m b e r   o f   p x   t o   o f f s e t   c l u e T i p   f r o m   t o p   o f   i n v o k i n g   e l e m e n t 
         l e f t O f f s e t :               1 5 ,               / /   N u m b e r   o f   p x   t o   o f f s e t   c l u e T i p   f r o m   l e f t   o f   i n v o k i n g   e l e m e n t 
         l o c a l :                         f a l s e ,         / /   W h e t h e r   t o   u s e   c o n t e n t   f r o m   t h e   s a m e   p a g e   f o r   t h e   c l u e T i p ' s   b o d y 
         h i d e L o c a l :                 t r u e ,           / /   I f   l o c a l   o p t i o n   i s   s e t   t o   t r u e ,   t h i s   d e t e r m i n e s   w h e t h e r   l o c a l   c o n t e n t 
                                                                 / /   t o   b e   s h o w n   i n   c l u e T i p   s h o u l d   b e   h i d d e n   a t   i t s   o r i g i n a l   l o c a t i o n 
         a t t r i b u t e :                 ' r e l ' ,         / /   t h e   a t t r i b u t e   t o   b e   u s e d   f o r   f e t c h i n g   t h e   c l u e T i p ' s   b o d y   c o n t e n t 
         t i t l e A t t r i b u t e :       ' t i t l e ' ,     / /   t h e   a t t r i b u t e   t o   b e   u s e d   f o r   f e t c h i n g   t h e   c l u e T i p ' s   t i t l e 
         s p l i t T i t l e :               ' ' ,               / /   A   c h a r a c t e r   u s e d   t o   s p l i t   t h e   t i t l e   a t t r i b u t e   i n t o   t h e   c l u e T i p   t i t l e   a n d   d i v s 
                                                                 / /   w i t h i n   t h e   c l u e T i p   b o d y .   m o r e   i n f o   b e l o w   [ 6 ] 
         s h o w T i t l e :                 t r u e ,           / /   s h o w   t i t l e   b a r   o f   t h e   c l u e T i p ,   e v e n   i f   t i t l e   a t t r i b u t e   n o t   s e t 
         c l u e t i p C l a s s :           ' j t i p ' , / /   c l a s s   a d d e d   t o   o u t e r m o s t   c l u e T i p   d i v   i n   t h e   f o r m   o f   ' c l u e t i p - '   +   c l u e T i p C l a s s . 
         h o v e r C l a s s :               ' ' ,               / /   c l a s s   a p p l i e d   t o   t h e   i n v o k i n g   e l e m e n t   o n m o u s e o v e r   a n d   r e m o v e d   o n m o u s e o u t 
         w a i t I m a g e :                 t r u e ,           / /   w h e t h e r   t o   s h o w   a   " l o a d i n g "   i m g ,   w h i c h   i s   s e t   i n   j q u e r y . c l u e t i p . c s s 
         c u r s o r :                       ' h e l p ' , 
         a r r o w s :                       f a l s e ,         / /   i f   t r u e ,   d i s p l a y s   a r r o w   o n   a p p r o p r i a t e   s i d e   o f   c l u e T i p 
         d r o p S h a d o w :               t r u e ,           / /   s e t   t o   f a l s e   i f   y o u   d o n ' t   w a n t   t h e   d r o p - s h a d o w   e f f e c t   o n   t h e   c l u e T i p 
         d r o p S h a d o w S t e p s :     6 ,                 / /   a d j u s t s   t h e   s i z e   o f   t h e   d r o p   s h a d o w 
         s t i c k y :                       f a l s e ,         / /   k e e p   v i s i b l e   u n t i l   m a n u a l l y   c l o s e d 
         m o u s e O u t C l o s e :         f a l s e ,         / /   c l o s e   w h e n   c l u e T i p   i s   m o u s e d   o u t 
         a c t i v a t i o n :               ' h o v e r ' ,     / /   s e t   t o   ' c l i c k '   t o   f o r c e   u s e r   t o   c l i c k   t o   s h o w   c l u e T i p 
                                                                 / /   s e t   t o   ' f o c u s '   t o   s h o w   o n   f o c u s   o f   a   f o r m   e l e m e n t   a n d   h i d e   o n   b l u r 
         c l i c k T h r o u g h :           f a l s e ,         / /   i f   t r u e ,   a n d   a c t i v a t i o n   i s   n o t   ' c l i c k ' ,   t h e n   c l i c k i n g   o n   l i n k   w i l l   t a k e   u s e r   t o   t h e   l i n k ' s   h r e f , 
                                                                 / /   e v e n   i f   h r e f   a n d   t i p A t t r i b u t e   a r e   e q u a l 
         t r a c k i n g :                   f a l s e ,         / /   i f   t r u e ,   c l u e T i p   w i l l   t r a c k   m o u s e   m o v e m e n t   ( e x p e r i m e n t a l ) 
         d e l a y e d C l o s e :           0 ,                 / /   c l o s e   c l u e T i p   o n   a   t i m e d   d e l a y   ( e x p e r i m e n t a l ) 
         c l o s e P o s i t i o n :         ' t o p ' ,         / /   l o c a t i o n   o f   c l o s e   t e x t   f o r   s t i c k y   c l u e t i p s ;   c a n   b e   ' t o p '   o r   ' b o t t o m '   o r   ' t i t l e ' 
         c l o s e T e x t :                 ' C l o s e ' ,     / /   t e x t   ( o r   H T M L )   t o   t o   b e   c l i c k e d   t o   c l o s e   s t i c k y   c l u e T i p s 
         t r u n c a t e :                   0 ,                 / /   n u m b e r   o f   c h a r a c t e r s   t o   t r u n c a t e   c l u e T i p ' s   c o n t e n t s .   i f   0 ,   n o   t r u n c a t i o n   o c c u r s 
 
         / /   e f f e c t   a n d   s p e e d   f o r   o p e n i n g   c l u e T i p s 
         f x :   {                           
                                             o p e n :               ' s h o w ' ,   / /   c a n   b e   ' s h o w '   o r   ' s l i d e D o w n '   o r   ' f a d e I n ' 
                                             o p e n S p e e d :     ' ' 
         } ,           
 
         / /   s e t t i n g s   f o r   w h e n   h o v e r I n t e n t   p l u g i n   i s   u s e d                           
         h o v e r I n t e n t :   {         
                                             s e n s i t i v i t y :     3 , 
                             	 	 	     i n t e r v a l :           5 0 , 
                             	 	 	     t i m e o u t :             0 
         } , 
 
         / /   f u n c t i o n   t o   r u n   j u s t   b e f o r e   c l u e T i p   i s   s h o w n .                       
         o n A c t i v a t e :               f u n c t i o n ( e )   { r e t u r n   t r u e ; } , 
 
         / /   f u n c t i o n   t o   r u n   j u s t   a f t e r   c l u e T i p   i s   s h o w n . 
         o n S h o w :                       f u n c t i o n ( c t ,   c ) { } , 
         
         / /   w h e t h e r   t o   c a c h e   r e s u l t s   o f   a j a x   r e q u e s t   t o   a v o i d   u n n e c e s s a r y   h i t s   t o   s e r v e r         
         a j a x C a c h e :                 t r u e ,     
 
         / /   p r o c e s s   d a t a   r e t r i e v e d   v i a   x h r   b e f o r e   i t ' s   d i s p l a y e d 
         a j a x P r o c e s s :             f u n c t i o n ( d a t a )   { 
                                                 d a t a   =   d a t a . r e p l a c e ( / < s ( c r i p t | t y l e ) ( . | \ s ) * ? \ / s ( c r i p t | t y l e ) > / g ,   ' ' ) . r e p l a c e ( / < ( l i n k | t i t l e ) ( . | \ s ) * ? \ / ( l i n k | t i t l e ) > / g , ' ' ) ; 
                                                 r e t u r n   d a t a ; 
         } ,                                 
 
         / /   c a n   p a s s   i n   s t a n d a r d   $ . a j a x ( )   p a r a m e t e r s ,   n o t   i n c l u d i n g   e r r o r ,   c o m p l e t e ,   s u c c e s s ,   a n d   u r l 
         a j a x S e t t i n g s :   {       
                                             d a t a T y p e :   ' h t m l ' 
         } , 
         d e b u g :   f a l s e 
     } ; 
 
 
 / * 
   *   G l o b a l   d e f a u l t s   f o r   c l u e T i p s .   A p p l y   t o   a l l   c a l l s   t o   t h e   c l u e T i p   p l u g i n . 
   * 
   *   @ e x a m p l e   $ . c l u e t i p . s e t u p ( { 
   *       i n s e r t i o n T y p e :   ' p r e p e n d T o ' , 
   *       i n s e r t i o n E l e m e n t :   ' # c o n t a i n e r ' 
   *   } ) ; 
   *   
   *   @ p r o p e r t y 
   *   @ n a m e   $ . c l u e t i p . s e t u p 
   *   @ t y p e   M a p 
   *   @ c a t   P l u g i n s / t o o l t i p 
   *   @ o p t i o n   S t r i n g   i n s e r t i o n T y p e :   D e f a u l t   i s   ' a p p e n d T o ' .   D e t e r m i n e s   t h e   m e t h o d   t o   b e   u s e d   f o r   i n s e r t i n g   t h e   c l u e T i p   i n t o   t h e   D O M .   P e r m i t t e d   v a l u e s   a r e   ' a p p e n d T o ' ,   ' p r e p e n d T o ' ,   ' i n s e r t B e f o r e ' ,   a n d   ' i n s e r t A f t e r ' 
   *   @ o p t i o n   S t r i n g   i n s e r t i o n E l e m e n t :   D e f a u l t   i s   ' b o d y ' .   D e t e r m i n e s   w h i c h   e l e m e n t   i n   t h e   D O M   t h e   p l u g i n   w i l l   r e f e r e n c e   w h e n   i n s e r t i n g   t h e   c l u e T i p . 
   * 
   * / 
       
     v a r   i n s e r t i o n T y p e   =   ' a p p e n d T o ' ,   i n s e r t i o n E l e m e n t   =   ' b o d y ' ; 
     $ . c l u e t i p   =   { } ; 
     $ . c l u e t i p . s e t u p   =   f u n c t i o n ( o p t i o n s )   { 
         i f   ( o p t i o n s   & &   o p t i o n s . i n s e r t i o n T y p e   & &   ( o p t i o n s . i n s e r t i o n T y p e ) . m a t c h ( / a p p e n d T o | p r e p e n d T o | i n s e r t B e f o r e | i n s e r t A f t e r / ) )   { 
             i n s e r t i o n T y p e   =   o p t i o n s . i n s e r t i o n T y p e ; 
         } 
         i f   ( o p t i o n s   & &   o p t i o n s . i n s e r t i o n E l e m e n t )   { 
             i n s e r t i o n E l e m e n t   =   o p t i o n s . i n s e r t i o n E l e m e n t ; 
         } 
     } ; 
     
 } ) ( j Q u e r y ) ; 
 
 / / E n d   C l u e T i p 
 
 / / S t a r t   C l u e t i p   s e t t i n g s 
 
 $ ( d o c u m e n t ) . r e a d y ( f u n c t i o n ( )   { 
 
 / /   $ . c l u e t i p . s e t u p ( { i n s e r t i o n T y p e :   ' i n s e r t B e f o r e ' ,   i n s e r t i o n E l e m e n t :   ' d i v : f i r s t ' } ) ; 
 
 / / d e f a u l t   t h e m e 
     $ ( ' a . C l u e ' ) . c l u e t i p ( {   
     s p l i t T i t l e :   ' | ' ,   
     p o s i t i o n B y :   ' m o u s e ' ,   
     s h o w T i t l e :   f a l s e , 
     t o p O f f s e t :   2 5 , 
     l e f t O f f s e t :   - 1 3 5 ,   
     d r o p S h a d o w :   f a l s e , 
     t r a c k i n g :   t r u e , 
     a r r o w s :   ' t r u e ' , 
     / /   c a n   b e   ' s h o w '   o r   ' s l i d e D o w n '   o r   ' f a d e I n ' 
     f x :   { o p e n : ' f a d e I n ' ,   o p e n S p e e d : ' 1 0 ' } , 
     h o v e r I n t e n t :   { s e n s i t i v i t y :     1 , 
                                 i n t e r v a l :           1 0 , 
                                 t i m e o u t :             0 } 
 } ) ; 
 
 } ) ; 
 
 / / E n d   o f   C l u e t i p   s e t t i n g s 
 
 / / S t a r t   C y c l e   ( c o r e   o n l y ) 
 
 / * 
   *   j Q u e r y   C y c l e   P l u g i n   ( c o r e   e n g i n e   o n l y ) 
   *   E x a m p l e s   a n d   d o c u m e n t a t i o n   a t :   h t t p : / / j q u e r y . m a l s u p . c o m / c y c l e / 
   *   C o p y r i g h t   ( c )   2 0 0 7 - 2 0 0 9   M .   A l s u p 
   *   V e r s i o n :   2 . 5 6   ( 0 3 - M A R - 2 0 0 9 ) 
   *   D u a l   l i c e n s e d   u n d e r   t h e   M I T   a n d   G P L   l i c e n s e s : 
   *   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 
   *   h t t p : / / w w w . g n u . o r g / l i c e n s e s / g p l . h t m l 
   *   R e q u i r e s :   j Q u e r y   v 1 . 2 . 3   o r   l a t e r 
   * 
   *   O r i g i n a l l y   b a s e d   o n   t h e   w o r k   o f : 
   * 	 1 )   M a t t   O a k e s   ( h t t p : / / p o r t f o l i o . g i z o n e . c o . u k / a p p l i c a t i o n s / s l i d e s h o w / ) 
   * 	 2 )   T o r s t e n   B a l d e s   ( h t t p : / / m e d i e n f r e u n d e . c o m / l a b / i n n e r f a d e / ) 
   * 	 3 )   B e n j a m i n   S t e r l i n g   ( h t t p : / / w w w . b e n j a m i n s t e r l i n g . c o m / e x p e r i m e n t s / j q S h u f f l e / ) 
   * / 
 ( f u n c t i o n ( $ ) { v a r   v e r = " 2 . 5 6 " ; i f ( $ . s u p p o r t = = u n d e f i n e d ) { $ . s u p p o r t = { o p a c i t y : ! ( $ . b r o w s e r . m s i e ) } ; } f u n c t i o n   l o g ( ) { i f ( w i n d o w . c o n s o l e & & w i n d o w . c o n s o l e . l o g ) { w i n d o w . c o n s o l e . l o g ( " [ c y c l e ]   " + A r r a y . p r o t o t y p e . j o i n . c a l l ( a r g u m e n t s , " " ) ) ; } } $ . f n . c y c l e = f u n c t i o n ( o p t i o n s , a r g 2 ) { i f ( t h i s . l e n g t h = = 0 & & o p t i o n s ! = " s t o p " ) { i f ( ! $ . i s R e a d y & & t h i s . s e l e c t o r ) { l o g ( " D O M   n o t   r e a d y ,   q u e u i n g   s l i d e s h o w " ) ; v a r   o = { s : t h i s . s e l e c t o r , c : t h i s . c o n t e x t } ; $ ( f u n c t i o n ( ) { $ ( o . s , o . c ) . c y c l e ( o p t i o n s , a r g 2 ) ; } ) ; r e t u r n   t h i s ; } l o g ( " t e r m i n a t i n g ;   z e r o   e l e m e n t s   f o u n d   b y   s e l e c t o r " + ( $ . i s R e a d y ? " " : "   ( D O M   n o t   r e a d y ) " ) ) ; r e t u r n   t h i s ; } r e t u r n   t h i s . e a c h ( f u n c t i o n ( ) { o p t i o n s = h a n d l e A r g u m e n t s ( t h i s , o p t i o n s , a r g 2 ) ; i f ( o p t i o n s = = = f a l s e ) { r e t u r n ; } i f ( t h i s . c y c l e T i m e o u t ) { c l e a r T i m e o u t ( t h i s . c y c l e T i m e o u t ) ; } t h i s . c y c l e T i m e o u t = t h i s . c y c l e P a u s e = 0 ; v a r   $ c o n t = $ ( t h i s ) ; v a r   $ s l i d e s = o p t i o n s . s l i d e E x p r ? $ ( o p t i o n s . s l i d e E x p r , t h i s ) : $ c o n t . c h i l d r e n ( ) ; v a r   e l s = $ s l i d e s . g e t ( ) ; i f ( e l s . l e n g t h < 2 ) { l o g ( " t e r m i n a t i n g ;   t o o   f e w   s l i d e s :   " + e l s . l e n g t h ) ; r e t u r n ; } v a r   o p t s = b u i l d O p t i o n s ( $ c o n t , $ s l i d e s , e l s , o p t i o n s ) ; i f ( o p t s = = = f a l s e ) { r e t u r n ; } i f ( o p t s . t i m e o u t | | o p t s . c o n t i n u o u s ) { t h i s . c y c l e 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 ( ) { g o ( e l s , o p t s , 0 , ! o p t s . r e v ) ; } , o p t s . c o n t i n u o u s ? 1 0 : o p t s . t i m e o u t + ( o p t s . d e l a y | | 0 ) ) ; } } ) ; } ; f u n c t i o n   h a n d l e A r g u m e n t s ( c o n t , o p t i o n s , a r g 2 ) { i f ( c o n t . c y c l e S t o p = = u n d e f i n e d ) { c o n t . c y c l e S t o p = 0 ; } i f ( o p t i o n s = = = u n d e f i n e d | | o p t i o n s = = = n u l l ) { o p t i o n s = { } ; } i f ( o p t i o n s . c o n s t r u c t o r = = S t r i n g ) { s w i t c h ( o p t i o n s ) { c a s e " s t o p " : c o n t . c y c l e S t o p + + ; i f ( c o n t . c y c l e T i m e o u t ) { c l e a r T i m e o u t ( c o n t . c y c l e T i m e o u t ) ; } c o n t . c y c l e T i m e o u t = 0 ; $ ( c o n t ) . r e m o v e D a t a ( " c y c l e . o p t s " ) ; r e t u r n   f a l s e ; c a s e " p a u s e " : c o n t . c y c l e P a u s e = 1 ; r e t u r n   f a l s e ; c a s e " r e s u m e " : c o n t . c y c l e P a u s e = 0 ; i f ( a r g 2 = = = t r u e ) { o p t i o n s = $ ( c o n t ) . d a t a ( " c y c l e . o p t s " ) ; i f ( ! o p t i o n s ) { l o g ( " o p t i o n s   n o t   f o u n d ,   c a n   n o t   r e s u m e " ) ; r e t u r n ; } i f ( c o n t . c y c l e T i m e o u t ) { c l e a r T i m e o u t ( c o n t . c y c l e T i m e o u t ) ; c o n t . c y c l e T i m e o u t = 0 ; } g o ( o p t i o n s . e l e m e n t s , o p t i o n s , 1 , 1 ) ; } r e t u r n   f a l s e ; d e f a u l t : o p t i o n s = { f x : o p t i o n s } ; } } e l s e { i f ( o p t i o n s . c o n s t r u c t o r = = N u m b e r ) { v a r   n u m = o p t i o n s ; o p t i o n s = $ ( c o n t ) . d a t a ( " c y c l e . o p t s " ) ; i f ( ! o p t i o n s ) { l o g ( " o p t i o n s   n o t   f o u n d ,   c a n   n o t   a d v a n c e   s l i d e " ) ; r e t u r n   f a l s e ; } i f ( n u m < 0 | | n u m > = o p t i o n s . e l e m e n t s . l e n g t h ) { l o g ( " i n v a l i d   s l i d e   i n d e x :   " + n u m ) ; r e t u r n   f a l s e ; } o p t i o n s . n e x t S l i d e = n u m ; i f ( c o n t . c y c l e T i m e o u t ) { c l e a r T i m e o u t ( t h i s . c y c l e T i m e o u t ) ; c o n t . c y c l e T i m e o u t = 0 ; } i f ( t y p e o f   a r g 2 = = " s t r i n g " ) { o p t i o n s . o n e T i m e F x = a r g 2 ; } g o ( o p t i o n s . e l e m e n t s , o p t i o n s , 1 , n u m > = o p t i o n s . c u r r S l i d e ) ; r e t u r n   f a l s e ; } } r e t u r n   o p t i o n s ; } f u n c t i o n   b u i l d O p t i o n s ( $ c o n t , $ s l i d e s , e l s , o p t i o n s ) { v a r   o p t s = $ . e x t e n d ( { } , $ . f n . c y c l e . d e f a u l t s , o p t i o n s | | { } , $ . m e t a d a t a ? $ c o n t . m e t a d a t a ( ) : $ . m e t a ? $ c o n t . d a t a ( ) : { } ) ; i f ( o p t s . a u t o s t o p ) { o p t s . c o u n t d o w n = o p t s . a u t o s t o p C o u n t | | e l s . l e n g t h ; } v a r   c o n t = $ c o n t [ 0 ] ; $ c o n t . d a t a ( " c y c l e . o p t s " , o p t s ) ; o p t s . $ c o n t = $ c o n t ; o p t s . s t o p C o u n t = c o n t . c y c l e S t o p ; o p t s . e l e m e n t s = e l s ; o p t s . b e f o r e = o p t s . b e f o r e ? [ o p t s . b e f o r e ] : [ ] ; o p t s . a f t e r = o p t s . a f t e r ? [ o p t s . a f t e r ] : [ ] ; o p t s . a f t e r . u n s h i f t ( f u n c t i o n ( ) { o p t s . b u s y = 0 ; } ) ; i f ( ! $ . s u p p o r t . o p a c i t y & & o p t s . c l e a r t y p e ) { o p t s . a f t e r . p u s h ( f u n c t i o n ( ) { t h i s . 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 " ) ; } ) ; } i f ( o p t s . c o n t i n u o u s ) { o p t s . a f t e r . p u s h ( f u n c t i o n ( ) { g o ( e l s , o p t s , 0 , ! o p t s . r e v ) ; } ) ; } s a v e O r i g i n a l O p t s ( o p t s ) ; i f ( ! $ . s u p p o r t . o p a c i t y & & o p t s . c l e a r t y p e & & ! o p t s . c l e a r t y p e N o B g ) { c l e a r T y p e F i x ( $ s l i d e s ) ; } i f ( $ c o n t . c s s ( " p o s i t i o n " ) = = " s t a t i c " ) { $ c o n t . c s s ( " p o s i t i o n " , " r e l a t i v e " ) ; } i f ( o p t s . w i d t h ) { $ c o n t . w i d t h ( o p t s . w i d t h ) ; } i f ( o p t s . h e i g h t & & o p t s . h e i g h t ! = " a u t o " ) { $ c o n t . h e i g h t ( o p t s . h e i g h t ) ; } i f ( o p t s . s t a r t i n g S l i d e ) { o p t s . s t a r t i n g S l i d e = p a r s e I n t ( o p t s . s t a r t i n g S l i d e ) ; } i f ( o p t s . r a n d o m ) { o p t s . r a n d o m M a p = [ ] ; f o r ( v a r   i = 0 ; i < e l s . l e n g t h ; i + + ) { o p t s . r a n d o m M a p . p u s h ( i ) ; } o p t s . r a n d o m M a p . s o r t ( f u n c t i o n ( a , b ) { r e t u r n   M a t h . r a n d o m ( ) - 0 . 5 ; } ) ; o p t s . r a n d o m I n d e x = 0 ; o p t s . s t a r t i n g S l i d e = o p t s . r a n d o m M a p [ 0 ] ; } e l s e { i f ( o p t s . s t a r t i n g S l i d e > = e l s . l e n g t h ) { o p t s . s t a r t i n g S l i d e = 0 ; } } o p t s . c u r r S l i d e = o p t s . s t a r t i n g S l i d e = o p t s . s t a r t i n g S l i d e | | 0 ; v a r   f i r s t = o p t s . s t a r t i n g S l i d e ; $ s l i d e s . c s s ( { p o s i t i o n : " a b s o l u t e " , t o p : 0 , l e f t : 0 } ) . h i d e ( ) . e a c h ( f u n c t i o n ( i ) { v a r   z = f i r s t ? i > = f i r s t ? e l s . l e n g t h - ( i - f i r s t ) : f i r s t - i : e l s . l e n g t h - i ; $ ( t h i s ) . c s s ( " z - i n d e x " , z ) ; } ) ; $ ( e l s [ f i r s t ] ) . c s s ( " o p a c i t y " , 1 ) . s h o w ( ) ; i f ( ! $ . s u p p o r t . o p a c i t y & & o p t s . c l e a r t y p e ) { e l s [ f i r s t ] . 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 " ) ; } i f ( o p t s . f i t & & o p t s . w i d t h ) { $ s l i d e s . w i d t h ( o p t s . w i d t h ) ; } i f ( o p t s . f i t & & o p t s . h e i g h t & & o p t s . h e i g h t ! = " a u t o " ) { $ s l i d e s . h e i g h t ( o p t s . h e i g h t ) ; } v a r   r e s h a p e = o p t s . c o n t a i n e r R e s i z e & & ! $ c o n t . i n n e r H e i g h t ( ) ; i f ( r e s h a p e ) { v a r   m a x w = 0 , m a x h = 0 ; f o r ( v a r   i = 0 ; i < e l s . l e n g t h ; i + + ) { v a r   $ e = $ ( e l s [ i ] ) , e = $ e [ 0 ] , w = $ e . o u t e r W i d t h ( ) , h = $ e . o u t e r H e i g h t ( ) ; i f ( ! w ) { w = e . o f f s e t W i d t h ; } i f ( ! h ) { h = e . o f f s e t H e i g h t ; } m a x w = w > m a x w ? w : m a x w ; m a x h = h > m a x h ? h : m a x h ; } i f ( m a x w > 0 & & m a x h > 0 ) { $ c o n t . c s s ( { w i d t h : m a x w + " p x " , h e i g h t : m a x h + " p x " } ) ; } } i f ( o p t s . p a u s e ) { $ c o n t . h o v e r ( f u n c t i o n ( ) { t h i s . c y c l e P a u s e + + ; } , f u n c t i o n ( ) { t h i s . c y c l e P a u s e - - ; } ) ; } s u p p o r t M u l t i T r a n s i t i o n s ( o p t s ) ; i f ( ! o p t s . m u l t i F x ) { v a r   i n i t = $ . f n . c y c l e . t r a n s i t i o n s [ o p t s . f x ] ; i f ( $ . i s F u n c t i o n ( i n i t ) ) { i n i t ( $ c o n t , $ s l i d e s , o p t s ) ; } e l s e { i f ( o p t s . f x ! = " c u s t o m " & & ! o p t s . m u l t i F x ) { l o g ( " u n k n o w n   t r a n s i t i o n :   " + o p t s . f x , " ;   s l i d e s h o w   t e r m i n a t i n g " ) ; r e t u r n   f a l s e ; } } } $ s l i d e s . e a c h ( f u n c t i o n ( ) { v a r   $ e l = $ ( t h i s ) ; t h i s . c y c l e H = ( o p t s . f i t & & o p t s . h e i g h t ) ? o p t s . h e i g h t : $ e l . h e i g h t ( ) ; t h i s . c y c l e W = ( o p t s . f i t & & o p t s . w i d t h ) ? o p t s . w i d t h : $ e l . w i d t h ( ) ; } ) ; o p t s . c s s B e f o r e = o p t s . c s s B e f o r e | | { } ; o p t s . a n i m I n = o p t s . a n i m I n | | { } ; o p t s . a n i m O u t = o p t s . a n i m O u t | | { } ; $ s l i d e s . n o t ( " : e q ( " + f i r s t + " ) " ) . c s s ( o p t s . c s s B e f o r e ) ; i f ( o p t s . c s s F i r s t ) { $ ( $ s l i d e s [ f i r s t ] ) . c s s ( o p t s . c s s F i r s t ) ; } i f ( o p t s . t i m e o u t ) { o p t s . t i m e o u t = p a r s e I n t ( o p t s . t i m e o u t ) ; i f ( o p t s . s p e e d . c o n s t r u c t o r = = S t r i n g ) { o p t s . s p e e d = $ . f x . s p e e d s [ o p t s . s p e e d ] | | p a r s e I n t ( o p t s . s p e e d ) ; } i f ( ! o p t s . s y n c ) { o p t s . s p e e d = o p t s . s p e e d / 2 ; } w h i l e ( ( o p t s . t i m e o u t - o p t s . s p e e d ) < 2 5 0 ) { o p t s . t i m e o u t + = o p t s . s p e e d ; } } i f ( o p t s . e a s i n g ) { o p t s . e a s e I n = o p t s . e a s e O u t = o p t s . e a s i n g ; } i f ( ! o p t s . s p e e d I n ) { o p t s . s p e e d I n = o p t s . s p e e d ; } i f ( ! o p t s . s p e e d O u t ) { o p t s . s p e e d O u t = o p t s . s p e e d ; } o p t s . s l i d e C o u n t = e l s . l e n g t h ; o p t s . c u r r S l i d e = o p t s . l a s t S l i d e = f i r s t ; i f ( o p t s . r a n d o m ) { o p t s . n e x t S l i d e = o p t s . c u r r S l i d e ; i f ( + + o p t s . r a n d o m I n d e x = = e l s . l e n g t h ) { o p t s . r a n d o m I n d e x = 0 ; } o p t s . n e x t S l i d e = o p t s . r a n d o m M a p [ o p t s . r a n d o m I n d e x ] ; } e l s e { o p t s . n e x t S l i d e = o p t s . s t a r t i n g S l i d e > = ( e l s . l e n g t h - 1 ) ? 0 : o p t s . s t a r t i n g S l i d e + 1 ; } v a r   e 0 = $ s l i d e s [ f i r s t ] ; i f ( o p t s . b e f o r e . l e n g t h ) { o p t s . b e f o r e [ 0 ] . a p p l y ( e 0 , [ e 0 , e 0 , o p t s , t r u e ] ) ; } i f ( o p t s . a f t e r . l e n g t h > 1 ) { o p t s . a f t e r [ 1 ] . a p p l y ( e 0 , [ e 0 , e 0 , o p t s , t r u e ] ) ; } i f ( o p t s . n e x t ) { $ ( o p t s . n e x t ) . c l i c k ( f u n c t i o n ( ) { r e t u r n   a d v a n c e ( o p t s , o p t s . r e v ? - 1 : 1 ) ; } ) ; } i f ( o p t s . p r e v ) { $ ( o p t s . p r e v ) . c l i c k ( f u n c t i o n ( ) { r e t u r n   a d v a n c e ( o p t s , o p t s . r e v ? 1 : - 1 ) ; } ) ; } i f ( o p t s . p a g e r ) { b u i l d P a g e r ( e l s , o p t s ) ; } e x p o s e A d d S l i d e ( o p t s , e l s ) ; r e t u r n   o p t s ; } f u n c t i o n   s a v e O r i g i n a l O p t s ( o p t s ) { o p t s . o r i g i n a l = { b e f o r e : [ ] , a f t e r : [ ] } ; o p t s . o r i g i n a l . c s s B e f o r e = $ . e x t e n d ( { } , o p t s . c s s B e f o r e ) ; o p t s . o r i g i n a l . c s s A f t e r = $ . e x t e n d ( { } , o p t s . c s s A f t e r ) ; o p t s . o r i g i n a l . a n i m I n = $ . e x t e n d ( { } , o p t s . a n i m I n ) ; o p t s . o r i g i n a l . a n i m O u t = $ . e x t e n d ( { } , o p t s . a n i m O u t ) ; $ . e a c h ( o p t s . b e f o r e , f u n c t i o n ( ) { o p t s . o r i g i n a l . b e f o r e . p u s h ( t h i s ) ; } ) ; $ . e a c h ( o p t s . a f t e r , f u n c t i o n ( ) { o p t s . o r i g i n a l . a f t e r . p u s h ( t h i s ) ; } ) ; } f u n c t i o n   s u p p o r t M u l t i T r a n s i t i o n s ( o p t s ) { v a r   t x s = $ . f n . c y c l e . t r a n s i t i o n s ; i f ( o p t s . f x . i n d e x O f ( " , " ) > 0 ) { o p t s . m u l t i F x = t r u e ; o p t s . f x s = o p t s . f x . r e p l a c e ( / \ s * / g , " " ) . s p l i t ( " , " ) ; f o r ( v a r   i = 0 ; i < o p t s . f x s . l e n g t h ; i + + ) { v a r   f x = o p t s . f x s [ i ] ; v a r   t x = t x s [ f x ] ; i f ( ! t x | | ! t x s . h a s O w n P r o p e r t y ( f x ) | | ! $ . i s F u n c t i o n ( t x ) ) { l o g ( " d i s c a r d i n g   u n k n o w t n   t r a n s i t i o n :   " , f x ) ; o p t s . f x s . s p l i c e ( i , 1 ) ; i - - ; } } i f ( ! o p t s . f x s . l e n g t h ) { l o g ( " N o   v a l i d   t r a n s i t i o n s   n a m e d ;   s l i d e s h o w   t e r m i n a t i n g . " ) ; r e t u r n   f a l s e ; } } e l s e { i f ( o p t s . f x = = " a l l " ) { o p t s . m u l t i F x = t r u e ; o p t s . f x s = [ ] ; f o r ( p   i n   t x s ) { v a r   t x = t x s [ p ] ; i f ( t x s . h a s O w n P r o p e r t y ( p ) & & $ . i s F u n c t i o n ( t x ) ) { o p t s . f x s . p u s h ( p ) ; } } } } i f ( o p t s . m u l t i F x & & o p t s . r a n d o m i z e E f f e c t s ) { v a r   r 1 = M a t h . f l o o r ( M a t h . r a n d o m ( ) * 2 0 ) + 3 0 ; f o r ( v a r   i = 0 ; i < r 1 ; i + + ) { v a r   r 2 = M a t h . f l o o r ( M a t h . r a n d o m ( ) * o p t s . f x s . l e n g t h ) ; o p t s . f x s . p u s h ( o p t s . f x s . s p l i c e ( r 2 , 1 ) [ 0 ] ) ; } l o g ( " r a n d o m i z e d   f x   s e q u e n c e :   " , o p t s . f x s ) ; } } f u n c t i o n   e x p o s e A d d S l i d e ( o p t s , e l s ) { o p t s . a d d S l i d e = f u n c t i o n ( n e w S l i d e , p r e p e n d ) { v a r   $ s = $ ( n e w S l i d e ) , s = $ s [ 0 ] ; i f ( ! o p t s . a u t o s t o p C o u n t ) { o p t s . c o u n t d o w n + + ; } e l s [ p r e p e n d ? " u n s h i f t " : " p u s h " ] ( s ) ; i f ( o p t s . e l s ) { o p t s . e l s [ p r e p e n d ? " u n s h i f t " : " p u s h " ] ( s ) ; } o p t s . s l i d e C o u n t = e l s . l e n g t h ; $ s . c s s ( " p o s i t i o n " , " a b s o l u t e " ) ; $ s [ p r e p e n d ? " p r e p e n d T o " : " a p p e n d T o " ] ( o p t s . $ c o n t ) ; i f ( p r e p e n d ) { o p t s . c u r r S l i d e + + ; o p t s . n e x t S l i d e + + ; } i f ( ! $ . s u p p o r t . o p a c i t y & & o p t s . c l e a r t y p e & & ! o p t s . c l e a r t y p e N o B g ) { c l e a r T y p e F i x ( $ s ) ; } i f ( o p t s . f i t & & o p t s . w i d t h ) { $ s . w i d t h ( o p t s . w i d t h ) ; } i f ( o p t s . f i t & & o p t s . h e i g h t & & o p t s . h e i g h t ! = " a u t o " ) { $ s l i d e s . h e i g h t ( o p t s . h e i g h t ) ; } s . c y c l e H = ( o p t s . f i t & & o p t s . h e i g h t ) ? o p t s . h e i g h t : $ s . h e i g h t ( ) ; s . c y c l e W = ( o p t s . f i t & & o p t s . w i d t h ) ? o p t s . w i d t h : $ s . w i d t h ( ) ; $ s . c s s ( o p t s . c s s B e f o r e ) ; i f ( o p t s . p a g e r ) { $ . f n . c y c l e . c r e a t e P a g e r A n c h o r ( e l s . l e n g t h - 1 , s , $ ( o p t s . p a g e r ) , e l s , o p t s ) ; } i f ( $ . i s F u n c t i o n ( o p t s . o n A d d S l i d e ) ) { o p t s . o n A d d S l i d e ( $ s ) ; } e l s e { $ s . h i d e ( ) ; } } ; } $ . f n . c y c l e . r e s e t S t a t e = f u n c t i o n ( o p t s , f x ) { v a r   f x = f x | | o p t s . f x ; o p t s . b e f o r e = [ ] ; o p t s . a f t e r = [ ] ; o p t s . c s s B e f o r e = $ . e x t e n d ( { } , o p t s . o r i g i n a l . c s s B e f o r e ) ; o p t s . c s s A f t e r = $ . e x t e n d ( { } , o p t s . o r i g i n a l . c s s A f t e r ) ; o p t s . a n i m I n = $ . e x t e n d ( { } , o p t s . o r i g i n a l . a n i m I n ) ; o p t s . a n i m O u t = $ . e x t e n d ( { } , o p t s . o r i g i n a l . a n i m O u t ) ; o p t s . f x F n = n u l l ; $ . e a c h ( o p t s . o r i g i n a l . b e f o r e , f u n c t i o n ( ) { o p t s . b e f o r e . p u s h ( t h i s ) ; } ) ; $ . e a c h ( o p t s . o r i g i n a l . a f t e r , f u n c t i o n ( ) { o p t s . a f t e r . p u s h ( t h i s ) ; } ) ; v a r   i n i t = $ . f n . c y c l e . t r a n s i t i o n s [ f x ] ; i f ( $ . i s F u n c t i o n ( i n i t ) ) { i n i t ( o p t s . $ c o n t , $ ( o p t s . e l e m e n t s ) , o p t s ) ; } } ; f u n c t i o n   g o ( e l s , o p t s , m a n u a l , f w d ) { i f ( m a n u a l & & o p t s . b u s y ) { $ ( e l s ) . s t o p ( t r u e , t r u e ) ; o p t s . b u s y = f a l s e ; } i f ( o p t s . b u s y ) { r e t u r n ; } v a r   p = o p t s . $ c o n t [ 0 ] , c u r r = e l s [ o p t s . c u r r S l i d e ] , n e x t = e l s [ o p t s . n e x t S l i d e ] ; i f ( p . c y c l e S t o p ! = o p t s . s t o p C o u n t | | p . c y c l e T i m e o u t = = = 0 & & ! m a n u a l ) { r e t u r n ; } i f ( ! m a n u a l & & ! p . c y c l e P a u s e & & ( ( o p t s . a u t o s t o p & & ( - - o p t s . c o u n t d o w n < = 0 ) ) | | ( o p t s . n o w r a p & & ! o p t s . r a n d o m & & o p t s . n e x t S l i d e < o p t s . c u r r S l i d e ) ) ) { i f ( o p t s . e n d ) { o p t s . e n d ( o p t s ) ; } r e t u r n ; } i f ( m a n u a l | | ! p . c y c l e P a u s e ) { v a r   f x = o p t s . f x ; c u r r . c y c l e H = c u r r . c y c l e H | | c u r r . o f f s e t H e i g h t ; c u r r . c y c l e W = c u r r . c y c l e W | | c u r r . o f f s e t W i d t h ; n e x t . c y c l e H = n e x t . c y c l e H | | n e x t . o f f s e t H e i g h t ; n e x t . c y c l e W = n e x t . c y c l e W | | n e x t . o f f s e t W i d t h ; i f ( o p t s . m u l t i F x ) { i f ( o p t s . l a s t F x = = u n d e f i n e d | | + + o p t s . l a s t F x > = o p t s . f x s . l e n g t h ) { o p t s . l a s t F x = 0 ; } f x = o p t s . f x s [ o p t s . l a s t F x ] ; o p t s . c u r r F x = f x ; } i f ( o p t s . o n e T i m e F x ) { f x = o p t s . o n e T i m e F x ; o p t s . o n e T i m e F x = n u l l ; } $ . f n . c y c l e . r e s e t S t a t e ( o p t s , f x ) ; i f ( o p t s . b e f o r e . l e n g t h ) { $ . e a c h ( o p t s . b e f o r e , f u n c t i o n ( i , o ) { i f ( p . c y c l e S t o p ! = o p t s . s t o p C o u n t ) { r e t u r n ; } o . a p p l y ( n e x t , [ c u r r , n e x t , o p t s , f w d ] ) ; } ) ; } v a r   a f t e r = f u n c t i o n ( ) { $ . e a c h ( o p t s . a f t e r , f u n c t i o n ( i , o ) { i f ( p . c y c l e S t o p ! = o p t s . s t o p C o u n t ) { r e t u r n ; } o . a p p l y ( n e x t , [ c u r r , n e x t , o p t s , f w d ] ) ; } ) ; } ; i f ( o p t s . n e x t S l i d e ! = o p t s . c u r r S l i d e ) { o p t s . b u s y = 1 ; i f ( o p t s . f x F n ) { o p t s . f x F n ( c u r r , n e x t , o p t s , a f t e r , f w d ) ; } e l s e { i f ( $ . i s F u n c t i o n ( $ . f n . c y c l e [ o p t s . f x ] ) ) { $ . f n . c y c l e [ o p t s . f x ] ( c u r r , n e x t , o p t s , a f t e r ) ; } e l s e { $ . f n . c y c l e . c u s t o m ( c u r r , n e x t , o p t s , a f t e r , m a n u a l & & o p t s . f a s t O n E v e n t ) ; } } } o p t s . l a s t S l i d e = o p t s . c u r r S l i d e ; i f ( o p t s . r a n d o m ) { o p t s . c u r r S l i d e = o p t s . n e x t S l i d e ; i f ( + + o p t s . r a n d o m I n d e x = = e l s . l e n g t h ) { o p t s . r a n d o m I n d e x = 0 ; } o p t s . n e x t S l i d e = o p t s . r a n d o m M a p [ o p t s . r a n d o m I n d e x ] ; } e l s e { v a r   r o l l = ( o p t s . n e x t S l i d e + 1 ) = = e l s . l e n g t h ; o p t s . n e x t S l i d e = r o l l ? 0 : o p t s . n e x t S l i d e + 1 ; o p t s . c u r r S l i d e = r o l l ? e l s . l e n g t h - 1 : o p t s . n e x t S l i d e - 1 ; } i f ( o p t s . p a g e r ) { $ . f n . c y c l e . u p d a t e A c t i v e P a g e r L i n k ( o p t s . p a g e r , o p t s . c u r r S l i d e ) ; } } v a r   m s = 0 ; i f ( o p t s . t i m e o u t & & ! o p t s . c o n t i n u o u s ) { m s = g e t T i m e o u t ( c u r r , n e x t , o p t s , f w d ) ; } e l s e { i f ( o p t s . c o n t i n u o u s & & p . c y c l e P a u s e ) { m s = 1 0 ; } } i f ( m s > 0 ) { p . c y c l e 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 ( ) { g o ( e l s , o p t s , 0 , ! o p t s . r e v ) ; } , m s ) ; } } $ . f n . c y c l e . u p d a t e A c t i v e P a g e r L i n k = f u n c t i o n ( p a g e r , c u r r S l i d e ) { $ ( p a g e r ) . f i n d ( " a " ) . r e m o v e C l a s s ( " a c t i v e S l i d e " ) . f i l t e r ( " a : e q ( " + c u r r S l i d e + " ) " ) . a d d C l a s s ( " a c t i v e S l i d e " ) ; } ; f u n c t i o n   g e t T i m e o u t ( c u r r , n e x t , o p t s , f w d ) { i f ( o p t s . t i m e o u t F n ) { v a r   t = o p t s . t i m e o u t F n ( c u r r , n e x t , o p t s , f w d ) ; i f ( t ! = = f a l s e ) { r e t u r n   t ; } } r e t u r n   o p t s . t i m e o u t ; } $ . f n . c y c l e . n e x t = f u n c t i o n ( o p t s ) { a d v a n c e ( o p t s , o p t s . r e v ? - 1 : 1 ) ; } ; $ . f n . c y c l e . p r e v = f u n c t i o n ( o p t s ) { a d v a n c e ( o p t s , o p t s . r e v ? 1 : - 1 ) ; } ; f u n c t i o n   a d v a n c e ( o p t s , v a l ) { v a r   e l s = o p t s . e l e m e n t s ; v a r   p = o p t s . $ c o n t [ 0 ] , t i m e o u t = p . c y c l e T i m e o u t ; i f ( t i m e o u t ) { c l e a r T i m e o u t ( t i m e o u t ) ; p . c y c l e T i m e o u t = 0 ; } i f ( o p t s . r a n d o m & & v a l < 0 ) { o p t s . r a n d o m I n d e x - - ; i f ( - - o p t s . r a n d o m I n d e x = = - 2 ) { o p t s . r a n d o m I n d e x = e l s . l e n g t h - 2 ; } e l s e { i f ( o p t s . r a n d o m I n d e x = = - 1 ) { o p t s . r a n d o m I n d e x = e l s . l e n g t h - 1 ; } } o p t s . n e x t S l i d e = o p t s . r a n d o m M a p [ o p t s . r a n d o m I n d e x ] ; } e l s e { i f ( o p t s . r a n d o m ) { i f ( + + o p t s . r a n d o m I n d e x = = e l s . l e n g t h ) { o p t s . r a n d o m I n d e x = 0 ; } o p t s . n e x t S l i d e = o p t s . r a n d o m M a p [ o p t s . r a n d o m I n d e x ] ; } e l s e { o p t s . n e x t S l i d e = o p t s . c u r r S l i d e + v a l ; i f ( o p t s . n e x t S l i d e < 0 ) { i f ( o p t s . n o w r a p ) { r e t u r n   f a l s e ; } o p t s . n e x t S l i d e = e l s . l e n g t h - 1 ; } e l s e { i f ( o p t s . n e x t S l i d e > = e l s . l e n g t h ) { i f ( o p t s . n o w r a p ) { r e t u r n   f a l s e ; } o p t s . n e x t S l i d e = 0 ; } } } } i f ( $ . i s F u n c t i o n ( o p t s . p r e v N e x t C l i c k ) ) { o p t s . p r e v N e x t C l i c k ( v a l > 0 , o p t s . n e x t S l i d e , e l s [ o p t s . n e x t S l i d e ] ) ; } g o ( e l s , o p t s , 1 , v a l > = 0 ) ; r e t u r n   f a l s e ; } f u n c t i o n   b u i l d P a g e r ( e l s , o p t s ) { v a r   $ p = $ ( o p t s . p a g e r ) ; $ . e a c h ( e l s , f u n c t i o n ( i , o ) { $ . f n . c y c l e . c r e a t e P a g e r A n c h o r ( i , o , $ p , e l s , o p t s ) ; } ) ; $ . f n . c y c l e . u p d a t e A c t i v e P a g e r L i n k ( o p t s . p a g e r , o p t s . s t a r t i n g S l i d e ) ; } $ . f n . c y c l e . c r e a t e P a g e r A n c h o r = f u n c t i o n ( i , e l , $ p , e l s , o p t s ) { v a r   a = ( $ . i s F u n c t i o n ( o p t s . p a g e r A n c h o r B u i l d e r ) ) ? o p t s . p a g e r A n c h o r B u i l d e r ( i , e l ) : ' < a   h r e f = " # " > ' + ( i + 1 ) + " < / a > " ; i f ( ! a ) { r e t u r n ; } v a r   $ a = $ ( a ) ; i f ( $ a . p a r e n t s ( " b o d y " ) . l e n g t h = = 0 ) { $ a . a p p e n d T o ( $ p ) ; } $ a . b i n d ( o p t s . p a g e r E v e n t , f u n c t i o n ( ) { o p t s . n e x t S l i d e = i ; v a r   p = o p t s . $ c o n t [ 0 ] , t i m e o u t = p . c y c l e T i m e o u t ; i f ( t i m e o u t ) { c l e a r T i m e o u t ( t i m e o u t ) ; p . c y c l e T i m e o u t = 0 ; } i f ( $ . i s F u n c t i o n ( o p t s . p a g e r C l i c k ) ) { o p t s . p a g e r C l i c k ( o p t s . n e x t S l i d e , e l s [ o p t s . n e x t S l i d e ] ) ; } g o ( e l s , o p t s , 1 , o p t s . c u r r S l i d e < i ) ; r e t u r n   f a l s e ; } ) ; i f ( o p t s . p a u s e O n P a g e r H o v e r ) { $ a . h o v e r ( f u n c t i o n ( ) { o p t s . $ c o n t [ 0 ] . c y c l e P a u s e + + ; } , f u n c t i o n ( ) { o p t s . $ c o n t [ 0 ] . c y c l e P a u s e - - ; } ) ; } } ; $ . f n . c y c l e . h o p s F r o m L a s t = f u n c t i o n ( o p t s , f w d ) { v a r   h o p s , l = o p t s . l a s t S l i d e , c = o p t s . c u r r S l i d e ; i f ( f w d ) { h o p s = c > l ? c - l : o p t s . s l i d e C o u n t - l ; } e l s e { h o p s = c < l ? l - c : l + o p t s . s l i d e C o u n t - c ; } r e t u r n   h o p s ; } ; f u n c t i o n   c l e a r T y p e F i x ( $ s l i d e s ) { f u n c t i o n   h e x ( s ) { v a r   s = p a r s e I n t ( s ) . t o S t r i n g ( 1 6 ) ; r e t u r n   s . l e n g t h < 2 ? " 0 " + s : s ; } f u n c t i o n   g e t B g ( e ) { f o r ( ; e & & e . n o d e N a m e . t o L o w e r C a s e ( ) ! = " h t m l " ; e = e . p a r e n t N o d e ) { v a r   v = $ . c s s ( e , " b a c k g r o u n d - c o l o r " ) ; i f ( v . i n d e x O f ( " r g b " ) > = 0 ) { v a r   r g b = v . m a t c h ( / \ d + / g ) ; r e t u r n " # " + h e x ( r g b [ 0 ] ) + h e x ( r g b [ 1 ] ) + h e x ( r g b [ 2 ] ) ; } i f ( v & & v ! = " t r a n s p a r e n t " ) { r e t u r n   v ; } } r e t u r n " # f f f f f f " ; } $ s l i d e s . e a c h ( f u n c t i o n ( ) { $ ( t h i s ) . c s s ( " b a c k g r o u n d - c o l o r " , g e t B g ( t h i s ) ) ; } ) ; } $ . f n . c y c l e . c o m m o n R e s e t = f u n c t i o n ( c u r r , n e x t , o p t s , w , h , r e v ) { $ ( o p t s . e l e m e n t s ) . n o t ( c u r r ) . h i d e ( ) ; o p t s . c s s B e f o r e . o p a c i t y = 1 ; o p t s . c s s B e f o r e . d i s p l a y = " b l o c k " ; i f ( w ! = = f a l s e & & n e x t . c y c l e W > 0 ) { o p t s . c s s B e f o r e . w i d t h = n e x t . c y c l e W ; } i f ( h ! = = f a l s e & & n e x t . c y c l e H > 0 ) { o p t s . c s s B e f o r e . h e i g h t = n e x t . c y c l e H ; } o p t s . c s s A f t e r = o p t s . c s s A f t e r | | { } ; o p t s . c s s A f t e r . d i s p l a y = " n o n e " ; $ ( c u r r ) . c s s ( " z I n d e x " , o p t s . s l i d e C o u n t + ( r e v = = = t r u e ? 1 : 0 ) ) ; $ ( n e x t ) . c s s ( " z I n d e x " , o p t s . s l i d e C o u n t + ( r e v = = = t r u e ? 0 : 1 ) ) ; } ; $ . f n . c y c l e . c u s t o m = f u n c t i o n ( c u r r , n e x t , o p t s , c b , s p e e d O v e r r i d e ) { v a r   $ l = $ ( c u r r ) , $ n = $ ( n e x t ) ; v a r   s p e e d I n = o p t s . s p e e d I n , s p e e d O u t = o p t s . s p e e d O u t , e a s e I n = o p t s . e a s e I n , e a s e O u t = o p t s . e a s e O u t ; $ n . c s s ( o p t s . c s s B e f o r e ) ; i f ( s p e e d O v e r r i d e ) { i f ( t y p e o f   s p e e d O v e r r i d e = = " n u m b e r " ) { s p e e d I n = s p e e d O u t = s p e e d O v e r r i d e ; } e l s e { s p e e d I n = s p e e d O u t = 1 ; } e a s e I n = e a s e O u t = n u l l ; } v a r   f n = f u n c t i o n ( ) { $ n . a n i m a t e ( o p t s . a n i m I n , s p e e d I n , e a s e I n , c b ) ; } ; $ l . a n i m a t e ( o p t s . a n i m O u t , s p e e d O u t , e a s e O u t , f u n c t i o n ( ) { i f ( o p t s . c s s A f t e r ) { $ l . c s s ( o p t s . c s s A f t e r ) ; } i f ( ! o p t s . s y n c ) { f n ( ) ; } } ) ; i f ( o p t s . s y n c ) { f n ( ) ; } } ; $ . f n . c y c l e . t r a n s i t i o n s = { f a d e : f u n c t i o n ( $ c o n t , $ s l i d e s , o p t s ) { $ s l i d e s . n o t ( " : e q ( " + o p t s . c u r r S l i d e + " ) " ) . c s s ( " o p a c i t y " , 0 ) ; o p t s . b e f o r e . p u s h ( f u n c t i o n ( c u r r , n e x t , o p t s ) { $ . f n . c y c l e . c o m m o n R e s e t ( c u r r , n e x t , o p t s ) ; o p t s . c s s B e f o r e . o p a c i t y = 0 ; } ) ; o p t s . a n i m I n = { o p a c i t y : 1 } ; o p t s . a n i m O u t = { o p a c i t y : 0 } ; o p t s . c s s B e f o r e = { t o p : 0 , l e f t : 0 } ; } } ; $ . f n . c y c l e . v e r = f u n c t i o n ( ) { r e t u r n   v e r ; } ; $ . f n . c y c l e . d e f a u l t s = { f x : " f a d e " , t i m e o u t : 4 0 0 0 , t i m e o u t F n : n u l l , c o n t i n u o u s : 0 , s p e e d : 1 0 0 0 , s p e e d I n : n u l l , s p e e d O u t : n u l l , n e x t : n u l l , p r e v : n u l l , p r e v N e x t C l i c k : n u l l , p a g e r : n u l l , p a g e r C l i c k : n u l l , p a g e r E v e n t : " c l i c k " , p a g e r A n c h o r B u i l d e r : n u l l , b e f o r e : n u l l , a f t e r : n u l l , e n d : n u l l , e a s i n g : n u l l , e a s e I n : n u l l , e a s e O u t : n u l l , s h u f f l e : n u l l , a n i m I n : n u l l , a n i m O u t : n u l l , c s s B e f o r e : n u l l , c s s A f t e r : n u l l , f x F n : n u l l , h e i g h t : " a u t o " , s t a r t i n g S l i d e : 0 , s y n c : 1 , r a n d o m : 0 , f i t : 0 , c o n t a i n e r R e s i z e : 1 , p a u s e : 0 , p a u s e O n P a g e r H o v e r : 0 , a u t o s t o p : 0 , a u t o s t o p C o u n t : 0 , d e l a y : 0 , s l i d e E x p r : n u l l , c l e a r t y p e : ! $ . s u p p o r t . o p a c i t y , n o w r a p : 0 , f a s t O n E v e n t : 0 , r a n d o m i z e E f f e c t s : 1 , r e v : 0 } ; } ) ( j Q u e r y ) ; 
 
 / / C y c l e   t r a n s i t i o n s 
 
 / / H o r i z o n t a l   S c r o l l 
 $ . f n . c y c l e . t r a n s i t i o n s . s c r o l l H o r z   =   f u n c t i o n ( $ c o n t ,   $ s l i d e s ,   o p t s )   { 
 	 $ c o n t . c s s ( ' o v e r f l o w ' , ' h i d d e n ' ) . w i d t h ( ) ; 
 	 o p t s . b e f o r e . p u s h ( f u n c t i o n ( c u r r ,   n e x t ,   o p t s ,   f w d )   { 
 	 	 $ . f n . c y c l e . c o m m o n R e s e t ( c u r r , n e x t , o p t s ) ; 
 	 	 o p t s . c s s B e f o r e . l e f t   =   f w d   ?   ( n e x t . c y c l e W - 1 )   :   ( 1 - n e x t . c y c l e W ) ; 
 	 	 o p t s . a n i m O u t . l e f t   =   f w d   ?   - c u r r . c y c l e W   :   c u r r . c y c l e W ; 
 	 } ) ; 
 	 o p t s . c s s F i r s t   =   {   l e f t :   0   } ; 
 	 o p t s . c s s B e f o r e =   {   t o p :   0   } ; 
 	 o p t s . a n i m I n       =   {   l e f t :   0   } ; 
 	 o p t s . a n i m O u t     =   {   t o p :   0   } ; 
 } ; 
 / / e n d   H o r i z o n t a l   S c r o l l 
 
 / /   c o v e r 
 / /   c u r r   s l i d e   c o v e r e d   b y   n e x t   s l i d e 
 $ . f n . c y c l e . t r a n s i t i o n s . c o v e r   =   f u n c t i o n ( $ c o n t ,   $ s l i d e s ,   o p t s )   { 
 	 v a r   d   =   o p t s . d i r e c t i o n   | |   ' l e f t ' ; 
 	 v a r   w   =   $ c o n t . c s s ( ' o v e r f l o w ' , ' h i d d e n ' ) . w i d t h ( ) ; 
 	 v a r   h   =   $ c o n t . h e i g h t ( ) ; 
 	 o p t s . b e f o r e . p u s h ( f u n c t i o n ( c u r r ,   n e x t ,   o p t s )   { 
 	 	 $ . f n . c y c l e . c o m m o n R e s e t ( c u r r , n e x t , o p t s ) ; 
 	 	 i f   ( d   = =   ' r i g h t ' )   
 	 	 	 o p t s . c s s B e f o r e . l e f t   =   - w ; 
 	 	 e l s e   i f   ( d   = =   ' u p ' ) 	       
 	 	 	 o p t s . c s s B e f o r e . t o p   =   h ; 
 	 	 e l s e   i f   ( d   = =   ' d o w n ' )     
 	 	 	 o p t s . c s s B e f o r e . t o p   =   - h ; 
 	 	 e l s e 
 	 	 	 o p t s . c s s B e f o r e . l e f t   =   w ; 
 	 } ) ; 
 	 o p t s . a n i m I n   =   {   l e f t :   0 ,   t o p :   0 } ; 
 	 o p t s . a n i m O u t   =   {   o p a c i t y :   1   } ; 
 	 o p t s . c s s B e f o r e   =   {   t o p :   0 ,   l e f t :   0   } ; 
 } ; 
 / /   e n d   c o v e r 
 
 / / E n d   C y c l e 
 
 / / S t a r t   C o l o r b o x   
 / / t h i s   i s   a   j Q u e r y   l i g h t b o x   p l u g i n 
 
 / /   C o l o r B o x   v 1 . 3 . 6   -   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   =   $ . b r o w s e r . m s i e   & &   ! $ . s u p p o r t . o p a c i t y ,   / /   f e a t u r e   d e t e c t i o n   a l o n e   g a v e   f a l s e   p o s i t i v e s   i n   s o m e   b r o w s e r s 
 	 i s I E 6   =   i s I E   & &   $ . b r o w s e r . v e r s i o n   <   7 , 
 
 	 / /   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 _ 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 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 B a y , 
 	 $ 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 , 
 	 e l e m e n t , 
 	 b o o k m a r k , 
 	 i n d e x , 
 	 s e t t i n g s , 
 	 o p e n , 
 	 a c t i v e , 
 	 
 	 / /   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 :   3 5 0 , 
 	 	 w i d t h :   F A L S E , 
 	 	 h e i g h t :   F A L S E , 
 	 	 i n n e r W i d t h :   F A L S E , 
 	 	 i n n e r H e i g h t :   F A L S E , 
 	 	 i n i t i a l W i d t h :   " 4 0 0 " , 
 	 	 i n i t i a l H e i g h t :   " 4 0 0 " , 
 	 	 m a x W i d t h :   F A L S E , 
 	 	 m a x H e i g h t :   F A L S E , 
 	 	 s c a l e P h o t o s :   T R U E , 
 	 	 s c r o l l i n g :   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 . 9 , 
 	 	 p r e l o a d i n g :   T R U E , 
 	 	 c u r r e n t :   " i m a g e   { 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 :   2 5 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 l i d e s h o w S t o p :   " s t o p   s l i d e s h o w " , 
 	 	 
 	 	 o n O p e n :   F A L S E , 
 	 	 o n L o a d :   F A L S E , 
 	 	 o n C o m p l e t e :   F A L S E , 
 	 	 o n C l e a n u p :   F A L S E , 
 	 	 o n C l o s e d :   F A L S E 
 	 } ; 
 	 
 	 / /   * * * * * * * * * * * * * * * * 
 	 / /   H E L P E R   F U N C T I O N S 
 	 / /   * * * * * * * * * * * * * * * * 
 	 	 
 	 / /   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 '   ?   $ w i n d o w . 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 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 ' )   ?   M a t h . r o u n d ( ( 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 )   { 
 	 	 u r l   =   $ . i s F u n c t i o n ( u r l )   ?   u r l . c a l l ( e l e m e n t )   :   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   ( $ . i s F u n c t i o n ( s e t t i n g s [ i ] )   & &   i . s u b s t r i n g ( 0 ,   2 )   ! = =   ' o n ' )   {   / /   c h e c k s   t o   m a k e   s u r e   t h e   f u n c t i o n   i s n ' t   o n e   o f   t h e   c a l l b a c k s ,   t h e y   w i l l   b e   h a n d l e d   a t   t h e   a p p r o p r i a t e   t i m e . 
 	 	 	         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 ) ; 
 	 	 	 } 
 	 	 } 
 	 	 s e t t i n g s . r e l   =   s e t t i n g s . r e l   | |   e l e m e n t . r e l ; 
 	 	 s e t t i n g s . 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 ; 
 	 	 s e t t i n g s . t i t l e   =   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 ; 
 	 } 
 
 	 f u n c t i o n   l a u n c h ( e l e m )   { 
 	 	 
 	 	 e l e m e n t   =   e l e m ; 
 	 	 
 	 	 s e t t i n g s   =   $ . e x t e n d ( { } ,   $ ( 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 ( ) ;   / /   C o n v e r t   f u n c t i o n s   t o   t h e i r   r e t u r n e d   v a l u e s . 
 	 	 
 	 	 i f   ( s e t t i n g s . r e l   & &   s e t t i n g s . 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   = = =   s e t t i n g s . 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 ) ; 
 	 	 	 
 	 	 	 / /   C h e c k   d i r e c t   c a l l s   t o   C o l o r B o x . 
 	 	 	 i f   ( i n d e x   <   0 )   { 
 	 	 	 	 $ 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 ; 
 	 	 	 
 	 	 	 a c t i v e   =   T R U E ;   / /   P r e v e n t s   t h e   p a g e - c h a n g e   a c t i o n   f r o m   q u e u i n g   u p   i f   t h e   v i s i t o r   h o l d s   d o w n   t h e   l e f t   o r   r i g h t   k e y s . 
 	 	 	 
 	 	 	 b o o k m a r k   =   e l e m e n t ; 
 	 	 	 
 	 	 	 b o o k m a r k . b l u r ( ) ;   / /   R e m o v e   t h e   f o c u s   f r o m   t h e   c a l l i n g   e l e m e n t . 
 	 	 	 
 	 	 	 / /   S e t   N a v i g a t i o n   K e y   B i n d i n g s 
 	 	 	 $ ( d o c u m e n t ) . 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 ( ) ; 
 	 	 	 	 } 
 	 	 	 } ) . b i n d ( " k e y d o w n . c b o x _ a r r o w s " ,   f u n c t i o n   ( e )   { 
 	 	 	 	 i f   ( $ r e l a t e d . l e n g t h   >   1 )   { 
 	 	 	 	 	 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 ( ) ; 
 	 	 	 	 	 } 
 	 	 	 	 } 
 	 	 	 } ) ; 
 	 	 	 
 	 	 	 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 ) ; 
 	 	 	 } 
 	 	 	 
 	 	 	 $ . e v e n t . t r i g g e r ( c b o x _ o p e n ) ; 
 	 	 	 i f   ( s e t t i n g s . o n O p e n )   { 
 	 	 	 	 s e t t i n g s . o n O p e n . c a l l ( e l e m e n t ) ; 
 	 	 	 } 
 	 	 	 
 	 	 	 $ 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 ( ) ; 
 	 	 	 
 	 	 	 / /   O p e n s   i n i t a l   e m p t y   C o l o r B o x   p r i o r   t o   c o n t e n t   b e i n g   l o a d e d . 
 	 	 	 s e t t i n g s . w   =   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 t i n g s . h   =   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 ' ) ; 
 	 	 	 c b o x P u b l i c . p o s i t i o n ( 0 ) ; 
 	 	 	 
 	 	 	 i f   ( i s I E 6 )   { 
 	 	 	 	 $ w i n d o w . b i n d ( ' 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 ' ,   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 ( " s c r o l l . c b o x i e 6 " ) ; 
 	 	 	 } 
 	 	 } 
 	 	 
 	 	 $ c u r r e n t . a d d ( $ p r e v ) . a d d ( $ n e x t ) . a d d ( $ s l i d e s h o w ) . a d d ( $ t i t l e ) . h i d e ( ) ; 
 	 	 
 	 	 $ c l o s e . h t m l ( s e t t i n g s . c l o s e ) . s h o w ( ) ; 
 	 	 
 	 	 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 ( ) ; 
 	 } 
 
 	 / /   * * * * * * * * * * * * * * * * 
 	 / /   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 a l l b a c k )   { 
 	 	 v a r   $ t h i s   =   t h i s ; 
 	 	 
 	 	 i f   ( ! $ t h i s . l e n g t h )   { 
 	 	 	 i f   ( $ t h i s . s e l e c t o r   = = =   ' ' )   {   / /   e m p t y   s e l e c t o r   m e a n s   a   d i r e c t   c a l l ,   i e :   $ . f n . c o l o r b o x ( ) ; 
 	 	 	 	 $ t h i s   =   $ ( ' < a / > ' ) ; 
 	 	 	 	 o p t i o n s . o p e n   =   T R U E ; 
 	 	 	 }   e l s e   {   / /   e l s e   t h e   s e l e c t o r   d i d n ' t   m a t c h   a n y t h i n g ,   a n d   c o l o r b o x   s h o u l d   g o   a h e a d   a n d   r e t u r n . 
 	 	 	 	 r e t u r n   t h i s ; 
 	 	 	 } 
 	 	 } 
 	 	 
 	 	 $ t h i s . e a c h ( f u n c t i o n   ( )   { 
 	 	 	 v a r   d a t a   =   $ . e x t e n d ( { } ,   $ ( t h i s ) . d a t a ( c o l o r b o x )   ?   $ ( t h i s ) . d a t a ( c o l o r b o x )   :   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 " ) ; 
 	 	 	 
 	 	 	 i f   ( c a l l b a c k )   { 
 	 	 	 	 $ ( t h i s ) . d a t a ( c o l o r b o x ) . o n C o m p l e t e   =   c a l l b a c k ; 
 	 	 	 } 
 	 	 } ) ; 
 	 	 
 	 	 i f   ( o p t i o n s   & &   o p t i o n s . o p e n )   { 
 	 	 	 l a u n c h ( $ t h i s ) ; 
 	 	 } 
 	 	 
 	 	 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 ' } ) ; 
 	 	 
 	 	 $ l o a d i n g B a y   =   $ ( " < d i v   s t y l e = ' p o s i t i o n : a b s o l u t e ;   t o p : 0 ;   l e f t : 0 ;   w i d t h : 9 9 9 9 p x ;   h e i g h t : 0 ; ' / > " ) ; 
 	 	 
 	 	 $ ( ' 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 ,   $ l o a d i n g B a y ) ) ; 
 	 	 	 	 
 	 	 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 ( ) 
 	 	 . b i n d ( ' m o u s e o v e r   m o u s e o u t ' ,   f u n c t i o n ( ) { 
 	 	 	 $ ( t h i s ) . t o g g l e C l a s s ( h o v e r ) ; 
 	 	 } ) . a d d C l a s s ( h o v e r ) ; 
 	 	 
 	 	 / /   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 E l e m e n t ' ) . l i v e ( ' c l i c k ' ,   f u n c t i o n   ( e )   { 
 	 	 	 i f   ( e . b u t t o n   ! = =   0   & &   t y p e o f   e . b u t t o n   ! = =   ' u n d e f i n e d ' )   { / /   c h e c k s   t o   s e e   i f   i t   w a s   a   n o n - l e f t   m o u s e - c l i c k . 
 	 	 	 	 r e t u r n   T R U E ; 
 	 	 	 }   e l s e   { 
 	 	 	 	 l a u n c h ( t h i s ) ; 	 	 	 
 	 	 	 	 r e t u r n   F A L S E ; 
 	 	 	 } 
 	 	 } ) ; 
 	 } ; 
 
 	 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   ( s p e e d ,   l o a d e d C a l l b a c k )   { 
 	 	 v a r 
 	 	 a n i m a t e _ s p e e d , 
 	 	 w i n H e i g h t   =   $ w i n d o w . h e i g h t ( ) , 
 	 	 / /   k e e p s   t h e   t o p   a n d   l e f t   p o s i t i o n s   w i t h i n   t h e   b r o w s e r ' s   v i e w p o r t . 
 	 	 p o s T o p   =   M a t h . m a x ( w i n H e i g h t   -   s e t t i n g s . h   -   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 , 0 ) / 2   +   $ w i n d o w . s c r o l l T o p ( ) , 
 	 	 p o s L e f t   =   M a t h . m a 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   -   s e t t i n g s . w   -   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 , 0 ) / 2   +   $ w i n d o w . s c r o l l L e f 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 ( )   = = =   s e t t i n g s . w + l o a d e d W i d t h   & &   $ c b o x . h e i g h t ( )   = = =   s e t t i n g s . h + l o a d e d 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 ( { w i d t h : s e t t i n g s . w + l o a d e d W i d t h ,   h e i g h t : s e t t i n g s . h + l o a d e d H e i g h t ,   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 ) ; 
 	 	 	 	 
 	 	 	 	 a c t i v e   =   F A L S E ; 
 	 	 	 	 
 	 	 	 	 / /   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   =   ( s e t t i n g s . w + 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 )   +   " p x " ; 
 	 	 	 	 $ w r a p [ 0 ] . s t y l e . h e i g h t   =   ( s e t t i n g s . h + 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 )   +   " 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 )   { 
 	 	 i f ( ! o p e n ) {   r e t u r n ;   } 
 	 	 
 	 	 v a r   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 
 	 	 	 	 v a r   $ c h i l d   =   $ l o a d e d . w r a p I n n e r ( " < d i v   s t y l e = ' o v e r f l o w : a u t o ' > < / d i v > " ) . c h i l d r e n ( ) ;   / /   t e m p o r a r y   w r a p p e r   t o   g e t   a n   a c c u r a t e   e s t i m a t e   o f   j u s t   h o w   h i g h   t h e   t o t a l   c o n t e n t   s h o u l d   b e . 
 	 	 	 	 s e t t i n g s . h   =   $ c h i l d . h e i g h t ( ) ; 
 	 	 	 	 $ l o a d e d . c s s ( { h e i g h t : s e t t i n g s . h } ) ; 
 	 	 	 	 $ c h i l d . r e p l a c e W i t h ( $ c h i l d . c h i l d r e n ( ) ) ;   / /   d i t c h   t h e   t e m p o r a r y   w r a p p e r   d i v   u s e d   i n   h e i g h t   c a l c u l a t i o n 
 	 	 	 	 c b o x P u b l i c . p o s i t i o n ( 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   =   $ ( ' < d i v   i d = " c b o x L o a d e d C o n t e n t " / > ' ) . h t m l ( o b j e c t ) ; 
 	 	 
 	 	 f u n c t i o n   g e t W i d t h ( ) { 
 	 	 	 s e t t i n g s . w   =   s e t t i n g s . w   | |   $ l o a d e d . w i d t h ( ) ; 
 	 	 	 s e t t i n g s . w   =   s e t t i n g s . m w   & &   s e t t i n g s . m w   <   s e t t i n g s . w   ?   s e t t i n g s . m w   :   s e t t i n g s . w ; 
 	 	 	 r e t u r n   s e t t i n g s . w ; 
 	 	 } 
 	 	 f u n c t i o n   g e t H e i g h t ( ) { 
 	 	 	 s e t t i n g s . h   =   s e t t i n g s . h   | |   $ l o a d e d . h e i g h t ( ) ; 
 	 	 	 s e t t i n g s . h   =   s e t t i n g s . m h   & &   s e t t i n g s . m h   <   s e t t i n g s . h   ?   s e t t i n g s . m h   :   s e t t i n g s . h ; 
 	 	 	 r e t u r n   s e t t i n g s . h ; 
 	 	 } 
 	 	 
 	 	 $ l o a d e d . h i d e ( ) 
 	 	 . a p p e n d T o ( $ l o a d i n g B a y ) / /   c o n t e n t   h a s   t o   b e   a p p e n d e d   t o   t h e   D O M   f o r   a c c u r a t e   s i z e   c a l c u l a t i o n s .     A p p e n d e d   t o   a n   a b s o l u t e l y   p o s i t i o n e d   e l e m e n t ,   r a t h e r   t h a n   B O D Y ,   w h i c h   a v o i d s   a n   e x t r e m e l y   b r i e f   d i s p l a y   o f   t h e   v e r t i c a l   s c r o l l b a r   i n   F i r e f o x   t h a t   c a n   o c c u r   f o r   a   s m a l l   m i n o r i t y   o f   w e b s i t e s . 
 	 	 . c s s ( { w i d t h : g e t W i d t h ( ) ,   o v e r f l o w : s e t t i n g s . s c r o l l i n g   ?   ' a u t o '   :   ' h i d d e n ' } ) 
 	 	 . 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 ) ; 
 	 	 
 	 	 $ ( ' # c b o x P h o t o ' ) . c s s ( { c s s F l o a t : ' n o n e ' } ) ; / /   f l o a t i n g   t h e   I M G   r e m o v e s   t h e   b o t t o m   l i n e - h e i g h t   a n d   f i x e d   a   p r o b l e m   w h e r e   I E   m i s c a l c u l a t e s   t h e   w i d t h   o f   t h e   p a r e n t   e l e m e n t   a s   1 0 0 %   o f   t h e   d o c u m e n t   w i d t h . 
 	 	 
 	 	 / /   H i d e s   S E L E C T   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 . s t y l e . 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 . s t y l e . v i s i b i l i t y   =   ' i n h e r i t ' ; 
 	 	 	 } ) ; 
 	 	 } 
 	 	 	 	 
 	 	 f u n c t i o n   s e t P o s i t i o n   ( s )   { 
 	 	 	 c b o x P u b l i c . p o s i t i o n ( 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 " ) ; 
 	 	 	 	 } 
 	 	 	 	 
 	 	 	 	 / / 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 . 
 	 	 	 	 i f ( s e t t i n g s . i f r a m e ) { 
 	 	 	 	 	 $ l o a d e d . a p p e n d ( " < i f r a m e   i d = ' c b o x I f r a m e ' "   +   ( s e t t i n g s . s c r o l l i n g   ?   "   "   :   " s c r o l l i n g = ' n o ' " )   +   "   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 + " '   "   +   ( i s I E   ?   " a l l o w t r a n s p a r e n c y = ' t r u e ' "   :   ' ' )   +   "   / > " ) ; 
 	 	 	 	 } 
 	 	 	 	 
 	 	 	 	 $ l o a d e d . s h o w ( ) ; 
 	 	 	 	 
 	 	 	 	 $ t i t l e . s h o w ( ) . h t m l ( s e t t i n g s . t i t l e ) ; 
 	 	 	 	 
 	 	 	 	 i f   ( $ r e l a t e d . l e n g t h > 1 )   { 
 	 	 	 	 	 $ c u r r e n t . h t m l ( s e t t i n g s . 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 ) ) . s h o w ( ) ; 
 	 	 	 	 	 $ n e x t . h t m l ( s e t t i n g s . n e x t ) . s h o w ( ) ; 
 	 	 	 	 	 $ p r e v . h t m l ( s e t t i n g s . p r e v i o u s ) . s h o w ( ) ; 
 	 	 	 	 	 
 	 	 	 	 	 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 ( ) ; 
 	 	 	 	 	 } 
 	 	 	 	 } 
 	 	 	 	 
 	 	 	 	 $ 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 ( ) ; 
 	 	 	 	 
 	 	 	 	 $ . 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   ( s e t t i n g s . o n C o m p l e t e )   { 
 	 	 	 	 	 s e t t i n g s . o n C o m p l e t e . 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 ( 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 r e f ,   i m g ,   s e t R e s i z e ,   r e s i z e   =   c b o x P u b l i c . r e s i z e ; 
 	 	 
 	 	 a c t i v e   =   T R U E ; 
 	 	 
 	 	 / * 
 	 	   
 	 	 / /   I   d e c i d e d   t o   c o m m e n t   t h i s   o u t   b e c a u s e   I   c a n   s e e   i t   c a u s i n g   p r o b l e m s   a s   u s e r s 
 	 	 / /   r e a l l y   s h o u l d   j u s t   s e t   t h e   d i m e n s i o n s   o n   t h e i r   I M G   e l e m e n t s   i n s t e a d , 
 	 	 / /   b u t   I ' m   l e a v i n g   t h e   c o d e   i n   a s   i t   m a y   b e   u s e f u l   t o   s o m e o n e . 
 	 	 / /   T o   u s e ,   u n c o m m e n t   t h e   f u n c t i o n   a n d   c h a n g e   ' 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 ) ;   } ' 
 	 	 / /   t o   ' i f ( t e x t S t a t u s   = = =   " s u c c e s s " ) {   p r e l o a d ( t h i s ) ;   } ' 
 	 	 
 	 	 / /   P r e l o a d   l o o p s   t h r o u g h   t h e   H T M L   t o   f i n d   I M G   e l e m e n t s   a n d   l o a d s   t h e i r   s o u r c e s . 
 	 	 / /   T h i s   a l l o w s   t h e   r e s i z e   m e t h o d   t o   a c c u r a t e l y   e s t i m a t e   t h e   d i m e n s i o n s   o f   t h e   n e w   c o n t e n t . 
 	 	 f u n c t i o n   p r e l o a d ( h t m l ) { 
 	 	 	 v a r 
 	 	 	 $ a j a x   =   $ ( h t m l ) , 
 	 	 	 $ i m g s   =   $ a j a x . f i n d ( ' i m g ' ) , 
 	 	 	 x   =   $ i m g s . l e n g t h ; 
 	 	 	 
 	 	 	 f u n c t i o n   l o a d l o o p ( ) { 
 	 	 	 	 v a r   i m g   =   n e w   I m a g e ( ) ; 
 	 	 	 	 x   =   x - 1 ; 
 	 	 	 	 i f ( x   > =   0 ) { 
 	 	 	 	 	 i m g . o n l o a d   =   l o a d l o o p ; 
 	 	 	 	 	 i m g . s r c   =   $ i m g s [ x ] . s r c ; 
 	 	 	 	 }   e l s e   { 
 	 	 	 	 	 r e s i z e ( $ a j a x ) ; 
 	 	 	 	 } 
 	 	 	 } 
 	 	 	 
 	 	 	 l o a d l o o p ( ) ; 
 	 	 } 
 	 	 * / 
 	 	 
 	 	 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 x t e n d ( { } ,   $ ( 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 ) ; 
 	 	 i f   ( s e t t i n g s . o n L o a d )   { 
 	 	 	 s e t t i n g s . o n L o a d . c a l l ( e l e m e n t ) ; 
 	 	 } 
 	 	 
 	 	 / /   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 . 
 	 	 s e t t i n g s . h   =   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   : 
 	 	 	 	 s e t t i n g s . i n n e r H e i g h t   ? 
 	 	 	 	 	 s e t S i z e ( s e t t i n g s . i n n e r H e i g h t ,   ' y ' )   : 
 	 	 	 	 	 F A L S E ; 
 	 	 s e t t i n g s . w   =   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   : 
 	 	 	 	 s e t t i n g s . i n n e r W i d t h   ? 
 	 	 	 	 	 s e t S i z e ( s e t t i n g s . i n n e r W i d t h ,   ' x ' )   : 
 	 	 	 	 	 F A L S E ; 
 	 	 
 	 	 / /   S e t s   t h e   m i n i m u m   d i m e n s i o n s   f o r   u s e   i n   i m a g e   s c a l i n g 
 	 	 s e t t i n g s . m w   =   s e t t i n g s . w ; 
 	 	 s e t t i n g s . m h   =   s e t t i n g s . h ; 
 	 	 
 	 	 / /   R e - e v a l u a t e   t h e   m i n i m u m   w i d t h   a n d   h e i g h t   b a s e d   o n   m a x W i d t h   a n d   m a x H e i g h t   v a l u e s . 
 	 	 / /   I f   t h e   w i d t h   o r   h e i g h t   e x c e e d   t h e   m a x W i d t h   o r   m a x H e i g h t ,   u s e   t h e   m a x i m u m   v a l u e s   i n s t e a d . 
 	 	 i f ( s e t t i n g s . m a x W i d t h ) { 
 	 	 	 s e t t i n g s . m w   =   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 ; 
 	 	 	 s e t t i n g s . m w   =   s e t t i n g s . w   & &   s e t t i n g s . w   <   s e t t i n g s . m w   ?   s e t t i n g s . w   :   s e t t i n g s . m w ; 
 	 	 } 
 	 	 i f ( s e t t i n g s . m a x H e i g h t ) { 
 	 	 	 s e t t i n g s . m h   =   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 ; 
 	 	 	 s e t t i n g s . m h   =   s e t t i n g s . h   & &   s e t t i n g s . h   <   s e t t i n g s . m h   ?   s e t t i n g s . h   :   s e t t i n g s . m h ; 
 	 	 } 
 	 	 
 	 	 h r e f   =   s e t t i n g s . 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 ( ) ; 
 	 	 
 	 	 i f   ( s e t t i n g s . i n l i n e )   { 
 	 	 	 / /   I n s e r t s   a n   e m p t y   p l a c e h o l d e r   w h e r e   i n l i n e   c o n t e n t   i s   b e i n g   p u l l e d   f r o m . 
 	 	 	 / /   A n   e v e n t   i s   b o u n d   t o   p u t   i n l i n e   c o n t e n t   b a c k   w h e n   C o l o r B o x   c l o s e s   o r   l o a d s   n e w   c o n t e n t . 
 	 	 	 $ ( ' < 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 ( ) { 
 	 	 	 	 $ ( t h i s ) . r e p l a c e W i t h ( $ l o a d e d . c h i l d r e n ( ) ) ; 
 	 	 	 } ) ; 
 	 	 	 r e s i z e ( $ ( h r e f ) ) ; 
 	 	 }   e l s e   i f   ( s e t t i n g s . i f r a m e )   { 
 	 	 	 / /   I F r a m e   e l e m e n t   w o n ' t   b e   a d d e d   t o   t h e   D O M   u n t i l   i t   i s   r e a d y   t o   b e   d i s p l a y e d , 
 	 	 	 / /   t o   a v o i d   p r o b l e m s   w i t h   D O M - r e a d y   J S   t h a t   m i g h t   b e   t r y i n g   t o   r u n   i n   t h a t   i f r a m e . 
 	 	 	 r e s i z e ( "   " ) ; 
 	 	 }   e l s e   i f   ( s e t t i n g s . h t m l )   { 
 	 	 	 r e s i z e ( 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 ) ) { 
 	 	 	 i m g   =   n e w   I m a g e ( ) ; 
 	 	 	 i m g . o n l o a d   =   f u n c t i o n ( ) { 
 	 	 	 	 v a r   p e r c e n t ; 
 	 	 	 	 
 	 	 	 	 i m g . o n l o a d   =   n u l l ; 
 	 	 	 	 
 	 	 	 	 i m g . i d   =   ' c b o x P h o t o ' ; 
 	 	 	 	 
 	 	 	 	 $ ( i m g ) . c s s ( { m a r g i n : ' a u t o ' ,   b o r d e r : ' n o n e ' ,   d i s p l a y : ' b l o c k ' ,   c s s F l o a t : ' l e f t ' } ) ; 
 	 	 	 	 
 	 	 	 	 i f ( s e t t i n g s . s c a l e P h o t o s ) { 
 	 	 	 	 	 s e t R e s i z e   =   f u n c t i o n ( ) { 
 	 	 	 	 	 	 i m g . h e i g h t   - =   i m g . h e i g h t   *   p e r c e n t ; 
 	 	 	 	 	 	 i m g . w i d t h   - =   i m g . w i d t h   *   p e r c e n t ; 	 
 	 	 	 	 	 } ; 
 	 	 	 	 	 i f ( s e t t i n g s . m w   & &   i m g . w i d t h   >   s e t t i n g s . m w ) { 
 	 	 	 	 	 	 p e r c e n t   =   ( i m g . w i d t h   -   s e t t i n g s . m w )   /   i m g . w i d t h ; 
 	 	 	 	 	 	 s e t R e s i z e ( ) ; 
 	 	 	 	 	 } 
 	 	 	 	 	 i f ( s e t t i n g s . m h   & &   i m g . h e i g h t   >   s e t t i n g s . m h ) { 
 	 	 	 	 	 	 p e r c e n t   =   ( i m g . h e i g h t   -   s e t t i n g s . m h )   /   i m g . h e i g h t ; 
 	 	 	 	 	 	 s e t R e s i z e ( ) ; 
 	 	 	 	 	 } 
 	 	 	 	 } 
 	 	 	 	 
 	 	 	 	 i f   ( s e t t i n g s . h )   { 
 	 	 	 	 	 i m g . s t y l e . m a r g i n T o p   =   M a t h . m a x ( s e t t i n g s . h   -   i m g . h e i g h t , 0 ) / 2   +   ' p x ' ; 
 	 	 	 	 } 
 	 	 	 	 
 	 	 	 	 r e s i z e ( i m g ) ; 
 	 	 	 	 
 	 	 	 	 i f ( $ r e l a t e d . l e n g t h   >   1 ) { 
 	 	 	 	 	 $ ( i m g ) . 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 ) { 
 	 	 	 	 	 i m g . 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 ' ; 
 	 	 	 	 } 
 	 	 	 } ; 
 	 	 	 i m g . s r c   =   h r e f ; 
 	 	 }   e l s e   { 
 	 	 	 $ ( ' < d i v   / > ' ) . a p p e n d T o ( $ l o a d i n g B a y ) . 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 f ( ! a c t i v e ) { 
 	 	 	 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 f ( ! a c t i v e ) { 
 	 	 	 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 o s e d ,   f u n c t i o n ( ) { 
 	 	 	 $ s l i d e s h o w . u n b i n d ( ) ; 
 	 	 	 c l e a r T i m e o u t ( t i m e O u t ) ; 
 	 	 	 $ 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 " + "   " + c l a s s N a m e + " o n " ) ; 
 	 	 } ) ; 
 	 	 
 	 	 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 ) ; 
 	 	 i f   ( s e t t i n g s . o n C l e a n u p )   { 
 	 	 	 s e t t i n g s . o n C l e a n u p . c a l l ( e l e m e n t ) ; 
 	 	 } 
 	 	 
 	 	 o p e n   =   F A L S E ; 
 	 	 $ ( d o c u m e n t ) . u n b i n d ( " k e y d o w n . c b o x _ c l o s e   k e y d o w n . c b o x _ a r r o w s " ) ; 
 	 	 $ w i n d o w . u n b i n d ( c b o x _ r e s i z e + '   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 ' ) ; 
 	 	 $ 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   ( )   { 
 	 	 	 $ ( ' # c o l o r b o x   i f r a m e ' ) . a t t r ( ' s r c ' ,   ' a b o u t : b l a n k ' ) ; 
 	 	 	 $ 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 } ) ; 
 	 	 	 
 	 	 	 t r y { 
 	 	 	 	 b o o k m a r k . f o c u s ( ) ; 
 	 	 	 }   c a t c h   ( e r ) { 
 	 	 	 	 / /   d o   n o t h i n g 
 	 	 	 } 
 	 	 	 
 	 	 	 $ . e v e n t . t r i g g e r ( c b o x _ c l o s e d ) ; 
 	 	 	 i f   ( s e t t i n g s . o n C l o s e d )   { 
 	 	 	 	 s e t t i n g s . o n C l o s e d . c a l l ( e l e m e n t ) ; 
 	 	 	 } 
 	 	 } ) ; 
 	 } ; 
 
 	 / /   A   m e t h o d   f o r   f e t c h i n g   t h e   c u r r e n t   e l e m e n t   C o l o r B o x   i s   r e f e r e n c i n g . 
 	 / /   r e t u r n s   a   j Q u e r y   o b j e c t . 
 	 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 ) ) ; 
 
 
 / / E n d   C o l o r B o x 
