ÿþ/ / D D   T a b   M e n u -   S c r i p t   r e w r i t t e n   A p r i l   2 7 t h ,   0 7 :   h t t p : / / w w w . d y n a m i c d r i v e . c o m  
 / / * * U p d a t e d   F e b   2 3 r d ,   0 8 ) :   A d d s   a b i l i t y   f o r   m e n u   t o   r e v e r t   b a c k   t o   d e f a u l t   s e l e c t e d   t a b   w h e n   m o u s e   m o v e s   o u t   o f   m e n u  
  
 / / O n l y   2   c o n f i g u r a t i o n   v a r i a b l e s   b e l o w :  
 f u n c t i o n   w r i t e C u r r e n t D a t e ( )  
 {  
 t o d a y = n e w   D a t e ( ) ;   / /   I n i t i a l i z e   D a t e   i n   r a w   f o r m  
 d a t e = t o d a y . g e t D a t e ( ) ;   / /   G e t   t h e   n u m e r i c a l   d a t e  
 y e a r = t o d a y . g e t Y e a r ( ) ;   / /   G e t   t h e   y e a r  
 d a y   =   t o d a y . g e t D a y ( ) ;   / /   G e t   t h e   d a y   i n   n u m b e r   f o r m   ( 0 , 1 , 2 , 3 , e t c . )  
 m o n t h = t o d a y . g e t M o n t h ( ) + 1 ;   / /   G e t   t h e   m o n t h  
  
 / /   M a k e   d a y   n u m b e r   v a l u e   c o r r e s p o n d   t o   a c t u a l   d a y   n a m e  
 v a r   d a y N a m e = n e w   A r r a y ( 7 )  
 d a y N a m e [ 0 ] = " C h ç  N h ­t " ;  
 d a y N a m e [ 1 ] = " T h é  H a i " ;  
 d a y N a m e [ 2 ] = " T h é  B a " ;  
 d a y N a m e [ 3 ] = " T h é  T °" ;  
 d a y N a m e [ 4 ] = " T h é  N m " ;  
 d a y N a m e [ 5 ] = " T h é  S á u " ;  
 d a y N a m e [ 6 ] = " T h é  B ©y " ;  
  
 / /   A d d   s u f f i x   t o   d a t e   ( 1 s t ,   2 n d ,   4 t h ,   e t c . )  
 i f   ( d a t e = = 1 )   s u f f i x = ( " s t " ) ;  
 e l s e   i f   ( d a t e = = 2 )   s u f f i x = ( " n d " ) ;  
 e l s e   i f   ( d a t e = = 3 )   s u f f i x = ( " r d " ) ;  
 e l s e   i f   ( d a t e = = 2 1 )   s u f f i x = ( " s t " ) ;  
 e l s e   i f   ( d a t e = = 2 2 )   s u f f i x = ( " n d " ) ;  
 e l s e   i f   ( d a t e = = 2 3 )   s u f f i x = ( " r d " ) ;  
 e l s e   i f   ( d a t e = = 3 1 )   s u f f i x = ( " s t " ) ;  
 e l s e   s u f f i x = ( " t h " ) ;  
  
 / /   M a k e   m o n t h   n u m b e r   c o r r e s p o n d   t o   m o n t h   n a m e  
 i f   ( m o n t h = = 1 )   m o n t h N a m e = ( " J a n u a r y " ) ;  
 e l s e   i f   ( m o n t h = = 2 )   m o n t h N a m e = ( " F e b r u a r y " ) ;  
 e l s e   i f   ( m o n t h = = 3 )   m o n t h N a m e = ( " M a r c h " ) ;  
 e l s e   i f   ( m o n t h = = 4 )   m o n t h N a m e = ( " A p r i l " ) ;  
 e l s e   i f   ( m o n t h = = 5 )   m o n t h N a m e = ( " M a y " ) ;  
 e l s e   i f   ( m o n t h = = 6 )   m o n t h N a m e = ( " J u n e " ) ;  
 e l s e   i f   ( m o n t h = = 7 )   m o n t h N a m e = ( " J u l y " ) ;  
 e l s e   i f   ( m o n t h = = 8 )   m o n t h N a m e = ( " A u g u s t " ) ;  
 e l s e   i f   ( m o n t h = = 9 )   m o n t h N a m e = ( " S e p t e m b e r " ) ;  
 e l s e   i f   ( m o n t h = = 1 0 )   m o n t h N a m e = ( " O c t o b e r " ) ;  
 e l s e   i f   ( m o n t h = = 1 1 )   m o n t h N a m e = ( " N o v e m b e r " ) ;  
 e l s e   m o n t h N a m e = ( " D e c e m b e r " ) ;  
  
 r e t u r n   d a y N a m e [ d a y ]   +   " ,   "   +   d a t e     +   " / "   +   m o n t h   +   " / "   +   y e a r ;  
 }  
  
 v a r   d d t a b m e n u = {  
 	 d i s a b l e t a b l i n k s :   f a l s e ,   / / D i s a b l e   h y p e r l i n k s   i n   1 s t   l e v e l   t a b s   w i t h   s u b   c o n t e n t s   ( t r u e   o r   f a l s e ) ?  
 	 s n a p 2 o r i g i n a l :   [ t r u e ,   3 0 0 ] ,   / / S h o u l d   t a b   r e v e r t   b a c k   t o   d e f a u l t   s e l e c t e d   w h e n   m o u s e   m o v e s   o u t   o f   m e n u ?   ( [ t r u e / f a l s e ,   d e l a y _ m i l l i s e c ]  
  
 	 c u r r e n t p a g e u r l :   w i n d o w . l o c a t i o n . h r e f . r e p l a c e ( " h t t p : / / " + w i n d o w . l o c a t i o n . h o s t n a m e ,   " " ) . r e p l a c e ( / ^ \ / / ,   " " ) ,   / / g e t   c u r r e n t   p a g e   u r l   ( m i n u s   h o s t n a m e ,   i e :   h t t p : / / w w w . d y n a m i c d r i v e . c o m / )  
  
 d e f i n e m e n u : f u n c t i o n ( t a b i d ,   d s e l e c t e d ) {  
 	 t h i s [ t a b i d + " - m e n u i t e m s " ] = n u l l  
 	 t h i s [ t a b i d + " - d s e l e c t e d " ] = - 1  
 	 t h i s . a d d E v e n t ( w i n d o w ,   f u n c t i o n ( ) { d d t a b m e n u . i n i t ( t a b i d ,   d s e l e c t e d ) } ,   " l o a d " )  
 } ,  
  
 s h o w s u b m e n u : f u n c t i o n ( t a b i d ,   t a r g e t i t e m ) {  
 	 v a r   m e n u i t e m s = t h i s [ t a b i d + " - m e n u i t e m s " ]  
 	 t h i s . c l e a r r e v e r t 2 d e f a u l t ( t a b i d )  
   f o r   ( i = 0 ;   i < m e n u i t e m s . l e n g t h ;   i + + ) {  
 	 	 m e n u i t e m s [ i ] . c l a s s N a m e = " "  
 	 	 i f   ( t y p e o f   m e n u i t e m s [ i ] . h a s S u b C o n t e n t ! = " u n d e f i n e d " )  
 	 	 	 d o c u m e n t . g e t E l e m e n t B y I d ( m e n u i t e m s [ i ] . g e t A t t r i b u t e ( " r e l " ) ) . s t y l e . d i s p l a y = " n o n e "  
 	 }  
 	 t a r g e t i t e m . c l a s s N a m e = " c u r r e n t "  
 	 i f   ( t y p e o f   t a r g e t i t e m . h a s S u b C o n t e n t ! = " u n d e f i n e d " )  
 	 	 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 t e m . g e t A t t r i b u t e ( " r e l " ) ) . s t y l e . d i s p l a y = " b l o c k "  
 } ,  
  
 i s S e l e c t e d : f u n c t i o n ( m e n u u r l ) {  
 	 v a r   m e n u u r l = m e n u u r l . r e p l a c e ( " h t t p : / / " + m e n u u r l . h o s t n a m e ,   " " ) . r e p l a c e ( / ^ \ / / ,   " " )  
 	 r e t u r n   ( d d t a b m e n u . c u r r e n t p a g e u r l = = m e n u u r l )  
 } ,  
  
 i s C o n t a i n e d : f u n c t i o n ( m ,   e ) {  
 	 v a r   e = w i n d o w . e v e n t   | |   e  
 	 v a r   c = e . r e l a t e d T a r g e t   | |   ( ( e . t y p e = = " m o u s e o v e r " ) ?   e . f r o m E l e m e n t   :   e . t o E l e m e n t )  
 	 w h i l e   ( c   & &   c ! = m ) t r y   { c = c . p a r e n t N o d e }   c a t c h ( e ) { c = m }  
 	 i f   ( c = = m )  
 	 	 r e t u r n   t r u e  
 	 e l s e  
 	 	 r e t u r n   f a l s e  
 } ,  
  
 r e v e r t 2 d e f a u l t : f u n c t i o n ( o u t o b j ,   t a b i d ,   e ) {  
 	 i f   ( ! d d t a b m e n u . i s C o n t a i n e d ( o u t o b j ,   t a b i d ,   e ) ) {  
 	 	 w i n d o w [ " h i d e t i m e r _ " + t a b i d ] = s e t T i m e o u t ( f u n c t i o n ( ) {  
 	 	 	 d d t a b m e n u . s h o w s u b m e n u ( t a b i d ,   d d t a b m e n u [ t a b i d + " - d s e l e c t e d " ] )  
 	 	 } ,   d d t a b m e n u . s n a p 2 o r i g i n a l [ 1 ] )  
 	 }  
 } ,  
  
 c l e a r r e v e r t 2 d e f a u l t : f u n c t i o n ( t a b i d ) {  
   i f   ( t y p e o f   w i n d o w [ " h i d e t i m e r _ " + t a b i d ] ! = " u n d e f i n e d " )  
 	 	 c l e a r T i m e o u t ( w i n d o w [ " h i d e t i m e r _ " + t a b i d ] )  
 } ,  
  
 a d d E v e n t : f u n c t i o n ( t a r g e t ,   f u n c t i o n r e f ,   t a s k t y p e ) {   / / a s s i g n   a   f u n c t i o n   t o   e x e c u t e   t o   a n   e v e n t   h a n d l e r   ( i e :   o n u n l o a d )  
 	 v a r   t a s k t y p e = ( w i n d o w . a d d E v e n t L i s t e n e r ) ?   t a s k t y p e   :   " o n " + t a s k t y p e  
 	 i f   ( t a r g e t . a d d E v e n t L i s t e n e r )  
 	 	 t a r g e t . a d d E v e n t L i s t e n e r ( t a s k t y p e ,   f u n c t i o n r e f ,   f a l s e )  
 	 e l s e   i f   ( t a r g e t . a t t a c h E v e n t )  
 	 	 t a r g e t . a t t a c h E v e n t ( t a s k t y p e ,   f u n c t i o n r e f )  
 } ,  
  
 i n i t : f u n c t i o n ( t a b i d ,   d s e l e c t e d ) {  
 	 v a r   m e n u i t e m s = d o c u m e n t . g e t E l e m e n t B y I d ( t a b i d ) . g e t E l e m e n t s B y T a g N a m e ( " a " )  
 	 t h i s [ t a b i d + " - m e n u i t e m s " ] = m e n u i t e m s  
 	 f o r   ( v a r   x = 0 ;   x < m e n u i t e m s . l e n g t h ;   x + + ) {  
 	 	 i f   ( m e n u i t e m s [ x ] . g e t A t t r i b u t e ( " r e l " ) ) {  
 	 	 	 t h i s [ t a b i d + " - m e n u i t e m s " ] [ x ] . h a s S u b C o n t e n t = t r u e  
 	 	 	 i f   ( d d t a b m e n u . d i s a b l e t a b l i n k s )  
 	 	 	 	 m e n u i t e m s [ x ] . o n c l i c k = f u n c t i o n ( ) { r e t u r n   f a l s e }  
 	 	 	 i f   ( d d t a b m e n u . s n a p 2 o r i g i n a l [ 0 ] = = t r u e ) {  
 	 	 	 	 v a r   s u b m e n u = d o c u m e n t . g e t E l e m e n t B y I d ( m e n u i t e m s [ x ] . g e t A t t r i b u t e ( " r e l " ) )  
 	 	 	 	 m e n u i t e m s [ x ] . o n m o u s e o u t = f u n c t i o n ( e ) { d d t a b m e n u . r e v e r t 2 d e f a u l t ( s u b m e n u ,   t a b i d ,   e ) }  
 	 	 	 	 s u b m e n u . o n m o u s e o v e r = f u n c t i o n ( ) { d d t a b m e n u . c l e a r r e v e r t 2 d e f a u l t ( t a b i d ) }  
 	 	 	 	 s u b m e n u . o n m o u s e o u t = f u n c t i o n ( e ) { d d t a b m e n u . r e v e r t 2 d e f a u l t ( t h i s ,   t a b i d ,   e ) }  
 	 	 	 }  
 	 	 }  
 	 	 e l s e   / / f o r   i t e m s   w i t h o u t   a   s u b m e n u ,   a d d   o n M o u s e o u t   e f f e c t  
 	 	 	 m e n u i t e m s [ x ] . o n m o u s e o u t = f u n c t i o n ( e ) { t h i s . c l a s s N a m e = " " ;   i f   ( d d t a b m e n u . s n a p 2 o r i g i n a l [ 0 ] = = t r u e )   d d t a b m e n u . r e v e r t 2 d e f a u l t ( t h i s ,   t a b i d ,   e ) }  
 	 	 m e n u i t e m s [ x ] . o n m o u s e o v e r = f u n c t i o n ( ) { d d t a b m e n u . s h o w s u b m e n u ( t a b i d ,   t h i s ) }  
 	 	 i f   ( d s e l e c t e d = = " a u t o "   & &   t y p e o f   s e t a l r e a d y = = " u n d e f i n e d "   & &   t h i s . i s S e l e c t e d ( m e n u i t e m s [ x ] . h r e f ) ) {  
 	 	 	 d d t a b m e n u . s h o w s u b m e n u ( t a b i d ,   m e n u i t e m s [ x ] )  
 	 	 	 t h i s [ t a b i d + " - d s e l e c t e d " ] = m e n u i t e m s [ x ]  
 	 	 	 v a r   s e t a l r e a d y = t r u e  
 	 	 }  
 	 	 e l s e   i f   ( p a r s e I n t ( d s e l e c t e d ) = = x ) {  
 	 	 	 d d t a b m e n u . s h o w s u b m e n u ( t a b i d ,   m e n u i t e m s [ x ] )  
 	 	 	 t h i s [ t a b i d + " - d s e l e c t e d " ] = m e n u i t e m s [ x ]  
 	 	 }  
 	 }  
 }  
 } 
