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