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