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