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