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