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