ÿþ 
 / /   C a l e n d a r   E N   l a n g u a g e  
 / /   A u t h o r :   M i h a i   B a z o n ,   < m i h a i _ b a z o n @ y a h o o . c o m >  
 / /   E n c o d i n g :   a n y  
 / /   D i s t r i b u t e d   u n d e r   t h e   s a m e   t e r m s   a s   t h e   c a l e n d a r   i t s e l f .  
  
 / /   F o r   t r a n s l a t o r s :   p l e a s e   u s e   U T F - 8   i f   p o s s i b l e .     W e   s t r o n g l y   b e l i e v e   t h a t  
 / /   U n i c o d e   i s   t h e   a n s w e r   t o   a   r e a l   i n t e r n a t i o n a l i z e d   w o r l d .     A l s o   p l e a s e  
 / /   i n c l u d e   y o u r   c o n t a c t   i n f o r m a t i o n   i n   t h e   h e a d e r ,   a s   c a n   b e   s e e n   a b o v e .  
  
 / /   f u l l   d a y   n a m e s  
  
 i f   ( t y p e o f   ( a g L a n g u a g e N a m e )   = =   " u n d e f i n e d " )  
         v a r   a g L a n g u a g e N a m e   =   " v i - V N " ;  
  
 i f   ( a g L a n g u a g e N a m e   = =   " e n - U S " )   {  
         C a l e n d a r . _ D N   =   n e w   A r r a y  
         ( " S u n d a y " ,  
           " M o n d a y " ,  
           " T u e s d a y " ,  
           " W e d n e s d a y " ,  
           " T h u r s d a y " ,  
           " F r i d a y " ,  
           " S a t u r d a y " ,  
           " S u n d a y " ) ;  
 }  
 e l s e   i f   ( a g L a n g u a g e N a m e   = =   " v i - V N " )   {  
         C a l e n d a r . _ D N   =   n e w   A r r a y  
         ( " C h ç  n h ­t " ,  
           " T h é  h a i " ,  
           " T h é  b a " ,  
           " T h é  t °" ,  
           " T h é  n m " ,  
           " T h é  s á u " ,  
           " T h é  b £y " ,  
           " C h ç  n h ­t " ) ;  
 }  
  
 / /   P l e a s e   n o t e   t h a t   t h e   f o l l o w i n g   a r r a y   o f   s h o r t   d a y   n a m e s   ( a n d   t h e   s a m e   g o e s  
 / /   f o r   s h o r t   m o n t h   n a m e s ,   _ S M N )   i s n ' t   a b s o l u t e l y   n e c e s s a r y .     W e   g i v e   i t   h e r e  
 / /   f o r   e x e m p l i f i c a t i o n   o n   h o w   o n e   c a n   c u s t o m i z e   t h e   s h o r t   d a y   n a m e s ,   b u t   i f  
 / /   t h e y   a r e   s i m p l y   t h e   f i r s t   N   l e t t e r s   o f   t h e   f u l l   n a m e   y o u   c a n   s i m p l y   s a y :  
 / /  
 / /       C a l e n d a r . _ S D N _ l e n   =   N ;   / /   s h o r t   d a y   n a m e   l e n g t h  
 / /       C a l e n d a r . _ S M N _ l e n   =   N ;   / /   s h o r t   m o n t h   n a m e   l e n g t h  
 / /  
 / /   I f   N   =   3   t h e n   t h i s   i s   n o t   n e e d e d   e i t h e r   s i n c e   w e   a s s u m e   a   v a l u e   o f   3   i f   n o t  
 / /   p r e s e n t ,   t o   b e   c o m p a t i b l e   w i t h   t r a n s l a t i o n   f i l e s   t h a t   w e r e   w r i t t e n   b e f o r e  
 / /   t h i s   f e a t u r e .  
  
 / /   s h o r t   d a y   n a m e s  
  
  
 / /   s h o r t   d a y   n a m e s  
 i f   ( a g L a n g u a g e N a m e   = =   " e n - U S " )   {  
         C a l e n d a r . _ S D N   =   n e w   A r r a y  
         ( " S u n " ,  
           " M o n " ,  
           " T u e " ,  
           " W e d " ,  
           " T h u " ,  
           " F r i " ,  
           " S a t " ,  
           " S u n " ) ;  
 }  
 e l s e   i f   ( a g L a n g u a g e N a m e   = =   " v i - V N " )   {  
         C a l e n d a r . _ S D N   =   n e w   A r r a y  
         ( " C N " ,  
           " T 2 " ,  
           " T 3 " ,  
           " T 4 " ,  
           " T 5 " ,  
           " T 6 " ,  
           " T 7 " ,  
           " C N " ) ;  
 }  
  
  
  
  
 / /   F i r s t   d a y   o f   t h e   w e e k .   " 0 "   m e a n s   d i s p l a y   S u n d a y   f i r s t ,   " 1 "   m e a n s   d i s p l a y  
 / /   M o n d a y   f i r s t ,   e t c .  
 C a l e n d a r . _ F D   =   0 ;  
  
  
 / / / / / /   f u l l   m o n t h   n a m e s  
 i f   ( a g L a n g u a g e N a m e   = =   " e n - U S " )   {  
         C a l e n d a r . _ M N   =   n e w   A r r a y  
         ( " J a n u a r y " ,  
           " F e b r u a r y " ,  
           " M a r c h " ,  
           " A p r i l " ,  
           " M a y " ,  
           " J u n e " ,  
           " J u l y " ,  
           " A u g u s t " ,  
           " S e p t e m b e r " ,  
           " O c t o b e r " ,  
           " N o v e m b e r " ,  
           " D e c e m b e r " ) ;  
 }  
 e l s e   i f   ( a g L a n g u a g e N a m e   = =   " v i - V N " )   {  
         C a l e n d a r . _ M N   =   n e w   A r r a y  
         ( " T h á n g   1 " ,  
           " T h á n g   2 " ,  
           " T h á n g   3 " ,  
           " T h á n g   4 " ,  
           " T h á n g   5 " ,  
           " T h á n g   6 " ,  
           " T h á n g   7 " ,  
           " T h á n g   8 " ,  
           " T h á n g   9 " ,  
           " T h á n g   1 0 " ,  
           " T h á n g   1 1 " ,  
           " T h á n g   1 2 " ) ;  
 }  
  
 / /   s h o r t   m o n t h   n a m e s  
 i f   ( a g L a n g u a g e N a m e   = =   " v i - V N " )   {  
         C a l e n d a r . _ S M N   =   n e w   A r r a y  
         ( " T h 1 " ,  
           " T h 2 " ,  
           " T h 3 " ,  
           " T h 4 " ,  
           " T h 5 " ,  
           " T h 6 " ,  
           " T h 7 " ,  
           " T h 8 " ,  
           " T h 9 " ,  
           " T h 1 0 " ,  
           " T h 1 1 " ,  
           " T h 1 2 " ) ;  
 }  
 e l s e   i f   ( a g L a n g u a g e N a m e   = =   " e n - U S " )   {  
         C a l e n d a r . _ S M N   =   n e w   A r r a y  
         ( " 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 " ) ;  
 }  
  
  
 / /   t o o l t i p s  
 i f   ( a g L a n g u a g e N a m e   = =   " v i - V N " )   {  
         C a l e n d a r . _ T T   =   { } ;  
         C a l e n d a r . _ T T [ " I N F O " ]   =   " T h ô n g   t i n   v Á  c h °¡n g   t r ì n h   L Ëc h " ;  
  
         C a l e n d a r . _ T T [ " A B O U T " ]   =  
         " D H T M L   D a t e / T i m e   S e l e c t o r \ n "   +  
         " ( c )   d y n a r c h . c o m   2 0 0 2 - 2 0 0 3 \ n "   +   / /   d o n ' t   t r a n s l a t e   t h i s   t h i s   ; - )  
         " Ã  b i ¿t   v Á  c á c   b £n   m Ûi   g h é   t h m :   h t t p : / / d y n a r c h . c o m / m i s h o o / c a l e n d a r . e p l \ n "   +  
         " °ãc   c u n g   c ¥p   t h e o   g i ¥y   p h é p   G N U   L G P L .     X e m   h t t p : / / g n u . o r g / l i c e n s e s / l g p l . h t m l   Ã  b i ¿t   t h ê m   c h i   t i ¿t . "   +  
         " \ n \ n "   +  
         " C h Ín   n g à y : \ n "   +  
         " -   D ù n g   \ x a b ,   \ x b b   Ã  c h Ín   n m \ n "   +  
         " -   D ù n g   "   +   S t r i n g . f r o m C h a r C o d e ( 0 x 2 0 3 9 )   +   " ,   "   +   S t r i n g . f r o m C h a r C o d e ( 0 x 2 0 3 a )   +   "   Ã  c h Ín   t h á n g \ n "   +  
         " -   N h ¥n   v à   g i ï  p h í m   c h u Ùt   t r ê n   b ¥t   c é  p h í m   n à o   Ã  c h Ín   n h a n h . " ;  
                 C a l e n d a r . _ T T [ " A B O U T _ T I M E " ]   =   " \ n \ n "   +  
         " C h Ín   g i Ý: \ n "   +  
         " -   N h ¥n   l ê n   g i Ý,   p h ú t ,   g i â y   Ã  t n g \ n "   +  
         " -   h o ·c   v ëa   n h ¥n   v ëa   g i ï  S h i f t   Ã  g i £m \ n "   +  
         " -   h o ·c   n h ¥n   v à   k é o   Ón g   t h Ýi   Ã  c h Ín   n h a n h . " ;  
 }  
 e l s e   i f   ( a g L a n g u a g e N a m e   = =   " e n - U S " )   {  
         C a l e n d a r . _ T T   =   { } ;  
         C a l e n d a r . _ T T [ " I N F O " ]   =   " A b o u t   t h e   c a l e n d a r " ;  
  
         C a l e n d a r . _ T T [ " A B O U T " ]   =  
         " D H T M L   D a t e / T i m e   S e l e c t o r \ n "   +  
         " ( c )   d y n a r c h . c o m   2 0 0 2 - 2 0 0 5   /   A u t h o r :   M i h a i   B a z o n \ n "   +   / /   d o n ' t   t r a n s l a t e   t h i s   t h i s   ; - )  
         " F o r   l a t e s t   v e r s i o n   v i s i t :   h t t p : / / w w w . d y n a r c h . c o m / p r o j e c t s / c a l e n d a r / \ n "   +  
         " D i s t r i b u t e d   u n d e r   G N U   L G P L .     S e e   h t t p : / / g n u . o r g / l i c e n s e s / l g p l . h t m l   f o r   d e t a i l s . "   +  
         " \ n \ n "   +  
         " D a t e   s e l e c t i o n : \ n "   +  
         " -   U s e   t h e   \ x a b ,   \ x b b   b u t t o n s   t o   s e l e c t   y e a r \ n "   +  
         " -   U s e   t h e   "   +   S t r i n g . f r o m C h a r C o d e ( 0 x 2 0 3 9 )   +   " ,   "   +   S t r i n g . f r o m C h a r C o d e ( 0 x 2 0 3 a )   +   "   b u t t o n s   t o   s e l e c t   m o n t h \ n "   +  
         " -   H o l d   m o u s e   b u t t o n   o n   a n y   o f   t h e   a b o v e   b u t t o n s   f o r   f a s t e r   s e l e c t i o n . " ;  
         C a l e n d a r . _ T T [ " A B O U T _ T I M E " ]   =   " \ n \ n "   +  
         " T i m e   s e l e c t i o n : \ n "   +  
         " -   C l i c k   o n   a n y   o f   t h e   t i m e   p a r t s   t o   i n c r e a s e   i t \ n "   +  
         " -   o r   S h i f t - c l i c k   t o   d e c r e a s e   i t \ n "   +  
         " -   o r   c l i c k   a n d   d r a g   f o r   f a s t e r   s e l e c t i o n . " ;  
 }  
  
  
 i f   ( a g L a n g u a g e N a m e   = =   " v i - V N " )   {  
         C a l e n d a r . _ T T [ " P R E V _ Y E A R " ]   =   " N m   t r °Ûc   ( h o l d   f o r   m e n u ) " ;  
         C a l e n d a r . _ T T [ " P R E V _ M O N T H " ]   =   " T h á n g   t r °Ûc   ( h o l d   f o r   m e n u ) " ;  
         C a l e n d a r . _ T T [ " G O _ T O D A Y " ]   =   " H ô m   n a y " ;  
         C a l e n d a r . _ T T [ " N E X T _ M O N T H " ]   =   " T h á n g   k ¿  ( h o l d   f o r   m e n u ) " ;  
         C a l e n d a r . _ T T [ " N E X T _ Y E A R " ]   =   " N m   s a u   ( h o l d   f o r   m e n u ) " ;  
         C a l e n d a r . _ T T [ " S E L _ D A T E " ]   =   " C h Ín   n g à y " ;  
         C a l e n d a r . _ T T [ " D R A G _ T O _ M O V E " ]   =   " K é o   Ã  d Ëc h   c h u y Ãn " ;  
         C a l e n d a r . _ T T [ " P A R T _ T O D A Y " ]   =   "   ( h ô m   n a y ) " ;  
 }  
 e l s e   i f   ( a g L a n g u a g e N a m e   = =   " e n - U S " )   {  
  
         C a l e n d a r . _ T T [ " P R E V _ Y E A R " ]   =   " P r e v .   y e a r   ( h o l d   f o r   m e n u ) " ;  
         C a l e n d a r . _ T T [ " P R E V _ M O N T H " ]   =   " P r e v .   m o n t h   ( h o l d   f o r   m e n u ) " ;  
         C a l e n d a r . _ T T [ " G O _ T O D A Y " ]   =   " G o   T o d a y " ;  
         C a l e n d a r . _ T T [ " N E X T _ M O N T H " ]   =   " N e x t   m o n t h   ( h o l d   f o r   m e n u ) " ;  
         C a l e n d a r . _ T T [ " N E X T _ Y E A R " ]   =   " N e x t   y e a r   ( h o l d   f o r   m e n u ) " ;  
         C a l e n d a r . _ T T [ " S E L _ D A T E " ]   =   " S e l e c t   d a t e " ;  
         C a l e n d a r . _ T T [ " D R A G _ T O _ M O V E " ]   =   " D r a g   t o   m o v e " ;  
         C a l e n d a r . _ T T [ " P A R T _ T O D A Y " ]   =   "   ( t o d a y ) " ;  
 }  
  
 / /   t h e   f o l l o w i n g   i s   t o   i n f o r m   t h a t   " % s "   i s   t o   b e   t h e   f i r s t   d a y   o f   w e e k  
 / /   % s   w i l l   b e   r e p l a c e d   w i t h   t h e   d a y   n a m e .  
 i f   ( a g L a n g u a g e N a m e   = =   " v i - V N " )   {  
         C a l e n d a r . _ T T [ " D A Y _ F I R S T " ]   =   " H i Ãn   t h Ë  \ " % s \ "   §u   t i ê n " ;  
 }  
 e l s e   i f   ( a g L a n g u a g e N a m e   = =   " e n - U S " )   {  
         C a l e n d a r . _ T T [ " D A Y _ F I R S T " ]   =   " D i s p l a y   \ " % s \ "   f i r s t " ;  
 }  
  
 / /   T h i s   m a y   b e   l o c a l e - d e p e n d e n t .     I t   s p e c i f i e s   t h e   w e e k - e n d   d a y s ,   a s   a n   a r r a y  
 / /   o f   c o m m a - s e p a r a t e d   n u m b e r s .     T h e   n u m b e r s   a r e   f r o m   0   t o   6 :   0   m e a n s   S u n d a y ,   1  
 / /   m e a n s   M o n d a y ,   e t c .  
 C a l e n d a r . _ T T [ " W E E K E N D " ]   =   " 0 , 6 " ;  
  
  
 i f   ( a g L a n g u a g e N a m e   = =   " v i - V N " )   {  
         C a l e n d a r . _ T T [ " C L O S E " ]   =   " ó n g " ;  
         C a l e n d a r . _ T T [ " T O D A Y " ]   =   " H ô m   n a y " ;  
         C a l e n d a r . _ T T [ " T I M E _ P A R T " ]   =   " ( S h i f t - ) C l i c k   o r   k é o   Ã  t h a y   Õi   g i á   t r Ë" ;  
 }  
 e l s e   i f   ( a g L a n g u a g e N a m e   = =   " e n - U S " )   {  
         C a l e n d a r . _ T T [ " C L O S E " ]   =   " C l o s e " ;  
         C a l e n d a r . _ T T [ " T O D A Y " ]   =   " T o d a y " ;  
         C a l e n d a r . _ T T [ " T I M E _ P A R T " ]   =   " ( S h i f t - ) C l i c k   o r   d r a g   t o   c h a n g e   v a l u e " ;  
 }  
  
 / /   d a t e   f o r m a t s  
 C a l e n d a r . _ T T [ " D E F _ D A T E _ F O R M A T " ]   =   " % Y - % m - % d " ;  
 C a l e n d a r . _ T T [ " T T _ D A T E _ F O R M A T " ]   =   " % a ,   % b   % e " ;  
  
 i f   ( a g L a n g u a g e N a m e   = =   " v i - V N " )   {  
         C a l e n d a r . _ T T [ " W K " ]   =   " T U " ;  
         C a l e n d a r . _ T T [ " T I M E " ]   =   " T h Ýi   g i a n : "  
 }  
 e l s e   i f   ( a g L a n g u a g e N a m e   = =   " e n - U S " )   {  
         C a l e n d a r . _ T T [ " W K " ]   =   " w k " ;  
         C a l e n d a r . _ T T [ " T I M E " ]   =   " T i m e : "  
 }  
 / *     C o p y r i g h t   M i h a i   B a z o n ,   2 0 0 2 ,   2 0 0 3     |     h t t p : / / d y n a r c h . c o m / m i s h o o /  
   *   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
   *  
   *   T h e   D H T M L   C a l e n d a r  
   *  
   *   D e t a i l s   a n d   l a t e s t   v e r s i o n   a t :  
   *   h t t p : / / d y n a r c h . c o m / m i s h o o / c a l e n d a r . e p l  
   *  
   *   T h i s   s c r i p t   i s   d i s t r i b u t e d   u n d e r   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 .  
   *   R e a d   t h e   e n t i r e   l i c e n s e   t e x t   h e r e :   h t t p : / / w w w . g n u . o r g / l i c e n s e s / l g p l . h t m l  
   *  
   *   T h i s   f i l e   d e f i n e s   h e l p e r   f u n c t i o n s   f o r   s e t t i n g   u p   t h e   c a l e n d a r .     T h e y   a r e  
   *   i n t e n d e d   t o   h e l p   n o n - p r o g r a m m e r s   g e t   a   w o r k i n g   c a l e n d a r   o n   t h e i r   s i t e  
   *   q u i c k l y .     T h i s   s c r i p t   s h o u l d   n o t   b e   s e e n   a s   p a r t   o f   t h e   c a l e n d a r .     I t   j u s t  
   *   s h o w s   y o u   w h a t   o n e   c a n   d o   w i t h   t h e   c a l e n d a r ,   w h i l e   i n   t h e   s a m e   t i m e  
   *   p r o v i d i n g   a   q u i c k   a n d   s i m p l e   m e t h o d   f o r   s e t t i n g   i t   u p .     I f   y o u   n e e d  
   *   e x h a u s t i v e   c u s t o m i z a t i o n   o f   t h e   c a l e n d a r   c r e a t i o n   p r o c e s s   f e e l   f r e e   t o  
   *   m o d i f y   t h i s   c o d e   t o   s u i t   y o u r   n e e d s   ( t h i s   i s   r e c o m m e n d e d   a n d   m u c h   b e t t e r  
   *   t h a n   m o d i f y i n g   c a l e n d a r . j s   i t s e l f ) .  
   * /  
  
 / /   $ I d :   c a l e n d a r - s e t u p . j s , v   1 . 1   2 0 0 6 / 0 9 / 0 3   1 1 : 2 9 : 2 2   t u n g   E x p   $  
  
 / * *  
   *     T h i s   f u n c t i o n   " p a t c h e s "   a n   i n p u t   f i e l d   ( o r   o t h e r   e l e m e n t )   t o   u s e   a   c a l e n d a r  
   *     w i d g e t   f o r   d a t e   s e l e c t i o n .  
   *  
   *     T h e   " p a r a m s "   i s   a   s i n g l e   o b j e c t   t h a t   c a n   h a v e   t h e   f o l l o w i n g   p r o p e r t i e s :  
   *  
   *         p r o p .   n a m e       |   d e s c r i p t i o n  
   *     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
   *       i n p u t F i e l d         |   t h e   I D   o f   a n   i n p u t   f i e l d   t o   s t o r e   t h e   d a t e  
   *       d i s p l a y A r e a       |   t h e   I D   o f   a   D I V   o r   o t h e r   e l e m e n t   t o   s h o w   t h e   d a t e  
   *       b u t t o n                 |   I D   o f   a   b u t t o n   o r   o t h e r   e l e m e n t   t h a t   w i l l   t r i g g e r   t h e   c a l e n d a r  
   *       e v e n t N a m e           |   e v e n t   t h a t   w i l l   t r i g g e r   t h e   c a l e n d a r ,   w i t h o u t   t h e   " o n "   p r e f i x   ( d e f a u l t :   " c l i c k " )  
   *       i f F o r m a t             |   d a t e   f o r m a t   t h a t   w i l l   b e   s t o r e d   i n   t h e   i n p u t   f i e l d  
   *       d a F o r m a t             |   t h e   d a t e   f o r m a t   t h a t   w i l l   b e   u s e d   t o   d i s p l a y   t h e   d a t e   i n   d i s p l a y A r e a  
   *       s i n g l e C l i c k       |   ( t r u e / f a l s e )   w e t h e r   t h e   c a l e n d a r   i s   i n   s i n g l e   c l i c k   m o d e   o r   n o t   ( d e f a u l t :   t r u e )  
   *       f i r s t D a y             |   n u m e r i c :   0   t o   6 .     " 0 "   m e a n s   d i s p l a y   S u n d a y   f i r s t ,   " 1 "   m e a n s   d i s p l a y   M o n d a y   f i r s t ,   e t c .  
   *       a l i g n                   |   a l i g n m e n t   ( d e f a u l t :   " B r " ) ;   i f   y o u   d o n ' t   k n o w   w h a t ' s   t h i s   s e e   t h e   c a l e n d a r   d o c u m e n t a t i o n  
   *       r a n g e                   |   a r r a y   w i t h   2   e l e m e n t s .     D e f a u l t :   [ 1 9 0 0 ,   2 9 9 9 ]   - -   t h e   r a n g e   o f   y e a r s   a v a i l a b l e  
   *       w e e k N u m b e r s       |   ( t r u e / f a l s e )   i f   i t ' s   t r u e   ( d e f a u l t )   t h e   c a l e n d a r   w i l l   d i s p l a y   w e e k   n u m b e r s  
   *       f l a t                     |   n u l l   o r   e l e m e n t   I D ;   i f   n o t   n u l l   t h e   c a l e n d a r   w i l l   b e   a   f l a t   c a l e n d a r   h a v i n g   t h e   p a r e n t   w i t h   t h e   g i v e n   I D  
   *       f l a t C a l l b a c k     |   f u n c t i o n   t h a t   r e c e i v e s   a   J S   D a t e   o b j e c t   a n d   r e t u r n s   a n   U R L   t o   p o i n t   t h e   b r o w s e r   t o   ( f o r   f l a t   c a l e n d a r )  
   *       d i s a b l e F u n c       |   f u n c t i o n   t h a t   r e c e i v e s   a   J S   D a t e   o b j e c t   a n d   s h o u l d   r e t u r n   t r u e   i f   t h a t   d a t e   h a s   t o   b e   d i s a b l e d   i n   t h e   c a l e n d a r  
   *       o n S e l e c t             |   f u n c t i o n   t h a t   g e t s   c a l l e d   w h e n   a   d a t e   i s   s e l e c t e d .     Y o u   d o n ' t   _ h a v e _   t o   s u p p l y   t h i s   ( t h e   d e f a u l t   i s   g e n e r a l l y   o k a y )  
   *       o n C l o s e               |   f u n c t i o n   t h a t   g e t s   c a l l e d   w h e n   t h e   c a l e n d a r   i s   c l o s e d .     [ d e f a u l t ]  
   *       o n U p d a t e             |   f u n c t i o n   t h a t   g e t s   c a l l e d   a f t e r   t h e   d a t e   i s   u p d a t e d   i n   t h e   i n p u t   f i e l d .     R e c e i v e s   a   r e f e r e n c e   t o   t h e   c a l e n d a r .  
   *       d a t e                     |   t h e   d a t e   t h a t   t h e   c a l e n d a r   w i l l   b e   i n i t i a l l y   d i s p l a y e d   t o  
   *       s h o w s T i m e           |   d e f a u l t :   f a l s e ;   i f   t r u e   t h e   c a l e n d a r   w i l l   i n c l u d e   a   t i m e   s e l e c t o r  
   *       t i m e F o r m a t         |   t h e   t i m e   f o r m a t ;   c a n   b e   " 1 2 "   o r   " 2 4 " ,   d e f a u l t   i s   " 1 2 "  
   *       e l e c t r i c             |   i f   t r u e   ( d e f a u l t )   t h e n   g i v e n   f i e l d s / d a t e   a r e a s   a r e   u p d a t e d   f o r   e a c h   m o v e ;   o t h e r w i s e   t h e y ' r e   u p d a t e d   o n l y   o n   c l o s e  
   *       s t e p                     |   c o n f i g u r e s   t h e   s t e p   o f   t h e   y e a r s   i n   d r o p - d o w n   b o x e s ;   d e f a u l t :   2  
   *       p o s i t i o n             |   c o n f i g u r e s   t h e   c a l e n d a r   a b s o l u t e   p o s i t i o n ;   d e f a u l t :   n u l l  
   *       c a c h e                   |   i f   " t r u e "   ( b u t   d e f a u l t :   " f a l s e " )   i t   w i l l   r e u s e   t h e   s a m e   c a l e n d a r   o b j e c t ,   w h e r e   p o s s i b l e  
   *       s h o w O t h e r s         |   i f   " t r u e "   ( b u t   d e f a u l t :   " f a l s e " )   i t   w i l l   s h o w   d a y s   f r o m   o t h e r   m o n t h s   t o o  
   *  
   *     N o n e   o f   t h e m   i s   r e q u i r e d ,   t h e y   a l l   h a v e   d e f a u l t   v a l u e s .     H o w e v e r ,   i f   y o u  
   *     p a s s   n o n e   o f   " i n p u t F i e l d " ,   " d i s p l a y A r e a "   o r   " b u t t o n "   y o u ' l l   g e t   a   w a r n i n g  
   *     s a y i n g   " n o t h i n g   t o   s e t u p " .  
   * /  
  
 C a l e n d a r . s e t u p   =   f u n c t i o n ( p a r a m s )   {  
         f u n c t i o n   p a r a m _ d e f a u l t ( p n a m e ,   d e f )   {   i f   ( t y p e o f   p a r a m s [ p n a m e ]   = =   " u n d e f i n e d " )   {   p a r a m s [ p n a m e ]   =   d e f ;   }   } ;  
  
         p a r a m _ d e f a u l t ( " i n p u t F i e l d " ,   n u l l ) ;  
         p a r a m _ d e f a u l t ( " d i s p l a y A r e a " ,   n u l l ) ;  
         p a r a m _ d e f a u l t ( " b u t t o n " ,   n u l l ) ;  
         p a r a m _ d e f a u l t ( " e v e n t N a m e " ,   " c l i c k " ) ;  
         p a r a m _ d e f a u l t ( " i f F o r m a t " ,   " % Y / % m / % d " ) ;  
         p a r a m _ d e f a u l t ( " d a F o r m a t " ,   " % Y / % m / % d " ) ;  
         p a r a m _ d e f a u l t ( " s i n g l e C l i c k " ,   t r u e ) ;  
         p a r a m _ d e f a u l t ( " d i s a b l e F u n c " ,   n u l l ) ;  
         p a r a m _ d e f a u l t ( " d a t e S t a t u s F u n c " ,   p a r a m s [ " d i s a b l e F u n c " ] ) ;   / /   t a k e s   p r e c e d e n c e   i f   b o t h   a r e   d e f i n e d  
         p a r a m _ d e f a u l t ( " d a t e T e x t " ,   n u l l ) ;  
         p a r a m _ d e f a u l t ( " f i r s t D a y " ,   n u l l ) ;  
         p a r a m _ d e f a u l t ( " a l i g n " ,   " B r " ) ;  
         p a r a m _ d e f a u l t ( " r a n g e " ,   [ 1 9 0 0 ,   2 9 9 9 ] ) ;  
         p a r a m _ d e f a u l t ( " w e e k N u m b e r s " ,   t r u e ) ;  
         p a r a m _ d e f a u l t ( " f l a t " ,   n u l l ) ;  
         p a r a m _ d e f a u l t ( " f l a t C a l l b a c k " ,   n u l l ) ;  
         p a r a m _ d e f a u l t ( " o n S e l e c t " ,   n u l l ) ;  
         p a r a m _ d e f a u l t ( " o n C l o s e " ,   n u l l ) ;  
         p a r a m _ d e f a u l t ( " o n U p d a t e " ,   n u l l ) ;  
         p a r a m _ d e f a u l t ( " d a t e " ,   n u l l ) ;  
         p a r a m _ d e f a u l t ( " s h o w s T i m e " ,   f a l s e ) ;  
         p a r a m _ d e f a u l t ( " t i m e F o r m a t " ,   " 2 4 " ) ;  
         p a r a m _ d e f a u l t ( " e l e c t r i c " ,   t r u e ) ;  
         p a r a m _ d e f a u l t ( " s t e p " ,   2 ) ;  
         p a r a m _ d e f a u l t ( " p o s i t i o n " ,   n u l l ) ;  
         p a r a m _ d e f a u l t ( " c a c h e " ,   f a l s e ) ;  
         p a r a m _ d e f a u l t ( " s h o w O t h e r s " ,   f a l s e ) ;  
         p a r a m _ d e f a u l t ( " m u l t i p l e " ,   n u l l ) ;  
  
         v a r   t m p   =   [ " i n p u t F i e l d " ,   " d i s p l a y A r e a " ,   " b u t t o n " ] ;  
         f o r   ( v a r   i   i n   t m p )   {  
                 i f   ( t y p e o f   p a r a m s [ t m p [ i ] ]   = =   " s t r i n g " )   {  
                         p a r a m s [ t m p [ i ] ]   =   d o c u m e n t . g e t E l e m e n t B y I d ( p a r a m s [ t m p [ i ] ] ) ;  
                 }  
         }  
         i f   ( ! ( p a r a m s . f l a t   | |   p a r a m s . m u l t i p l e   | |   p a r a m s . i n p u t F i e l d   | |   p a r a m s . d i s p l a y A r e a   | |   p a r a m s . b u t t o n ) )   {  
                 a l e r t ( " C a l e n d a r . s e t u p : \ n     N o t h i n g   t o   s e t u p   ( n o   f i e l d s   f o u n d ) .     P l e a s e   c h e c k   y o u r   c o d e " ) ;  
                 r e t u r n   f a l s e ;  
         }  
  
         f u n c t i o n   o n S e l e c t ( c a l )   {  
                 v a r   p   =   c a l . p a r a m s ;  
                 v a r   u p d a t e   =   ( c a l . d a t e C l i c k e d   | |   p . e l e c t r i c ) ;  
                 i f   ( u p d a t e   & &   p . i n p u t F i e l d )   {  
                         p . i n p u t F i e l d . v a l u e   =   c a l . d a t e . p r i n t ( p . i f F o r m a t ) ;  
                         i f   ( t y p e o f   p . i n p u t F i e l d . o n c h a n g e   = =   " f u n c t i o n " )  
                                 p . i n p u t F i e l d . o n c h a n g e ( ) ;  
                 }  
                 i f   ( u p d a t e   & &   p . d i s p l a y A r e a )  
                         p . d i s p l a y A r e a . i n n e r H T M L   =   c a l . d a t e . p r i n t ( p . d a F o r m a t ) ;  
                 i f   ( u p d a t e   & &   t y p e o f   p . o n U p d a t e   = =   " f u n c t i o n " )  
                         p . o n U p d a t e ( c a l ) ;  
                 i f   ( u p d a t e   & &   p . f l a t )   {  
                         i f   ( t y p e o f   p . f l a t C a l l b a c k   = =   " f u n c t i o n " )  
                                 p . f l a t C a l l b a c k ( c a l ) ;  
                 }  
                 i f   ( u p d a t e   & &   p . s i n g l e C l i c k   & &   c a l . d a t e C l i c k e d )  
                         c a l . c a l l C l o s e H a n d l e r ( ) ;  
         } ;  
  
         i f   ( p a r a m s . f l a t   ! =   n u l l )   {  
                 i f   ( t y p e o f   p a r a m s . f l a t   = =   " s t r i n g " )  
                         p a r a m s . f l a t   =   d o c u m e n t . g e t E l e m e n t B y I d ( p a r a m s . f l a t ) ;  
                 / / 	 	 i f   ( ! p a r a m s . f l a t )   {  
                 / / 	 	 	 a l e r t ( " C a l e n d a r . s e t u p : \ n     F l a t   s p e c i f i e d   b u t   c a n ' t   f i n d   p a r e n t . " ) ;  
                 / / 	 	 	 r e t u r n   f a l s e ;  
                 / / 	 	 }  
                 v a r   c a l   =   n e w   C a l e n d a r ( p a r a m s . f i r s t D a y ,   p a r a m s . d a t e ,   p a r a m s . o n S e l e c t   | |   o n S e l e c t ) ;  
                 c a l . s h o w s O t h e r M o n t h s   =   p a r a m s . s h o w O t h e r s ;  
                 c a l . s h o w s T i m e   =   p a r a m s . s h o w s T i m e ;  
                 c a l . t i m e 2 4   =   ( p a r a m s . t i m e F o r m a t   = =   " 2 4 " ) ;  
                 c a l . p a r a m s   =   p a r a m s ;  
                 c a l . w e e k N u m b e r s   =   p a r a m s . w e e k N u m b e r s ;  
                 c a l . s e t R a n g e ( p a r a m s . r a n g e [ 0 ] ,   p a r a m s . r a n g e [ 1 ] ) ;  
                 c a l . s e t D a t e S t a t u s H a n d l e r ( p a r a m s . d a t e S t a t u s F u n c ) ;  
                 c a l . g e t D a t e T e x t   =   p a r a m s . d a t e T e x t ;  
                 i f   ( p a r a m s . i f F o r m a t )   {  
                         c a l . s e t D a t e F o r m a t ( p a r a m s . i f F o r m a t ) ;  
                 }  
                 i f   ( p a r a m s . i n p u t F i e l d   & &   t y p e o f   p a r a m s . i n p u t F i e l d . v a l u e   = =   " s t r i n g " )   {  
                         c a l . p a r s e D a t e ( p a r a m s . i n p u t F i e l d . v a l u e ) ;  
                 }  
                 c a l . c r e a t e ( p a r a m s . f l a t ) ;  
                 c a l . s h o w ( ) ;  
                 r e t u r n   f a l s e ;  
         }  
  
         v a r   t r i g g e r E l   =   p a r a m s . b u t t o n   | |   p a r a m s . d i s p l a y A r e a   | |   p a r a m s . i n p u t F i e l d ;  
         t r i g g e r E l [ " o n "   +   p a r a m s . e v e n t N a m e ]   =   f u n c t i o n ( )   {  
                 v a r   d a t e E l   =   p a r a m s . i n p u t F i e l d   | |   p a r a m s . d i s p l a y A r e a ;  
                 v a r   d a t e F m t   =   p a r a m s . i n p u t F i e l d   ?   p a r a m s . i f F o r m a t   :   p a r a m s . d a F o r m a t ;  
                 v a r   m u s t C r e a t e   =   f a l s e ;  
                 v a r   c a l   =   w i n d o w . c a l e n d a r ;  
                 i f   ( d a t e E l )  
                         p a r a m s . d a t e   =   D a t e . p a r s e D a t e ( d a t e E l . v a l u e   | |   d a t e E l . i n n e r H T M L ,   d a t e F m t ) ;  
                 i f   ( ! ( c a l   & &   p a r a m s . c a c h e ) )   {  
                         w i n d o w . c a l e n d a r   =   c a l   =   n e w   C a l e n d a r ( p a r a m s . f i r s t D a y ,  
 	 	 	 	 	 	 	           p a r a m s . d a t e ,  
 	 	 	 	 	 	 	           p a r a m s . o n S e l e c t   | |   o n S e l e c t ,  
 	 	 	 	 	 	 	           p a r a m s . o n C l o s e   | |   f u n c t i o n ( c a l )   {   c a l . h i d e ( ) ;   } ) ;  
                         c a l . s h o w s T i m e   =   p a r a m s . s h o w s T i m e ;  
                         c a l . t i m e 2 4   =   ( p a r a m s . t i m e F o r m a t   = =   " 2 4 " ) ;  
                         c a l . w e e k N u m b e r s   =   p a r a m s . w e e k N u m b e r s ;  
                         m u s t C r e a t e   =   t r u e ;  
                 }   e l s e   {  
                         i f   ( p a r a m s . d a t e )  
                                 c a l . s e t D a t e ( p a r a m s . d a t e ) ;  
                         c a l . h i d e ( ) ;  
                 }  
                 i f   ( p a r a m s . m u l t i p l e )   {  
                         c a l . m u l t i p l e   =   { } ;  
                         f o r   ( v a r   i   =   p a r a m s . m u l t i p l e . l e n g t h ;   - - i   > =   0 ;   )   {  
                                 v a r   d   =   p a r a m s . m u l t i p l e [ i ] ;  
                                 v a r   d s   =   d . p r i n t ( " % Y % m % d " ) ;  
                                 c a l . m u l t i p l e [ d s ]   =   d ;  
                         }  
                 }  
                 c a l . s h o w s O t h e r M o n t h s   =   p a r a m s . s h o w O t h e r s ;  
                 c a l . y e a r S t e p   =   p a r a m s . s t e p ;  
                 c a l . s e t R a n g e ( p a r a m s . r a n g e [ 0 ] ,   p a r a m s . r a n g e [ 1 ] ) ;  
                 c a l . p a r a m s   =   p a r a m s ;  
                 c a l . s e t D a t e S t a t u s H a n d l e r ( p a r a m s . d a t e S t a t u s F u n c ) ;  
                 c a l . g e t D a t e T e x t   =   p a r a m s . d a t e T e x t ;  
                 c a l . s e t D a t e F o r m a t ( d a t e F m t ) ;  
                 i f   ( m u s t C r e a t e )  
                         c a l . c r e a t e ( ) ;  
                 c a l . r e f r e s h ( ) ;  
                 i f   ( ! p a r a m s . p o s i t i o n )  
                         c a l . s h o w A t E l e m e n t ( p a r a m s . b u t t o n   | |   p a r a m s . d i s p l a y A r e a   | |   p a r a m s . i n p u t F i e l d ,   p a r a m s . a l i g n ) ;  
                 e l s e  
                         c a l . s h o w A t ( p a r a m s . p o s i t i o n [ 0 ] ,   p a r a m s . p o s i t i o n [ 1 ] ) ;  
                 r e t u r n   f a l s e ;  
         } ;  
         a l e r t ( c a l ) ;  
         r e t u r n   c a l ;  
 } ;  
 
