ÿþ/ /   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
 / /             S i m p l e   C a l e n d a r   W i d g e t   -   C r o s s - B r o w s e r   J a v a s c r i p t   p o p - u p   c a l e n d a r .  
 / /  
 / /       C o p y r i g h t   ( C )   2 0 0 5 - 2 0 0 7     A n t h o n y   G a r r e t t  
 / /  
 / /       T h i s   l i b r a r y   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   L e s s e r   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   2 . 1   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   l i b r a r y   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  
 / /       L e s s e r   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   L e s s e r   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   l i b r a r y ;   i f   n o t ,   i t   i s   a v a i l a b l e   a t  
 / /       t h e   G N U   w e b   s i t e   ( h t t p : / / w w w . g n u . o r g / )   o r   b y   w r i t i n g   t o   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 ,   I n c . ,   5 1   F r a n k l i n   S t ,   F i f t h   F l o o r ,  
 / /       B o s t o n ,   M A     0 2 1 1 0 - 1 3 0 1     U S A  
 / /  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
 / /  
 / /   C o n t a c t :       S o r r y ,   I   c a n ' t   o f f e r   s u p p o r t   f o r   t h i s   b u t   i f   y o u   f i n d   a   p r o b l e m  
 / /                         ( o r   j u s t   w a n t   t o   t e l l   m e   h o w   u s e f u l   y o u   f i n d   i t ) ,   p l e a s e   s e n d  
 / /                         m e   a n   e m a i l   a t   s c w f e e d b a c k @ t a r r g e t . i n f o   ( N o t e   t h e   t w o   R s   i n  
 / /                         t a r r g e t ) .     I   w i l l   t r y   t o   f i x   p r o b l e m s   q u i c k l y   b u t   t h i s   i s   a  
 / /                         s p a r e   t i m e   t h i n g   f o r   m e .  
 / /  
 / /   C r e d i t s :       I   w r o t e   t h i s   f r o m   s c r a t c h   m y s e l f   b u t   I   c o u l d n ' t   h a v e   d o n e   i t  
 / /                         w i t h o u t   t h e   s u p e r b   " J a v a S c r i p t   T h e   D e f i n i t i v e   G u i d e "   b y   D a v i d  
 / /                         F l a n a g a n   ( P u b .   O ' R e i l l y   I S B N   0 - 5 9 6 - 0 0 0 4 8 - 0 ) .     I   a l s o   r e c o g n i s e  
 / /                         a   c o n t r i b u t i o n   f r o m   m y   e x p e r i e n c e   w i t h   P o p C a l e n d a r   4 . 1   b y  
 / /                         L i m i n g ( V i c t o r )   W e n g .  
 / /  
 / /   L i n k   b a c k :   P l e a s e   g i v e   m e   c r e d i t   a n d   l i n k   b a c k   t o   m y   p a g e .     T o   e n s u r e   t h a t  
 / /                         s e a r c h   e n g i n e s   g i v e   m y   p a g e   a   h i g h e r   r a n k i n g   y o u   c a n   a d d   t h e  
 / /                         f o l l o w i n g   H T M L   t o   a n y   i n d e x e d   p a g e   o n   y o u r   w e b   s i t e :  
 / /  
 / /                         < A   H R E F = " h t t p : / / w w w . t a r r g e t . i n f o / c a l e n d a r / s c w . h t m " >  
 / /                             S i m p l e   C a l e n d a r   W i d g e t   b y   A n t h o n y   G a r r e t t  
 / /                         < / A >  
 / /  
 / /   F e a t u r e s :     E a s i l y   c u s t o m i s e d  
 / /                                     ( o u t p u t   d a t e   f o r m a t ,   c o l o u r s ,   l a n g u a g e ,   y e a r   r a n g e   a n d  
 / /                                       w e e k   s t a r t   d a y )  
 / /                         A c c e p t s   a   d a t e   a s   i n p u t  
 / /                                     ( s e e   c o m m e n t s   b e l o w   f o r   f o r m a t s ) .  
 / /                         C r o s s - b r o w s e r   c o d e   t e s t e d   a g a i n s t ;  
 / /                                     I n t e r n e t   E x p l o r e r   6 . 0 . 2 8           M o z i l l a     1 . 7 . 1  
 / /                                     O p e r a                           7 . 5 2 +             F i r e f o x     0 . 9 . 1 +  
 / /                                     K o n q u e r o r                   3 . 4 . 0             F l o c k         0 . 4 . 9  
 / /  
 / /   H o w   t o   a d d   t h e   C a l e n d a r   t o   y o u r   p a g e :  
 / /                         T h i s   s c r i p t   n e e d s   t o   b e   d e f i n e d   f o r   y o u r   p a g e   s o ,   i m m e d i a t e l y  
 / /                         a f t e r   t h e   B O D Y   t a g   a d d   t h e   f o l l o w i n g   l i n e ;  
 / /  
 / /                                     < s c r i p t   t y p e = ' T e x t / J a v a S c r i p t '   s r c = ' s c w . j s ' > < / s c r i p t >  
 / /  
 / /                         Y o u r   r o o t   d i r e c t o r y   o f   t h e   w e b   s i t e   s h o u l d   a l s o   c o n t a i n   a n   e m p t y  
 / /                         f i l e   c a l l e d   " s c w b l a n k . h t m l " .   S e e  
 / /                                     h t t p : / / w w w . t a r r g e t . i n f o / c a l e n d a r / I E n i g h t m a r e . h t m l  
 / /                         f o r   a   f u l l   e x p l a n a t i o n .  
 / /  
 / /   H o w   t o   u s e   t h e   C a l e n d a r   o n c e   i t   i s   d e f i n e d   f o r   y o u r   p a g e :  
 / /  
 / /                         S i m p l y   c h o o s e   a n   e v e n t   t o   t r i g g e r   t h e   c a l e n d a r   ( l i k e   a n   o n C l i c k  
 / /                         o r   a n   o n M o u s e O v e r )   a n d   a n   e l e m e n t   t o   w o r k   o n   ( f o r   t h e   c a l e n d a r  
 / /                         t o   t a k e   i t s   i n i t i a l   d a t e   f r o m   a n d   w r i t e   i t s   o u t p u t   d a t e   t o )   t h e n  
 / /                         w r i t e   i t   l i k e   t h i s ;  
 / /  
 / /                                     < < e v e n t > > = " s c w S h o w ( < < e l e m e n t > > , e v e n t ) ; "  
 / /  
 / /                         e . g .   o n C l i c k = " s c w S h o w ( s c w I D ( ' m y E l e m e n t ' ) , e v e n t ) ; "  
 / /                         o r       o n M o u s e O v e r = " s c w S h o w ( t h i s , e v e n t ) ; "  
 / /  
 / /                         N O T E :   I f   y o u   w i s h   t o   u s e   t h e   c a l e n d a r   w i t h   a n   A n c h o r   t a g ,   d o  
 / /                                     n o t   u s e   t h e   s y n t a x :       h r e f = " j a v a s c r i p t : s c w S h o w ( . . . ) "  
 / /                                     I n s t e a d   y o u   s h o u l d   u s e   t h e   f o l l o w i n g ;  
 / /  
 / /                                     < a   h r e f = " # "   o n c l i c k = " s c w S h o w ( < < e l e m e n t > > , e v e n t ) ; r e t u r n   f a l s e ; " >  
 / /                                             < < y o u r   t e x t > >  
 / /                                     < / a >  
 / /  
 / /                         I f   y o u   a r e   u s i n g   a   t e x t   n o d e   t h e n   s p e c i f y   t h e   t e x t ' s   p a r e n t   n o d e  
 / /                         i n   t h e   f u n c t i o n   c a l l .   T h e   d a t e   s h o u l d   b e   t h e   o n l y   t e x t   u n d e r   t h a t  
 / /                         n o d e ;  
 / /  
 / /                         e . g .     < p   o n c l i c k = " s c w S h o w ( t h i s , e v e n t ) ; " > < < d a t e > > < / p >  
 / /  
 / /                         Y o u   c a n   a l s o   d i s a b l e   d a y s   o f   t h e   w e e k   b y   a d d i n g   a r g u m e n t s   t o   t h e  
 / /                         c a l l   t o   s c w S h o w .     T h e   v a l u e s   s h o u l d   b e   S u n d a y   =   0   t h r o u g h   t o  
 / /                         S a t u r d a y   =   6 .     A   c a l l   t o   s c w S h o w   w i t h   F r i d a y   a n d   M o n d a y   d i s a b l e d  
 / /                         w o u l d   l o o k   s o m e t h i n g   l i k e   t h i s ;  
 / /  
 / /                                     s c w S h o w ( < < e l e m e n t > > , e v e n t , 5 , 1 ) ;  
 / /  
 / /                         F i n a l l y   y o u   c a n   u s e   t h e   f o l l o w i n g   t e c h n i q u e   t o   r u n   a   f u n c t i o n  
 / /                         w h e n   t h e   c a l e n d a r   c l o s e s :  
 / /  
 / /                                     s c w N e x t A c t i o n = < < f u n c t i o n > > . r u n s A f t e r S C W ( t h i s , < < a r g u m e n t s > > ) ;  
 / /                                     s c w S h o w ( < < e l e m e n t > > , e v e n t   < < , o p t i o n a l   a r g u m e n t s   a b o v e > > ) ;  
 / /  
 / /                         W h e r e   < < f u n c t i o n > >   i s   a   f u n c t i o n   d e f i n e d   o n   t h e   c a l l i n g   p a g e  
 / /                         a n d   < < a r g u m e n t s > >   i s   t h e   l i s t   o f   a r g u m e n t s   b e i n g   p a s s e d   t o   t h a t  
 / /                         f u n c t i o n .  
 / /  
 / /             N o   e v e n t ?   N o   p r o b l e m !  
 / /  
 / /                         N o r m a l l y   t h e   c a l e n d a r   w i l l   b e   t r i g g e r e d   b y   a n   e v e n t   b u t   i f   y o u   w i s h   t o  
 / /                         c o n t r o l   i t   i n   c o d e   a n d   t h e   e v e n t   i s   n o t   a v a i l a b l e   t o   y o u ,   s i m p l y   p a s s  
 / /                         a n   e l e m e n t   a s   t h e   s e c o n d   p a r a m e t e r ;  
 / /  
 / /                         E . G .     s c w S h o w ( < < t a r g e t   e l e m e n t > > , < < s o u r c e   e l e m e n t > > ) ;  
 / /                                     a s   i n :   s c w S h o w ( t h i s , t h i s ) ;  
 / /  
 / /                         - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 / /                         H e r e ' s   a n   e x t r e m e l y   t r i v i a l   b u t   f u l l y   f u n c t i o n i n g   e x a m p l e   p a g e  
 / /                         s h o w i n g   t w o   o f   t h e   w a y s   t o   t r i g g e r   t h e   c a l e n d a r ;  
 / /  
 / /                         < h t m l >  
 / /                                 < h e a d > < t i t l e > B a s i c   E x a m p l e < / t i t l e > < / h e a d >  
 / /                                 < b o d y >  
 / /                                         < s c r i p t   t y p e = ' t e x t / J a v a S c r i p t '   s r c = ' s c w . j s ' > < / s c r i p t >  
 / /                                         < p   o n c l i c k = ' s c w S h o w ( t h i s , e v e n t ) ; ' > 0 6 - D e c - 2 0 0 6 < / p >  
 / /                                         < i n p u t   o n c l i c k = ' s c w S h o w ( t h i s , e v e n t ) ; '   v a l u e = ' 0 7 - D e c - 2 0 0 6 '   / >  
 / /                                         < b r / > < b r / >  
 / /                                         < a   h r e f = ' # '   o n c l i c k = ' s c w S h o w ( t h i s , e v e n t ) ; r e t u r n   f a l s e ; ' >  
 / /                                                 0 8 - D e c - 2 0 0 6  
 / /                                         < / a >  
 / /                                 < / b o d y >  
 / /                         < / h t m l >  
 / /  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
 / /  
 / /   S e e   h t t p : / / w w w . t a r r g e t . i n f o / c a l e n d a r / s c w . h t m   f o r   a   c o m p l e t e   v e r s i o n   h i s t o r y  
 / /  
 / /   V e r s i o n       D a t e                 B y                               D e s c r i p t i o n  
 / /   = = = = = = =       = = = =                 = = = = = = = = = = = = = = =     = = = = = = = = = = =  
 / /       3 . 5 8         2 0 0 7 - 0 4 - 0 4     A n t h o n y   G a r r e t t     R e s o l v e d   a n   e r r o r   c a u s e d   w h e n   t h e   d a t e  
 / /                                                                                   r a n g e   d o e s   n o t   i n c l u d e   t h e   c u r r e n t   y e a r .  
 / /                                                                                   T h a n k s   t o   S t e v e   D a v i s   f o r   l e t t i n g   m e   k n o w .  
 / /  
 / /                                                                                 F i x e d   " T o d a y "   s e l e c t o r   d i s p l a y   w h i c h  
 / /                                                                                   w a s   i n c o r r e c t l y   v i s i b l e   w h e n   y e a r   r a n g e  
 / /                                                                                   e n d e d   l a s t   y e a r .   ( A l s o   t h e   r e s u l t   o f  
 / /                                                                                   i n v e s t i g a t i o n s   b a s e d   o n   S t e v e   D a v i s '  
 / /                                                                                   f e e d b a c k ) .  
 / /  
 / /       3 . 5 9         2 0 0 7 - 0 6 - 1 3     A n t h o n y   G a r r e t t     A d d e d   V e r d a n a   t o   f o n t   l i s t   o f  
 / /                                                                                   c a l e n d a r ' s   C S S .     R e s o l v e s   r e n d e r i n g  
 / /                                                                                   b u g   i n   S a f a r i   B e t a   3   f o r   W i n d o w s .  
 / /  
 / /       3 . 6 0         2 0 0 7 - 0 7 - 3 1     A n t h o n y   G a r r e t t     F i x e d   j a v a s c r i p t   e r r o r   t h a t   o c c u r r e d  
 / /                                                                                   w h e n   t h e   t a r g e t   e l e m e n t   h a d   n o   v a l u e  
 / /                                                                                   a t t r i b u t e .     T h e   e r r o r   h a d   n o   i m p a c t  
 / /                                                                                   o n   t h e   b e h a v i o u r   o f   t h e   s c r i p t .     T h a n k s  
 / /                                                                                   t o   J o h n   P h e l p s   f o r   r e p o r t i n g   t h i s   b u g .  
 / /  
 / /       3 . 7 0         2 0 0 7 - 0 9 - 2 1     A n t h o n y   G a r r e t t     U p d a t e d   t h e   e v e n t   t r a p p i n g   t o   m a k e   i t  
 / /                                                                                   l e s s   i n t r u s i v e   o n   t h e   p a g e   b o d y .  
 / /                                                                                   N O T E :   T h i s   r e q u i r e s   t h a t   a   c a l e n d a r ' s  
 / /                                                                                   s e c o n d   p a r a m e t e r   s h o u l d   b e   t h e   c a l l i n g  
 / /                                                                                   e v e n t   ( n o t   t h e   c a l l i n g   o b j e c t   a s   i n  
 / /                                                                                   p r e v i o u s   v e r s i o n s ) .  
 / /                                                                                   T h a n k s   t o   S t e v e   D a v i s   f o r   t h e   b u g   r e p o r t  
 / /                                                                                   t h a t   l e d   t o   t h i s   c h a n g e .  
 / /  
 / /                                                                                 F i x e d   a   b u g   t h a t   c a u s e d   u n d e l i m i t e d  
 / /                                                                                   d a t e s   t o   b e   h a n d l e d   i n c o r r e c t l y .   T h e y  
 / /                                                                                   a r e   n o w   p a r s e d   a g a i n s t   t h e   f u l l   d a t e  
 / /                                                                                   o u t p u t   f o r m a t   t h e n   c h e c k e d   f o r   v a l i d i t y .  
 / /                                                                                   T h a n k s   t o   D a n   W o o d   f o r   r a i s i n g   t h i s   b u g .  
 / /  
 / /                                                                                 R e p l a c e d   t h e   d a t e   i n p u t   s e q u e n c e   u s e r  
 / /                                                                                   c o n f i g u r a t i o n   s e t t i n g   w i t h   p a r s i n g   t h e  
 / /                                                                                   s e q u e n c e   f r o m   t h e   f u l l   f o r m a t .   N e w   u s e r s  
 / /                                                                                   a r e   o f t e n   c o n f u s e d   b y   t h e   s e q u e n c e   a n d  
 / /                                                                                   i n   p r a c t i c e   ( t o   a l l o w   t h e   c a l e n d a r ' s   d a t e  
 / /                                                                                   o u t p u t   t o   b e   u s e d   f o r   i n p u t )   t h e   s e q u e n c e  
 / /                                                                                   m u s t   a l w a y s   m a t c h   t h e   f u l l   f o r m a t   e l e m e n t  
 / /                                                                                   o r d e r .  
 / /  
 / /                                                                                 E x t e n d e d   I F R A M E   b a c k i n g   t o   a l l   c a l e n d a r   o b j e c t s  
 / /                                                                                   i n   o r d e r   t o   i m p r o v e   c a l e n d a r   d i s p l a y   o v e r  
 / /                                                                                   s o m e   e m b e d d e d   a p p l e t s   a n d   o b j e c t s .     T h a n k s   t o  
 / /                                                                                   S t a n k o   K u p c e v i c   f o r   h i s   f e e d b a c k   o n   t h i s .  
 / /                                                                                   N O T E :   I t   i s   n o t   p o s s i b l e   t o   p r o t e c t   a n y  
 / /                                                                                   J a v a S c r i p t   o b j e c t   d i s p l a y e d   o v e r   a n  
 / /                                                                                   e m b e d d e d   D Y N A M I C   ( a n d ,   t h e r e f o r e   r e f r e s h e d )  
 / /                                                                                   o b j e c t   b e c a u s e   b r o w s e r s   u s u a l l y   d o   n o t  
 / /                                                                                   d i r e c t l y   c o n t r o l   t h e   s c r e e n   h a n d l i n g   w i t h i n  
 / /                                                                                   t h e   o b j e c t .     T h e   b e s t   a d v i c e   t h e r e f o r e   r e m a i n s  
 / /                                                                                   t o   d e s i g n   p a g e s   i n   s u c h   a   w a y   t h a t   t h e   c a l e n d a r  
 / /                                                                                   d o e s   n o t   o v e r l a p   e m b e d d e d   o b j e c t s .  
 / /  
 / /     3 . 7 1           2 0 0 8 - 1 2 - 1 4     A n t h o n y   G a r r e t t     R e s t o r e d   t h e   a b i l i t y   t o   u s e   a n   e l e m e n t  
 / /                                                                                   a s   t h e   s e c o n d   p a r a m e t e r   w h e n   o p e n i n g   a  
 / /                                                                                   c a l e n d a r   w h i l e   r e t a i n i n g   t h e   o p t i o n  
 / /                                                                                   o f   p a s s i n g   a n   e v e n t .   T h a n k s   t o   T h i e r r y   B l i n d  
 / /                                                                                   a n d   S e r g e y   S n o v s k y   f o r   t h e   f e e d b a c k .  
 / /  
 / /     3 . 7 2           2 0 0 8 - 0 2 - 2 4     A n t h o n y   G a r r e t t     T r a p p e d   c a l l s   t o   s c r i p t   w i t h   o n l y   a  
 / /                                                                                   N A M E   a t t r i b u t e   i s   s e t   f o r   t h e   t a r g e t  
 / /                                                                                   e l e m e n t   w h e n   t h e   s c r i p t   r e a l l y   r e q u i r e s  
 / /                                                                                   a n   I D   a t t r i b u t e .     T h i s   i s   t h e   m o s t  
 / /                                                                                   f r e q u e n t   m i s t a k e   r e p o r t e d   t o   m e .  
 / /  
 / /     3 . 7 3           2 0 0 8 - 0 4 - 1 1     A n t h o n y   G a r r e t t     C o r r e c t e d   t h e   i n p u t   m o n t h   n a m e   p a r s i n g  
 / /                                                                                   s o   t h a t   i t   s e t   t h e   c a l e n d a r   t o   t h e  
 / /                                                                                   r i g h t   m o n t h   w h e n   l o n g   m o n t h   n a m e s   u s e d .  
 / /                                                                                   T h a n k s   t o   B e n   D i a m a n d   f o r   t h i s   b u g   r e p o r t .  
 / /  
 / /     3 . 8 0           2 0 0 8 - 0 4 - 2 9     A n t h o n y   G a r r e t t     A d d e d   o p t i o n a l   a u t o - p o s i t i o n i n g   o f   t h e  
 / /                                                                                   c a l e n d a r   w h e n   i t s   n o r m a l   p o s i t i o n   w o u l d  
 / /                                                                                   g o   o f f   t h e   v i s i b l e   a r e a .  
 / /                                                                                   T h a n k s   t o   C h a n d r a m o u l i   I y e r   f o r   t h i s  
 / /                                                                                   s u g g e s t i o n .  
 / /  
 / /     3 . 9 0           2 0 0 8 - 0 5 - 0 5     A n t h o n y   G a r r e t t     A d d e d   a n   o p t i o n a l   " C l e a r "   b u t t o n   f o r  
 / /                                                                                   u s e   w h e n   h a n d l i n g   a   r e a d - o n l y   t e x t  
 / /                                                                                   i n p u t   e l e m e n t .   T h a n k s   t o   S a n j a y   G a n g w a l  
 / /                                                                                   f o r   h i s   s u g g e s t i o n .  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
 / /   S t a r t   o f   S i m p l e   C a l e n d a r   W i d g e t   C o d e  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
  
 / /   T h i s   d a t e   i s   u s e d   t h r o u g h o u t   t o   d e t e r m i n e   t o d a y ' s   d a t e .  
  
         v a r   s c w D a t e N o w   =   n e w   D a t e ( D a t e . p a r s e ( n e w   D a t e ( ) . t o D a t e S t r i n g ( ) ) ) ;  
  
 / / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
 / / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 / /   C u s t o m i s a t i o n   s e c t i o n  
 / / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 / / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
  
         / /   S e t   t h e   b o u n d s   f o r   t h e   c a l e n d a r   h e r e . . .  
         / /   I f   y o u   w a n t   t h e   y e a r   t o   r o l l   f o r w a r d   y o u   c a n   u s e   s o m e t h i n g   l i k e   t h i s . . .  
         / /             v a r   s c w B a s e Y e a r   =   s c w D a t e N o w . g e t F u l l Y e a r ( ) - 5 ;  
         / /   a l t e r n a t i v e l y ,   h a r d   c o d e   a   d a t e   l i k e   t h i s . . .  
         / /             v a r   s c w B a s e Y e a r   =   1 9 9 0 ;  
  
         v a r   s c w B a s e Y e a r                 =   s c w D a t e N o w . g e t F u l l Y e a r ( ) - 1 0 ;  
  
         / /   H o w   m a n y   y e a r s   d o   w a n t   t o   b e   v a l i d   a n d   t o   s h o w   i n   t h e   d r o p - d o w n   l i s t ?  
  
         v a r   s c w D r o p D o w n Y e a r s       =   2 0 ;  
  
         / /   A l l   l a n g u a g e - d e p e n d e n t   c h a n g e s   c a n   b e   m a d e   h e r e . . .  
  
         / /   I f   y o u   w i s h   t o   w o r k   i n   a   s i n g l e   l a n g u a g e   ( o t h e r   t h a n   E n g l i s h )   t h e n  
         / /   j u s t   r e p l a c e   t h e   E n g l i s h   ( i n   t h e   f u n c t i o n   s c w S e t L a n g u a g e   b e l o w )   w i t h  
         / /   y o u r   o w n   t e x t .  
  
         / /   U s i n g   m u l t i p l e   l a n g u a g e s :  
         / /   I n   o r d e r   t o   k e e p   t h i s   s c r i p t   t o   a   r e s o n a b l e   s i z e   I   h a v e   n o t   i n c l u d e d  
         / /   l a n g u a g e s   h e r e .     Y o u   c a n   s e t   l a n g u a g e   f i e l d s   i n   a   f u n c t i o n   t h a t   y o u  
         / /   s h o u l d   c a l l     s c w S e t L a n g u a g e     t h e   s c r i p t   w i l l   u s e   y o u r   l a n g u a g e s .  
         / /   I   h a v e   i n c l u d e d   a l l   t h e   t r a n s l a t i o n s   t h a t   h a v e   b e e n   s e n t   t o   m e   i n  
         / /   s u c h   a   f u n c t i o n   o n   t h e   d e m o n s t r a t i o n   p a g e .  
  
         v a r   s c w L a n g u a g e ;  
  
         f u n c t i o n   s c w S e t D e f a u l t L a n g u a g e ( )  
                 { t r y  
                         { s c w S e t L a n g u a g e ( ) ; }  
                   c a t c h   ( e x c e p t i o n )  
                         { / /   E n g l i s h  
                           s c w T o d a y                               =   ' T o d a y : ' ;  
                           s c w C l e a r                               =   ' C l e a r ' ;  
                           s c w D r a g                                 =   ' c l i c k   h e r e   t o   d r a g ' ;  
                           s c w A r r M o n t h N a m e s               =   [ ' J a n ' , ' F e b ' , ' M a r ' , ' A p r ' , ' M a y ' , ' J u n ' ,  
                                                                               ' J u l ' , ' A u g ' , ' S e p ' , ' O c t ' , ' N o v ' , ' D e c ' ] ;  
                           s c w A r r W e e k I n i t s                 =   [ ' S ' , ' M ' , ' T ' , ' W ' , ' T ' , ' F ' , ' S ' ] ;  
                           s c w I n v a l i d D a t e M s g             =   ' T h e   e n t e r e d   d a t e   i s   i n v a l i d . \ n ' ;  
                           s c w O u t O f R a n g e M s g               =   ' T h e   e n t e r e d   d a t e   i s   o u t   o f   r a n g e . ' ;  
                           s c w D o e s N o t E x i s t M s g           =   ' T h e   e n t e r e d   d a t e   d o e s   n o t   e x i s t . ' ;  
                           s c w I n v a l i d A l e r t                 =   [ ' I n v a l i d   d a t e   ( ' , ' )   i g n o r e d . ' ] ;  
                           s c w D a t e D i s a b l i n g E r r o r     =   [ ' E r r o r   ' , '   i s   n o t   a   D a t e   o b j e c t . ' ] ;  
                           s c w R a n g e D i s a b l i n g E r r o r   =   [ ' E r r o r   ' ,  
                                                                               '   s h o u l d   c o n s i s t   o f   t w o   e l e m e n t s . ' ] ;  
                         }  
                 } ;  
          
         f u n c t i o n   s c w S e t L a n g u a g e ( )  
                 { s w i t c h   ( s c w L a n g u a g e )  
                         { c a s e   ' a r ' :  
                                 / /   S p a n i s h [ C a s t e l l a n o / A r g e n t i n e ]   ( p r o v i d e d   b y   S e b a s t i a n   V e g a )  
                                 s c w T o d a y                               =   ' H o y : ' ;  
                                 s c w C l e a r                               =   ' C l e a r ' ;  
                                 s c w D r a g                                 =   ' c l i c k   a q u \ u 0 0 E D   p a r a   a r r a s t r a r ' ;  
                                 s c w A r r M o n t h N a m e s               =   [ ' E n e ' , ' F e b ' , ' M a r ' , ' A b r ' , ' M a y ' , ' J u n ' ,  
                                                                                     ' J u l ' , ' A g o ' , ' S e p ' , ' O c t ' , ' N o v ' , ' D i c ' ] ;  
                                 s c w A r r W e e k I n i t s                 =   [ ' D ' , ' L ' , ' M ' , ' M ' , ' J ' , ' V ' , ' S ' ] ;  
                                 s c w I n v a l i d D a t e M s g             =   ' L a   f e c h a   i n g r e s a d a   e s   i n v \ u 0 0 E 1 l i d a . \ n ' ;  
                                 s c w O u t O f R a n g e M s g               =   ' L a   f e c h a   i n g r e s a d a   e s t \ u 0 0 E 1   f u e r a   d e   r a n g o . ' ;  
                                 s c w D o e s N o t E x i s t M s g           =   ' L a   f e c h a   i n g r e s a d a   n o   e x i s t e . ' ;  
                                 s c w I n v a l i d A l e r t                 =   [ ' F e c h a   i n v \ u 0 0 E 1 l i d a   ( ' , ' )   i g n o r a d a . ' ] ;  
                                 s c w D a t e D i s a b l i n g E r r o r     =   [ ' E r r o r   ' , '   n o   e s   u n   o b j e t o   F e c h a . ' ] ;  
                                 s c w R a n g e D i s a b l i n g E r r o r   =   [ ' E r r o r   ' , '   d e b e r \ u 0 0 E D a   c o n s i s t i r   d e   d o s   e l e m e n t o s . ' ] ;  
                                 b r e a k ;  
  
                           c a s e   ' b r ' :  
                                 / /   B r a z i l i a n   P o r t u g u e s e   ( p r o v i d e d   b y   R a f a e l   P i r o l l a )  
                                 s c w T o d a y                               =   ' H o j e : ' ;  
                                 s c w C l e a r                               =   ' C l e a r ' ;  
                                 s c w D r a g                                 =   ' c l i q u e   a q u i   p a r a   a r r a s t a r ' ;  
                                 s c w A r r M o n t h N a m e s               =   [ ' J a n ' , ' F e v ' , ' M a r ' , ' A b r ' , ' M a i ' , ' J u n ' ,  
                                                                                     ' J u l ' , ' A g o ' , ' S e t ' , ' O u t ' , ' N o v ' , ' D e z ' ] ;  
                                 s c w A r r W e e k I n i t s                 =   [ ' D ' , ' S ' , ' T ' , ' Q ' , ' Q ' , ' S ' , ' S ' ] ;  
                                 s c w I n v a l i d D a t e M s g             =   ' A   d a t a   e   i n v a l i d a . \ n ' ;  
                                 s c w O u t O f R a n g e M s g               =   ' A   d a t a   e s t a   f o r a   d o   e s c o p o   d e f i n i d o . ' ;  
                                 s c w D o e s N o t E x i s t M s g           =   ' A   d a t a   n a o   e x i s t e . ' ;  
                                 s c w I n v a l i d A l e r t                 =   [ ' D a t a   i n v a l i d a   ( ' , ' )   i g n o r a d a . ' ] ;  
                                 s c w D a t e D i s a b l i n g E r r o r     =   [ ' E r r o   ' , '   n \ u 0 0 E 3 o   \ u 0 0 E 9   u m   o b j e t o   D a t e . ' ] ;  
                                 s c w R a n g e D i s a b l i n g E r r o r   =   [ ' E r r o   ' , '   d e v e r i a   c o n s i s t i r   d e   d o i s   e l e m e n t o s . ' ] ;  
                                 b r e a k ;  
  
 	 	 	 c a s e   ' c r ' :  
 	 	 	 	 / /   C r o a t i a n   ( p r o v i d e d   b y   A m i r   D u p a n o v i )  
 	 	 	 	 s c w T o d a y                               =   ' D a n a s : ' ;  
                                 s c w C l e a r                               =   ' C l e a r ' ;  
 	 	 	 	 s c w D r a g                                 =   ' k l i k n i   o v d j e   z a   p o v l a \ u 0 1 0 d e n j e ' ;  
 	 	 	 	 s c w A r r M o n t h N a m e s               =   [ ' S i j ' , ' V e l j ' , ' O \ u 0 1 7 e u ' , ' T r a ' , ' S v i ' , ' L i p ' ,    
 	 	 	 	 	                                             ' S r p ' , ' K o l ' , ' R u j ' , ' L i s ' , ' S t u ' , ' P r o ' ] ;  
 	 	 	 	 s c w A r r W e e k I n i t s                 =   [ ' N ' , ' P ' , ' U ' , ' S ' , ' \ u 0 1 0 c ' , ' P ' , ' S ' ] ;  
 	 	 	 	 s c w I n v a l i d D a t e M s g             =   ' U n e \ u 0 1 6 1 e n i   d a t u m   n i j e   i s p r a v a n . \ n ' ;  
 	 	 	 	 s c w O u t O f R a n g e M s g               =   ' U n e \ u 0 1 6 1 e n i   d a t u m   j e   v a n   g r a n i c a . ' ;  
 	 	 	 	 s c w D o e s N o t E x i s t M s g           =   ' U n e \ u 0 1 6 1 e n i   d a t u m   j e   n e p o s t o j e \ u 0 1 0 7 i . ' ;  
 	 	 	 	 s c w I n v a l i d A l e r t                 =   [ ' N e i s p r a v a n   d a t u m   ( ' , ' )   i g n o r i r a n . ' ] ;  
 	 	 	 	 s c w D a t e D i s a b l i n g E r r o r     =   [ ' P o g r e \ u 0 1 6 1 k a   ' , '   n i j e   D a t e   o b j e k t . ' ] ;  
 	 	 	 	 s c w R a n g e D i s a b l i n g E r r o r   =   [ ' P o g r e \ u 0 1 6 1 k a   ' , '   s e   m o r a   s a s t o j a t i   o d   d v a   e l e m e n t a . ' ] ;  
 	 	 	 	 b r e a k ;  
 	 	 	 	 	  
                         c a s e   ' c z ' :  
 	 	 	 	 / /   C z e c h   ( p r o v i d e d   b y   O n d r e j   L i s y )  
                                 s c w T o d a y                               =   ' D n e s : ' ;  
                                 s c w C l e a r                               =   ' C l e a r ' ;  
                                 s c w D r a g                                 =   ' P r o   p \ u 0 1 5 9 e s u n   k l i k n \ u 0 1 1 b t e   z d e ' ;  
                                 s c w A r r M o n t h N a m e s               =   [ ' L e d ' , ' \ u 0 0 d a n o ' , ' B \ u 0 1 5 9 e ' , ' D u b ' , ' K v \ u 0 1 1 b ' , ' \ u 0 1 0 c e r ' ,  
                                                                                     ' \ u 0 1 0 c e r ' , ' S r p ' , ' Z \ u 0 0 e 1 \ u 0 1 5 9 ' , ' \ u 0 1 5 8 \ u 0 0 e d j ' , ' L i s ' , ' P r o ' ] ;  
                                 s c w A r r W e e k I n i t s                 =   [ ' N ' , ' P ' , ' \ u 0 0 d a ' , ' S ' , ' \ u 0 1 0 c ' , ' P ' , ' S ' ] ;  
                                 s c w I n v a l i d D a t e M s g             =   ' Z a d a n \ u 0 0 e 9   d a t u m   n e n \ u 0 0 e d   p l a t n \ u 0 0 f d . \ n ' ;  
                                 s c w O u t O f R a n g e M s g               =   ' Z a d a n \ u 0 0 e 9   d a t u m   j e   m i m o   r o z s a h . ' ;  
                                 s c w D o e s N o t E x i s t M s g           =   ' Z a d a n \ u 0 0 e 9   d a t u m   n e e x i s t u j e . ' ;  
                                 s c w I n v a l i d A l e r t                 =   [ ' N e p l a t n \ u 0 0 f d   d a t u m   ( ' , ' )   i g n o r o v \ u 0 0 e 9 n . ' ] ;  
                                 s c w D a t e D i s a b l i n g E r r o r     =   [ ' C h y b a   ' , '   n e n \ u 0 0 e d   o b j e k t e m   t y p u   D a t e . ' ] ;  
                                 s c w R a n g e D i s a b l i n g E r r o r   =   [ ' C h y b a   ' , '   m u s \ u 0 0 e d   o b s a h o v a t   d v a   e l e m e n t y . ' ] ;  
                                 b r e a k ;  
 	 	 	 	  
                         c a s e   ' d e ' :  
                                 / /   G e r m a n   ( p r o v i d e d   b y   H e n n i n g   H r a b a n   R a m m )  
                                 s c w T o d a y                               =   ' H e u t e : ' ;  
                                 s c w C l e a r                               =   ' C l e a r ' ;  
                                 s c w D r a g                                 =   ' z u m   Z i e h e n   h i e r   k l i c k e n ' ;  
                                 s c w A r r M o n t h N a m e s               =   [ ' J a n ' , ' F e b ' , ' M \ u 0 0 E 4 r ' , ' A p r ' , ' M a i ' , ' J u n ' ,  
                                                                                     ' J u l ' , ' A u g ' , ' S e p ' , ' O k t ' , ' N o v ' , ' D e z ' ] ;  
                                 s c w A r r W e e k I n i t s                 =   [ ' S ' , ' M ' , ' D ' , ' M ' , ' D ' , ' F ' , ' S ' ] ;  
                                 s c w I n v a l i d D a t e M s g             =   ' D a s   e i n g e g e b e n e   D a t u m   i s t   u n g \ u 0 0 F C l t i g . \ n ' ;  
                                 s c w O u t O f R a n g e M s g               =   ' D a s   e i n g e g e b e n e   D a t u m   l i e g t   a u \ u 0 0 D F e r h a l b   d e r   g e s e t z t e n   G r e n z e n . ' ;  
                                 s c w D o e s N o t E x i s t M s g           =   ' D a s   e i n g e g e b e n e   D a t u m   g i b t   e s   n i c h t . ' ;  
                                 s c w I n v a l i d A l e r t                 =   [ ' U n g \ u 0 0 F C l t i g e s   D a t u m   ( ' , ' )   i g n o r i e r t . ' ] ;  
                                 s c w D a t e D i s a b l i n g E r r o r     =   [ ' F e h l e r   ' , '   i s t   k e i n   D a t u m s o b j e k t . ' ] ;  
                                 s c w R a n g e D i s a b l i n g E r r o r   =   [ ' F e h l e r   ' , '   m u s s   a u s   z w e i   E l e m e n t e n   b e s t e h e n . ' ] ;  
                                 b r e a k ;  
  
                         c a s e   ' e s ' :  
                                 / /   S p a n i s h   ( p r o v i d e d   b y   V i c t o r   D a v a l o s )  
                                 s c w T o d a y                               =   ' H o y : ' ;  
                                 s c w C l e a r                               =   ' C l e a r ' ;  
                                 s c w D r a g                                 =   ' c l i c k   a q u \ u 0 0 E D   p a r a   a r r a s t r a r ' ;  
                                 s c w A r r M o n t h N a m e s               =   [ ' E n e ' , ' F e b ' , ' M a r ' , ' A b r ' , ' M a y ' , ' J u n ' ,  
                                                                                     ' J u l ' , ' A g o ' , ' S e p ' , ' O c t ' , ' N o v ' , ' D i c ' ] ;  
                                 s c w A r r W e e k I n i t s                 =   [ ' D ' , ' L ' , ' M ' , ' M ' , ' J ' , ' V ' , ' S ' ] ;  
                                 s c w I n v a l i d D a t e M s g             =   ' L a   f e c h a   i n g r e s a d a   e s   i n v \ u 0 0 E 1 l i d a . \ n ' ;  
                                 s c w O u t O f R a n g e M s g               =   ' L a   f e c h a   i n g r e s a d a   e s t \ u 0 0 E 1   f u e r a   d e   r a n g o . ' ;  
                                 s c w D o e s N o t E x i s t M s g           =   ' L a   f e c h a   i n g r e s a d a   n o   e x i s t e . ' ;  
                                 s c w I n v a l i d A l e r t                 =   [ ' F e c h a   i n v \ u 0 0 E 1 l i d a   ( ' , ' )   i g n o r a d a . ' ] ;  
                                 s c w D a t e D i s a b l i n g E r r o r     =   [ ' E r r o r   ' , '   n o   e s   u n   o b j e t o   F e c h a . ' ] ;  
                                 s c w R a n g e D i s a b l i n g E r r o r   =   [ ' E r r o r   ' , '   d e b e r \ u 0 0 E D a   c o n s i s t i r   d e   d o s   e l e m e n t o s . ' ] ;  
                                 b r e a k ;  
  
                         c a s e   ' f i ' :  
                                 / /   F i n n i s h   ( p r o v i d e d   b y   E s a   R i s t i l ä )  
                                 s c w T o d a y                               =   ' T ä n ä ä n : ' ;  
                                 s c w C l e a r                               =   ' T y h j e n n ä ' ;  
                                 s c w D r a g                                 =   ' K l i k k a a   t ä s t ä   s i i r t ä ä k s e s i ' ;  
                                 s c w A r r M o n t h N a m e s               =   [ ' T a m m i ' , ' H e l m i ' , ' M a a l i s ' , ' H u h t i ' , ' T o u k o ' , ' K e s ä ' ,  
                                                                                     ' H e i n ä ' , ' E l o ' , ' S y y s ' , ' L o k a ' , ' M a r r a s ' , ' J o u l u ' ] ;  
                                 s c w A r r W e e k I n i t s                 =   [ ' S u ' , ' M a ' , ' T i ' , ' K e ' , ' T o ' , ' P e ' , ' L a ' ] ;  
                                 s c w I n v a l i d D a t e M s g             =   ' A n n e t t u   p ä i v ä y s   o n   v i r h e e l l i n e n . \ n ' ;  
                                 s c w O u t O f R a n g e M s g               =   ' A n n e t t u   p ä i v ä y s   o n   r a j o j e n   u l k o p u o l e l l a . ' ;  
                                 s c w D o e s N o t E x i s t M s g           =   ' A n n e t t u a   p ä i v ä y s t ä   e i   o l e   o l e m a s s a . ' ;  
                                 s c w I n v a l i d A l e r t                 =   [ ' V i r h e e l l i s t ä   p ä i v ä y s t ä   ( ' , ' )   e i   h u o m i o i t u . ' ] ;  
                                 s c w D a t e D i s a b l i n g E r r o r     =   [ ' V i r h e   ' , '   e i   o l e   D a t e   o b j e k t i . ' ] ;  
                                 s c w R a n g e D i s a b l i n g E r r o r   =   [ ' V i r h e   ' , '   p i t ä i s i   s i s ä l t ä ä   k a k s i   o s a a . ' ] ;  
                                 b r e a k ;  
  
 	 	 	 c a s e   ' f r ' :  
                                 / /   F r e n c h   ( p r o v i d e d   b y   A l a i n   B o u t e )  
                                 s c w T o d a y                               =   ' A u j o u r d \ ' h u i : ' ;  
                                 s c w C l e a r                               =   ' C l e a r ' ;  
                                 s c w D r a g                                 =   ' D \ u 0 0 E 9 p l a c e r   l e   c a l e n d r i e r ' ;  
                                 s c w A r r M o n t h N a m e s               =   [ ' J a n ' , ' F \ u 0 0 E 9 v ' , ' M a r ' , ' A v r ' , ' M a i ' , ' J u i n ' ,  
                                                                                     ' J u i ' , ' A o u ' , ' S e p ' , ' O c t ' , ' N o v ' , ' D \ u 0 0 E 9 c ' ] ;  
                                 s c w A r r W e e k I n i t s                 =   [ ' D i ' , ' L u ' , ' M a ' , ' M e ' , ' J e ' , ' V e ' , ' S a ' ] ;  
                                 s c w I n v a l i d D a t e M s g             =   ' D a t e   i n v a l i d e . \ n ' ;  
                                 s c w O u t O f R a n g e M s g               =   ' D a t e   e n   d e h o r s   d e   l a   p l a g e   a u t o r i s \ u 0 0 E 9 e . ' ;  
                                 s c w D o e s N o t E x i s t M s g           =   ' L a   d a t e   n \ ' e x i s t e   p a s . ' ;  
                                 s c w I n v a l i d A l e r t                 =   [ ' L a   d a t e   ( ' , ' )   n \ ' e s t   p a s   r e c o n n u e   ( i g n o r \ u 0 0 E 9 e ) . ' ] ;  
                                 s c w D a t e D i s a b l i n g E r r o r     =   [ ' E r r e u r   ' , '   n \ ' e s t   p a s   u n   o b j e t   D a t e . ' ] ;  
                                 s c w R a n g e D i s a b l i n g E r r o r   =   [ ' E r r e u r   ' , '   d o i t   a v o i r   d e u x   \ u 0 0 E 9 l \ u 0 0 E 9 m e n t s . ' ] ;  
                                 b r e a k ;  
  
                         c a s e   ' i t ' :  
 	 	 	 	 / /   I t a l i a n   ( p r o v i d e d   b y   F u l v i o   B i l l e ' )  
 	 	 	 	 s c w T o d a y                               =   ' O g g i : ' ;  
                                 s c w C l e a r                               =   ' C l e a r ' ;  
 	 	 	 	 s c w D r a g                                 =   ' C l i c k   p e r   t r a s c i n a r e ' ;  
 	 	 	 	 s c w A r r M o n t h N a m e s               =   [ ' G e n ' , ' F e b ' , ' M a r ' , ' A p r ' , ' M a g ' , ' G i u ' ,    
 	 	 	 	 	 	 	 	 	 	     ' L u g ' , ' A g o ' , ' S e t ' , ' O t t ' , ' N o v ' , ' D i c ' ] ;  
 	 	 	 	 s c w A r r W e e k I n i t s                 =   [ ' D ' , ' L ' , ' M ' , ' M ' , ' G ' , ' V ' , ' S ' ] ;  
 	 	 	 	 s c w I n v a l i d D a t e M s g             =   ' L a   d a t a   i n s e r i t a   n o n   è   v a l i d a . \ n ' ;  
 	 	 	 	 s c w O u t O f R a n g e M s g               =   ' L a   d a t a   i n s e r i t a   è   f u o r i   r a n g e . ' ;  
 	 	 	 	 s c w D o e s N o t E x i s t M s g           =   ' L a   d a t a   i n s e r i t a   n o n   e s i s t e . ' ;  
 	 	 	 	 s c w I n v a l i d A l e r t                 =   [ ' D a t a   n o n   v a l i d a   ( ' , ' )   i g n o r a t a . ' ] ;  
 	 	 	 	 s c w D a t e D i s a b l i n g E r r o r     =   [ ' E r r o r e   ' , '   q u e s t o   n o n   è   u n   o g g e t t o   D a t e . ' ] ;    
 	 	 	 	 s c w R a n g e D i s a b l i n g E r r o r   =   [ ' E r r o r e   ' , '   d o v r e b b e   a v e r e   d u e   e l e m e n t i . ' ] ; 	 	 	  
                                 b r e a k ;  
 	 	 	 	  
                         c a s e   ' n l ' :  
                                 / /   D u t c h   ( p r o v i d e d   b y   K e e s   P i j n e n b u r g ,   S e b a s t i a a n   A l t o r f   a n d   M a r k   d e   H a a n )  
                                 s c w T o d a y                               =   ' V a n d a a g : ' ;  
                                 s c w C l e a r                               =   ' C l e a r ' ;  
                                 s c w D r a g                                 =   ' k l i k   h i e r   o m   t e   s l e p e n ' ;  
                                 s c w A r r M o n t h N a m e s               =   [ ' J a n ' , ' F e b ' , ' M a r ' , ' A p r ' , ' M e i ' , ' J u n ' ,  
                                                                                     ' J u l ' , ' A u g ' , ' S e p ' , ' O k t ' , ' N o v ' , ' D e c ' ] ;  
                                 s c w A r r W e e k I n i t s                 =   [ ' Z ' , ' M ' , ' D ' , ' W ' , ' D ' , ' V ' , ' Z ' ] ;  
                                 s c w I n v a l i d D a t e M s g             =   ' D e   i n g e v o e r d e   d a t u m   i s   o n g e l d i g . \ n ' ;  
                                 s c w O u t O f R a n g e M s g               =   ' D e   i n g e v o e r d e   d a t u m   l i g t   b u i t e n   d e   i n g e s t e l d e   g r e n z e n . ' ;  
                                 s c w D o e s N o t E x i s t M s g           =   ' D e   i n g e v o e r d e   d a t u m   b e s t a a t   n i e t . ' ;  
                                 s c w I n v a l i d A l e r t                 =   [ ' O n g e l d i g e   d a t u m   ( ' , ' )   g e n e g e e r d . ' ] ;  
                                 s c w D a t e D i s a b l i n g E r r o r     =   [ ' F o u t   ' , '   n \ u 0 0 E 3 o   \ u 0 0 E 9   i s   g e e n   d a t u m   o b j e c t . ' ] ;  
                                 s c w R a n g e D i s a b l i n g E r r o r   =   [ ' F o u t   ' , '   m o e t   u i t   t w e e   e l e m e n t e n   b e s t a a n . ' ] ;  
                                 b r e a k ;  
  
                         c a s e   ' p l ' :  
                                 / /   P o l i s h   ( p r o v i d e d   b y   B a r t e k   J a b l o n s k i )  
                                 s c w T o d a y                               =   ' D z i \ u 0 1 5 b : ' ;  
                                 s c w C l e a r                               =   ' C l e a r ' ;  
                                 s c w D r a g                                 =   ' K l i k n i j   a b y   p r z e c i \ u 0 1 0 5 g n \ u 0 1 0 5 \ u 0 1 0 7 ' ;  
                                 s c w A r r M o n t h N a m e s               =   [ ' S t y ' , ' L u t ' , ' M a r ' , ' K w i ' , ' M a j ' , ' C z e ' ,  
                                                                                     ' L i p ' , ' S i e ' , ' W r z ' , ' P a \ u 0 1 7 a ' , ' L i s ' , ' G r u ' ] ;  
                                 s c w A r r W e e k I n i t s                 =   [ ' N ' , ' P ' , ' W ' , ' \ u 0 1 5 a ' , ' C ' , ' P ' , ' S ' ] ;  
                                 s c w I n v a l i d D a t e M s g             =   ' P o d a n a   d a t a   j e s t   n i e p o p r a w n a . \ n ' ;  
                                 s c w O u t O f R a n g e M s g               =   ' P o d a n a   d a t a   j e s t   p o z a   z a s i \ u 0 1 1 9 g i e m . ' ;  
                                 s c w D o e s N o t E x i s t M s g           =   ' P o d a n a   d a t a   n i e   i s t n i e j e . ' ;  
                                 s c w I n v a l i d A l e r t                 =   [ ' N i e p o p r a w n a   d a t a   ( ' , ' )   z i g n o r o w a n a . ' ] ;  
                                 s c w D a t e D i s a b l i n g E r r o r     =   [ ' B \ u 0 1 4 2 \ u 0 1 0 5 d   ' , '   n i e   j e s t   o b i e k t e m   t y p u   D a t e . ' ] ;  
                                 s c w R a n g e D i s a b l i n g E r r o r   =   [ ' B \ u 0 1 4 2 \ u 0 1 0 5 d   ' , '   p o w i n i e n   s k \ u 0 1 4 2 a d a \ u 0 1 0 7   s i \ u 0 1 1 9   z   d w \ u 0 0 f 3 c h   e l e m e n t \ u 0 0 f 3 w . ' ] ;  
                                 b r e a k ;  
  
                         c a s e   '  C' :  
 	 	 	 	 / /      CAA:89  ( p r o v i d e d   b y   R u s l a n   A n d r o s y u k )  
 	 	 	 	 s c w T o d a y                               =   ' !53>4=O: ' ;  
                                 s c w C l e a r                               =   ' C l e a r ' ;  
 	 	 	 	 s c w D r a g                                 =   ' ;8:=8B5  GB>1K  ?5@5B0I8BL' ;  
 	 	 	 	 s c w A r r M o n t h N a m e s               =   [ ' /=2' , ' $52' , ' 0@' , ' ?@' , ' 09' , ' N=' , 	 	 	 	 	  
 	 	 	 	 	 	 	 	 	 	     ' N;' , ' 23' , ' !5=' , ' :B' , ' >O' , ' 5:' ] ;  
 	 	 	 	 s c w A r r W e e k I n i t s                 =   [ ' ' , ' ' , ' ' , ' !' , ' '' , ' ' , ' !' ] ;  
 	 	 	 	 s c w I n v a l i d D a t e M s g             =   ' 525@=0O  40B0. \ n ' ;  
 	 	 	 	 s c w O u t O f R a n g e M s g               =   ' 2545==0O  40B0  2=5  480?07>=0. ' ;  
 	 	 	 	 s c w D o e s N o t E x i s t M s g           =   ' 2545==>9  40BK  =5  ACI5AB2C5B. ' ;  
 	 	 	 	 s c w I n v a l i d A l e r t                 =   [ ' 525@=0O  40B0  ( ' , ' )   ?@>83=>@8@>20=0. ' ] ;  
 	 	 	 	 s c w D a t e D i s a b l i n g E r r o r     =   [ ' H81:0  ' , '   =5  O2;O5BAO  40B>9. ' ] ;  
 	 	 	 	 s c w R a n g e D i s a b l i n g E r r o r   =   [ ' H81:0  ' , '   4>;6=0  A>AB>OBL  87  42CE  M;5<5=B>2. ' ] ;  
                                 b r e a k ;  
  
                         c a s e   ' s v ' :  
 	 	 	 	 / /   S w e d i s h   ( p r o v i d e d   b y   F r a n z   G r a n l u n d )  
 	 	 	 	 s c w T o d a y                               =   ' I d a g : ' ;  
                                 s c w C l e a r                               =   ' C l e a r ' ;  
 	 	 	 	 s c w D r a g                                 =   ' K l i c k a   h ä r   f ö r   a t t   d r a ' ;  
 	 	 	 	 s c w A r r M o n t h N a m e s               =   [ ' J a n ' , ' F e b ' , ' M a r ' , ' A p r ' , ' M a j ' , ' J u n ' ,    
 	 	 	 	 	 	 	 	 	 	     ' J u l ' , ' A u g ' , ' S e p ' , ' O k t ' , ' N o v ' , ' D e c ' ] ;  
 	 	 	 	 s c w A r r W e e k I n i t s                 =   [ ' S ' , ' M ' , ' T ' , ' O ' , ' T ' , ' F ' , ' L ' ] ;  
 	 	 	 	 s c w I n v a l i d D a t e M s g             =   ' D e t   a n g i v n a   d a t u m e t   ä r   o g i l t i g t . \ n ' ;  
 	 	 	 	 s c w O u t O f R a n g e M s g               =   ' D e t   a n g i v n a   d a t u m e t   ä r   u t a n f ö r   g r ä n s e r n a . ' ;  
 	 	 	 	 s c w D o e s N o t E x i s t M s g           =   ' D e t   a n g i v n a   d a t u m e t   e x i s t e r a r   i n t e . ' ;  
 	 	 	 	 s c w I n v a l i d A l e r t                 =   [ ' O g i l t i g t   d a t u m   ( ' , ' )   i g n o r e r a t . ' ] ;  
 	 	 	 	 s c w D a t e D i s a b l i n g E r r o r     =   [ ' F e l   ' , '   ä r   i n t e   e t t   D a t e   o b j e k t . ' ] ;    
 	 	 	 	 s c w R a n g e D i s a b l i n g E r r o r   =   [ ' F e l   ' , '   b o r d e   b e s t å   a v   t v å   e l e m e n t . ' ] ; 	 	 	  
                                 b r e a k ;  
 	 	 	 	  
 	 	 	 d e f a u l t :  
                                 / /   E n g l i s h  
                                 s c w T o d a y                               =   ' T o d a y : ' ;  
                                 s c w C l e a r                               =   ' C l e a r ' ;  
                                 s c w D r a g                                 =   ' c l i c k   h e r e   t o   d r a g ' ;  
                                 s c w A r r M o n t h N a m e s               =   [ ' J a n ' , ' F e b ' , ' M a r ' , ' A p r ' , ' M a y ' , ' J u n ' ,  
                                                                                     ' J u l ' , ' A u g ' , ' S e p ' , ' O c t ' , ' N o v ' , ' D e c ' ] ;  
                                 s c w A r r W e e k I n i t s                 =   [ ' S ' , ' M ' , ' T ' , ' W ' , ' T ' , ' F ' , ' S ' ] ;  
                                 s c w I n v a l i d D a t e M s g             =   ' T h e   e n t e r e d   d a t e   i s   i n v a l i d . \ n ' ;  
                                 s c w O u t O f R a n g e M s g               =   ' T h e   e n t e r e d   d a t e   i s   o u t   o f   r a n g e . ' ;  
                                 s c w D o e s N o t E x i s t M s g           =   ' T h e   e n t e r e d   d a t e   d o e s   n o t   e x i s t . ' ;  
                                 s c w I n v a l i d A l e r t                 =   [ ' I n v a l i d   d a t e   ( ' , ' )   i g n o r e d . ' ] ;  
                                 s c w D a t e D i s a b l i n g E r r o r     =   [ ' E r r o r   ' , '   i s   n o t   a   D a t e   o b j e c t . ' ] ;  
                                 s c w R a n g e D i s a b l i n g E r r o r   =   [ ' E r r o r   ' , '   s h o u l d   c o n s i s t   o f   t w o   e l e m e n t s . ' ] ;  
                         }  
                 }  
         / /   N o t e :     A l w a y s   s t a r t   t h e   s c w A r r W e e k I n i t s   a r r a y   w i t h   y o u r   s t r i n g   f o r  
         / /                 S u n d a y   w h a t e v e r   s c w W e e k S t a r t   ( b e l o w )   i s   s e t   t o .  
  
         / /   s c w W e e k S t a r t   d e t e r m i n e s   t h e   s t a r t   o f   t h e   w e e k   i n   t h e   d i s p l a y  
         / /   S e t   i t   t o :   0   ( Z e r o )   f o r   S u n d a y ,   1   ( O n e )   f o r   M o n d a y   e t c . .  
  
         v a r   s c w W e e k S t a r t               =         1 ;  
  
         / /   T h e   w e e k   s t a r t   d a y   f o r   t h e   d i s p l a y   i s   t a k e n   a s   t h e   w e e k   s t a r t  
         / /   f o r   w e e k   n u m b e r i n g .     T h i s   e n s u r e s   t h a t   o n l y   o n e   w e e k   n u m b e r  
         / /   a p p l i e s   t o   o n e   l i n e   o f   t h e   c a l e n d a r   t a b l e .  
         / /   [ I S O   8 6 0 1   b e g i n s   t h e   w e e k   w i t h   D a y   1   =   M o n d a y . ]  
  
         / /   I f   y o u   w a n t   t o   s e e   w e e k   n u m b e r i n g   o n   t h e   c a l e n d a r ,   s e t  
         / /   t h i s   t o   t r u e .     I f   n o t ,   f a l s e .  
  
         v a r   s c w W e e k N u m b e r D i s p l a y         =   f a l s e ;  
  
         / /   W e e k   n u m b e r i n g   r u l e s   a r e   g e n e r a l l y   b a s e d   o n   a   d a y   i n   t h e   w e e k  
         / /   t h a t   d e t e r m i n e s   t h e   f i r s t   w e e k   o f   t h e   y e a r .     I S O   8 6 0 1   u s e s  
         / /   T h u r s d a y   ( d a y   f o u r   w h e n   S u n d a y   i s   d a y   z e r o ) .     Y o u   c a n   a l t e r  
         / /   t h e   b a s e   d a y   h e r e .  
  
         / /   S e e   h t t p : / / w w w . c l . c a m . a c . u k / ~ m g k 2 5 / i s o - t i m e . h t m l   f o r   m o r e   i n f o r m a t i o n  
  
         v a r   s c w W e e k N u m b e r B a s e D a y         =   4 ;  
  
         / /   E a c h   o f   t h e   c a l e n d a r ' s   a l e r t   m e s s a g e   t y p e s   c a n   b e   d i s a b l e d  
         / /   i n d e p e n d e n t l y   h e r e .  
  
         v a r   s c w S h o w I n v a l i d D a t e M s g               =   t r u e ,  
                 s c w S h o w O u t O f R a n g e M s g                 =   t r u e ,  
                 s c w S h o w D o e s N o t E x i s t M s g             =   t r u e ,  
                 s c w S h o w I n v a l i d A l e r t                   =   t r u e ,  
                 s c w S h o w D a t e D i s a b l i n g E r r o r       =   t r u e ,  
                 s c w S h o w R a n g e D i s a b l i n g E r r o r     =   t r u e ;  
  
         / /   S e t   t h e   a l l o w e d   i n p u t   d a t e   d e l i m i t e r s   h e r e . . .  
         / /   E . g .   T o   s e t   t h e   r i s i n g   s l a s h ,   h y p h e n ,   f u l l - s t o p   ( a k a   s t o p   o r   p o i n t ) ,  
         / /             c o m m a   a n d   s p a c e   a s   d e l i m i t e r s   u s e  
         / /                             v a r   s c w A r r D e l i m i t e r s       =   [ ' / ' , ' - ' , ' . ' , ' , ' , '   ' ] ;  
  
         v a r   s c w A r r D e l i m i t e r s       =   [ ' / ' , ' - ' , ' . ' , ' , ' , '   ' ] ;  
  
         / /   S e t   t h e   f o r m a t   f o r   t h e   d i s p l a y e d   ' T o d a y '   d a t e   a n d   f o r   t h e   o u t p u t  
         / /   d a t e   h e r e .  
         / /  
         / /   T h e   f o r m a t   i s   d e s c r i b e d   u s i n g   d e l i m i t e r s   o f   y o u r   c h o i c e   ( a s   s e t  
         / /   i n   s c w A r r D e l i m i t e r s   a b o v e )   a n d   c a s e   i n s e n s i t i v e   l e t t e r s   D ,   M   a n d   Y .  
         / /  
         / /   N O T E :   I f   n o   d e l i m i t e r s   a r e   i n p u t   t h e n   t h e   d a t e   o u t p u t   f o r m a t   i s   u s e d  
         / /               t o   p a r s e   t h e   v a l u e .     T h i s   a l l o w s   l e s s   f l e x i b l i l i t y   i n   t h e   i n p u t  
         / /               v a l u e   t h a n   u s i n g   d e l i m i t e r s   b u t   a n   a c c u r a t e l y   e n t e r e d   d a t e  
         / /               r e m a i n s   p a r s a b l e .  
         / /  
         / /   D e f i n i t i o n                               R e t u r n s  
         / /   - - - - - - - - - -                               - - - - - - -  
         / /   D                         d a t e   i n   t h e   m o n t h   w i t h o u t   z e r o   f i l l i n g  
         / /   D D                       d a t e   i n   t h e   m o n t h   l e f t   z e r o   f i l l e d  
         / /   M                         m o n t h   n u m b e r   w i t h o u t   z e r o   f i l l i n g  
         / /   M M                       m o n t h   n u m b e r   l e f t   z e r o   f i l l e d  
         / /   M M M                     m o n t h   s t r i n g   f r o m   s c w A r r M o n t h N a m e s  
         / /   Y Y                       y e a r   n u m b e r   i n   t w o   d i g i t s  
         / /   Y Y Y Y                   y e a r   n u m b e r   i n   f o u r   d i g i t s  
  
         / /   D i s p l a y e d   " T o d a y "   d a t e   f o r m a t  
  
         v a r   s c w D a t e D i s p l a y F o r m a t   =   ' d d / m m / y y ' ;           / /   e . g .   ' M M M - D D - Y Y Y Y '   f o r   t h e   U S  
  
         / /   O u t p u t   d a t e   f o r m a t  
  
         v a r   s c w D a t e O u t p u t F o r m a t     =   ' D D / M M / Y Y Y Y ' ;   / /   e . g .   ' M M M - D D - Y Y Y Y '   f o r   t h e   U S  
  
         / /   N o t e :   T h e   d e l i m i t e r s   u s e d   s h o u l d   b e   i n   s c w A r r D e l i m i t e r s .  
  
         / /   s c w Z i n d e x   c o n t r o l s   h o w   t h e   p o p - u p   c a l e n d a r   i n t e r a c t s   w i t h   t h e   r e s t  
         / /   o f   t h e   p a g e .     I t   i s   u s u a l l y   a d e q u a t e   t o   l e a v e   i t   a s   1   ( O n e )   b u t   I  
         / /   h a v e   m a d e   i t   a v a i l a b l e   h e r e   t o   h e l p   a n y o n e   w h o   n e e d s   t o   a l t e r   t h e  
         / /   l e v e l   i n   o r d e r   t o   e n s u r e   t h a t   t h e   c a l e n d a r   d i s p l a y s   c o r r e c t l y   i n  
         / /   r e l a t i o n   t o   a l l   o t h e r   e l e m e n t s   o n   t h e   p a g e .  
  
         v a r   s c w Z i n d e x                     =   1 ;  
  
         / /   P e r s o n a l l y   I   l i k e   t h e   f a c t   t h a t   e n t e r i n g   3 1 - S e p - 2 0 0 5   d i s p l a y s  
         / /   1 - O c t - 2 0 0 5 ,   h o w e v e r   y o u   m a y   w a n t   t h a t   t o   b e   a n   e r r o r .     I f   s o ,  
         / /   s e t   s c w B l n S t r i c t   =   t r u e .     T h a t   w i l l   c a u s e   a n   e r r o r   m e s s a g e   t o  
         / /   d i s p l a y   a n d   t h e   s e l e c t e d   m o n t h   i s   d i s p l a y e d   w i t h o u t   a   s e l e c t e d  
         / /   d a y .   T h a n k s   t o   B r a d   A l l a n   f o r   h i s   f e e d b a c k   p r o m p t i n g   t h i s   f e a t u r e .  
  
         v a r   s c w B l n S t r i c t               =   f a l s e ;  
  
         / /   I f   y o u   a r e   u s i n g   R e a d O n l y   o r   D i s a b l e d   f i e l d s   t o   r e t u r n   t h e   d a t e  
         / /   v a l u e   i n t o ,   i t   c a n   b e   u s e f u l   t o   s h o w   a   b u t t o n   o n   t h e   c a l e n d a r  
         / /   t h a t   a l l o w s   t h e   v a l u e   t o   b e   c l e a r e d .     I f   y o u   w a n t   t o   d o   t h a t ,  
         / /   s e t   s c w C l e a r B u t t o n   =   t r u e ;  
  
         v a r   s c w C l e a r B u t t o n           =   t r u e ;  
  
         / /   T h e   c a l e n d a r   w i l l   p o s i t i o n   i t s e l f   a l i g n e d   w i t h   t h e   b o t t o m   l e f t  
         / /   c o r n e r   o f   t h e   t a r g e t   e l e m e n t .     I f   a u t o m a t i c   p o s i t i o n i n g   i s   t u r n e d  
         / /   o n     w i t h     s c w A u t o P o s i t i o n   =   t r u e     t h e n   i f   t h a t   w o u l d   c a u s e   t h e  
         / /   c a l e n d a r   t o   d i s p l a y   o f f   t h e   v i s i b l e   s c r e e n ,   i t   i s   s h i f t e d   t o  
         / /   a   p o s i t i o n   t h a t   i s   v i s i b l e .  
  
         v a r   s c w A u t o P o s i t i o n         =   t r u e ;  
  
         / /   I f   y o u   w i s h   t o   d i s a b l e   a n y   d i s p l a y e d   d a y ,   e . g .   E v e r y   M o n d a y ,  
         / /   y o u   c a n   d o   i t   b y   s e t t i n g   t h e   f o l l o w i n g   a r r a y .     T h e   a r r a y   e l e m e n t s  
         / /   m a t c h   t h e   d i s p l a y e d   c e l l s .  
         / /  
         / /   Y o u   c o u l d   p u t   s o m e t h i n g   l i k e   t h e   f o l l o w i n g   i n   y o u r   c a l l i n g   p a g e  
         / /   t o   d i s a b l e   a l l   w e e k e n d   d a y s ;  
         / /  
         / /     f o r   ( v a r   i = 0 ; i < s c w E n a b l e d D a y . l e n g t h ; i + + )  
         / /             { i f   ( i % 7 % 6 = = 0 )   s c w E n a b l e d D a y [ i ]   =   f a l s e ; }  
         / /  
         / /   T h e   a b o v e   a p p r o a c h   w i l l   a l l o w   y o u   t o   d i s a b l e   d a y s   o f   t h e   w e e k  
         / /   f o r   t h e   w h o l e   o f   y o u r   p a g e   e a s i l y .     I f   y o u   n e e d   t o   s e t   d i f f e r e n t  
         / /   d i s a b l e d   d a y s   f o r   a   n u m b e r   o f   d a t e   i n p u t   f i e l d s   o n   y o u r   p a g e  
         / /   t h e r e   i s   a n   e a s i e r   w a y :   Y o u   c a n   p a s s   a d d i t i o n a l   a r g u m e n t s   t o  
         / /   s c w S h o w .   T h e   s y n t a x   i s   d e s c r i b e d   a t   t h e   t o p   o f   t h i s   s c r i p t   i n  
         / /   t h e   s e c t i o n :  
         / /         " H o w   t o   u s e   t h e   C a l e n d a r   o n c e   i t   i s   d e f i n e d   f o r   y o u r   p a g e : "  
         / /  
         / /   I t   i s   p o s s i b l e   t o   u s e   t h e s e   t w o   a p p r o a c h e s   i n   c o m b i n a t i o n .  
  
         v a r   s c w E n a b l e d D a y             =   [ t r u e ,   t r u e ,   t r u e ,   t r u e ,   t r u e ,   t r u e ,   t r u e ,  
                                                             t r u e ,   t r u e ,   t r u e ,   t r u e ,   t r u e ,   t r u e ,   t r u e ,  
                                                             t r u e ,   t r u e ,   t r u e ,   t r u e ,   t r u e ,   t r u e ,   t r u e ,  
                                                             t r u e ,   t r u e ,   t r u e ,   t r u e ,   t r u e ,   t r u e ,   t r u e ,  
                                                             t r u e ,   t r u e ,   t r u e ,   t r u e ,   t r u e ,   t r u e ,   t r u e ,  
                                                             t r u e ,   t r u e ,   t r u e ,   t r u e ,   t r u e ,   t r u e ,   t r u e ] ;  
  
         / /   Y o u   c a n   d i s a b l e   a n y   s p e c i f i c   d a t e   ( e . g .   2 4 - J a n - 2 0 0 6   o r   T o d a y )   b y  
         / /   c r e a t i n g   a n   e l e m e n t   o f   t h e   a r r a y   s c w D i s a b l e d D a t e s   a s   a   d a t e   o b j e c t  
         / /   w i t h   t h e   v a l u e   y o u   w a n t   t o   d i s a b l e .     D a t e   r a n g e s   c a n   b e   d i s a b l e d  
         / /   b y   p l a c i n g   a n   a r r a y   o f   t w o   v a l u e s   ( S t a r t   a n d   E n d )   i n t o   a n   e l e m e n t  
         / /   o f   t h i s   a r r a y .  
  
         v a r   s c w D i s a b l e d D a t e s       =   n e w   A r r a y ( ) ;  
  
         / /   e . g .   T o   d i s a b l e   1 0 - D e c - 2 0 0 5 :  
         / /                     s c w D i s a b l e d D a t e s [ 0 ]   =   n e w   D a t e ( 2 0 0 5 , 1 1 , 1 0 ) ;  
         / /  
         / /             o r   a   r a n g e   f r o m   2 0 0 4 - D e c - 2 5   t o   2 0 0 5 - J a n - 0 1 :  
         / /                     s c w D i s a b l e d D a t e s [ 1 ]   =   [ n e w   D a t e ( 2 0 0 4 , 1 1 , 2 5 ) , n e w   D a t e ( 2 0 0 5 , 0 , 1 ) ] ;  
         / /  
         / /   R e m e m b e r   t h a t   J a v a s c r i p t   m o n t h s   a r e   Z e r o - b a s e d .  
  
         / /   T h e   d i s a b l i n g   b y   d a t e   a n d   d a t e   r a n g e   d o e s   p r e v e n t   t h e   c u r r e n t   d a y  
         / /   f r o m   b e i n g   s e l e c t e d .     D i s a b l i n g   d a y s   o f   t h e   w e e k   d o e s   n o t   s o   y o u   c a n   s e t  
         / /   t h e   s c w A c t i v e T o d a y   v a l u e   t o   f a l s e   t o   p r e v e n t   s e l e c t i o n .  
  
         v a r   s c w A c t i v e T o d a y   =   t r u e ;  
  
         / /   D a t e s   t h a t   a r e   o u t   o f   t h e   d i s p l a y e d   m o n t h   a r e   s h o w n   a t   t h e   s t a r t  
         / /   ( u n l e s s   t h e   m o n t h   s t a r t s   o n   t h e   f i r s t   d a y   o f   t h e   w e e k )   a n d   e n d   o f   e a c h  
         / /   m o n t h .  
         / /  
         / /   S e t   s c w O u t O f M o n t h D i s a b l e   t o     t r u e     t o   d i s a b l e   t h e s e   d a t e s   ( o r     f a l s e  
         / /   t o   a l l o w   t h e i r   s e l e c t i o n ) .  
         / /  
         / /   S e t   s c w O u t O f M o n t h H i d e         t o     t r u e     t o   h i d e         t h e s e   d a t e s   ( o r     f a l s e  
         / /   t o   m a k e   t h e m   v i s i b l e ) .  
  
         v a r   s c w O u t O f M o n t h D i s a b l e   =   f a l s e ;  
         v a r   s c w O u t O f M o n t h H i d e         =   f a l s e ;  
  
         / /   D a t e s   t h a t   a r e   o u t   o f   t h e   s p e c i f i e d   r a n g e   c a n   b e   d i s p l a y e d   a t   t h e   s t a r t  
         / /   o f   t h e   v e r y   f i r s t   m o n t h   a n d   e n d   o f   t h e   v e r y   l a s t .     S e t  
         / /   s c w O u t O f R a n g e D i s a b l e   t o     t r u e     t o   d i s a b l e   t h e s e   d a t e s   ( o r     f a l s e     t o  
         / /   a l l o w   t h e i r   s e l e c t i o n ) .  
  
         v a r   s c w O u t O f R a n g e D i s a b l e   =   t r u e ;  
  
         / /   I f   y o u   w a n t   a   s p e c i a l   f o r m a t   f o r   t h e   c e l l   t h a t   c o n t a i n s   t h e   c u r r e n t   d a y  
         / /   s e t   t h i s   t o   t r u e .     T h i s   s e t s   a   t h i n   b o r d e r   a r o u n d   t h e   c e l l   i n   t h e   c o l o u r  
         / /   s e t   b y   s c w T o d a y C e l l B o r d e r C o l o u r .  
  
         v a r   s c w F o r m a t T o d a y C e l l   =   t r u e ;  
         v a r   s c w T o d a y C e l l B o r d e r C o l o u r   =   ' r e d ' ;  
  
         / /   Y o u   c a n   a l l o w   t h e   c a l e n d a r   t o   b e   d r a g g e d   a r o u n d   t h e   s c r e e n   b y  
         / /   u s i n g   t h e   s e t t i n g   s c w A l l o w D r a g   t o   t r u e .  
         / /   I   c a n ' t   s a y   I   r e c o m m e n d   i t   b e c a u s e   o f   t h e   d a n g e r   o f   t h e   u s e r  
         / /   f o r g e t t i n g   w h i c h   d a t e   f i e l d   t h e   c a l e n d a r   w i l l   u p d a t e   w h e n   t h e r e  
         / /   a r e   m u l t i p l e   d a t e   f i e l d s   o n   a   p a g e .  
  
         v a r   s c w A l l o w D r a g   =   f a l s e ;  
  
         / /   C l o s i n g   t h e   c a l e n d a r   b y   c l i c k i n g   o n   i t   ( r a t h e r   t h a n   e l s e w h e r e   o n   t h e  
         / /   m a i n   p a g e )   c a n   b e   i n c o n v e n i e n t .     T h e   s c w C l i c k T o H i d e   b o o l e a n   v a l u e  
         / /   c o n t r o l s   t h i s   f e a t u r e .  
  
         v a r   s c w C l i c k T o H i d e   =   f a l s e ;  
  
         / /   I   h a v e   m a d e   e v e r y   e f f o r t   t o   i s o l a t e   t h e   p o p - u p   s c r i p t   f r o m   a n y  
         / /   C S S   d e f i n e d   o n   t h e   m a i n   p a g e   b u t   i f   y o u   h a v e   a n y t h i n g   s e t   t h a t  
         / /   a f f e c t s   t h e   p o p - u p   ( o r   y o u   m a y   w a n t   t o   c h a n g e   t h e   w a y   i t   l o o k s )  
         / /   t h e n   y o u   c a n   a d d r e s s   i t   i n   t h e   f o l l o w i n g   s t y l e   s h e e t s .  
  
         d o c u m e n t . w r i t e l n (  
                 ' < s t y l e   t y p e = " t e x t / c s s " > '                                                                               +  
                         ' . s c w                       { p a d d i n g : 1 p x ; v e r t i c a l - a l i g n : m i d d l e ; } '               +  
                         ' i f r a m e . s c w           { p o s i t i o n : a b s o l u t e ; z - i n d e x : '   +   s c w Z i n d e x         +  
                                                         ' ; t o p : 0 p x ; l e f t : 0 p x ; v i s i b i l i t y : h i d d e n ; '             +  
                                                         ' w i d t h : 1 p x ; h e i g h t : 1 p x ; } '                                         +  
                         ' t a b l e . s c w             { p a d d i n g : 0 p x ; v i s i b i l i t y : h i d d e n ; '                         +  
                                                         ' p o s i t i o n : a b s o l u t e ; c u r s o r : d e f a u l t ; '                   +  
                                                         ' w i d t h : 2 0 0 p x ; t o p : 0 p x ; l e f t : 0 p x ; '                           +  
                                                         ' z - i n d e x : '   +   ( s c w Z i n d e x + 1 )                                     +  
                                                         ' ; t e x t - a l i g n : c e n t e r ; } '                                             +  
                 ' < / s t y l e > '     ) ;  
  
         / /   T h i s   s t y l e   s h e e t   c a n   b e   e x t r a c t e d   f r o m   t h e   s c r i p t   a n d   e d i t e d   i n t o   r e g u l a r  
         / /   C S S   ( b y   r e m o v i n g   a l l   o c c u r r e n c e s   o f   +   a n d   ' ) .   T h a t   c a n   b e   u s e d   a s   t h e  
         / /   b a s i s   f o r   t h e m e s .   C l a s s e s   a r e   d e s c r i b e d   i n   c o m m e n t s   w i t h i n   t h e   s t y l e  
         / /   s h e e t .  
  
         d o c u m e n t . w r i t e l n (  
                 ' < s t y l e   t y p e = " t e x t / c s s " > '                                                                               +  
                         ' / *   I M P O R T A N T :     T h e   S C W   c a l e n d a r   s c r i p t   r e q u i r e s   a l l   '             +  
                         '                               t h e   c l a s s e s   d e f i n e d   h e r e . '                                     +  
                         ' * / '                                                                                                                 +  
                         ' t a b l e . s c w             { p a d d i n g :               1 p x ; '                                               +  
                                                         ' v e r t i c a l - a l i g n : m i d d l e ; '                                         +  
                                                         ' b o r d e r :                 r i d g e   2 p x ; '                                   +  
                                                         ' f o n t - s i z e :           1 0 p t ; '                                             +  
                                                         ' f o n t - f a m i l y :       '   +  
                                                                       ' V e r d a n a , A r i a l , H e l v e t i c a , S a n s - S e r i f ; ' +  
                                                         ' f o n t - w e i g h t :       b o l d ; } '                                           +  
                         ' t d . s c w D r a g , '                                                                                               +  
                         ' t d . s c w H e a d                                   { p a d d i n g :               0 p x   0 p x ; '               +  
                                                                                 ' t e x t - a l i g n :         c e n t e r ; } '               +  
                         ' t d . s c w D r a g                                   { f o n t - s i z e :           8 p t ; } '                     +  
                         ' s e l e c t . s c w H e a d                           { m a r g i n :                 3 p x   1 p x ; '               +  
                                                                                 ' t e x t - a l i g n :         c e n t e r ; } '               +  
                         ' i n p u t . s c w H e a d                             { h e i g h t :                 2 2 p x ; '                     +  
                                                                                 ' w i d t h :                   2 2 p x ; '                     +  
                                                                                 ' v e r t i c a l - a l i g n : m i d d l e ; '                 +  
                                                                                 ' t e x t - a l i g n :         c e n t e r ; '                 +  
                                                                                 ' m a r g i n :                 2 p x   1 p x ; '               +  
                                                                                 ' f o n t - w e i g h t :       b o l d ; '                     +  
                                                                                 ' f o n t - s i z e :           1 0 p t ; '                     +  
                                                                                 ' f o n t - f a m i l y :       f i x e d S y s ; } '           +  
                         ' t d . s c w W e e k N u m b e r H e a d , '                                                                           +  
                         ' t d . s c w W e e k                                   { p a d d i n g :               0 p x ; '                       +  
                                                                                 ' t e x t - a l i g n :         c e n t e r ; '                 +  
                                                                                 ' f o n t - w e i g h t :       b o l d ; } '                   +  
                         ' t d . s c w N o w , '                                                                                                 +  
                         ' t d . s c w N o w H o v e r , '                                                                                       +  
                         ' t d . s c w N o w : h o v e r , '                                                                                     +  
                         ' t d . s c w N o w D i s a b l e d                     { p a d d i n g :               0 p x ; '                       +  
                                                                                 ' t e x t - a l i g n :         c e n t e r ; '                 +  
                                                                                 ' v e r t i c a l - a l i g n : m i d d l e ; '                 +  
                                                                                 ' f o n t - w e i g h t :       n o r m a l ; } '               +  
                         ' t a b l e . s c w C e l l s                           { t e x t - a l i g n :         r i g h t ; '                   +  
                                                                                 ' f o n t - s i z e :           8 p t ; '                       +  
                                                                                 ' w i d t h :                   9 6 % ; } '                     +  
                         ' t d . s c w C e l l s , '                                     +  
                         ' t d . s c w C e l l s H o v e r , '                           +  
                         ' t d . s c w C e l l s : h o v e r , '                         +  
                         ' t d . s c w C e l l s D i s a b l e d , '                     +  
                         ' t d . s c w C e l l s E x M o n t h , '                       +  
                         ' t d . s c w C e l l s E x M o n t h H o v e r , '             +  
                         ' t d . s c w C e l l s E x M o n t h : h o v e r , '           +  
                         ' t d . s c w C e l l s E x M o n t h D i s a b l e d , '       +  
                         ' t d . s c w C e l l s W e e k e n d , '                       +  
                         ' t d . s c w C e l l s W e e k e n d H o v e r , '             +  
                         ' t d . s c w C e l l s W e e k e n d : h o v e r , '           +  
                         ' t d . s c w C e l l s W e e k e n d D i s a b l e d , '       +  
                         ' t d . s c w I n p u t D a t e , '                             +  
                         ' t d . s c w I n p u t D a t e H o v e r , '                   +  
                         ' t d . s c w I n p u t D a t e : h o v e r , '                 +  
                         ' t d . s c w I n p u t D a t e D i s a b l e d , '             +  
                         ' t d . s c w W e e k N o , '                                   +  
                         ' t d . s c w W e e k s                                 { p a d d i n g :                       3 p x ; '               +  
                                                                                 ' w i d t h :                           1 6 p x ; '             +  
                                                                                 ' h e i g h t :                         1 6 p x ; '             +  
                                                                                 ' b o r d e r - w i d t h :             1 p x ; '               +  
                                                                                 ' b o r d e r - s t y l e :             s o l i d ; '           +  
                                                                                 ' f o n t - w e i g h t :               b o l d ; '             +  
                                                                                 ' v e r t i c a l - a l i g n :         m i d d l e ; } '       +  
                         ' / *   B l e n d   t h e   c o l o u r s   i n t o   y o u r   p a g e   h e r e . . .         * / '                   +  
                         ' / *   C a l e n d a r   b a c k g r o u n d   * / '                                                                   +  
                         ' t a b l e . s c w                                     { b a c k g r o u n d - c o l o r :     # 6 6 6 6 C C ; } '     +  
                         ' / *   D r a g   H a n d l e   * / '                                                                                   +  
                         ' t d . s c w D r a g                                   { b a c k g r o u n d - c o l o r :     # 9 9 9 9 C C ; '       +  
                                                                                 ' c o l o r :                           # C C C C F F ; } '     +  
                         ' / *   W e e k   n u m b e r   h e a d i n g   * / '                                                                   +  
                         ' t d . s c w W e e k N u m b e r H e a d               { c o l o r :                           # 6 6 6 6 C C ; } '     +  
                         ' / *   W e e k   d a y   h e a d i n g s   * / '                                                                       +  
                         ' t d . s c w W e e k                                   { c o l o r :                           # C C C C C C ; } '     +  
                         ' / *   W e e k   n u m b e r s   * / '                                                                                 +  
                         ' t d . s c w W e e k N o                               { b a c k g r o u n d - c o l o r :     # 7 7 6 6 7 7 ; '       +  
                                                                                 ' c o l o r :                           # C C C C C C ; } '     +  
                         ' / *   E n a b l e d   D a y s   * / '                                                                                 +  
                         ' / *   W e e k   D a y   * / '                                                                                         +  
                         ' t d . s c w C e l l s                                 { b a c k g r o u n d - c o l o r :     # C C C C C C ; '       +  
                                                                                 ' c o l o r :                           # 0 0 0 0 0 0 ; } '     +  
                         ' / *   D a y   m a t c h i n g   t h e   i n p u t   d a t e   * / '                                                   +  
                         ' t d . s c w I n p u t D a t e                         { b a c k g r o u n d - c o l o r :     # C C 9 9 9 9 ; '       +  
                                                                                 ' c o l o r :                           # F F 0 0 0 0 ; } '     +  
                         ' / *   W e e k e n d   D a y   * / '                                                                                   +  
                         ' t d . s c w C e l l s W e e k e n d                   { b a c k g r o u n d - c o l o r :     # C C C C C C ; '       +  
                                                                                 ' c o l o r :                           # C C 6 6 6 6 ; } '     +  
                         ' / *   D a y   o u t s i d e   t h e   c u r r e n t   m o n t h   * / '                                               +  
                         ' t d . s c w C e l l s E x M o n t h                   { b a c k g r o u n d - c o l o r :     # C C C C C C ; '       +  
                                                                                 ' c o l o r :                           # 6 6 6 6 6 6 ; } '     +  
                         ' / *   T o d a y   s e l e c t o r   * / '                                                                             +  
                         ' t d . s c w N o w                                     { b a c k g r o u n d - c o l o r :     # 6 6 6 6 C C ; '       +  
                                                                                 ' c o l o r :                           # F F F F F F ; } '     +  
                         ' / *   C l e a r   B u t t o n   * / '                                                                                 +  
                         ' t d . s c w C l e a r                                 { p a d d i n g :                       0 p x ; } '             +  
                         ' i n p u t . s c w C l e a r                           { p a d d i n g :                       0 p x ; '               +  
                                                                                 ' t e x t - a l i g n :                 c e n t e r ; '         +  
                                                                                 ' f o n t - s i z e :                   8 p t ; } '             +  
                         ' / *   M o u s e O v e r / H o v e r   f o r m a t t i n g   '                                                         +  
                         '               I f   y o u   w a n t   t o   " t u r n   o f f "   a n y   o f   t h e   f o r m a t t i n g   '       +  
                         '               t h e n   j u s t   s e t   t o   t h e   s a m e   a s   t h e   s t a n d a r d   f o r m a t '       +  
                         '               a b o v e . '                                                                                           +  
                         '   '                                                                                                                   +  
                         '               N o t e :   T h e   r e a s o n   t h a t   t h e   f o l l o w i n g   a r e '                         +  
                         '               i m p l e m e n t e d   u s i n g   b o t h   a   c l a s s   a n d   a   : h o v e r '                 +  
                         '               p s e u d o c l a s s   i s   b e c a u s e   O p e r a   h a n d l e s   t h e   r e n d e r i n g '   +  
                         '               i n v o l v e d   i n   t h e   c l a s s   s w a p   v e r y   p o o r l y   a n d   I E 6   '         +  
                         '               ( a n d   b e l o w )   o n l y   i m p l e m e n t s   p s e u d o c l a s s e s   o n   t h e '       +  
                         '               a n c h o r   t a g . '                                                                                 +  
                         ' * / '                                                                                                                 +  
                         ' / *   A c t i v e   c e l l s   * / '                                                                                 +  
                         ' t d . s c w C e l l s : h o v e r , '                                                                                 +  
                         ' t d . s c w C e l l s H o v e r                       { b a c k g r o u n d - c o l o r :     # F F F F 0 0 ; '       +  
                                                                                 ' c u r s o r :                         p o i n t e r ; '       +  
                                                                                 ' c o l o r :                           # 0 0 0 0 0 0 ; } '     +  
                         ' / *   D a y   m a t c h i n g   t h e   i n p u t   d a t e   * / '                                                   +  
                         ' t d . s c w I n p u t D a t e : h o v e r , '                                                                         +  
                         ' t d . s c w I n p u t D a t e H o v e r               { b a c k g r o u n d - c o l o r :     # F F F F 0 0 ; '       +  
                                                                                 ' c u r s o r :                         p o i n t e r ; '       +  
                                                                                 ' c o l o r :                           # 0 0 0 0 0 0 ; } '     +  
                         ' / *   W e e k e n d   c e l l s   * / '                                                                               +  
                         ' t d . s c w C e l l s W e e k e n d : h o v e r , '                                                                   +  
                         ' t d . s c w C e l l s W e e k e n d H o v e r         { b a c k g r o u n d - c o l o r :     # F F F F 0 0 ; '       +  
                                                                                 ' c u r s o r :                         p o i n t e r ; '       +  
                                                                                 ' c o l o r :                           # 0 0 0 0 0 0 ; } '     +  
                         ' / *   D a y   o u t s i d e   t h e   c u r r e n t   m o n t h   * / '                                               +  
                         ' t d . s c w C e l l s E x M o n t h : h o v e r , '                                                                   +  
                         ' t d . s c w C e l l s E x M o n t h H o v e r         { b a c k g r o u n d - c o l o r :     # F F F F 0 0 ; '       +  
                                                                                 ' c u r s o r :                         p o i n t e r ; '       +  
                                                                                 ' c o l o r :                           # 0 0 0 0 0 0 ; } '     +  
                         ' / *   T o d a y   s e l e c t o r   * / '                                                                             +  
                         ' t d . s c w N o w : h o v e r , '                                                                                     +  
                         ' t d . s c w N o w H o v e r                           { c o l o r :                           # F F F F 0 0 ; '       +  
                                                                                 ' c u r s o r :                         p o i n t e r ; '       +  
                                                                                 ' f o n t - w e i g h t :               b o l d ; } '           +  
                         ' / *   D i s a b l e d   c e l l s   * / '                                                                             +  
                         ' / *   W e e k   D a y   * / '                                                                                         +  
                         ' / *   D a y   m a t c h i n g   t h e   i n p u t   d a t e   * / '                                                   +  
                         ' t d . s c w I n p u t D a t e D i s a b l e d         { b a c k g r o u n d - c o l o r :     # 9 9 9 9 9 9 ; '       +  
                                                                                 ' c o l o r :                           # 0 0 0 0 0 0 ; } '     +  
                         ' t d . s c w C e l l s D i s a b l e d                 { b a c k g r o u n d - c o l o r :     # 9 9 9 9 9 9 ; '       +  
                                                                                 ' c o l o r :                           # 0 0 0 0 0 0 ; } '     +  
                         ' / *   W e e k e n d   D a y   * / '                                                                                   +  
                         ' t d . s c w C e l l s W e e k e n d D i s a b l e d   { b a c k g r o u n d - c o l o r :     # 9 9 9 9 9 9 ; '       +  
                                                                                 ' c o l o r :                           # C C 6 6 6 6 ; } '     +  
                         ' / *   D a y   o u t s i d e   t h e   c u r r e n t   m o n t h   * / '                                               +  
                         ' t d . s c w C e l l s E x M o n t h D i s a b l e d   { b a c k g r o u n d - c o l o r :     # 9 9 9 9 9 9 ; '       +  
                                                                                 ' c o l o r :                           # 6 6 6 6 6 6 ; } '     +  
                         ' t d . s c w N o w D i s a b l e d                     { b a c k g r o u n d - c o l o r :     # 6 6 6 6 C C ; '       +  
                                                                                 ' c o l o r :                           # F F F F F F ; } '     +  
                 ' < / s t y l e > '  
                                         ) ;  
  
 / / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
 / / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 / /   E n d   o f   c u s t o m i s a t i o n   s e c t i o n  
 / / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 / / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
  
 / /     V a r i a b l e s   r e q u i r e d   b y   b o t h   s c w S h o w   a n d   s c w S h o w M o n t h  
  
         v a r   s c w T a r g e t E l e ,  
                 s c w T r i g g e r E l e ,  
                 s c w M o n t h S u m                         =   0 ,  
                 s c w B l n F u l l I n p u t D a t e         =   f a l s e ,  
                 s c w P a s s E n a b l e d D a y             =   n e w   A r r a y ( ) ,  
                 s c w S e e d D a t e                         =   n e w   D a t e ( ) ,  
                 s c w P a r m A c t i v e T o d a y           =   t r u e ,  
                 s c w W e e k S t a r t                       =   s c w W e e k S t a r t % 7 ,  
                 s c w T o d a y ,  
                 s c w C l e a r ,  
                 s c w D r a g ,  
                 s c w A r r M o n t h N a m e s ,  
                 s c w A r r W e e k I n i t s ,  
                 s c w I n v a l i d D a t e M s g ,  
                 s c w O u t O f R a n g e M s g ,  
                 s c w D o e s N o t E x i s t M s g ,  
                 s c w I n v a l i d A l e r t ,  
                 s c w D a t e D i s a b l i n g E r r o r ,  
                 s c w R a n g e D i s a b l i n g E r r o r ;  
  
         / /   A d d   a   m e t h o d   t o   f o r m a t   a   d a t e   i n t o   t h e   r e q u i r e d   p a t t e r n  
  
         D a t e . p r o t o t y p e . s c w F o r m a t   =  
                 f u n c t i o n ( s c w F o r m a t )  
                         { v a r   c h a r C o u n t   =   0 ,  
                                   c o d e C h a r     =   ' ' ,  
                                   r e s u l t         =   ' ' ;  
  
                           f o r   ( v a r   i = 0 ; i < = s c w F o r m a t . l e n g t h ; i + + )  
                                 { i f   ( i < s c w F o r m a t . l e n g t h   & &   s c w F o r m a t . c h a r A t ( i ) = = c o d e C h a r )  
                                                 { / /   I f   w e   h a v e n ' t   h i t   t h e   e n d   o f   t h e   s t r i n g   a n d  
                                                   / /   t h e   f o r m a t   s t r i n g   c h a r a c t e r   i s   t h e   s a m e   a s  
                                                   / /   t h e   p r e v i o u s   o n e ,   j u s t   c l o c k   u p   o n e   t o   t h e  
                                                   / /   l e n g t h   o f   t h e   c u r r e n t   e l e m e n t   d e f i n i t i o n  
                                                   c h a r C o u n t + + ;  
                                                 }  
                                   e l s e       { s w i t c h   ( c o d e C h a r )  
                                                         { c a s e   ' y ' :   c a s e   ' Y ' :  
                                                                 r e s u l t   + =   ( t h i s . g e t F u l l Y e a r ( ) % M a t h .  
                                                                                         p o w ( 1 0 , c h a r C o u n t ) ) . t o S t r i n g ( ) .  
                                                                                         s c w P a d L e f t ( c h a r C o u n t ) ;  
                                                                 b r e a k ;  
                                                           c a s e   ' m ' :   c a s e   ' M ' :  
                                                                 / /   I f   w e   f i n d   a n   M ,   c h e c k   t h e   n u m b e r   o f   t h e m   t o  
                                                                 / /   d e t e r m i n e   w h e t h e r   t o   g e t   t h e   m o n t h   n u m b e r   o r  
                                                                 / /   t h e   m o n t h   n a m e .  
                                                                 r e s u l t   + =   ( c h a r C o u n t < 3 )  
                                                                                         ? ( t h i s . g e t M o n t h ( ) + 1 ) .  
                                                                                                 t o S t r i n g ( ) . s c w P a d L e f t ( c h a r C o u n t )  
                                                                                         : s c w A r r M o n t h N a m e s [ t h i s . g e t M o n t h ( ) ] ;  
                                                                 b r e a k ;  
                                                           c a s e   ' d ' :   c a s e   ' D ' :  
                                                                 / /   I f   w e   f i n d   a   D ,   g e t   t h e   d a t e   a n d   f o r m a t   i t  
                                                                 r e s u l t   + =   t h i s . g e t D a t e ( ) . t o S t r i n g ( ) .  
                                                                                         s c w P a d L e f t ( c h a r C o u n t ) ;  
                                                                 b r e a k ;  
                                                           d e f a u l t :  
                                                                 / /   C o p y   a n y   u n r e c o g n i s e d   c h a r a c t e r s   a c r o s s  
                                                                 w h i l e   ( c h a r C o u n t - -   >   0 )   { r e s u l t   + =   c o d e C h a r ; }  
                                                         }  
  
                                                   i f   ( i < s c w F o r m a t . l e n g t h )  
                                                         { / /   S t o r e   t h e   c h a r a c t e r   w e   h a v e   j u s t   w o r k e d   o n  
                                                           c o d e C h a r     =   s c w F o r m a t . c h a r A t ( i ) ;  
                                                           c h a r C o u n t   =   1 ;  
                                                         }  
                                                 }  
                                 }  
                           r e t u r n   r e s u l t ;  
                         } ;  
  
         / /   A d d   a   m e t h o d   t o   l e f t   p a d   z e r o e s  
  
         S t r i n g . p r o t o t y p e . s c w P a d L e f t   =  
                 f u n c t i o n ( p a d T o L e n g t h )  
                         { v a r   r e s u l t   =   ' ' ;  
                           f o r   ( v a r   i = 0 ; i < ( p a d T o L e n g t h   -   t h i s . l e n g t h ) ; i + + )   { r e s u l t   + =   ' 0 ' ; }  
                           r e t u r n   ( r e s u l t   +   t h i s ) ;  
                         } ;  
  
         / /   S e t   u p   a   c l o s u r e   s o   t h a t   a n y   n e x t   f u n c t i o n   c a n   b e   t r i g g e r e d  
         / /   a f t e r   t h e   c a l e n d a r   h a s   b e e n   c l o s e d   A N D   t h a t   f u n c t i o n   c a n   t a k e  
         / /   a r g u m e n t s .  
  
         F u n c t i o n . p r o t o t y p e . r u n s A f t e r S C W   =  
                 f u n c t i o n ( )     { v a r   f u n c   =   t h i s ,  
                                                   a r g s   =   n e w   A r r a y ( a r g u m e n t s . l e n g t h ) ;  
  
                                           f o r   ( v a r   i = 0 ; i < a r g s . l e n g t h ; + + i )   { a r g s [ i ]   =   a r g u m e n t s [ i ] ; }  
  
                                           r e t u r n   f u n c t i o n ( )  
                                                 { / /   c o n c a t / j o i n   t h e   t w o   a r g u m e n t   a r r a y s  
                                                   f o r   ( v a r   i = 0 ; i < a r g u m e n t s . l e n g t h ; + + i )   { a r g s [ a r g s . l e n g t h ]   =   a r g u m e n t s [ i ] ; }  
                                                   r e t u r n   ( a r g s . s h i f t ( ) = = s c w T r i g g e r E l e ) ? f u n c . a p p l y ( t h i s ,   a r g s ) : n u l l ;  
                                                 } ;  
                                         } ;  
  
         / /   S e t   u p   s o m e   s h o r t c u t s  
  
         f u n c t i o n   s c w I D ( i d )  
                 { i f   ( 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 o c u m e n t . g e t E l e m e n t B y I d ( i d )   & &   d o c u m e n t . g e t E l e m e n t s B y N a m e ( i d ) . l e n g t h = = 0 ) )  
                                                                         / /   I F       A n   I D   a t t r i b u t e   i s   a s s i g n e d  
                                                                         / /   O R       N o   I D   a t t r i b u t e   i s   a s s i g n e d   b u t   u s i n g   I E   a n d   O p e r a  
                                                                         / /                     ( w h i c h   w i l l   f i n d   t h e   N A M E   a t t r i b u t e   v a l u e   u s i n g   g e t E l e m e n t B y I d )  
                                                                         / /   O R       N o   e l e m e n t   h a s   t h i s   I D   o r   N A M E   a t t r i b u t e   v a l u e  
                                                                         / /                     ( u s e d   i n t e r n a l l y   b y   t h e   s c r i p t )  
                                                                         / /   T H E N   R e t u r n   t h e   r e q u i r e d   e l e m e n t .  
                                 { r e t u r n   d o c u m e n t . g e t E l e m e n t B y I d ( i d ) ; }  
                   e l s e       { i f   ( d o c u m e n t . g e t E l e m e n t s B y N a m e ( i d ) . l e n g t h = = 1 )  
                                                                 / /   I F       N o   I D   a t t r i b u t e   i s   a s s i g n e d  
                                                                 / /   A N D     U s i n g   a   s t a n d a r d s - b a s e d   b r o w s e r  
                                                                 / /   A N D     O n l y   o n e   e l e m e n t   h a s   t h e   N A M E   a t t r i b u t e   s e t   t o   t h e   v a l u e  
                                                                 / /   T H E N   R e t u r n   t h e   r e q u i r e d   e l e m e n t   ( u s i n g   t h e   N A M E   a t t r i b u t e   v a l u e ) .  
                                                 { r e t u r n   d o c u m e n t . g e t E l e m e n t s B y N a m e ( i d ) [ 0 ] ; }  
                                   e l s e       { i f   ( d o c u m e n t . g e t E l e m e n t s B y N a m e ( i d ) . l e n g t h > 1 )  
                                                         {       / /   I F       N o   I D   a t t r i b u t e   i s   a s s i g n e d  
                                                                 / /   A N D     u s i n g   a   s t a n d a r d s - b a s e d   b r o w s e r  
                                                                 / /   A N D     m o r e   t h a n   o n e   e l e m e n t   h a s   t h e   N A M E   a t t r i b u t e   s e t   t o   t h e   v a l u e  
                                                                 / /   T H E N   a l e r t   d e v e l o p e r   t o   f i x   t h e   f a u l t .  
                                                           a l e r t (   ' S C W '   +  
                                                                         '   \ n C a n n o t   u n i q u e l y   i d e n t i f y   e l e m e n t   n a m e d :   '   +   i d   +  
                                                                         ' . \ n M o r e   t h a n   o n e   i d e n t i c a l   N A M E   a t t r i b u t e   d e f i n e d '   +  
                                                                         ' . \ n S o l u t i o n :   A s s i g n   t h e   r e q u i r e d   e l e m e n t   a   u n i q u e   I D   a t t r i b u t e   v a l u e . ' ) ;  
                                                         }  
                                                 }  
                                 }  
                 } ;  
  
         / /   U s e   a   g l o b a l   v a r i a b l e   f o r   t h e   r e t u r n   v a l u e   f r o m   t h e   n e x t   a c t i o n  
         / /   I E   f a i l s   t o   p a s s   t h e   f u n c t i o n   t h r o u g h   i f   t h e   t a r g e t   e l e m e n t   i s   i n  
         / /   a   f o r m   a n d   s c w N e x t A c t i o n   i s   n o t   d e f i n e d .  
  
         v a r   s c w N e x t A c t i o n R e t u r n ,   s c w N e x t A c t i o n ;  
  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
 / /   S t a r t   o f   F u n c t i o n   L i b r a r y  
 / /  
 / /     E x p o s e d   f u n c t i o n s :  
 / /  
 / /             s c w S h o w                           E n t r y   p o i n t   f o r   d i s p l a y   o f   c a l e n d a r ,  
 / /                                                             c a l l e d   i n   m a i n   p a g e .  
 / /             s h o w C a l                           L e g a c y   n a m e   o f   s c w S h o w :  
 / /                                                             P a s s e s   o n l y   l e g a c y   a r g u m e n t s ,  
 / /                                                             n o t   t h e   o p t i o n a l   d a y   d i s a b l i n g   a r g u m e n t s .  
 / /  
 / /             s c w S h o w M o n t h                 D i s p l a y s   a   m o n t h   o n   t h e   c a l e n d a r ,  
 / /                                                             C a l l e d   w h e n   a   m o n t h   i s   s e t   o r   c h a n g e d .  
 / /  
 / /             s c w B e g i n D r a g                 C o n t r o l s   c a l e n d a r   d r a g g i n g .  
 / /  
 / /             s c w C a n c e l                       C a l l e d   w h e n   t h e   c a l e n d a r   b a c k g r o u n d   i s   c l i c k e d :  
 / /                                                             C a l l s   s c w S t o p P r o p a g a t i o n   a n d   m a y   c a l l   s c w H i d e .  
 / /             s c w H i d e                           H i d e s   t h e   c a l e n d a r ,   c a l l e d   o n   v a r i o u s   e v e n t s .  
 / /             s c w S t o p P r o p a g a t i o n     S t o p s   t h e   p r o p a g a t i o n   o f   a n   e v e n t .  
 / /  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
  
         f u n c t i o n   s h o w C a l ( s c w E l e , s c w S o u r c e )   { s c w S h o w ( s c w E l e , s c w S o u r c e ) ; } ;  
         f u n c t i o n   s c w S h o w ( s c w E l e , s c w S o u r c e )  
                 { i f   ( ! s c w S o u r c e )   { s c w S o u r c e   =   w i n d o w . e v e n t ; }  
  
                   i f   ( s c w S o u r c e . t a g N a m e )   / /   S e c o n d   p a r a m e t e r   i s n ' t   a n   e v e n t   i t ' s   a n   e l e m e n t  
                         { v a r   s c w S o u r c e E l e   =   s c w S o u r c e ;  
  
                           i f   ( s c w I D ( ' s c w I E ' ) )     { w i n d o w . e v e n t . c a n c e l B u b b l e   =   t r u e ; }  
                           e l s e   { s c w S o u r c e E l e . p a r e n t N o d e . a d d E v e n t L i s t e n e r ( ' c l i c k ' , s c w S t o p P r o p a g a t i o n , f a l s e ) ; }  
                         }  
                   e l s e       / /   S e c o n d   p a r a m e t e r   i s   a n   e v e n t  
                         { v a r   s c w S o u r c e E l e   =   ( s c w S o u r c e . t a r g e t )  
                                                                         ? s c w S o u r c e . t a r g e t  
                                                                         : s c w S o u r c e . s r c E l e m e n t ;  
  
                           / /   S t o p   t h e   c l i c k   e v e n t   t h a t   o p e n s   t h e   c a l e n d a r   f r o m   b u b b l i n g   u p   t o  
                           / /   t h e   d o c u m e n t - l e v e l   e v e n t   h a n d l e r   t h a t   h i d e s   i t !  
                           i f   ( s c w S o u r c e . s t o p P r o p a g a t i o n )   { s c w S o u r c e . s t o p P r o p a g a t i o n ( ) ; }  
                           e l s e                                                       { s c w S o u r c e . c a n c e l B u b b l e   =   t r u e ; }  
                         }  
  
                   s c w T r i g g e r E l e   =   s c w S o u r c e E l e ;  
  
                   / /   T a k e   a n y   p a r a m e t e r s   t h a t   t h e r e   m i g h t   b e   f r o m   t h e   t h i r d   o n w a r d s   a s  
                   / /   d a y   n u m b e r s   t o   b e   d i s a b l e d   0   =   S u n d a y   t h r o u g h   t o   6   =   S a t u r d a y .  
  
                   s c w P a r m A c t i v e T o d a y   =   t r u e ;  
  
                   f o r   ( v a r   i = 0 ; i < 7 ; i + + )  
                         { s c w P a s s E n a b l e d D a y [ ( i + 7 - s c w W e e k S t a r t ) % 7 ]   =   t r u e ;  
                           f o r   ( v a r   j = 2 ; j < a r g u m e n t s . l e n g t h ; j + + )  
                                 { i f   ( a r g u m e n t s [ j ] = = i )  
                                         { s c w P a s s E n a b l e d D a y [ ( i + 7 - s c w W e e k S t a r t ) % 7 ]   =   f a l s e ;  
                                           i f   ( s c w D a t e N o w . g e t D a y ( ) = = i )   { s c w P a r m A c t i v e T o d a y   =   f a l s e ; }  
                                         }  
                                 }  
                         }  
  
                   / /       I f   n o   v a l u e   i s   p r e s e t   t h e n   t h e   s e e d   d a t e   i s  
                   / /             T o d a y   ( w h e n   t o d a y   i s   i n   r a n g e )   O R  
                   / /             T h e   m i d d l e   o f   t h e   d a t e   r a n g e .  
  
                   s c w S e e d D a t e   =   s c w D a t e N o w ;  
  
                   / /   F i n d   t h e   d a t e   a n d   S t r i p   s p a c e   c h a r a c t e r s   f r o m   s t a r t   a n d  
                   / /   e n d   o f   d a t e   i n p u t .  
  
                   v a r   s c w D a t e V a l u e   =   ' ' ;  
  
                   i f   ( s c w E l e . v a l u e )   { s c w D a t e V a l u e   =   s c w E l e . v a l u e . r e p l a c e ( / ^ \ s + / , ' ' ) . r e p l a c e ( / \ s + $ / , ' ' ) ; }  
                   e l s e       { i f   ( t y p e o f   s c w E l e . v a l u e   = =   ' u n d e f i n e d ' )  
                                         { v a r   s c w C h i l d N o d e s   =   s c w E l e . c h i l d N o d e s ;  
                                           f o r   ( v a r   i = 0 ; i < s c w C h i l d N o d e s . l e n g t h ; i + + )  
                                                 { i f   ( s c w C h i l d N o d e s [ i ] . n o d e T y p e   = =   3 )  
                                                         { s c w D a t e V a l u e   =   s c w C h i l d N o d e s [ i ] . n o d e V a l u e . r e p l a c e ( / ^ \ s + / , ' ' ) . r e p l a c e ( / \ s + $ / , ' ' ) ;  
                                                           i f   ( s c w D a t e V a l u e . l e n g t h   >   0 )  
                                                                 { s c w T r i g g e r E l e . s c w T e x t N o d e   =   s c w C h i l d N o d e s [ i ] ;  
                                                                   s c w T r i g g e r E l e . s c w L e n g t h       =   s c w C h i l d N o d e s [ i ] . n o d e V a l u e . l e n g t h ;  
                                                                   b r e a k ;  
                                                                 }  
                                                         }  
                                                 }  
                                         }  
                                 }  
  
                   / /   S e t   t h e   l a n g u a g e - d e p e n d e n t   e l e m e n t s  
  
                   s c w S e t D e f a u l t L a n g u a g e ( ) ;  
  
                   s c w I D ( ' s c w D r a g T e x t ' ) . i n n e r H T M L   =   s c w D r a g ;  
  
                   s c w I D ( ' s c w M o n t h s ' ) . o p t i o n s . l e n g t h   =   0 ;  
                   f o r   ( v a r   i = 0 ; i < s c w A r r M o n t h N a m e s . l e n g t h ; i + + )  
                         { s c w I D ( ' s c w M o n t h s ' ) . o p t i o n s [ i ]   =   n e w   O p t i o n ( s c w A r r M o n t h N a m e s [ i ] , s c w A r r M o n t h N a m e s [ i ] ) ; }  
  
                   s c w I D ( ' s c w Y e a r s ' ) . o p t i o n s . l e n g t h   =   0 ;  
                   f o r   ( v a r   i = 0 ; i < s c w D r o p D o w n Y e a r s ; i + + )  
                         { s c w I D ( ' s c w Y e a r s ' ) . o p t i o n s [ i ]   =     n e w   O p t i o n ( ( s c w B a s e Y e a r + i ) , ( s c w B a s e Y e a r + i ) ) ; }  
  
                   f o r   ( v a r   i = 0 ; i < s c w A r r W e e k I n i t s . l e n g t h ; i + + )  
                         { s c w I D ( ' s c w W e e k I n i t '   +   i ) . i n n e r H T M L   =   s c w A r r W e e k I n i t s [ ( i + s c w W e e k S t a r t ) % s c w A r r W e e k I n i t s . l e n g t h ] ; }  
  
                   i f   ( ( ( n e w   D a t e ( s c w B a s e Y e a r   +   s c w D r o p D o w n Y e a r s ,   0 ,   0 ) )   >   s c w D a t e N o w   & &  
                             ( n e w   D a t e ( s c w B a s e Y e a r ,   0 ,   0 ) )                                         <   s c w D a t e N o w )   | |  
                           ( s c w C l e a r B u t t o n   & &   ( s c w E l e . r e a d O n l y   | |   s c w E l e . d i s a b l e d ) )  
                         )       { s c w I D ( ' s c w F o o t ' ) . s t y l e . d i s p l a y   =   ' ' ;  
                                   s c w I D ( ' s c w N o w ' ) . i n n e r H T M L   =   s c w T o d a y   +   '   '   +   s c w D a t e N o w . s c w F o r m a t ( s c w D a t e D i s p l a y F o r m a t ) ;  
                                   s c w I D ( ' s c w C l e a r B u t t o n ' ) . v a l u e   =   s c w C l e a r ;  
                                   i f   ( ( n e w   D a t e ( s c w B a s e Y e a r   +   s c w D r o p D o w n Y e a r s ,   0 ,   0 ) )   >   s c w D a t e N o w   & &  
                                           ( n e w   D a t e ( s c w B a s e Y e a r ,   0 ,   0 ) )                                         <   s c w D a t e N o w  
                                         )       { s c w I D ( ' s c w N o w ' ) . s t y l e . d i s p l a y   =   ' ' ;  
                                                   i f   ( s c w C l e a r B u t t o n   & &   ( s c w E l e . r e a d O n l y   | |   s c w E l e . d i s a b l e d ) )  
                                                                 { s c w I D ( ' s c w C l e a r ' ) . s t y l e . d i s p l a y       =   ' ' ;  
                                                                   s c w I D ( ' s c w C l e a r ' ) . s t y l e . t e x t A l i g n   =   ' l e f t ' ;  
                                                                   s c w I D ( ' s c w N o w ' ) . s t y l e . t e x t A l i g n       =   ' r i g h t ' ;  
                                                                 }  
                                                   e l s e       { s c w I D ( ' s c w C l e a r ' ) . s t y l e . d i s p l a y   =   ' n o n e ' ;  
                                                                   s c w I D ( ' s c w N o w ' ) . s t y l e . t e x t A l i g n   =   ' c e n t e r ' ;  
                                                                 }  
                                                 }  
                                   e l s e       { s c w I D ( ' s c w C l e a r ' ) . s t y l e . t e x t A l i g n   =   ' c e n t e r ' ;  
                                                   s c w I D ( ' s c w C l e a r ' ) . s t y l e . d i s p l a y   =   ' ' ;  
                                                   s c w I D ( ' s c w N o w ' ) . s t y l e . d i s p l a y   =   ' n o n e ' ;  
                                                 }  
                                 }  
                   e l s e       { s c w I D ( ' s c w F o o t ' ) . s t y l e . d i s p l a y   =   ' n o n e ' ; }  
  
                   i f   ( s c w D a t e V a l u e . l e n g t h = = 0 )  
                         { / /   I f   n o   v a l u e   i s   e n t e r e d   a n d   t o d a y   i s   w i t h i n   t h e   r a n g e ,  
                           / /   u s e   t o d a y ' s   d a t e ,   o t h e r w i s e   u s e   t h e   m i d d l e   o f   t h e   v a l i d   r a n g e .  
  
                           s c w B l n F u l l I n p u t D a t e = f a l s e ;  
  
                           i f   ( ( n e w   D a t e ( s c w B a s e Y e a r + s c w D r o p D o w n Y e a r s , 0 , 0 ) ) < s c w S e e d D a t e   | |  
                                   ( n e w   D a t e ( s c w B a s e Y e a r , 0 , 1 ) )                                   > s c w S e e d D a t e  
                                 )  
                                 { s c w S e e d D a t e   =   n e w   D a t e ( s c w B a s e Y e a r   +   M a t h . f l o o r ( s c w D r o p D o w n Y e a r s   /   2 ) ,   5 ,   1 ) ; }  
                         }  
                   e l s e  
                         { f u n c t i o n   s c w I n p u t F o r m a t ( )  
                                 { v a r   s c w A r r S e e d   =   n e w   A r r a y ( ) ,  
                                           s c w A r r I n p u t   =   s c w D a t e V a l u e . s p l i t ( n e w   R e g E x p ( ' [ \ \ ' + s c w A r r D e l i m i t e r s . j o i n ( ' \ \ ' ) + ' ] + ' , ' g ' ) ) ;  
  
                                   / /   " E s c a p e "   a l l   t h e   u s e r   d e f i n e d   d a t e   d e l i m i t e r s   a b o v e   -  
                                   / /   s e v e r a l   d e l i m i t e r s   w i l l   n e e d   i t   a n d   i t   d o e s   n o   h a r m   f o r  
                                   / /   t h e   o t h e r s .  
  
                                   / /   S t r i p   a n y   e m p t y   a r r a y   e l e m e n t s   ( c a u s e d   b y   d e l i m i t e r s )  
                                   / /   f r o m   t h e   b e g i n n i n g   o r   e n d   o f   t h e   a r r a y .   T h e y   w i l l  
                                   / /   s t i l l   a p p e a r   i n   t h e   o u t p u t   s t r i n g   i f   i n   t h e   o u t p u t  
                                   / /   f o r m a t .  
  
                                   i f   ( s c w A r r I n p u t [ 0 ] ! = n u l l )  
                                         { i f   ( s c w A r r I n p u t [ 0 ] . l e n g t h = = 0 )                                             { s c w A r r I n p u t . s p l i c e ( 0 , 1 ) ; }  
                                           i f   ( s c w A r r I n p u t [ s c w A r r I n p u t . l e n g t h - 1 ] . l e n g t h = = 0 )       { s c w A r r I n p u t . s p l i c e ( s c w A r r I n p u t . l e n g t h - 1 , 1 ) ; }  
                                         }  
  
                                   s c w B l n F u l l I n p u t D a t e   =   f a l s e ;  
  
                                   s c w D a t e O u t p u t F o r m a t   =   s c w D a t e O u t p u t F o r m a t . t o U p p e r C a s e ( ) ;  
  
                                   / /   L i s t   a l l   t h e   a l l o w e d   l e t t e r s   i n   t h e   d a t e   f o r m a t  
                                   v a r   t e m p l a t e   =   [ ' D ' , ' M ' , ' Y ' ] ;  
  
                                   / /   P r e p a r e   t h e   s e q u e n c e   o f   d a t e   i n p u t   e l e m e n t s  
                                   v a r   r e s u l t   =   n e w   A r r a y ( ) ;  
  
                                   f o r   ( v a r   i = 0 ; i < t e m p l a t e . l e n g t h ; i + + )  
                                         { i f   ( s c w D a t e O u t p u t F o r m a t . s e a r c h ( t e m p l a t e [ i ] ) > - 1 )  
                                                 { r e s u l t [ s c w D a t e O u t p u t F o r m a t . s e a r c h ( t e m p l a t e [ i ] ) ]   =   t e m p l a t e [ i ] ; }  
                                         }  
  
                                   v a r   s c w D a t e S e q u e n c e   =   r e s u l t . j o i n ( ' ' ) ;  
  
                                   / /   S e p a r a t e   t h e   e l e m e n t s   o f   t h e   d a t e   i n p u t  
                                   s w i t c h   ( s c w A r r I n p u t . l e n g t h )  
                                         { c a s e   1 :  
                                                 { i f   ( s c w D a t e O u t p u t F o r m a t . i n d e x O f ( ' Y ' ) > - 1   & &  
                                                           s c w A r r I n p u t [ 0 ] . l e n g t h > s c w D a t e O u t p u t F o r m a t . l a s t I n d e x O f ( ' Y ' ) )  
                                                         { s c w A r r S e e d [ 0 ]   =   p a r s e I n t ( s c w A r r I n p u t [ 0 ] . s u b s t r i n g ( s c w D a t e O u t p u t F o r m a t . i n d e x O f ( ' Y ' ) ,  
                                                                                                                                                               s c w D a t e O u t p u t F o r m a t . l a s t I n d e x O f ( ' Y ' ) + 1 ) , 1 0 ) ;  
                                                         }  
                                                   e l s e       { s c w A r r S e e d [ 0 ]   =   0 ; }  
  
                                                   i f   ( s c w D a t e O u t p u t F o r m a t . i n d e x O f ( ' M ' ) > - 1   & &  
                                                           s c w A r r I n p u t [ 0 ] . l e n g t h > s c w D a t e O u t p u t F o r m a t . l a s t I n d e x O f ( ' M ' ) )  
                                                         { s c w A r r S e e d [ 1 ]   =   s c w A r r I n p u t [ 0 ] . s u b s t r i n g ( s c w D a t e O u t p u t F o r m a t . i n d e x O f ( ' M ' ) ,  
                                                                                                                                             s c w D a t e O u t p u t F o r m a t . l a s t I n d e x O f ( ' M ' ) + 1 ) ;  
                                                         }  
                                                   e l s e       { s c w A r r S e e d [ 1 ]   =   ' 6 ' ; }  
  
                                                   i f   ( s c w D a t e O u t p u t F o r m a t . i n d e x O f ( ' D ' ) > - 1   & &  
                                                           s c w A r r I n p u t [ 0 ] . l e n g t h > s c w D a t e O u t p u t F o r m a t . l a s t I n d e x O f ( ' D ' ) )  
                                                         { s c w A r r S e e d [ 2 ]   =   p a r s e I n t ( s c w A r r I n p u t [ 0 ] . s u b s t r i n g ( s c w D a t e O u t p u t F o r m a t . i n d e x O f ( ' D ' ) ,  
                                                                                                                                                               s c w D a t e O u t p u t F o r m a t . l a s t I n d e x O f ( ' D ' ) + 1 ) , 1 0 ) ;  
                                                         }  
                                                   e l s e       { s c w A r r S e e d [ 2 ]   =   1 ; }  
  
                                                   i f   ( s c w A r r I n p u t [ 0 ] . l e n g t h = = s c w D a t e O u t p u t F o r m a t . l e n g t h )   { s c w B l n F u l l I n p u t D a t e   =   t r u e ; }  
                                                   b r e a k ;  
                                                 }  
                                           c a s e   2 :  
                                                 { / /   Y e a r   a n d   M o n t h   e n t r y  
                                                   s c w A r r S e e d [ 0 ]   =  
                                                           p a r s e I n t ( s c w A r r I n p u t [ s c w D a t e S e q u e n c e .  
                                                                                                         r e p l a c e ( / D / i , ' ' ) .  
                                                                                                         s e a r c h ( / Y / i ) ] , 1 0 ) ;     / /   Y e a r  
                                                   s c w A r r S e e d [ 1 ]   =   s c w A r r I n p u t [ s c w D a t e S e q u e n c e .  
                                                                                                         r e p l a c e ( / D / i , ' ' ) .  
                                                                                                         s e a r c h ( / M / i ) ] ;             / /   M o n t h  
                                                   s c w A r r S e e d [ 2 ]   =   1 ;                                                           / /   D a y  
                                                   b r e a k ;  
                                                 }  
                                           c a s e   3 :  
                                                 { / /   D a y   M o n t h   a n d   Y e a r   e n t r y  
  
                                                   s c w A r r S e e d [ 0 ]   =  
                                                           p a r s e I n t ( s c w A r r I n p u t [ s c w D a t e S e q u e n c e .  
                                                                                                         s e a r c h ( / Y / i ) ] , 1 0 ) ;     / /   Y e a r  
                                                   s c w A r r S e e d [ 1 ]   =   s c w A r r I n p u t [ s c w D a t e S e q u e n c e .  
                                                                                                         s e a r c h ( / M / i ) ] ;             / /   M o n t h  
                                                   s c w A r r S e e d [ 2 ]   =  
                                                           p a r s e I n t ( s c w A r r I n p u t [ s c w D a t e S e q u e n c e .  
                                                                                                         s e a r c h ( / D / i ) ] , 1 0 ) ;     / /   D a y  
  
                                                   s c w B l n F u l l I n p u t D a t e   =   t r u e ;  
                                                   b r e a k ;  
                                                 }  
                                           d e f a u l t :  
                                                 { / /   A   s t u f f - u p   h a s   l e d   t o   m o r e   t h a n   t h r e e   e l e m e n t s   i n  
                                                   / /   t h e   d a t e .  
                                                   s c w A r r S e e d [ 0 ]   =   0 ;           / /   Y e a r  
                                                   s c w A r r S e e d [ 1 ]   =   0 ;           / /   M o n t h  
                                                   s c w A r r S e e d [ 2 ]   =   0 ;           / /   D a y  
                                                 }  
                                         }  
  
                                   / /   T h e s e   r e g u l a r   e x p r e s s i o n s   v a l i d a t e   t h e   i n p u t   d a t e   f o r m a t  
                                   / /   t o   t h e   f o l l o w i n g   r u l e s ;  
                                   / /                   D a y       1 - 3 1   ( o p t i o n a l   z e r o   o n   s i n g l e   d i g i t s )  
                                   / /                   M o n t h   1 - 1 2   ( o p t i o n a l   z e r o   o n   s i n g l e   d i g i t s )  
                                   / /                                           o r   c a s e   i n s e n s i t i v e   n a m e  
                                   / /                   Y e a r     O n e ,   T w o   o r   f o u r   d i g i t s  
  
                                   / /   M o n t h s   n a m e s   a r e   a s   s e t   i n   t h e   l a n g u a g e - d e p e n d e n t  
                                   / /   d e f i n i t i o n s   a n d   d e l i m i t e r s   a r e   s e t   j u s t   b e l o w   t h e r e  
  
                                   v a r   s c w E x p V a l D a y         =   n e w   R e g E x p ( ' ^ ( 0 ? [ 1 - 9 ] | [ 1 - 2 ] [ 0 - 9 ] | 3 [ 0 - 1 ] ) $ ' ) ,  
                                           s c w E x p V a l M o n t h     =   n e w   R e g E x p ( ' ^ ( 0 ? [ 1 - 9 ] | 1 [ 0 - 2 ] | '                 +  
                                                                                                     s c w A r r M o n t h N a m e s . j o i n ( ' | ' )   +  
                                                                                                     ' ) $ ' , ' i ' ) ,  
                                           s c w E x p V a l Y e a r       =   n e w   R e g E x p ( ' ^ ( [ 0 - 9 ] { 1 , 2 } | [ 0 - 9 ] { 4 } ) $ ' ) ;  
  
                                   / /   A p p l y   v a l i d a t i o n   a n d   r e p o r t   f a i l u r e s  
  
                                   i f   ( s c w E x p V a l Y e a r . e x e c ( s c w A r r S e e d [ 0 ] )     = =   n u l l   | |  
                                           s c w E x p V a l M o n t h . e x e c ( s c w A r r S e e d [ 1 ] )   = =   n u l l   | |  
                                           s c w E x p V a l D a y . e x e c ( s c w A r r S e e d [ 2 ] )       = =   n u l l  
                                         )  
                                         { i f   ( s c w S h o w I n v a l i d D a t e M s g )  
                                                 { a l e r t ( s c w I n v a l i d D a t e M s g     +  
                                                               s c w I n v a l i d A l e r t [ 0 ]   +   s c w D a t e V a l u e   +  
                                                               s c w I n v a l i d A l e r t [ 1 ] ) ; }  
                                           s c w B l n F u l l I n p u t D a t e   =   f a l s e ;  
                                           s c w A r r S e e d [ 0 ]   =   s c w B a s e Y e a r   +  
                                                                           M a t h . f l o o r ( s c w D r o p D o w n Y e a r s / 2 ) ;   / /   Y e a r  
                                           s c w A r r S e e d [ 1 ]   =   ' 6 ' ;                                                         / /   M o n t h  
                                           s c w A r r S e e d [ 2 ]   =   1 ;                                                             / /   D a y  
                                         }  
  
                                   / /   R e t u r n   t h e     Y e a r         i n   s c w A r r S e e d [ 0 ]  
                                   / /                           M o n t h       i n   s c w A r r S e e d [ 1 ]  
                                   / /                           D a y           i n   s c w A r r S e e d [ 2 ]  
  
                                   r e t u r n   s c w A r r S e e d ;  
                                 } ;  
  
                           / /   P a r s e   t h e   s t r i n g   i n t o   a n   a r r a y   u s i n g   t h e   a l l o w e d   d e l i m i t e r s  
  
                           s c w A r r S e e d D a t e   =   s c w I n p u t F o r m a t ( ) ;  
  
                           / /   S o   n o w   w e   h a v e   t h e   Y e a r ,   M o n t h   a n d   D a y   i n   a n   a r r a y .  
  
                           / /       I f   t h e   y e a r   i s   o n e   o r   t w o   d i g i t s   t h e n   t h e   r o u t i n e   a s s u m e s   a  
                           / /       y e a r   b e l o n g s   i n   t h e   2 1 s t   C e n t u r y   u n l e s s   i t   i s   l e s s   t h a n   5 0  
                           / /       i n   w h i c h   c a s e   i t   a s s u m e s   t h e   2 0 t h   C e n t u r y   i s   i n t e n d e d .  
  
                           i f   ( s c w A r r S e e d D a t e [ 0 ] < 1 0 0 )   { s c w A r r S e e d D a t e [ 0 ]   + =   ( s c w A r r S e e d D a t e [ 0 ] > 5 0 ) ? 1 9 0 0 : 2 0 0 0 ; }  
  
                           / /   C h e c k   w h e t h e r   t h e   m o n t h   i s   i n   d i g i t s   o r   a n   a b b r e v i a t i o n  
  
                           i f   ( s c w A r r S e e d D a t e [ 1 ] . s e a r c h ( / \ d + / ) < 0 )  
                                 { f o r   ( i = 0 ; i < s c w A r r M o n t h N a m e s . l e n g t h ; i + + )  
                                         { i f   ( s c w A r r S e e d D a t e [ 1 ] . t o U p p e r C a s e ( ) = = s c w A r r M o n t h N a m e s [ i ] . t o U p p e r C a s e ( ) )  
                                                 { s c w A r r S e e d D a t e [ 1 ] = i + 1 ;  
                                                   b r e a k ;  
                                                 }  
                                         }  
                                 }  
  
                           s c w S e e d D a t e   =   n e w   D a t e ( s c w A r r S e e d D a t e [ 0 ] , s c w A r r S e e d D a t e [ 1 ] - 1 , s c w A r r S e e d D a t e [ 2 ] ) ;  
                         }  
  
                   / /   T e s t   t h a t   w e   h a v e   a r r i v e d   a t   a   v a l i d   d a t e  
  
                   i f   ( i s N a N ( s c w S e e d D a t e ) )  
                         { i f   ( s c w S h o w I n v a l i d D a t e M s g )   { a l e r t ( s c w I n v a l i d D a t e M s g   +   s c w I n v a l i d A l e r t [ 0 ]   +   s c w D a t e V a l u e   +   s c w I n v a l i d A l e r t [ 1 ] ) ; }  
                           s c w S e e d D a t e   =   n e w   D a t e ( s c w B a s e Y e a r   +   M a t h . f l o o r ( s c w D r o p D o w n Y e a r s / 2 ) , 5 , 1 ) ;  
                           s c w B l n F u l l I n p u t D a t e = f a l s e ;  
                         }  
                   e l s e  
                         { / /   T e s t   t h a t   t h e   d a t e   i s   w i t h i n   r a n g e ,  
                           / /   i f   n o t   t h e n   s e t   d a t e   t o   a   s e n s i b l e   d a t e   i n   r a n g e .  
  
                           i f   ( ( n e w   D a t e ( s c w B a s e Y e a r , 0 , 1 ) )   >   s c w S e e d D a t e )  
                                 { i f   ( s c w B l n S t r i c t   & &   s c w S h o w O u t O f R a n g e M s g )   { a l e r t ( s c w O u t O f R a n g e M s g ) ; }  
                                   s c w S e e d D a t e   =   n e w   D a t e ( s c w B a s e Y e a r , 0 , 1 ) ;  
                                   s c w B l n F u l l I n p u t D a t e = f a l s e ;  
                                 }  
                           e l s e  
                                 { i f   ( ( n e w   D a t e ( s c w B a s e Y e a r + s c w D r o p D o w n Y e a r s , 0 , 0 ) ) < s c w S e e d D a t e )  
                                         { i f   ( s c w B l n S t r i c t   & &   s c w S h o w O u t O f R a n g e M s g )   { a l e r t ( s c w O u t O f R a n g e M s g ) ; }  
                                           s c w S e e d D a t e   =   n e w   D a t e ( s c w B a s e Y e a r   +   M a t h . f l o o r ( s c w D r o p D o w n Y e a r s ) - 1 , 1 1 , 1 ) ;  
                                           s c w B l n F u l l I n p u t D a t e = f a l s e ;  
                                         }  
                                   e l s e  
                                         { i f   ( s c w B l n S t r i c t   & &   s c w B l n F u l l I n p u t D a t e   & &  
                                                     ( s c w S e e d D a t e . g e t D a t e ( )             ! =   s c w A r r S e e d D a t e [ 2 ]   | |  
                                                       ( s c w S e e d D a t e . g e t M o n t h ( ) + 1 )   ! =   s c w A r r S e e d D a t e [ 1 ]   | |  
                                                       s c w S e e d D a t e . g e t F u l l Y e a r ( )     ! =   s c w A r r S e e d D a t e [ 0 ]  
                                                     )  
                                                 )  
                                                 { i f   ( s c w S h o w D o e s N o t E x i s t M s g )   a l e r t ( s c w D o e s N o t E x i s t M s g ) ;  
                                                   s c w S e e d D a t e   =   n e w   D a t e ( s c w S e e d D a t e . g e t F u l l Y e a r ( ) , s c w S e e d D a t e . g e t M o n t h ( ) - 1 , 1 ) ;  
                                                   s c w B l n F u l l I n p u t D a t e = f a l s e ;  
                                                 }  
                                         }  
                                 }  
                         }  
  
                   / /   T e s t   t h e   d i s a b l e d   d a t e s   f o r   v a l i d i t y  
                   / /   G i v e   e r r o r   m e s s a g e   i f   n o t   v a l i d .  
  
                   f o r   ( v a r   i = 0 ; i < s c w D i s a b l e d D a t e s . l e n g t h ; i + + )  
                         { i f   ( ! ( ( t y p e o f   s c w D i s a b l e d D a t e s [ i ]   = =   ' o b j e c t ' )   & &   ( s c w D i s a b l e d D a t e s [ i ] . c o n s t r u c t o r   = =   D a t e ) ) )  
                                 { i f   ( ( t y p e o f   s c w D i s a b l e d D a t e s [ i ]   = =   ' o b j e c t ' )   & &   ( s c w D i s a b l e d D a t e s [ i ] . c o n s t r u c t o r   = =   A r r a y ) )  
                                         { v a r   s c w P a s s   =   t r u e ;  
  
                                           i f   ( s c w D i s a b l e d D a t e s [ i ] . l e n g t h   ! = 2 )  
                                                 { i f   ( s c w S h o w R a n g e D i s a b l i n g E r r o r )  
                                                         { a l e r t ( s c w R a n g e D i s a b l i n g E r r o r [ 0 ]   +   s c w D i s a b l e d D a t e s [ i ]   +   s c w R a n g e D i s a b l i n g E r r o r [ 1 ] ) ; }  
                                                   s c w P a s s   =   f a l s e ;  
                                                 }  
                                           e l s e  
                                                 { f o r   ( v a r   j = 0 ; j < s c w D i s a b l e d D a t e s [ i ] . l e n g t h ; j + + )  
                                                         { i f   ( ! ( ( t y p e o f   s c w D i s a b l e d D a t e s [ i ] [ j ]   = =   ' o b j e c t ' )   & &   ( s c w D i s a b l e d D a t e s [ i ] [ j ] . c o n s t r u c t o r   = =   D a t e ) ) )  
                                                                 { i f   ( s c w S h o w R a n g e D i s a b l i n g E r r o r )  
                                                                         { a l e r t (     s c w D a t e D i s a b l i n g E r r o r [ 0 ]   +   s c w D i s a b l e d D a t e s [ i ] [ j ]   +   s c w D a t e D i s a b l i n g E r r o r [ 1 ] ) ; }  
                                                                   s c w P a s s   =   f a l s e ;  
                                                                 }  
                                                         }  
                                                 }  
  
                                           i f   ( s c w P a s s   & &   ( s c w D i s a b l e d D a t e s [ i ] [ 0 ]   >   s c w D i s a b l e d D a t e s [ i ] [ 1 ] ) )   { s c w D i s a b l e d D a t e s [ i ] . r e v e r s e ( ) ; }  
                                         }  
                                   e l s e  
                                         { i f   ( s c w S h o w R a n g e D i s a b l i n g E r r o r )   { a l e r t ( s c w D a t e D i s a b l i n g E r r o r [ 0 ]   +   s c w D i s a b l e d D a t e s [ i ]   +   s c w D a t e D i s a b l i n g E r r o r [ 1 ] ) ; } }  
                                 }  
                         }  
  
                   / /   C a l c u l a t e   t h e   n u m b e r   o f   m o n t h s   t h a t   t h e   e n t e r e d   ( o r  
                   / /   d e f a u l t e d )   m o n t h   i s   a f t e r   t h e   s t a r t   o f   t h e   a l l o w e d  
                   / /   d a t e   r a n g e .  
  
                   s c w M o n t h S u m   =     1 2 * ( s c w S e e d D a t e . g e t F u l l Y e a r ( ) - s c w B a s e Y e a r ) + s c w S e e d D a t e . g e t M o n t h ( ) ;  
  
                   s c w I D ( ' s c w Y e a r s '   ) . o p t i o n s . s e l e c t e d I n d e x   =   M a t h . f l o o r ( s c w M o n t h S u m / 1 2 ) ;  
                   s c w I D ( ' s c w M o n t h s ' ) . o p t i o n s . s e l e c t e d I n d e x   =   ( s c w M o n t h S u m % 1 2 ) ;  
  
                   / /   C h e c k   w h e t h e r   o r   n o t   d r a g g i n g   i s   a l l o w e d   a n d   d i s p l a y   d r a g   h a n d l e   i f   n e c e s s a r y  
  
                   s c w I D ( ' s c w D r a g ' ) . s t y l e . d i s p l a y = ( s c w A l l o w D r a g ) ? ' ' : ' n o n e ' ;  
  
                   / /   D i s p l a y   t h e   m o n t h  
  
                   s c w S h o w M o n t h ( 0 ) ;  
  
                   / /   P o s i t i o n   t h e   c a l e n d a r   b o x  
  
                   / /   T h e   o b j e c t   s n i f f i n g   f o r   O p e r a   a l l o w s   f o r   t h e   f a c t   t h a t   O p e r a  
                   / /   i s   t h e   o n l y   m a j o r   b r o w s e r   t h a t   c o r r e c t l y   r e p o r t s   t h e   p o s i t i o n  
                   / /   o f   a n   e l e m e n t   i n   a   s c r o l l a b l e   D I V .     T h i s   i s   b e c a u s e   I E   a n d  
                   / /   F i r e f o x   o m i t   t h e   D I V   f r o m   t h e   o f f s e t P a r e n t   t r e e .  
  
                   s c w T a r g e t E l e = s c w E l e ;  
  
                   v a r   o f f s e t T o p   = p a r s e I n t ( s c w E l e . o f f s e t T o p   , 1 0 )   +   p a r s e I n t ( s c w E l e . o f f s e t H e i g h t , 1 0 ) ,  
                           o f f s e t L e f t = p a r s e I n t ( s c w E l e . o f f s e t L e f t , 1 0 ) ;  
  
                   i f   ( ! w i n d o w . o p e r a )  
                           { w h i l e   ( s c w E l e . t a g N a m e ! = ' B O D Y '   & &   s c w E l e . t a g N a m e ! = ' H T M L ' )  
                                   { o f f s e t T o p   - = p a r s e I n t ( s c w E l e . s c r o l l T o p ,   1 0 ) ;  
                                     o f f s e t L e f t - = p a r s e I n t ( s c w E l e . s c r o l l L e f t , 1 0 ) ;  
                                     s c w E l e = s c w E l e . p a r e n t N o d e ;  
                                   }  
                             s c w E l e = s c w T a r g e t E l e ;  
                           }  
  
                   d o   { s c w E l e = s c w E l e . o f f s e t P a r e n t ;  
                           o f f s e t T o p   + = p a r s e I n t ( s c w E l e . o f f s e t T o p ,   1 0 ) ;  
                           o f f s e t L e f t + = p a r s e I n t ( s c w E l e . o f f s e t L e f t , 1 0 ) ;  
                         }  
                   w h i l e   ( s c w E l e . t a g N a m e ! = ' B O D Y '   & &   s c w E l e . t a g N a m e ! = ' H T M L ' ) ;  
  
                   i f   ( s c w A u t o P o s i t i o n )  
                           { v a r   s c w W i d t h             =   p a r s e I n t ( s c w I D ( ' s c w ' ) . o f f s e t W i d t h ,   1 0 ) ,  
                                     s c w H e i g h t           =   p a r s e I n t ( s c w I D ( ' s c w ' ) . o f f s e t H e i g h t , 1 0 ) ,  
                                     s c w W i n d o w L e f t   =  
                                           ( d o c u m e n t . b o d y   & &   d o c u m e n t . b o d y . s c r o l l L e f t )  
                                                     ? d o c u m e n t . b o d y . s c r o l l L e f t                                     / / D O M   c o m p l i a n t  
                                                     : ( d o c u m e n t . d o c u m e n t E l e m e n t   & &   d o c u m e n t . d o c u m e n t E l e m e n t . s c r o l l L e f t )  
                                                             ? d o c u m e n t . d o c u m e n t E l e m e n t . s c r o l l L e f t       / / I E 6 +   s t a n d a r d s   c o m p l i a n t  
                                                             : 0 ,                                                                         / / F a i l e d  
                                     s c w W i n d o w W i d t h   =  
                                             ( t y p e o f ( i n n e r W i d t h )   = =   ' n u m b e r ' )  
                                                     ? i n n e r W i d t h                                                                 / / D O M   c o m p l i a n t  
                                                     : ( d o c u m e n t . d o c u m e n t E l e m e n t   & &   d o c u m e n t . d o c u m e n t E l e m e n t . c l i e n t W i d t h )  
                                                             ? d o c u m e n t . d o c u m e n t E l e m e n t . c l i e n t W i d t h     / / I E 6 +   s t a n d a r d s   c o m p l i a n t  
                                                             : ( d o c u m e n t . b o d y   & &   d o c u m e n t . b o d y . c l i e n t W i d t h )  
                                                                     ? d o c u m e n t . b o d y . c l i e n t W i d t h                   / / I E   n o n - c o m p l i a n t  
                                                                     : 0 ,                                                                 / / F a i l e d  
                                     s c w W i n d o w T o p   =  
                                             ( d o c u m e n t . b o d y   & &   d o c u m e n t . b o d y . s c r o l l T o p )  
                                                     ? d o c u m e n t . b o d y . s c r o l l T o p                                       / / D O M   c o m p l i a n t  
                                                     : ( d o c u m e n t . d o c u m e n t E l e m e n t   & &   d o c u m e n t . d o c u m e n t E l e m e n t . s c r o l l T o p )  
                                                             ? d o c u m e n t . d o c u m e n t E l e m e n t . s c r o l l T o p         / / I E 6 +   s t a n d a r d s   c o m p l i a n t  
                                                             : 0 ,                                                                         / / F a i l e d  
                                     s c w W i n d o w H e i g h t   =  
                                             ( t y p e o f ( i n n e r H e i g h t )   = =   ' n u m b e r ' )  
                                                     ? i n n e r H e i g h t                                                               / / D O M   c o m p l i a n t  
                                                     : ( d o c u m e n t . d o c u m e n t E l e m e n t   & &   d o c u m e n t . d o c u m e n t E l e m e n t . c l i e n t H e i g h t )  
                                                             ? d o c u m e n t . d o c u m e n t E l e m e n t . c l i e n t H e i g h t   / / I E 6 +   s t a n d a r d s   c o m p l i a n t  
                                                             : ( d o c u m e n t . b o d y   & &   d o c u m e n t . b o d y . c l i e n t H e i g h t )  
                                                                     ? d o c u m e n t . b o d y . c l i e n t H e i g h t                 / / I E   n o n - c o m p l i a n t  
                                                                     : 0 ;                                                                 / / F a i l e d  
  
                             o f f s e t L e f t   - =   ( o f f s e t L e f t   -   s c w W i d t h   +   p a r s e I n t ( s c w T a r g e t E l e . o f f s e t W i d t h , 1 0 )   > =   s c w W i n d o w L e f t   & &  
                                                           o f f s e t L e f t   +   s c w W i d t h   >   s c w W i n d o w L e f t   +   s c w W i n d o w W i d t h  
                                                         ) ? ( s c w W i d t h   -   p a r s e I n t ( s c w T a r g e t E l e . o f f s e t W i d t h , 1 0 ) ) : 0 ;  
  
                             o f f s e t T o p   - =   ( o f f s e t T o p   -   s c w H e i g h t   -   p a r s e I n t ( s c w T a r g e t E l e . o f f s e t H e i g h t , 1 0 )   > =   s c w W i n d o w T o p   & &  
                                                         o f f s e t T o p   +   s c w H e i g h t   >   s c w W i n d o w T o p   +   s c w W i n d o w H e i g h t  
                                                       ) ? ( s c w H e i g h t   +   p a r s e I n t ( s c w T a r g e t E l e . o f f s e t H e i g h t , 1 0 ) ) : 0 ;  
                           }  
  
                   s c w I D ( ' s c w ' ) . s t y l e . t o p                   =   o f f s e t T o p + ' p x ' ;  
                   s c w I D ( ' s c w ' ) . s t y l e . l e f t                 =   o f f s e t L e f t + ' p x ' ;  
                   s c w I D ( ' s c w I f r a m e ' ) . s t y l e . t o p       =   o f f s e t T o p + ' p x ' ;  
                   s c w I D ( ' s c w I f r a m e ' ) . s t y l e . l e f t     =   o f f s e t L e f t + ' p x ' ;  
  
                   s c w I D ( ' s c w I f r a m e ' ) . s t y l e . w i d t h   = ( s c w I D ( ' s c w ' ) . o f f s e t W i d t h - ( s c w I D ( ' s c w I E ' ) ? 2 : 4 ) ) + ' p x ' ;  
                   s c w I D ( ' s c w I f r a m e ' ) . s t y l e . h e i g h t = ( s c w I D ( ' s c w ' ) . o f f s e t H e i g h t - ( s c w I D ( ' s c w I E ' ) ? 2 : 4 ) ) + ' p x ' ;  
                   s c w I D ( ' s c w I f r a m e ' ) . s t y l e . v i s i b i l i t y = ' i n h e r i t ' ;  
  
                   / /   S h o w   i t   o n   t h e   p a g e  
                   s c w I D ( ' s c w ' ) . s t y l e . v i s i b i l i t y = ' i n h e r i t ' ;  
                 } ;  
  
         f u n c t i o n   s c w H i d e ( )  
                 { s c w I D ( ' s c w ' ) . s t y l e . v i s i b i l i t y = ' h i d d e n ' ;  
                   s c w I D ( ' s c w I f r a m e ' ) . s t y l e . v i s i b i l i t y = ' h i d d e n ' ;  
                   i f   ( t y p e o f   s c w N e x t A c t i o n ! = ' u n d e f i n e d '   & &   s c w N e x t A c t i o n ! = n u l l )  
                           { s c w N e x t A c t i o n R e t u r n   =   s c w N e x t A c t i o n ( ) ;  
                             / /   E x p l i c i t   n u l l   s e t   t o   p r e v e n t   c l o s u r e   c a u s i n g   m e m o r y   l e a k  
                             s c w N e x t A c t i o n   =   n u l l ;  
                           }  
                 } ;  
  
         f u n c t i o n   s c w C a n c e l ( s c w E v t )  
                 { i f   ( s c w C l i c k T o H i d e )   { s c w H i d e ( ) ; }  
                   s c w S t o p P r o p a g a t i o n ( s c w E v t ) ;  
                 } ;  
  
         f u n c t i o n   s c w S t o p P r o p a g a t i o n ( s c w E v t )  
                 { i f   ( s c w E v t . s t o p P r o p a g a t i o n )  
                                 { s c w E v t . s t o p P r o p a g a t i o n ( ) ; }           / /   C a p t u r e   p h a s e  
                   e l s e       { s c w E v t . c a n c e l B u b b l e   =   t r u e ; }       / /   B u b b l i n g   p h a s e  
                 } ;  
  
         f u n c t i o n   s c w B e g i n D r a g ( e v e n t )  
                 { v a r   e l e m e n t T o D r a g   =   s c w I D ( ' s c w ' ) ;  
  
                   v a r   d e l t a X         =   e v e n t . c l i e n t X ,  
                           d e l t a Y         =   e v e n t . c l i e n t Y ,  
                           o f f s e t E l e   =   e l e m e n t T o D r a g ;  
  
                   d o   { d e l t a X       - =   p a r s e I n t ( o f f s e t E l e . o f f s e t L e f t , 1 0 ) ;  
                           d e l t a Y       - =   p a r s e I n t ( o f f s e t E l e . o f f s e t T o p   , 1 0 ) ;  
                           o f f s e t E l e   =   o f f s e t E l e . o f f s e t P a r e n t ;  
                         }  
                   w h i l e   ( o f f s e t E l e . t a g N a m e ! = ' B O D Y '   & &  
                                 o f f s e t E l e . t a g N a m e ! = ' H T M L ' ) ;  
  
                   i f   ( d o c u m e n t . a d d E v e n t L i s t e n e r )  
                                 { d o c u m e n t . a d d E v e n t L i s t e n e r ( ' m o u s e m o v e ' , m o v e H a n d l e r , t r u e ) ;                 / /   C a p t u r e   p h a s e  
                                   d o c u m e n t . a d d E v e n t L i s t e n e r ( ' m o u s e u p ' ,     u p H a n d l e r ,     t r u e ) ;                 / /   C a p t u r e   p h a s e  
                                 }  
                   e l s e       { e l e m e n t T o D r a g . a t t a c h E v e n t ( ' o n m o u s e m o v e ' , m o v e H a n d l e r ) ;   / /   B u b b l i n g   p h a s e  
                                   e l e m e n t T o D r a g . a t t a c h E v e n t ( ' o n m o u s e u p ' ,     u p H a n d l e r ) ;       / /   B u b b l i n g   p h a s e  
                                   e l e m e n t T o D r a g . s e t C a p t u r e ( ) ;  
                                 }  
  
                   s c w S t o p P r o p a g a t i o n ( e v e n t ) ;  
  
                   f u n c t i o n   m o v e H a n d l e r ( s c w E v t )  
                         { i f   ( ! s c w E v t )   s c w E v t   =   w i n d o w . e v e n t ;  
  
                           e l e m e n t T o D r a g . s t y l e . l e f t   =   ( s c w E v t . c l i e n t X   -   d e l t a X )   +   ' p x ' ;  
                           e l e m e n t T o D r a g . s t y l e . t o p     =   ( s c w E v t . c l i e n t Y   -   d e l t a Y )   +   ' p x ' ;  
  
                           s c w I D ( ' s c w I f r a m e ' ) . s t y l e . l e f t   =   ( s c w E v t . c l i e n t X   -   d e l t a X )   +   ' p x ' ;  
                           s c w I D ( ' s c w I f r a m e ' ) . s t y l e . t o p     =   ( s c w E v t . c l i e n t Y   -   d e l t a Y )   +   ' p x ' ;  
  
                           s c w S t o p P r o p a g a t i o n ( s c w E v t ) ;  
                         } ;  
  
                   f u n c t i o n   u p H a n d l e r ( s c w E v t )  
                         { i f   ( ! s c w E v t )   s c w E v t   =   w i n d o w . e v e n t ;  
  
                           i f   ( d o c u m e n t . r e m o v e E v e n t L i s t e n e r )  
                                         { d o c u m e n t . r e m o v e E v e n t L i s t e n e r ( ' m o u s e m o v e ' , m o v e H a n d l e r , t r u e ) ;           / /   C a p t u r e   p h a s e  
                                           d o c u m e n t . r e m o v e E v e n t L i s t e n e r ( ' m o u s e u p ' ,     u p H a n d l e r ,     t r u e ) ;           / /   C a p t u r e   p h a s e  
                                         }  
                           e l s e       { e l e m e n t T o D r a g . d e t a c h E v e n t ( ' o n m o u s e u p ' ,     u p H a n d l e r ) ;       / /   B u b b l i n g   p h a s e  
                                           e l e m e n t T o D r a g . d e t a c h E v e n t ( ' o n m o u s e m o v e ' , m o v e H a n d l e r ) ;   / /   B u b b l i n g   p h a s e  
                                           e l e m e n t T o D r a g . r e l e a s e C a p t u r e ( ) ;  
                                         }  
  
                           s c w S t o p P r o p a g a t i o n ( s c w E v t ) ;  
                         } ;  
                 } ;  
  
         f u n c t i o n   s c w S h o w M o n t h ( s c w B i a s )  
                 { / /   S e t   t h e   s e l e c t a b l e   M o n t h   a n d   Y e a r  
                   / /   M a y   b e   c a l l e d :   f r o m   t h e   l e f t   a n d   r i g h t   a r r o w s  
                   / /                                     ( s h i f t   m o n t h   - 1   a n d   + 1   r e s p e c t i v e l y )  
                   / /                                 f r o m   t h e   m o n t h   s e l e c t i o n   l i s t  
                   / /                                 f r o m   t h e   y e a r   s e l e c t i o n   l i s t  
                   / /                                 f r o m   t h e   s h o w C a l   r o u t i n e  
                   / /                                     ( w h i c h   i n i t i a t e s   t h e   d i s p l a y ) .  
  
                   v a r   s c w S h o w D a t e     =   n e w   D a t e ( D a t e . p a r s e ( n e w   D a t e ( ) . t o D a t e S t r i n g ( ) ) ) ,  
                           s c w S t a r t D a t e   =   n e w   D a t e ( ) ;  
  
                   / /   S e t   t h e   t i m e   t o   t h e   m i d d l e   o f   t h e   d a y   s o   t h a t   t h e   h a n d f u l   o f  
                   / /   r e g i o n s   t h a t   h a v e   d a y l i g h t   s a v i n g   s h i f t s   t h a t   c h a n g e   t h e   d a y  
                   / /   o f   t h e   m o n t h   ( i . e .   t u r n   t h e   c l o c k   b a c k   a t   m i d n i g h t   o r   f o r w a r d  
                   / /   a t   2 3 : 0 0 )   d o   n o t   m e s s   u p   t h e   d a t e   d i s p l a y   i n   t h e   c a l e n d a r .  
  
                   s c w S h o w D a t e . s e t H o u r s ( 1 2 ) ;  
  
                   s c w S e l Y e a r s     =   s c w I D ( ' s c w Y e a r s ' ) ;  
                   s c w S e l M o n t h s   =   s c w I D ( ' s c w M o n t h s ' ) ;  
  
                   i f   ( s c w S e l Y e a r s . o p t i o n s . s e l e c t e d I n d e x > - 1 )  
                         { s c w M o n t h S u m = 1 2 * ( s c w S e l Y e a r s . o p t i o n s . s e l e c t e d I n d e x ) + s c w B i a s ;  
                           i f   ( s c w S e l M o n t h s . o p t i o n s . s e l e c t e d I n d e x > - 1 )   { s c w M o n t h S u m + = s c w S e l M o n t h s . o p t i o n s . s e l e c t e d I n d e x ; }  
                         }  
                   e l s e  
                         { i f   ( s c w S e l M o n t h s . o p t i o n s . s e l e c t e d I n d e x > - 1 )   { s c w M o n t h S u m + = s c w S e l M o n t h s . o p t i o n s . s e l e c t e d I n d e x ; } }  
  
                   s c w S h o w D a t e . s e t F u l l Y e a r ( s c w B a s e Y e a r   +   M a t h . f l o o r ( s c w M o n t h S u m / 1 2 ) , ( s c w M o n t h S u m % 1 2 ) , 1 ) ;  
  
                   / /   I f   t h e   W e e k   n u m b e r s   a r e   d i s p l a y e d ,   s h i f t   t h e   w e e k   d a y   n a m e s   t o   t h e   r i g h t .  
                   s c w I D ( ' s c w W e e k _ ' ) . s t y l e . d i s p l a y = ( s c w W e e k N u m b e r D i s p l a y ) ? ' ' : ' n o n e ' ;  
  
                   / /   O p e r a   h a s   a   b u g   w i t h   s e t t i n g   t h e   s e l e c t e d   i n d e x .  
                   / /   I t   r e q u i r e s   t h e   f o l l o w i n g   w o r k - a r o u n d   t o   f o r c e   S E L E C T s   t o   d i s p l a y   c o r r e c t l y .  
                   i f   ( w i n d o w . o p e r a )  
                         { s c w I D ( ' s c w M o n t h s ' ) . s t y l e . d i s p l a y   =   ' i n h e r i t ' ;  
                           s c w I D ( ' s c w Y e a r s '   ) . s t y l e . d i s p l a y   =   ' i n h e r i t ' ;  
                       }  
  
                   / /   S e t   t h e   d r o p   d o w n   b o x e s .  
                   s c w T e m p   =   ( 1 2 * p a r s e I n t ( ( s c w S h o w D a t e . g e t F u l l Y e a r ( ) - s c w B a s e Y e a r ) , 1 0 ) )   +   p a r s e I n t ( s c w S h o w D a t e . g e t M o n t h ( ) , 1 0 ) ;  
  
                   i f   ( s c w T e m p   >   - 1   & &   s c w T e m p   <   ( 1 2 * s c w D r o p D o w n Y e a r s ) )  
                         { s c w S e l Y e a r s . o p t i o n s . s e l e c t e d I n d e x = M a t h . f l o o r ( s c w M o n t h S u m / 1 2 ) ;  
                           s c w S e l M o n t h s . o p t i o n s . s e l e c t e d I n d e x = ( s c w M o n t h S u m % 1 2 ) ;  
  
                           s c w C u r M o n t h   =   s c w S h o w D a t e . g e t M o n t h ( ) ;  
  
                           s c w S h o w D a t e . s e t D a t e ( ( ( ( s c w S h o w D a t e .  
                                                                         g e t D a y ( ) - s c w W e e k S t a r t ) < 0 ) ? - 6 : 1 ) +  
                                                                   s c w W e e k S t a r t - s c w S h o w D a t e . g e t D a y ( ) ) ;  
  
                           / /   T h i s   s t a t e m e n t   m o v e d   b y   M i c h a e l   C e r v e n y   t o   m a k e   v e r s i o n   3 . 5 5  
                           v a r   s c w C o m p a r e D a t e V a l u e   =   n e w   D a t e ( s c w S h o w D a t e . g e t F u l l Y e a r ( ) ,  
                                                                                                 s c w S h o w D a t e . g e t M o n t h ( ) ,  
                                                                                                 s c w S h o w D a t e . g e t D a t e ( ) ) . v a l u e O f ( ) ;  
  
                           s c w S t a r t D a t e   =   n e w   D a t e ( s c w S h o w D a t e ) ;  
  
                           i f   ( ( n e w   D a t e ( s c w B a s e Y e a r   +   s c w D r o p D o w n Y e a r s ,   0 ,   0 ) )   >   s c w D a t e N o w   & &  
                                   ( n e w   D a t e ( s c w B a s e Y e a r ,   0 ,   0 ) )                                         <   s c w D a t e N o w )  
                                 { v a r   s c w N o w   =   s c w I D ( ' s c w N o w ' ) ;  
  
                                   f u n c t i o n   s c w N o w O u t p u t ( )   { s c w S e t O u t p u t ( s c w D a t e N o w ) ; } ;  
  
                                   i f   ( s c w D i s a b l e d D a t e s . l e n g t h = = 0 )  
                                         { i f   ( s c w A c t i v e T o d a y   & &   s c w P a r m A c t i v e T o d a y )  
                                                 { s c w N o w . o n c l i c k           =   s c w N o w O u t p u t ;  
                                                   s c w N o w . c l a s s N a m e       =   ' s c w N o w ' ;  
  
                                                   i f   ( s c w I D ( ' s c w I E ' ) )  
                                                         { s c w N o w . o n m o u s e o v e r     =   s c w C h a n g e C l a s s ;  
                                                           s c w N o w . o n m o u s e o u t       =   s c w C h a n g e C l a s s ;  
                                                         }  
  
                                                 }  
                                           e l s e  
                                                 { s c w N o w . o n c l i c k           =   n u l l ;  
                                                   s c w N o w . c l a s s N a m e       =   ' s c w N o w D i s a b l e d ' ;  
  
                                                   i f   ( s c w I D ( ' s c w I E ' ) )  
                                                         { s c w N o w . o n m o u s e o v e r     =   n u l l ;  
                                                           s c w N o w . o n m o u s e o u t       =   n u l l ;  
                                                         }  
  
                                                   i f   ( d o c u m e n t . a d d E v e n t L i s t e n e r )  
                                                                 { s c w N o w . a d d E v e n t L i s t e n e r ( ' c l i c k ' , s c w S t o p P r o p a g a t i o n , f a l s e ) ; }  
                                                   e l s e       { s c w N o w . a t t a c h E v e n t ( ' o n c l i c k ' , s c w S t o p P r o p a g a t i o n ) ; }  
                                                 }  
                                         }  
                                   e l s e  
                                         { f o r   ( v a r   k = 0 ; k < s c w D i s a b l e d D a t e s . l e n g t h ; k + + )  
                                                 { i f   ( ! s c w A c t i v e T o d a y   | |   ! s c w P a r m A c t i v e T o d a y   | |  
                                                           ( ( t y p e o f   s c w D i s a b l e d D a t e s [ k ]   = =   ' o b j e c t ' )                                       & &  
                                                                   ( ( ( s c w D i s a b l e d D a t e s [ k ] . c o n s t r u c t o r   = =   D a t e )                           & &  
                                                                       s c w D a t e N o w . v a l u e O f ( )   = =   s c w D i s a b l e d D a t e s [ k ] . v a l u e O f ( )  
                                                                     )   | |  
                                                                     ( ( s c w D i s a b l e d D a t e s [ k ] . c o n s t r u c t o r   = =   A r r a y )                               & &  
                                                                       s c w D a t e N o w . v a l u e O f ( )   > =   s c w D i s a b l e d D a t e s [ k ] [ 0 ] . v a l u e O f ( )   & &  
                                                                       s c w D a t e N o w . v a l u e O f ( )   < =   s c w D i s a b l e d D a t e s [ k ] [ 1 ] . v a l u e O f ( )  
                                                                     )  
                                                                   )  
                                                           )  
                                                         )  
                                                         { s c w N o w . o n c l i c k           =   n u l l ;  
                                                           s c w N o w . c l a s s N a m e       =   ' s c w N o w D i s a b l e d ' ;  
  
                                                           i f   ( s c w I D ( ' s c w I E ' ) )  
                                                                 { s c w N o w . o n m o u s e o v e r     =   n u l l ;  
                                                                   s c w N o w . o n m o u s e o u t       =   n u l l ;  
                                                                 }  
  
                                                           i f   ( d o c u m e n t . a d d E v e n t L i s t e n e r )  
                                                                         { s c w N o w . a d d E v e n t L i s t e n e r ( ' c l i c k ' , s c w S t o p P r o p a g a t i o n , f a l s e ) ; }  
                                                           e l s e       { s c w N o w . a t t a c h E v e n t ( ' o n c l i c k ' , s c w S t o p P r o p a g a t i o n ) ; }  
                                                           b r e a k ;  
                                                         }  
                                                   e l s e  
                                                         { s c w N o w . o n c l i c k = s c w N o w O u t p u t ;  
                                                           s c w N o w . c l a s s N a m e = ' s c w N o w ' ;  
  
                                                           i f   ( s c w I D ( ' s c w I E ' ) )  
                                                                 { s c w N o w . o n m o u s e o v e r     =   s c w C h a n g e C l a s s ;  
                                                                   s c w N o w . o n m o u s e o u t       =   s c w C h a n g e C l a s s ;  
                                                                 }  
                                                         }  
                                                 }  
                                         }  
                                 }  
  
                           f u n c t i o n   s c w S e t O u t p u t ( s c w O u t p u t D a t e )  
                                 { i f   ( t y p e o f   s c w T a r g e t E l e . v a l u e   = =   ' u n d e f i n e d ' )  
                                             { s c w T r i g g e r E l e . s c w T e x t N o d e . r e p l a c e D a t a ( 0 , s c w T r i g g e r E l e . s c w L e n g t h , s c w O u t p u t D a t e . s c w F o r m a t ( s c w D a t e O u t p u t F o r m a t ) ) ; }  
                                   e l s e   { s c w T a r g e t E l e . v a l u e   =   s c w O u t p u t D a t e . s c w F o r m a t ( s c w D a t e O u t p u t F o r m a t ) ; }  
                                   s c w H i d e ( ) ;  
                                 } ;  
  
                           f u n c t i o n   s c w C e l l O u t p u t ( s c w E v t )  
                                 { v a r   s c w E l e   =   s c w E v e n t T r i g g e r ( s c w E v t ) ,  
                                           s c w O u t p u t D a t e   =   n e w   D a t e ( s c w S t a r t D a t e ) ;  
  
                                   i f   ( s c w E l e . n o d e T y p e = = 3 )   s c w E l e = s c w E l e . p a r e n t N o d e ;  
  
                                   s c w O u t p u t D a t e . s e t D a t e ( s c w S t a r t D a t e . g e t D a t e ( )   +   p a r s e I n t ( s c w E l e . i d . s u b s t r ( 8 ) , 1 0 ) ) ;  
  
                                   s c w S e t O u t p u t ( s c w O u t p u t D a t e ) ;  
                                 } ;  
  
                           f u n c t i o n   s c w C h a n g e C l a s s ( s c w E v t )  
                                 { v a r   s c w E l e   =   s c w E v e n t T r i g g e r ( s c w E v t ) ;  
  
                                   i f   ( s c w E l e . n o d e T y p e = = 3 )   { s c w E l e = s c w E l e . p a r e n t N o d e ; }  
  
                                   s w i t c h   ( s c w E l e . c l a s s N a m e )  
                                         { c a s e   ' s c w C e l l s ' :  
                                                 s c w E l e . c l a s s N a m e   =   ' s c w C e l l s H o v e r ' ;  
                                                 b r e a k ;  
                                           c a s e   ' s c w C e l l s H o v e r ' :  
                                                 s c w E l e . c l a s s N a m e   =   ' s c w C e l l s ' ;  
                                                 b r e a k ;  
                                           c a s e   ' s c w C e l l s E x M o n t h ' :  
                                                 s c w E l e . c l a s s N a m e   =   ' s c w C e l l s E x M o n t h H o v e r ' ;  
                                                 b r e a k ;  
                                           c a s e   ' s c w C e l l s E x M o n t h H o v e r ' :  
                                                 s c w E l e . c l a s s N a m e   =   ' s c w C e l l s E x M o n t h ' ;  
                                                 b r e a k ;  
                                           c a s e   ' s c w C e l l s W e e k e n d ' :  
                                                 s c w E l e . c l a s s N a m e   =   ' s c w C e l l s W e e k e n d H o v e r ' ;  
                                                 b r e a k ;  
                                           c a s e   ' s c w C e l l s W e e k e n d H o v e r ' :  
                                                 s c w E l e . c l a s s N a m e   =   ' s c w C e l l s W e e k e n d ' ;  
                                                 b r e a k ;  
                                           c a s e   ' s c w N o w ' :  
                                                 s c w E l e . c l a s s N a m e   =   ' s c w N o w H o v e r ' ;  
                                                 b r e a k ;  
                                           c a s e   ' s c w N o w H o v e r ' :  
                                                 s c w E l e . c l a s s N a m e   =   ' s c w N o w ' ;  
                                                 b r e a k ;  
                                           c a s e   ' s c w I n p u t D a t e ' :  
                                                 s c w E l e . c l a s s N a m e   =   ' s c w I n p u t D a t e H o v e r ' ;  
                                                 b r e a k ;  
                                           c a s e   ' s c w I n p u t D a t e H o v e r ' :  
                                                 s c w E l e . c l a s s N a m e   =   ' s c w I n p u t D a t e ' ;  
                                         }  
  
                                   r e t u r n   t r u e ;  
                                 }  
  
                           f u n c t i o n   s c w E v e n t T r i g g e r ( s c w E v t )  
                                 { i f   ( ! s c w E v t )   { s c w E v t   =   e v e n t ; }  
                                   r e t u r n   s c w E v t . t a r g e t | | s c w E v t . s r c E l e m e n t ;  
                                 } ;  
  
                           f u n c t i o n   s c w W e e k N u m b e r ( s c w I n D a t e )  
                                 { / /   T h e   b a s e   d a y   i n   t h e   w e e k   o f   t h e   i n p u t   d a t e  
                                   v a r   s c w I n D a t e W e e k B a s e   =   n e w   D a t e ( s c w I n D a t e ) ;  
  
                                   s c w I n D a t e W e e k B a s e . s e t D a t e ( s c w I n D a t e W e e k B a s e . g e t D a t e ( )  
                                                                                         -   s c w I n D a t e W e e k B a s e . g e t D a y ( )  
                                                                                         +   s c w W e e k N u m b e r B a s e D a y  
                                                                                         +   ( ( s c w I n D a t e . g e t D a y ( ) >  
                                                                                                 s c w W e e k N u m b e r B a s e D a y ) ? 7 : 0 ) ) ;  
  
                                   / /   T h e   f i r s t   B a s e   D a y   i n   t h e   y e a r  
                                   v a r   s c w F i r s t B a s e D a y   =   n e w   D a t e ( s c w I n D a t e W e e k B a s e . g e t F u l l Y e a r ( ) , 0 , 1 ) ;  
  
                                   s c w F i r s t B a s e D a y . s e t D a t e ( s c w F i r s t B a s e D a y . g e t D a t e ( )  
                                                                                         -   s c w F i r s t B a s e D a y . g e t D a y ( )  
                                                                                         +   s c w W e e k N u m b e r B a s e D a y  
                                                                                 ) ;  
  
                                   i f   ( s c w F i r s t B a s e D a y   <   n e w   D a t e ( s c w I n D a t e W e e k B a s e . g e t F u l l Y e a r ( ) , 0 , 1 ) )  
                                         { s c w F i r s t B a s e D a y . s e t D a t e ( s c w F i r s t B a s e D a y . g e t D a t e ( ) + 7 ) ; }  
  
                                   / /   S t a r t   o f   W e e k   0 1  
                                   v a r   s c w S t a r t W e e k O n e   =   n e w   D a t e ( s c w F i r s t B a s e D a y  
                                                                                                 -   s c w W e e k N u m b e r B a s e D a y  
                                                                                                 +   s c w I n D a t e . g e t D a y ( ) ) ;  
  
                                   i f   ( s c w S t a r t W e e k O n e   >   s c w F i r s t B a s e D a y )  
                                         { s c w S t a r t W e e k O n e . s e t D a t e ( s c w S t a r t W e e k O n e . g e t D a t e ( ) - 7 ) ; }  
  
                                   / /   S u b t r a c t   t h e   d a t e   o f   t h e   c u r r e n t   w e e k   f r o m   t h e   d a t e   o f   t h e  
                                   / /   f i r s t   w e e k   o f   t h e   y e a r   t o   g e t   t h e   n u m b e r   o f   w e e k s   i n  
                                   / /   m i l l i s e c o n d s .     D i v i d e   b y   t h e   n u m b e r   o f   m i l l i s e c o n d s  
                                   / /   i n   a   w e e k   t h e n   r o u n d   t o   n o   d e c i m a l s   i n   o r d e r   t o   r e m o v e  
                                   / /   t h e   e f f e c t   o f   d a y l i g h t   s a v i n g .     A d d   o n e   t o   m a k e   t h e   f i r s t  
                                   / /   w e e k ,   w e e k   1 .     P l a c e   a   s t r i n g   z e r o   o n   t h e   f r o n t   s o   t h a t  
                                   / /   w e e k   n u m b e r s   a r e   z e r o   f i l l e d .  
  
                                   v a r   s c w W e e k N o   =   ' 0 '   +   ( M a t h . r o u n d ( ( s c w I n D a t e W e e k B a s e   -   s c w F i r s t B a s e D a y ) / 6 0 4 8 0 0 0 0 0 , 0 )   +   1 ) ;  
  
                                   / /   R e t u r n   t h e   l a s t   t w o   c h a r a c t e r s   i n   t h e   w e e k   n u m b e r   s t r i n g  
  
                                   r e t u r n   s c w W e e k N o . s u b s t r i n g ( s c w W e e k N o . l e n g t h - 2 ,   s c w W e e k N o . l e n g t h ) ;  
                                 } ;  
  
                           / /   T r e e w a l k   t o   d i s p l a y   t h e   d a t e s .  
                           / /   I   t r i e d   t o   u s e   g e t E l e m e n t s B y N a m e   b u t   I E   r e f u s e d   t o   c o o p e r a t e  
                           / /   s o   I   r e s o r t e d   t o   t h i s   m e t h o d   w h i c h   w o r k s   f o r   a l l   t e s t e d  
                           / /   b r o w s e r s .  
  
                           v a r   s c w C e l l s   =   s c w I D ( ' s c w C e l l s ' ) ;  
  
                           f o r   ( i = 0 ; i < s c w C e l l s . c h i l d N o d e s . l e n g t h ; i + + )  
                                 { v a r   s c w R o w s   =   s c w C e l l s . c h i l d N o d e s [ i ] ;  
                                   i f   ( s c w R o w s . n o d e T y p e = = 1   & &   s c w R o w s . t a g N a m e = = ' T R ' )  
                                         { i f   ( s c w W e e k N u m b e r D i s p l a y )  
                                                 { / / C a l c u l a t e   t h e   w e e k   n u m b e r   u s i n g   s c w S h o w D a t e  
                                                   s c w T m p E l   =   s c w R o w s . c h i l d N o d e s [ 0 ] ;  
                                                   s c w T m p E l . i n n e r H T M L   =   s c w W e e k N u m b e r ( s c w S h o w D a t e ) ;  
                                                   s c w T m p E l . s t y l e . b o r d e r C o l o r   =  
                                                           ( s c w T m p E l . c u r r e n t S t y l e )  
                                                                 ? s c w T m p E l . c u r r e n t S t y l e [ ' b a c k g r o u n d C o l o r ' ]  
                                                                 : ( w i n d o w . g e t C o m p u t e d S t y l e )  
                                                                         ? d o c u m e n t . d e f a u l t V i e w . g e t C o m p u t e d S t y l e ( s c w T m p E l , n u l l ) . g e t P r o p e r t y V a l u e ( ' b a c k g r o u n d - c o l o r ' )  
                                                                         : ' ' ;  
                                                   s c w T m p E l . s t y l e . d i s p l a y = ' ' ;  
                                                 }  
                                           e l s e  
                                                 { s c w R o w s . c h i l d N o d e s [ 0 ] . s t y l e . d i s p l a y = ' n o n e ' ; }  
  
                                           f o r   ( j = 1 ; j < s c w R o w s . c h i l d N o d e s . l e n g t h ; j + + )  
                                                 { v a r   s c w C o l s   =   s c w R o w s . c h i l d N o d e s [ j ] ;  
                                                   i f   ( s c w C o l s . n o d e T y p e = = 1   & &   s c w C o l s . t a g N a m e = = ' T D ' )  
                                                         { s c w R o w s . c h i l d N o d e s [ j ] . i n n e r H T M L =  
                                                                 s c w S h o w D a t e . g e t D a t e ( ) ;  
                                                           v a r   s c w C e l l = s c w R o w s . c h i l d N o d e s [ j ] ,  
                                                                   s c w D i s a b l e d   =  
                                                                         ( ( s c w O u t O f R a n g e D i s a b l e   & &  
                                                                                 ( s c w S h o w D a t e   <  
                                                                                         ( n e w   D a t e ( s c w B a s e Y e a r , 0 , 1 ,  
                                                                                                             s c w S h o w D a t e . g e t H o u r s ( ) ) )  
                                                                                   | |  
                                                                                   s c w S h o w D a t e   >  
                                                                                         ( n e w   D a t e ( s c w B a s e Y e a r +  
                                                                                                             s c w D r o p D o w n Y e a r s , 0 , 0 ,  
                                                                                                             s c w S h o w D a t e . g e t H o u r s ( ) ) )  
                                                                                 )  
                                                                           )   | |  
                                                                           ( s c w O u t O f M o n t h D i s a b l e   & &  
                                                                                 ( s c w S h o w D a t e   <  
                                                                                         ( n e w   D a t e ( s c w S h o w D a t e . g e t F u l l Y e a r ( ) ,  
                                                                                                             s c w C u r M o n t h , 1 ,  
                                                                                                             s c w S h o w D a t e . g e t H o u r s ( ) ) )  
                                                                                   | |  
                                                                                   s c w S h o w D a t e   >  
                                                                                         ( n e w   D a t e ( s c w S h o w D a t e . g e t F u l l Y e a r ( ) ,  
                                                                                                             s c w C u r M o n t h + 1 , 0 ,  
                                                                                                             s c w S h o w D a t e . g e t H o u r s ( ) ) )  
                                                                                 )  
                                                                           )  
                                                                         ) ? t r u e : f a l s e ;  
  
                                                           s c w C e l l . s t y l e . v i s i b i l i t y   =  
                                                                 ( s c w O u t O f M o n t h H i d e   & &  
                                                                         ( s c w S h o w D a t e   <  
                                                                                 ( n e w   D a t e ( s c w S h o w D a t e . g e t F u l l Y e a r ( ) ,  
                                                                                                     s c w C u r M o n t h , 1 ,  
                                                                                                     s c w S h o w D a t e . g e t H o u r s ( ) ) )  
                                                                           | |  
                                                                           s c w S h o w D a t e   >  
                                                                                 ( n e w   D a t e ( s c w S h o w D a t e . g e t F u l l Y e a r ( ) ,  
                                                                                                     s c w C u r M o n t h + 1 , 0 ,  
                                                                                                     s c w S h o w D a t e . g e t H o u r s ( ) ) )  
                                                                         )  
                                                                 ) ? ' h i d d e n ' : ' i n h e r i t ' ;  
  
                                                           f o r   ( v a r   k = 0 ; k < s c w D i s a b l e d D a t e s . l e n g t h ; k + + )  
                                                                 { i f   ( ( t y p e o f   s c w D i s a b l e d D a t e s [ k ] = = ' o b j e c t ' )   & &  
                                                                           ( s c w D i s a b l e d D a t e s [ k ] . c o n s t r u c t o r   = =   D a t e )   & &  
                                                                           s c w C o m p a r e D a t e V a l u e   = =   s c w D i s a b l e d D a t e s [ k ] . v a l u e O f ( )  
                                                                         )  
                                                                         { s c w D i s a b l e d   =   t r u e ; }  
                                                                   e l s e  
                                                                         { i f   ( ( t y p e o f   s c w D i s a b l e d D a t e s [ k ] = = ' o b j e c t ' )   & &  
                                                                                   ( s c w D i s a b l e d D a t e s [ k ] . c o n s t r u c t o r   = =   A r r a y )   & &  
                                                                                   s c w C o m p a r e D a t e V a l u e   > =   s c w D i s a b l e d D a t e s [ k ] [ 0 ] . v a l u e O f ( )   & &  
                                                                                   s c w C o m p a r e D a t e V a l u e   < =   s c w D i s a b l e d D a t e s [ k ] [ 1 ] . v a l u e O f ( )  
                                                                                 )  
                                                                                 { s c w D i s a b l e d   =   t r u e ; }  
                                                                         }  
                                                                 }  
  
                                                           i f   ( s c w D i s a b l e d   | |  
                                                                   ! s c w E n a b l e d D a y [ j - 1 + ( 7 * ( ( i * s c w C e l l s . c h i l d N o d e s . l e n g t h ) / 6 ) ) ]   | |  
                                                                   ! s c w P a s s E n a b l e d D a y [ ( j - 1 + ( 7 * ( i * s c w C e l l s . c h i l d N o d e s . l e n g t h / 6 ) ) ) % 7 ]  
                                                                 )  
                                                                 { s c w R o w s . c h i l d N o d e s [ j ] . o n c l i c k   =   n u l l ;  
  
                                                                   i f   ( s c w I D ( ' s c w I E ' ) )  
                                                                         { s c w R o w s . c h i l d N o d e s [ j ] . o n m o u s e o v e r     =   n u l l ;  
                                                                           s c w R o w s . c h i l d N o d e s [ j ] . o n m o u s e o u t       =   n u l l ;  
                                                                         }  
  
                                                                   s c w C e l l . c l a s s N a m e =  
                                                                         ( s c w S h o w D a t e . g e t M o n t h ( ) ! = s c w C u r M o n t h )  
                                                                                 ? ' s c w C e l l s E x M o n t h D i s a b l e d '  
                                                                                 : ( s c w B l n F u l l I n p u t D a t e   & &  
                                                                                     s c w S h o w D a t e . t o D a t e S t r i n g ( ) = =  
                                                                                     s c w S e e d D a t e . t o D a t e S t r i n g ( ) )  
                                                                                         ? ' s c w I n p u t D a t e D i s a b l e d '  
                                                                                         : ( s c w S h o w D a t e . g e t D a y ( ) % 6 = = 0 )  
                                                                                                 ? ' s c w C e l l s W e e k e n d D i s a b l e d '  
                                                                                                 : ' s c w C e l l s D i s a b l e d ' ;  
  
                                                                   s c w C e l l . s t y l e . b o r d e r C o l o r   =  
                                                                           ( s c w F o r m a t T o d a y C e l l   & &   s c w S h o w D a t e . t o D a t e S t r i n g ( ) = = s c w D a t e N o w . t o D a t e S t r i n g ( ) )  
                                                                                 ? s c w T o d a y C e l l B o r d e r C o l o u r  
                                                                                 : ( s c w C e l l . c u r r e n t S t y l e )  
                                                                                         ? s c w C e l l . c u r r e n t S t y l e [ ' b a c k g r o u n d C o l o r ' ]  
                                                                                         : ( w i n d o w . g e t C o m p u t e d S t y l e )  
                                                                                                 ? d o c u m e n t . d e f a u l t V i e w . g e t C o m p u t e d S t y l e ( s c w C e l l , n u l l ) . g e t P r o p e r t y V a l u e ( ' b a c k g r o u n d - c o l o r ' )  
                                                                                                 : ' ' ;  
                                                                 }  
                                                           e l s e  
                                                                 { s c w R o w s . c h i l d N o d e s [ j ] . o n c l i c k = s c w C e l l O u t p u t ;  
  
                                                                   i f   ( s c w I D ( ' s c w I E ' ) )  
                                                                         { s c w R o w s . c h i l d N o d e s [ j ] . o n m o u s e o v e r     =   s c w C h a n g e C l a s s ;  
                                                                           s c w R o w s . c h i l d N o d e s [ j ] . o n m o u s e o u t       =   s c w C h a n g e C l a s s ;  
                                                                         }  
  
                                                                   s c w C e l l . c l a s s N a m e =  
                                                                           ( s c w S h o w D a t e . g e t M o n t h ( ) ! = s c w C u r M o n t h )  
                                                                                 ? ' s c w C e l l s E x M o n t h '  
                                                                                 : ( s c w B l n F u l l I n p u t D a t e   & &  
                                                                                     s c w S h o w D a t e . t o D a t e S t r i n g ( ) = =  
                                                                                     s c w S e e d D a t e . t o D a t e S t r i n g ( ) )  
                                                                                         ? ' s c w I n p u t D a t e '  
                                                                                         : ( s c w S h o w D a t e . g e t D a y ( ) % 6 = = 0 )  
                                                                                                 ? ' s c w C e l l s W e e k e n d '  
                                                                                                 : ' s c w C e l l s ' ;  
  
                                                                   s c w C e l l . s t y l e . b o r d e r C o l o r   =  
                                                                           ( s c w F o r m a t T o d a y C e l l   & &   s c w S h o w D a t e . t o D a t e S t r i n g ( )   = =   s c w D a t e N o w . t o D a t e S t r i n g ( ) )  
                                                                                 ? s c w T o d a y C e l l B o r d e r C o l o u r  
                                                                                 : ( s c w C e l l . c u r r e n t S t y l e )  
                                                                                         ? s c w C e l l . c u r r e n t S t y l e [ ' b a c k g r o u n d C o l o r ' ]  
                                                                                         : ( w i n d o w . g e t C o m p u t e d S t y l e )  
                                                                                                 ? d o c u m e n t . d e f a u l t V i e w . g e t C o m p u t e d S t y l e ( s c w C e l l , n u l l ) . g e t P r o p e r t y V a l u e ( ' b a c k g r o u n d - c o l o r ' )  
                                                                                                 : ' ' ;  
                                                               }  
  
                                                           s c w S h o w D a t e . s e t D a t e ( s c w S h o w D a t e . g e t D a t e ( ) + 1 ) ;  
                                                           s c w C o m p a r e D a t e V a l u e   =   n e w   D a t e ( s c w S h o w D a t e . g e t F u l l Y e a r ( ) , s c w S h o w D a t e . g e t M o n t h ( ) , s c w S h o w D a t e . g e t D a t e ( ) ) . v a l u e O f ( ) ;  
                                                         }  
                                                 }  
                                         }  
                                 }  
                         }  
  
                   / /   O p e r a   h a s   a   b u g   w i t h   s e t t i n g   t h e   s e l e c t e d   i n d e x .  
                   / /   I t   r e q u i r e s   t h e   f o l l o w i n g   w o r k - a r o u n d   t o   f o r c e   S E L E C T s   t o   d i s p l a y   c o r r e c t l y .  
                   / /   A l s o   O p e r a ' s   p o o r   d y n a m i c   r e n d e r i n g   p r i o r   t o   9 . 5   r e q u i r e s  
                   / /   t h e   v i s i b i l i t y   t o   b e   r e s e t   t o   p r e v e n t   g a r b a g e   i n   t h e   c a l e n d a r  
                   / /   w h e n   t h e   d i s p l a y e d   m o n t h   i s   c h a n g e d .  
  
                   i f   ( w i n d o w . o p e r a )  
                         { s c w I D ( ' s c w M o n t h s ' ) . s t y l e . d i s p l a y   =   ' i n l i n e ' ;  
                           s c w I D ( ' s c w Y e a r s '   ) . s t y l e . d i s p l a y   =   ' i n l i n e ' ;  
                           s c w I D ( ' s c w ' ) . s t y l e . v i s i b i l i t y = ' h i d d e n ' ;  
                           s c w I D ( ' s c w ' ) . s t y l e . v i s i b i l i t y = ' i n h e r i t ' ;  
                       }  
                 } ;  
  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * *  
 / /     E n d   o f   F u n c t i o n   L i b r a r y  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * *  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * *  
 / /   S t a r t   o f   C a l e n d a r   s t r u c t u r e  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * *  
  
         d o c u m e n t . w r i t e l n ( " < ! - - [ i f   I E ] > < d i v   i d = ' s c w I E ' > < / d i v > < ! [ e n d i f ] - - > " ) ;  
         d o c u m e n t . w r i t e l n ( " < ! - - [ i f   l t   I E   7 ] > < d i v   i d = ' s c w I E l t 7 ' > < / d i v > < ! [ e n d i f ] - - > " ) ;  
         d o c u m e n t . w r i t e (  
           " < i f r a m e   c l a s s = ' s c w '   "   +   ( s c w I D ( ' s c w I E l t 7 ' ) ? " s r c = ' / s c w b l a n k . h t m l   ' " : ' ' )   +  
                           " i d = ' s c w I f r a m e '   n a m e = ' s c w I f r a m e '   f r a m e b o r d e r = ' 0 ' > "   +  
           " < / i f r a m e > "   +  
           " < t a b l e   i d = ' s c w '   c l a s s = ' s c w ' > "   +  
               " < t r   c l a s s = ' s c w ' > "   +  
                   " < t d   c l a s s = ' s c w ' > "   +  
                       " < t a b l e   c l a s s = ' s c w H e a d '   i d = ' s c w H e a d '   w i d t h = ' 1 0 0 % '   "   +  
                                         " c e l l s p a c i n g = ' 0 '   c e l l p a d d i n g = ' 0 ' > "   +  
                         " < t r   i d = ' s c w D r a g '   s t y l e = ' d i s p l a y : n o n e ; ' > "   +  
                                 " < t d   c o l s p a n = ' 4 '   c l a s s = ' s c w D r a g '   "   +  
                                         " o n m o u s e d o w n = ' s c w B e g i n D r a g ( e v e n t ) ; ' > "   +  
                                         " < s p a n   i d = ' s c w D r a g T e x t ' > < / s p a n > "   +  
                                 " < / t d > "   +  
                         " < / t r > "   +  
                         " < t r   c l a s s = ' s c w H e a d '   > "   +  
                                   " < t d   c l a s s = ' s c w H e a d ' > "   +  
                                         " < i n p u t   c l a s s = ' s c w H e a d '   i d = ' s c w H e a d L e f t '   t y p e = ' b u t t o n '   v a l u e = ' < '   "   +  
                                                         " o n c l i c k = ' s c w S h o w M o n t h ( - 1 ) ; '     / > < / t d > "   +  
                                   " < t d   c l a s s = ' s c w H e a d ' > "   +  
                                         " < s e l e c t   i d = ' s c w M o n t h s '   c l a s s = ' s c w H e a d '   "   +  
                                                         " o n c h a n g e = ' s c w S h o w M o n t h ( 0 ) ; ' > "   +  
                                         " < / s e l e c t > "   +  
                                   " < / t d > "   +  
                                   " < t d   c l a s s = ' s c w H e a d ' > "   +  
                                         " < s e l e c t   i d = ' s c w Y e a r s '   c l a s s = ' s c w H e a d '   "   +  
                                                         " o n c h a n g e = ' s c w S h o w M o n t h ( 0 ) ; ' > "   +  
                                         " < / s e l e c t > "   +  
                                   " < / t d > "   +  
                                   " < t d   c l a s s = ' s c w H e a d ' > "   +  
                                         " < i n p u t   c l a s s = ' s c w H e a d '   i d = ' s c w H e a d R i g h t '   t y p e = ' b u t t o n '   v a l u e = ' > '   "   +  
                                                         " o n c l i c k = ' s c w S h o w M o n t h ( 1 ) ; '   / > < / t d > "   +  
                                 " < / t r > "   +  
                             " < / t a b l e > "   +  
                         " < / t d > "   +  
                     " < / t r > "   +  
                     " < t r   c l a s s = ' s c w ' > "   +  
                         " < t d   c l a s s = ' s c w ' > "   +  
                             " < t a b l e   c l a s s = ' s c w C e l l s '   a l i g n = ' c e n t e r ' > "   +  
                                 " < t h e a d > "   +  
                                     " < t r > < t d   c l a s s = ' s c w W e e k N u m b e r H e a d '   i d = ' s c w W e e k _ '   > < / t d > " ) ;  
  
         f o r   ( i = 0 ; i < 7 ; i + + )  
                 { d o c u m e n t . w r i t e (  
                                             " < t d   c l a s s = ' s c w W e e k '   i d = ' s c w W e e k I n i t "   +   i   +   " ' > < / t d > " ) ;  
                 }  
  
         d o c u m e n t . w r i t e ( " < / t r > "   +  
                                 " < / t h e a d > "   +  
                                 " < t b o d y   i d = ' s c w C e l l s '   o n C l i c k = ' s c w S t o p P r o p a g a t i o n ( e v e n t ) ; ' > " ) ;  
  
         f o r   ( i = 0 ; i < 6 ; i + + )  
                 { d o c u m e n t . w r i t e (  
                                         " < t r > "   +  
                                             " < t d   c l a s s = ' s c w W e e k N o '   i d = ' s c w W e e k _ "   +   i   +   " ' > < / t d > " ) ;  
                   f o r   ( j = 0 ; j < 7 ; j + + )  
                         { d o c u m e n t . w r i t e (  
                                                 " < t d   c l a s s = ' s c w C e l l s '   i d = ' s c w C e l l _ "   +   ( j + ( i * 7 ) )   +  
                                                 " ' > < / t d > " ) ;  
                         }  
  
                   d o c u m e n t . w r i t e (  
                                         " < / t r > " ) ;  
                 }  
  
         d o c u m e n t . w r i t e (  
                                 " < / t b o d y > "   +  
                                 " < t f o o t > "   +  
                                     " < t r   i d = ' s c w F o o t ' > "   +  
                                         " < t d   c o l s p a n = ' 8 '   s t y l e = ' p a d d i n g : 0 p x ; ' > "   +  
                                             " < t a b l e   w i d t h = ' 1 0 0 % ' > "   +  
                                                 " < t r > "   +  
                                                     " < t d   i d = ' s c w C l e a r '   c l a s s = ' s c w C l e a r ' > "   +  
                                                         " < i n p u t   t y p e = ' b u t t o n '   i d = ' s c w C l e a r B u t t o n '   c l a s s = ' s c w C l e a r '   "   +  
                                                                       " o n c l i c k = ' s c w T a r g e t E l e . v a l u e   =   \ " \ " ; s c w H i d e ( ) ; '   / > "   +  
                                                     " < / t d > "   +  
                                                     " < t d   c l a s s = ' s c w N o w '   i d = ' s c w N o w ' > < / t d > "   +  
                                                 " < / t r > "   +  
                                             " < / t a b l e > "   +  
                                         " < / t d > "   +  
                                     " < / t r > "   +  
                                 " < / t f o o t > "   +  
                             " < / t a b l e > "   +  
                         " < / t d > "   +  
                     " < / t r > "   +  
                 " < / t a b l e > " ) ;  
  
         i f   ( d o c u m e n t . a d d E v e n t L i s t e n e r )  
                         { s c w I D ( ' s c w '                   ) . a d d E v e n t L i s t e n e r ( ' c l i c k ' , s c w C a n c e l , f a l s e ) ;  
                           s c w I D ( ' s c w H e a d L e f t '   ) . a d d E v e n t L i s t e n e r ( ' c l i c k ' , s c w S t o p P r o p a g a t i o n , f a l s e ) ;  
                           s c w I D ( ' s c w M o n t h s '       ) . a d d E v e n t L i s t e n e r ( ' c l i c k ' , s c w S t o p P r o p a g a t i o n , f a l s e ) ;  
                           s c w I D ( ' s c w M o n t h s '       ) . a d d E v e n t L i s t e n e r ( ' c h a n g e ' , s c w S t o p P r o p a g a t i o n , f a l s e ) ;  
                           s c w I D ( ' s c w Y e a r s '         ) . a d d E v e n t L i s t e n e r ( ' c l i c k ' , s c w S t o p P r o p a g a t i o n , f a l s e ) ;  
                           s c w I D ( ' s c w Y e a r s '         ) . a d d E v e n t L i s t e n e r ( ' c h a n g e ' , s c w S t o p P r o p a g a t i o n , f a l s e ) ;  
                           s c w I D ( ' s c w H e a d R i g h t ' ) . a d d E v e n t L i s t e n e r ( ' c l i c k ' , s c w S t o p P r o p a g a t i o n , f a l s e ) ;  
                         }  
         e l s e         { s c w I D ( ' s c w '                   ) . a t t a c h E v e n t ( ' o n c l i c k ' , s c w C a n c e l ) ;  
                           s c w I D ( ' s c w H e a d L e f t '   ) . a t t a c h E v e n t ( ' o n c l i c k ' , s c w S t o p P r o p a g a t i o n ) ;  
                           s c w I D ( ' s c w M o n t h s '       ) . a t t a c h E v e n t ( ' o n c l i c k ' , s c w S t o p P r o p a g a t i o n ) ;  
                           s c w I D ( ' s c w M o n t h s '       ) . a t t a c h E v e n t ( ' o n c h a n g e ' , s c w S t o p P r o p a g a t i o n ) ;  
                           s c w I D ( ' s c w Y e a r s '         ) . a t t a c h E v e n t ( ' o n c l i c k ' , s c w S t o p P r o p a g a t i o n ) ;  
                           s c w I D ( ' s c w Y e a r s '         ) . a t t a c h E v e n t ( ' o n c h a n g e ' , s c w S t o p P r o p a g a t i o n ) ;  
                           s c w I D ( ' s c w H e a d R i g h t ' ) . a t t a c h E v e n t ( ' o n c l i c k ' , s c w S t o p P r o p a g a t i o n ) ;  
                         }  
  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * *  
 / /     E n d   o f   C a l e n d a r   s t r u c t u r e  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * *  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
 / /   S t a r t   o f   d o c u m e n t   l e v e l   e v e n t   d e f i n i t i o n  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
  
         i f   ( d o c u m e n t . a d d E v e n t L i s t e n e r )  
                         { d o c u m e n t . a d d E v e n t L i s t e n e r ( ' c l i c k ' , s c w H i d e ,   f a l s e ) ; }  
         e l s e         { d o c u m e n t . a t t a c h E v e n t ( ' o n c l i c k ' , s c w H i d e ) ; }  
  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
 / /     E n d   o f   d o c u m e n t   l e v e l   e v e n t   d e f i n i t i o n  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
 / /     E n d   o f   S i m p l e   C a l e n d a r   W i d g e t   C o d e  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
