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