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