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