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