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