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