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