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