ÿþ 
    
                       v   a   r       a   l   l   M   o   n   t   h   =   [   3   1   ,       2   8   ,       3   1   ,       3   0   ,       3   1   ,       3   0   ,       3   1   ,       3   1   ,       3   0   ,       3   1   ,       3   0   ,       3   1   ]   ;    
    
                     v a r   a l l N a m e O f W e e k D a y s = [ "  N" , " ŒN" ,   " 	N" ,   " ÛV" ,   " ”N" ,   " mQ" ,   " åe" ] ;  
         	         v a r   a l l N a m e O f M o n t h s = [ "  Ng" , " ŒNg" , " 	Ng" , " ÛVg" , " ”Ng" , " mQg" , " Ng" , " kQg" , " ]Ng" , " ASg" , " AS Ng" , " ASŒNg" ] ;  
    
                       v   a   r       n   e   w   D   a   t   e   =   n   e   w       D   a   t   e   (   )   ;    
    
                       v   a   r       y   e   a   r   Z   e   r   o   =   n   e   w   D   a   t   e   .   g   e   t   F   u   l   l   Y   e   a   r   (   )   ;    
    
                       v   a   r       m   o   n   t   h   Z   e   r   o   =   n   e   w   D   a   t   e   .   g   e   t   M   o   n   t   h   (   )   ;    
    
                       v   a   r       d   a   y   =   n   e   w   D   a   t   e   .   g   e   t   D   a   t   e   (   )   ;    
    
                       v   a   r       c   u   r   r   e   n   t   D   a   y   =   0   ,       c   u   r   r   e   n   t   D   a   y   Z   e   r   o   =   0   ;    
    
                       v   a   r       m   o   n   t   h   =   m   o   n   t   h   Z   e   r   o   ,       y   e   a   r   =   y   e   a   r   Z   e   r   o   ;    
    
                       v   a   r       y   e   a   r   M   i   n   =   1   9   9   0   ,       y   e   a   r   M   a   x   =   2   0   1   0   ;    
    
                       v   a   r       t   a   r   g   e   t   =   '   '   ;    
    
                       v   a   r       h   o   v   e   r   E   l   e   =   f   a   l   s   e   ;    
    
                       f   u   n   c   t   i   o   n       s   e   t   T   a   r   g   e   t   (   e   )   {    
    
                                           i   f   (   e   )       r   e   t   u   r   n       e   .   t   a   r   g   e   t   ;    
    
                                           i   f   (   e   v   e   n   t   )       r   e   t   u   r   n       e   v   e   n   t   .   s   r   c   E   l   e   m   e   n   t   ;    
    
                       }    
    
                       f   u   n   c   t   i   o   n       n   e   w   E   l   e   m   e   n   t   (   t   y   p   e   ,       a   t   t   r   s   ,       c   o   n   t   e   n   t   ,       t   o   N   o   d   e   )       {    
    
                                           v   a   r       e   l   e   =   d   o   c   u   m   e   n   t   .   c   r   e   a   t   e   E   l   e   m   e   n   t   (   t   y   p   e   )   ;    
    
                                           i   f   (   a   t   t   r   s   )       {    
    
                                                               f   o   r   (   v   a   r       i   =   0   ;       i   <   a   t   t   r   s   .   l   e   n   g   t   h   ;       i   +   +   )       {    
    
                                                                                   e   v   a   l   (   '   e   l   e   .   '   +   a   t   t   r   s   [   i   ]   [   0   ]   +   (   a   t   t   r   s   [   i   ]   [   2   ]       ?       '   =   \   u   0   0   2   7   '       :   '   =   '   )   +   a   t   t   r   s   [   i   ]   [   1   ]   +   (   a   t   t   r   s   [   i   ]   [   2   ]       ?       '   \   u   0   0   2   7   '       :   '   '   )   )   ;    
    
                                                               }    
    
                                           }    
    
                                           i   f   (   c   o   n   t   e   n   t   )       e   l   e   .   a   p   p   e   n   d   C   h   i   l   d   (   d   o   c   u   m   e   n   t   .   c   r   e   a   t   e   T   e   x   t   N   o   d   e   (   c   o   n   t   e   n   t   )   )   ;    
    
                                           i   f   (   t   o   N   o   d   e   )       t   o   N   o   d   e   .   a   p   p   e   n   d   C   h   i   l   d   (   e   l   e   )   ;    
    
                                           r   e   t   u   r   n       e   l   e   ;    
    
                       }    
    
                       f   u   n   c   t   i   o   n       s   e   t   M   o   n   t   h   (   e   l   e   )   {   m   o   n   t   h   =   p   a   r   s   e   I   n   t   (   e   l   e   .   v   a   l   u   e   )   ;   c   a   l   e   n   d   e   r   (   )   }    
    
                       f   u   n   c   t   i   o   n       s   e   t   Y   e   a   r   (   e   l   e   )   {   y   e   a   r   =   p   a   r   s   e   I   n   t   (   e   l   e   .   v   a   l   u   e   )   ;   c   a   l   e   n   d   e   r   (   )   }    
    
                       f   u   n   c   t   i   o   n       s   e   t   V   a   l   u   e   (   e   l   e   )       {    
    
                                           i   f   (   e   l   e   .   p   a   r   e   n   t   N   o   d   e   .   c   l   a   s   s   N   a   m   e   =   =   '   w   e   e   k   '       &   &       e   l   e   .   f   i   r   s   t   C   h   i   l   d   )   {    
    
                                                               v   a   r       d   a   y   O   u   t   =   e   l   e   .   f   i   r   s   t   C   h   i   l   d   .   n   o   d   e   V   a   l   u   e   ;    
    
                                                               i   f   (   d   a   y   O   u   t       <       1   0   )       d   a   y   O   u   t   =   '   0   '   +   d   a   y   O   u   t   ;    
    
                                                               v   a   r       m   o   n   t   h   O   u   t   =   m   o   n   t   h   +   1   ;    
    
                                                               i   f   (   m   o   n   t   h   O   u   t       <       1   0   )       m   o   n   t   h   O   u   t   =   '   0   '   +   m   o   n   t   h   O   u   t   ;    
    
                                                               t   a   r   g   e   t   .   v   a   l   u   e   =   y   e   a   r       +       '   -   '       +       m   o   n   t   h   O   u   t       +       '   -   '       +       d   a   y   O   u   t   ;    
    
                                                               r   e   m   o   v   e   C   a   l   e   n   d   e   r   (   )   ;    
    
                                           }    
    
                       }    
    
                       f   u   n   c   t   i   o   n       r   e   m   o   v   e   C   a   l   e   n   d   e   r   (   )       {    
    
                                           v   a   r       p   a   r   e   n   t   E   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   a   l   e   n   d   e   r   "   )   ;    
    
                                           w   h   i   l   e   (   p   a   r   e   n   t   E   l   e   .   f   i   r   s   t   C   h   i   l   d   )       p   a   r   e   n   t   E   l   e   .   r   e   m   o   v   e   C   h   i   l   d   (   p   a   r   e   n   t   E   l   e   .   f   i   r   s   t   C   h   i   l   d   )   ;    
    
                                           d   o   c   u   m   e   n   t   .   g   e   t   E   l   e   m   e   n   t   B   y   I   d   (   '   b   a   s   i   s   '   )   .   p   a   r   e   n   t   N   o   d   e   .   r   e   m   o   v   e   C   h   i   l   d   (   d   o   c   u   m   e   n   t   .   g   e   t   E   l   e   m   e   n   t   B   y   I   d   (   '   b   a   s   i   s   '   )   )   ;    
    
                       }                                            
    
                       f   u   n   c   t   i   o   n       c   a   l   e   n   d   e   r   (   )       {    
    
                                           v   a   r       p   a   r   e   n   t   E   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   a   l   e   n   d   e   r   "   )   ;    
    
                                           p   a   r   e   n   t   E   l   e   .   o   n   m   o   u   s   e   o   v   e   r   =   f   u   n   c   t   i   o   n   (   e   )       {    
    
                                                               v   a   r       e   l   e   =   s   e   t   T   a   r   g   e   t   (   e   )   ;    
    
                                                               i   f   (   e   l   e   .   p   a   r   e   n   t   N   o   d   e   .   c   l   a   s   s   N   a   m   e   =   =   '   w   e   e   k   '       &   &       e   l   e   .   f   i   r   s   t   C   h   i   l   d       &   &       e   l   e   !   =   h   o   v   e   r   E   l   e   )       {    
    
                                                                                   i   f   (   h   o   v   e   r   E   l   e   )       h   o   v   e   r   E   l   e   .   c   l   a   s   s   N   a   m   e   =   h   o   v   e   r   E   l   e   .   c   l   a   s   s   N   a   m   e   .   r   e   p   l   a   c   e   (   /   h   o   v   e   r   E   l   e       ?   /   ,   '   '   )   ;    
    
                                                                                   h   o   v   e   r   E   l   e   =   e   l   e   ;    
    
                                                                                   e   l   e   .   c   l   a   s   s   N   a   m   e   =   '   h   o   v   e   r   E   l   e       '   +   e   l   e   .   c   l   a   s   s   N   a   m   e   ;    
    
                                                               }       e   l   s   e       {    
    
                                                                                   i   f   (   h   o   v   e   r   E   l   e   )       {    
    
                                                                                                       h   o   v   e   r   E   l   e   .   c   l   a   s   s   N   a   m   e   =   h   o   v   e   r   E   l   e   .   c   l   a   s   s   N   a   m   e   .   r   e   p   l   a   c   e   (   /   h   o   v   e   r   E   l   e       ?   /   ,   '   '   )   ;    
    
                                                                                                       h   o   v   e   r   E   l   e   =   f   a   l   s   e   ;    
    
                                                                                   }    
    
                                                               }    
    
                                           }    
    
                                           w   h   i   l   e   (   p   a   r   e   n   t   E   l   e   .   f   i   r   s   t   C   h   i   l   d   )       p   a   r   e   n   t   E   l   e   .   r   e   m   o   v   e   C   h   i   l   d   (   p   a   r   e   n   t   E   l   e   .   f   i   r   s   t   C   h   i   l   d   )   ;    
    
                                           f   u   n   c   t   i   o   n       c   h   e   c   k   (   )   {    
    
                                                               i   f   (   y   e   a   r   %   4   =   =   0   &   &   (   y   e   a   r   %   1   0   0   !   =   0   |   |   y   e   a   r   %   4   0   0   =   =   0   )   )   a   l   l   M   o   n   t   h   [   1   ]   =   2   9   ;    
    
                                                               e   l   s   e       a   l   l   M   o   n   t   h   [   1   ]   =   2   8   ;    
    
                                           }    
    
                                           f   u   n   c   t   i   o   n       a   d   d   C   l   a   s   s       (   n   a   m   e   )       {       i   f   (   !   c   u   r   r   e   n   t   C   l   a   s   s   )   {   c   u   r   r   e   n   t   C   l   a   s   s   =   n   a   m   e   }       e   l   s   e       {   c   u   r   r   e   n   t   C   l   a   s   s   +   =   '       '   +   n   a   m   e   }       }   ;    
    
                                           i   f   (   m   o   n   t   h       <       0   )   {   m   o   n   t   h   +   =   1   2   ;       y   e   a   r   -   =   1   }    
    
                                           i   f   (   m   o   n   t   h       >       1   1   )   {   m   o   n   t   h   -   =   1   2   ;       y   e   a   r   +   =   1   }    
    
                                           i   f   (   y   e   a   r   =   =   y   e   a   r   M   a   x   -   1   )       y   e   a   r   M   a   x   +   =   1   ;    
    
                                           i   f   (   y   e   a   r   =   =   y   e   a   r   M   i   n   )       y   e   a   r   M   i   n   -   =   1   ;    
    
                                           c   h   e   c   k   (   )   ;    
    
                                           v   a   r       c   o   n   t   r   o   l   =   n   e   w   E   l   e   m   e   n   t   (   '   p   '   ,   [   [   '   i   d   '   ,   '   c   o   n   t   r   o   l   '   ,   1   ]   ]   ,   f   a   l   s   e   ,   p   a   r   e   n   t   E   l   e   )   ;    
    
                                           v   a   r       c   o   n   t   r   o   l   P   l   u   s   =   n   e   w   E   l   e   m   e   n   t   (   '   a   '   ,       [   [   '   h   r   e   f   '   ,   '   j   a   v   a   s   c   r   i   p   t   :   m   o   n   t   h   -   -   ;   c   a   l   e   n   d   e   r   (   )   '   ,   1   ]   ,   [   '   c   l   a   s   s   N   a   m   e   '   ,   '   c   o   n   t   r   o   l   P   l   u   s   '   ,   1   ]   ]   ,       '   <   '   ,       c   o   n   t   r   o   l   )   ;    
    
                                           v   a   r       s   e   l   e   c   t   =   n   e   w   E   l   e   m   e   n   t   (   '   s   e   l   e   c   t   '   ,       [   [   '   o   n   c   h   a   n   g   e   '   ,   f   u   n   c   t   i   o   n   (   )   {   s   e   t   M   o   n   t   h   (   t   h   i   s   )   }   ]   ]   ,       f   a   l   s   e   ,       c   o   n   t   r   o   l   )   ;    
    
                                           f   o   r   (   v   a   r       i   =   0   ;       i   <   a   l   l   N   a   m   e   O   f   M   o   n   t   h   s   .   l   e   n   g   t   h   ;       i   +   +   )       n   e   w   E   l   e   m   e   n   t   (   '   o   p   t   i   o   n   '   ,       [   [   '   v   a   l   u   e   '   ,   i   ,   1   ]   ]   ,       a   l   l   N   a   m   e   O   f   M   o   n   t   h   s   [   i   ]   ,       s   e   l   e   c   t   )   ;    
    
                                           s   e   l   e   c   t   .   s   e   l   e   c   t   e   d   I   n   d   e   x   =   m   o   n   t   h   ;    
    
                                           s   e   l   e   c   t   =   n   e   w   E   l   e   m   e   n   t   (   '   s   e   l   e   c   t   '   ,       [   [   '   o   n   c   h   a   n   g   e   '   ,   f   u   n   c   t   i   o   n   (   )   {   s   e   t   Y   e   a   r   (   t   h   i   s   )   }   ]   ]   ,       f   a   l   s   e   ,       c   o   n   t   r   o   l   )   ;    
    
                                           f   o   r   (   v   a   r       i   =   y   e   a   r   M   i   n   ;       i   <   y   e   a   r   M   a   x   ;       i   +   +   )       n   e   w   E   l   e   m   e   n   t   (   '   o   p   t   i   o   n   '   ,       [   [   '   v   a   l   u   e   '   ,   i   ,   1   ]   ]   ,       i   ,       s   e   l   e   c   t   )   ;    
    
                                           s   e   l   e   c   t   .   s   e   l   e   c   t   e   d   I   n   d   e   x   =   y   e   a   r   -   y   e   a   r   M   i   n   ;    
    
                                           c   o   n   t   r   o   l   P   l   u   s   =   n   e   w   E   l   e   m   e   n   t   (   '   a   '   ,       [   [   '   h   r   e   f   '   ,   '   j   a   v   a   s   c   r   i   p   t   :   m   o   n   t   h   +   +   ;   c   a   l   e   n   d   e   r   (   )   '   ,   1   ]   ,   [   '   c   l   a   s   s   N   a   m   e   '   ,   '   c   o   n   t   r   o   l   P   l   u   s   '   ,   1   ]   ]   ,       '   >   '   ,       c   o   n   t   r   o   l   )   ;    
    
                                           c   h   e   c   k   (   )   ;    
    
                                           c   u   r   r   e   n   t   D   a   y   =   1   -   n   e   w       D   a   t   e   (   y   e   a   r   ,   m   o   n   t   h   ,   1   )   .   g   e   t   D   a   y   (   )   ;    
    
                                           i   f   (   c   u   r   r   e   n   t   D   a   y       >       0   )       c   u   r   r   e   n   t   D   a   y   -   =   7   ;    
    
                                           c   u   r   r   e   n   t   D   a   y   Z   e   r   o   =   c   u   r   r   e   n   t   D   a   y   ;    
    
                                           v   a   r       n   e   w   M   o   n   t   h   =   n   e   w   E   l   e   m   e   n   t   (   '   t   a   b   l   e   '   ,   [   [   '   c   e   l   l   S   p   a   c   i   n   g   '   ,   0   ,   1   ]   ,   [   '   o   n   c   l   i   c   k   '   ,   f   u   n   c   t   i   o   n   (   e   )   {   s   e   t   V   a   l   u   e   (   s   e   t   T   a   r   g   e   t   (   e   )   )   }   ]   ]   ,       f   a   l   s   e   ,       p   a   r   e   n   t   E   l   e   )   ;    
    
                                           v   a   r       n   e   w   M   o   n   t   h   B   o   d   y   =   n   e   w   E   l   e   m   e   n   t   (   '   t   b   o   d   y   '   ,       f   a   l   s   e   ,       f   a   l   s   e   ,       n   e   w   M   o   n   t   h   )   ;    
    
                                           v   a   r       t   r   =   n   e   w   E   l   e   m   e   n   t   (   '   t   r   '   ,       [   [   '   c   l   a   s   s   N   a   m   e   '   ,   '   h   e   a   d   '   ,   1   ]   ]   ,       f   a   l   s   e   ,       n   e   w   M   o   n   t   h   B   o   d   y   )   ;    
    
                                           t   r   =   n   e   w   E   l   e   m   e   n   t   (   '   t   r   '   ,       [   [   '   c   l   a   s   s   N   a   m   e   '   ,   '   w   e   e   k   d   a   y   s   '   ,   1   ]   ]   ,       f   a   l   s   e   ,       n   e   w   M   o   n   t   h   B   o   d   y   )   ;    
    
                                           f   o   r   (   i   =   0   ;   i   <   7   ;   i   +   +   )       t   d   =   n   e   w   E   l   e   m   e   n   t   (   '   t   d   '   ,       f   a   l   s   e   ,       a   l   l   N   a   m   e   O   f   W   e   e   k   D   a   y   s   [   i   ]   ,       t   r   )   ;                        
    
                                           t   r   =   n   e   w   E   l   e   m   e   n   t   (   '   t   r   '   ,       [   [   '   c   l   a   s   s   N   a   m   e   '   ,   '   w   e   e   k   '   ,   1   ]   ]   ,       f   a   l   s   e   ,       n   e   w   M   o   n   t   h   B   o   d   y   )   ;    
    
                                           f   o   r   (   i   =   0   ;       i   <   a   l   l   M   o   n   t   h   [   m   o   n   t   h   ]   -   c   u   r   r   e   n   t   D   a   y   Z   e   r   o   ;       i   +   +   )   {    
    
                                                               v   a   r       c   u   r   r   e   n   t   C   l   a   s   s   =   f   a   l   s   e   ;                                                                
    
                                                               c   u   r   r   e   n   t   D   a   y   +   +   ;    
    
                                                               i   f   (   c   u   r   r   e   n   t   D   a   y   =   =   d   a   y       &   &       m   o   n   t   h   =   =   m   o   n   t   h   Z   e   r   o       &   &       y   e   a   r   =   =   y   e   a   r   Z   e   r   o   )       a   d   d   C   l   a   s   s       (   '   t   o   d   a   y   '   )   ;    
    
                                                               i   f   (   c   u   r   r   e   n   t   D   a   y       <   =       0       )       {    
    
                                                                                   i   f   (   c   u   r   r   e   n   t   D   a   y   Z   e   r   o   !   =   -   7   )       t   d   =   n   e   w   E   l   e   m   e   n   t   (   '   t   d   '   ,       f   a   l   s   e   ,       f   a   l   s   e   ,       t   r   )   ;    
    
                                                               }    
    
                                                               e   l   s   e       {    
    
                                                                                   i   f   (   (   c   u   r   r   e   n   t   D   a   y   -   c   u   r   r   e   n   t   D   a   y   Z   e   r   o   )   %   7   =   =   0   )       a   d   d   C   l   a   s   s       (   '   h   o   l   i   d   a   y   '   )   ;    
    
                                                                                   t   d   =   n   e   w   E   l   e   m   e   n   t   (   '   t   d   '   ,       (   !   c   u   r   r   e   n   t   C   l   a   s   s       ?       f   a   l   s   e       :       [   [   '   c   l   a   s   s   N   a   m   e   '   ,   c   u   r   r   e   n   t   C   l   a   s   s   ,   1   ]   ]       )   ,       c   u   r   r   e   n   t   D   a   y   ,       t   r   )   ;    
    
                                                                                   i   f   (   (   c   u   r   r   e   n   t   D   a   y   -   c   u   r   r   e   n   t   D   a   y   Z   e   r   o   )   %   7   =   =   0   )       t   r   =   n   e   w   E   l   e   m   e   n   t   (   '   t   r   '   ,       [   [   '   c   l   a   s   s   N   a   m   e   '   ,   '   w   e   e   k   '   ,   1   ]   ]   ,       f   a   l   s   e   ,       n   e   w   M   o   n   t   h   B   o   d   y   )   ;    
    
                                                               }    
    
                                                               i   f   (   i   =   =   a   l   l   M   o   n   t   h   [   m   o   n   t   h   ]   -   c   u   r   r   e   n   t   D   a   y   Z   e   r   o   -   1   )   {    
    
                                                                                   i   +   +   ;    
    
                                                                                   w   h   i   l   e   (   i   %   7   !   =   0   )   {   i   +   +   ;   t   d   =   n   e   w   E   l   e   m   e   n   t   (   '   t   d   '   ,       f   a   l   s   e   ,       f   a   l   s   e   ,       t   r   )   }   ;    
    
                                                               }    
    
                                           }    
    
                       }    
    
                       f   u   n   c   t   i   o   n       s   h   o   w   C   a   l   e   n   d   e   r   (   e   l   e   ,   t   a   r   g   e   t   I   D   )       {    
    
                                           i   f   (   d   o   c   u   m   e   n   t   .   g   e   t   E   l   e   m   e   n   t   B   y   I   d   (   '   b   a   s   i   s   '   )   )       {       r   e   m   o   v   e   C   a   l   e   n   d   e   r   (   )       }    
    
                                           e   l   s   e       {    
    
                                                               t   a   r   g   e   t   =   d   o   c   u   m   e   n   t   .   g   e   t   E   l   e   m   e   n   t   B   y   I   d   (   t   a   r   g   e   t   I   D   )   ;        
    
                                                               v   a   r       b   a   s   i   s   =   e   l   e   .   p   a   r   e   n   t   N   o   d   e   .   i   n   s   e   r   t   B   e   f   o   r   e   (   d   o   c   u   m   e   n   t   .   c   r   e   a   t   e   E   l   e   m   e   n   t   (   '   d   i   v   '   )   ,   e   l   e   )   ;    
    
                                                               b   a   s   i   s   .   i   d   =   '   b   a   s   i   s   '   ;    
    
                                                               n   e   w   E   l   e   m   e   n   t   (   '   d   i   v   '   ,       [   [   '   i   d   '   ,   '   c   a   l   e   n   d   e   r   '   ,   1   ]   ]   ,       f   a   l   s   e   ,       b   a   s   i   s   )   ;    
    
                                                               c   a   l   e   n   d   e   r   (   )   ;    
    
                                           }    
    
                       }    
    
   
