ÿþ/ / F e a t u r e d   C o n t e n t   G l i d e r :   B y   h t t p : / / w w w . d y n a m i c d r i v e . c o m  
 / / C r e a t e d :   D e c   2 2 n d ,   0 7 '  
 / / U p d a t e d   ( J a n   2 9 t h ,   0 8 ) :   A d d e d   f o u r   p o s s i b l e   s l i d e   d i r e c t i o n s :   " u p d o w n " ,   " d o w n u p " ,   " l e f t r i g h t " ,   o r   " r i g h t l e f t "  
 / / U p d a t e d   ( F e b   1 s t ,   0 8 ) :   C h a n g e d   g l i d e   b e h a v i o r   t o   r e v e r s e   d i r e c t i o n   w h e n   p r e v i o u s   b u t t o n   i s   c l i c k e d  
 / / U p d a t e d   ( F e b   1 2 t h ,   0 8 ) :   A d d e d   a b i l i t y   t o   r e t r i e v e   g l i d i n g   c o n t e n t s   f r o m   a n   e x t e r n a l   f i l e   u s i n g   A j a x   ( " r e m o t e c o n t e n t "   v a r i a b l e   a d d e d   t o   c o n f i g u r a t i o n )  
  
 v a r   f e a t u r e d c o n t e n t g l i d e r = {  
 	 c s s z i n d e x :   1 0 0 ,  
 	 a j a x l o a d i n g m s g :   ' < b > /1  -'D  ('1¯2'1Ì    D7A'  5(1  ©FÌ/  < / b > ' ,  
 	 g l i d e : f u n c t i o n ( c o n f i g ,   s h o w p a g e ,   i s p r e v ) {  
 	 	 v a r   s e l e c t e d = p a r s e I n t ( s h o w p a g e )  
 	 	 i f   ( s e l e c t e d > = c o n f i g . $ c o n t e n t d i v s . l e n g t h ) {   / / i f   n o   c o n t e n t   e x i s t s   a t   t h i s   i n d e x   p o s i t i o n  
 	 	 	 a l e r t ( " N o   c o n t e n t   e x i s t s   a t   p a g e   " + ( s e l e c t e d + 1 ) + " !   L o a d i n g   1 s t   p a g e   i n s t e a d . " )  
 	 	 	 s e l e c t e d = 0  
 	 	 }  
 	 	 v a r   $ t a r g e t = c o n f i g . $ c o n t e n t d i v s . e q ( s e l e c t e d )  
 	 	 / / T e s t   f o r   t o g g l e r   n o t   b e i n g   i n i t i a l i z e d   y e t ,   o r   u s e r   c l i c k s   o n   t h e   c u r r e n t l y   s e l e c t e d   p a g e ) :  
 	 	 i f   ( c o n f i g . $ t o g g l e r d i v . a t t r ( ' l a s t s e l e c t e d ' ) = = n u l l   | |   p a r s e I n t ( c o n f i g . $ t o g g l e r d i v . a t t r ( ' l a s t s e l e c t e d ' ) ) ! = s e l e c t e d ) {  
 	 	 	 v a r   $ s e l e c t e d l i n k = c o n f i g . $ t o c . e q ( s e l e c t e d )  
 	 	 	 c o n f i g . $ n e x t . a t t r ( ' l o a d p a g e ' ,   ( s e l e c t e d < c o n f i g . $ c o n t e n t d i v s . l e n g t h - 1 ) ?   s e l e c t e d + 1 + ' p g '   :   0 + ' p g ' )  
 	 	 	 c o n f i g . $ p r e v . a t t r ( ' l o a d p a g e ' ,   ( s e l e c t e d = = 0 ) ?   c o n f i g . $ c o n t e n t d i v s . l e n g t h - 1 + ' p g '   :   s e l e c t e d - 1 + ' p g ' )  
 	 	 	 v a r   s t a r t p o i n t = ( i s p r e v = = " p r e v i o u s " ) ?   - c o n f i g . s t a r t p o i n t   :   c o n f i g . s t a r t p o i n t  
 	 	 	 $ t a r g e t . c s s ( c o n f i g . l e f t o r t o p ,   s t a r t p o i n t ) . c s s ( " z I n d e x " ,   t h i s . c s s z i n d e x + + )   / / h i d e   c o n t e n t   s o   i t ' s   j u s t   o u t   o f   v i e w   b e f o r e   a n i m a t i n g   i t  
 	 	 	 v a r   e n d p o i n t = ( c o n f i g . l e f t o r t o p = = " l e f t " ) ?   { l e f t : 0 }   :   { t o p : 0 }   / / a n i m a t e   i t   i n t o   v i e w  
 	 	 	 $ t a r g e t . a n i m a t e ( e n d p o i n t ,   c o n f i g . s p e e d )  
 	 	 	 c o n f i g . $ t o c . r e m o v e C l a s s ( ' s e l e c t e d ' )  
 	 	 	 $ s e l e c t e d l i n k . a d d C l a s s ( ' s e l e c t e d ' )  
 	 	 	 c o n f i g . $ t o g g l e r d i v . a t t r ( ' l a s t s e l e c t e d ' ,   s e l e c t e d + ' p g ' )  
 	 	 }  
 	 } ,  
  
 	 g e t r e m o t e c o n t e n t : f u n c t i o n ( c o n f i g ) {  
 	 	 c o n f i g . $ g l i d e r . h t m l ( t h i s . a j a x l o a d i n g m s g )  
 	 	 $ . a j a x ( {  
 	 	 	 u r l :   c o n f i g . r e m o t e c o n t e n t ,  
 	 	 	 e r r o r : f u n c t i o n ( a j a x r e q u e s t ) {  
 	 	 	 	 c o n f i g . $ g l i d e r . h t m l ( ' E r r o r   f e t c h i n g   c o n t e n t . < b r   / > S e r v e r   R e s p o n s e :   ' + a j a x r e q u e s t . r e s p o n s e T e x t )  
 	 	 	 } ,  
 	 	 	 s u c c e s s : f u n c t i o n ( c o n t e n t ) {  
 	 	 	 	 c o n f i g . $ g l i d e r . h t m l ( c o n t e n t )  
 	 	 	 	 f e a t u r e d c o n t e n t g l i d e r . s e t u p t o g g l e r ( c o n f i g )  
 	 	 	 }  
 	 	 } )  
 	 } ,  
  
 	 a l i g n c o n t e n t s : f u n c t i o n ( c o n f i g ) {  
 	 	 c o n f i g . $ c o n t e n t d i v s = $ ( " # " + c o n f i g . g l i d e r i d + "   . " + c o n f i g . c o n t e n t c l a s s )  
 	 	 c o n f i g . $ c o n t e n t d i v s . c s s ( c o n f i g . l e f t o r t o p ,   c o n f i g . s t a r t p o i n t ) . c s s ( { h e i g h t :   c o n f i g . $ g l i d e r . h e i g h t ( ) ,   v i s i b i l i t y :   ' v i s i b l e ' } )   / / p o s i t i o n   c o n t e n t   d i v s   s o   t h e y ' r e   o u t   o f   v i e w :  
 	 } ,  
  
 	 s e t u p t o g g l e r : f u n c t i o n ( c o n f i g ) {  
 	 	 t h i s . a l i g n c o n t e n t s ( c o n f i g )  
 	 	 c o n f i g . $ t o g g l e r d i v . h i d e ( )  
 	 	 c o n f i g . $ t o c . e a c h ( f u n c t i o n ( i n d e x ) {  
 	 	 	 	 $ ( t h i s ) . a t t r ( ' p a g e n u m b e r ' ,   i n d e x + ' p g ' )  
 	 	 	 	 i f   ( i n d e x   >   ( c o n f i g . $ c o n t e n t d i v s . l e n g t h - 1 ) )  
 	 	 	 	 	 $ ( t h i s ) . c s s ( { d i s p l a y :   ' n o n e ' } )   / / h i d e   r e d u n d a n t   " t o c "   l i n k s  
 	 	 } )  
 	 	 v a r   $ n e x t a n d p r e v = $ ( " # " + c o n f i g . t o g g l e r i d + "   . n e x t ,   # " + c o n f i g . t o g g l e r i d + "   . p r e v " )  
 	 	 $ n e x t a n d p r e v . c l i c k ( f u n c t i o n ( e v e n t ) {   / / A s s i g n   c l i c k   b e h a v i o r   t o   ' n e x t '   a n d   ' p r e v '   l i n k s  
 	 	 	 f e a t u r e d c o n t e n t g l i d e r . g l i d e ( c o n f i g ,   t h i s . g e t A t t r i b u t e ( ' l o a d p a g e ' ) ,   t h i s . g e t A t t r i b u t e ( ' b u t t o n t y p e ' ) )  
 	 	 	 e v e n t . p r e v e n t D e f a u l t ( )   / / c a n c e l   d e f a u l t   l i n k   a c t i o n  
 	 	 } )  
 	 	 c o n f i g . $ t o c . c l i c k ( f u n c t i o n ( e v e n t ) {   / / A s s i g n   c l i c k   b e h a v i o r   t o   ' t o c '   l i n k s  
 	 	 	 f e a t u r e d c o n t e n t g l i d e r . g l i d e ( c o n f i g ,   t h i s . g e t A t t r i b u t e ( ' p a g e n u m b e r ' ) )  
 	 	 	 e v e n t . p r e v e n t D e f a u l t ( )  
 	 	 } )  
 	 	 c o n f i g . $ t o g g l e r d i v . f a d e I n ( 1 0 0 0 ,   f u n c t i o n ( ) {  
 	 	 	 f e a t u r e d c o n t e n t g l i d e r . g l i d e ( c o n f i g ,   c o n f i g . s e l e c t e d )  
 	 	 	 i f   ( c o n f i g . a u t o r o t a t e = = t r u e ) {   / / a u t o   r o t a t e   c o n t e n t s ?  
 	 	 	 	 c o n f i g . s t e p c o u n t = 0   / / s e t   s t e p s   t a k e n  
 	 	 	 	 c o n f i g . t o t a l s t e p s = c o n f i g . $ c o n t e n t d i v s . l e n g t h * c o n f i g . a u t o r o t a t e c o n f i g [ 1 ]   / / T o t a l   s t e p s   l i m i t :   n u m   o f   c o n t e n t s   x   n u m   o f   u s e r   s p e c i f i e d   c y c l e s )  
 	 	 	 	 f e a t u r e d c o n t e n t g l i d e r . a u t o r o t a t e ( c o n f i g )  
 	 	 	 }  
 	 	 } )  
 	 	 c o n f i g . $ t o g g l e r d i v . c l i c k ( f u n c t i o n ( ) {  
 	 	 	 f e a t u r e d c o n t e n t g l i d e r . c a n c e l a u t o r o t a t e ( c o n f i g . t o g g l e r i d )  
 	 	 } )  
 	 } ,  
  
 	 a u t o r o t a t e : f u n c t i o n ( c o n f i g ) {  
 	 	 v a r   r o t a t e s p e e d = c o n f i g . s p e e d + c o n f i g . a u t o r o t a t e c o n f i g [ 0 ]  
 	 	 w i n d o w [ c o n f i g . t o g g l e r i d + " t i m e r " ] = s e t I n t e r v a l ( f u n c t i o n ( ) {  
 	 	 	 i f   ( c o n f i g . t o t a l s t e p s > 0   & &   c o n f i g . s t e p c o u n t > = c o n f i g . t o t a l s t e p s ) {  
 	 	 	 	 c l e a r I n t e r v a l ( w i n d o w [ c o n f i g . t o g g l e r i d + " t i m e r " ] )  
 	 	 	 }  
 	 	 	 e l s e {  
 	 	 	 	 c o n f i g . $ n e x t . c l i c k ( )  
 	 	 	 	 c o n f i g . s t e p c o u n t + +  
 	 	 	 }  
 	 	 } ,   r o t a t e s p e e d )  
 	 } ,  
  
 	 c a n c e l a u t o r o t a t e : f u n c t i o n ( t o g g l e r i d ) {  
 	 	 i f   ( w i n d o w [ t o g g l e r i d + " t i m e r " ] )  
 	 	 	 c l e a r I n t e r v a l ( w i n d o w [ t o g g l e r i d + " t i m e r " ] )  
 	 } ,  
  
 	 g e t C o o k i e : f u n c t i o n ( N a m e ) {    
 	 	 v a r   r e = n e w   R e g E x p ( N a m e + " = [ ^ ; ] + " ,   " i " )   / / c o n s t r u c t   R E   t o   s e a r c h   f o r   t a r g e t   n a m e / v a l u e   p a i r  
 	 	 i f   ( d o c u m e n t . c o o k i e . m a t c h ( r e ) )   / / i f   c o o k i e   f o u n d  
 	 	 	 r e t u r n   d o c u m e n t . c o o k i e . m a t c h ( r e ) [ 0 ] . s p l i t ( " = " ) [ 1 ]   / / r e t u r n   i t s   v a l u e  
 	 	 r e t u r n   n u l l  
 	 } ,  
  
 	 s e t C o o k i e : f u n c t i o n ( n a m e ,   v a l u e ) {  
 	 	 d o c u m e n t . c o o k i e   =   n a m e + " = " + v a l u e  
 	 } ,  
  
 	 i n i t : f u n c t i o n ( c o n f i g ) {  
 	 	 $ ( d o c u m e n t ) . r e a d y ( f u n c t i o n ( ) {  
 	 	 	 c o n f i g . $ g l i d e r = $ ( " # " + c o n f i g . g l i d e r i d )  
 	 	 	 c o n f i g . $ t o g g l e r d i v = $ ( " # " + c o n f i g . t o g g l e r i d )  
 	 	 	 c o n f i g . $ t o c = c o n f i g . $ t o g g l e r d i v . f i n d ( ' . t o c ' )  
 	 	 	 c o n f i g . $ n e x t = c o n f i g . $ t o g g l e r d i v . f i n d ( ' . n e x t ' )  
 	 	 	 c o n f i g . $ p r e v = c o n f i g . $ t o g g l e r d i v . f i n d ( ' . p r e v ' )  
 	 	 	 c o n f i g . $ p r e v . a t t r ( ' b u t t o n t y p e ' ,   ' p r e v i o u s ' )  
 	 	 	 v a r   s e l e c t e d = ( c o n f i g . p e r s i s t s t a t e ) ?   f e a t u r e d c o n t e n t g l i d e r . g e t C o o k i e ( c o n f i g . g l i d e r i d )   :   c o n f i g . s e l e c t e d  
 	 	 	 c o n f i g . s e l e c t e d = ( i s N a N ( p a r s e I n t ( s e l e c t e d ) ) )   ?   c o n f i g . s e l e c t e d   :   s e l e c t e d   / / t e s t   f o r   c o o k i e   v a l u e   c o n t a i n i n g   n u l l   ( 1 s t   p a g e   l o a d )   o r   " u n d e f i n e d "   s t r i n g 	  
 	 	 	 c o n f i g . l e f t o r t o p = ( / u p / i . t e s t ( c o n f i g . d i r e c t i o n ) ) ?   " t o p "   :   " l e f t "   / / s e t   w h i c h   C S S   p r o p e r t y   t o   m a n i p u l a t e   b a s e d   o n   " d i r e c t i o n "  
 	 	 	 c o n f i g . h e i g h t o r w i d t h = ( / u p / i . t e s t ( c o n f i g . d i r e c t i o n ) ) ?   c o n f i g . $ g l i d e r . h e i g h t ( )   :   c o n f i g . $ g l i d e r . w i d t h ( )   / / G e t   g l i d e r   h e i g h t   o r   w i d t h   b a s e d   o n   " d i r e c t i o n "  
 	 	 	 c o n f i g . s t a r t p o i n t = ( / ^ ( l e f t | u p ) / i . t e s t ( c o n f i g . d i r e c t i o n ) ) ?   - c o n f i g . h e i g h t o r w i d t h   :   c o n f i g . h e i g h t o r w i d t h   / / s e t   i n i t i a l   p o s i t i o n   o f   c o n t e n t s   b a s e d   o n   " d i r e c t i o n "  
 	 	 	 i f   ( t y p e o f   c o n f i g . r e m o t e c o n t e n t ! = " u n d e f i n e d "   & &   c o n f i g . r e m o t e c o n t e n t . l e n g t h > 0 )  
 	 	 	 	 f e a t u r e d c o n t e n t g l i d e r . g e t r e m o t e c o n t e n t ( c o n f i g )  
 	 	 	 e l s e  
 	 	 	 	 f e a t u r e d c o n t e n t g l i d e r . s e t u p t o g g l e r ( c o n f i g )  
 	 	 	 $ ( w i n d o w ) . b i n d ( ' u n l o a d ' ,   f u n c t i o n ( ) {   / / c l e a n   u p   a n d   p e r s i s t  
 	 	 	 	 c o n f i g . $ t o g g l e r d i v . u n b i n d ( ' c l i c k ' )  
 	 	 	 	 c o n f i g . $ t o c . u n b i n d ( ' c l i c k ' )  
 	 	 	 	 c o n f i g . $ n e x t . u n b i n d ( ' c l i c k ' )  
 	 	 	 	 c o n f i g . $ p r e v . u n b i n d ( ' c l i c k ' )  
 	 	 	 	 i f   ( c o n f i g . p e r s i s t s t a t e )  
 	 	 	 	 	 f e a t u r e d c o n t e n t g l i d e r . s e t C o o k i e ( c o n f i g . g l i d e r i d ,   c o n f i g . $ t o g g l e r d i v . a t t r ( ' l a s t s e l e c t e d ' ) )  
 	 	 	 	 c o n f i g = n u l l  
 	 	 	 	  
 	 	 	 } )  
 	 	 } )  
 	 }  
 } 
