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