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