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