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