ÿþ/ / /   < r e f e r e n c e   p a t h = " j q u e r y - v s d o c . j s "   / >  
  
 v a r   l o a d e r H T M L   =   " < d i v   c l a s s = \ " p w L o a d e r \ "   s t y l e = \ " z - i n d e x :   9 9 9 9 9 9 9 9 9 9 9 ; \ " > < d i v > < i m g   s r c = \ " h t t p : / / i m g . l a v v a . c o m / a j a x - l o a d e r - n e w . g i f \ "   a l t = \ " P l e a s e   w a i t . \ "   w i d t h = \ " 3 2 \ "   h e i g h t = \ " 3 2 \ "   / > < / d i v > < / d i v > " ;  
  
 v a r   a j a x L o a d e r H T M L   =   " < d i v   c l a s s = \ " l o a d W r a p p e r \ " > < d i v   c l a s s = \ " l o a d I n n e r O f f s e t \ " > < d i v   c l a s s = \ " l o a d C o n t a i n e r \ " > < i m g   s r c = \ " h t t p : / / i m g . l a v v a . c o m / a j a x - l o a d e r - n e w . g i f \ "   a l t = \ " P l e a s e   w a i t . \ "   / > < / d i v > < / d i v > < / d i v > " ;  
  
 v a r   n e w M e s s a g e s B l i c k i n g T i m e r ;  
 f u n c t i o n   f i r e E v e n t ( e l e m e n t ,   e v e n t )   {  
         i f   ( d o c u m e n t . c r e a t e E v e n t O b j e c t )   {  
                 / /   d i s p a t c h   f o r   I E  
                 v a r   e v t   =   d o c u m e n t . c r e a t e E v e n t O b j e c t ( ) ;  
                 r e t u r n   e l e m e n t . f i r e E v e n t ( ' o n '   +   e v e n t ,   e v t ) ;  
         }  
         e l s e   {  
                 / /   d i s p a t c h   f o r   f i r e f o x   +   o t h e r s  
                 v a r   e v t   =   d o c u m e n t . c r e a t e E v e n t ( " M o u s e E v e n t s " ) ;  
                 e v t . i n i t E v e n t ( e v e n t ,   t r u e ,   t r u e ) ;   / /   e v e n t   t y p e , b u b b l i n g , c a n c e l a b l e  
                 / / e v t . i n i t M o u s e E v e n t ( e v e n t ,   t r u e ,   t r u e ,   w i n d o w ,   0 ,   0 ,   0 ,   0 ,   0 ,   f a l s e ,  
                 / /     f a l s e ,   f a l s e ,   f a l s e ,   0 ,   n u l l ) ;  
                 r e t u r n   ! e l e m e n t . d i s p a t c h E v e n t ( e v t ) ;  
         }  
 }  
  
 f u n c t i o n   r a t e A d v ( s e n d e r ,   a d v I d ,   i s I n c r e a s e ,   p w W n d S e n d e r )   {  
         $ . p o s t ( " h t t p : / / w w w . l a v v a . c o m / S e r v i c e s / L a v v a S e r v i c e . a s h x ? m e t h = R A T E A D V " ,   {   a d v I d :   a d v I d ,   i n c r e a s e :   i s I n c r e a s e   } ,   f u n c t i o n   ( r e s u l t )   {   o n R a t e A d v ( r e s u l t ,   s e n d e r ,   p w W n d S e n d e r ) ;   } ,   " j s o n " ) ;  
 }  
  
 v a r   G e o L o c a t i o n S e r v i c e   =   {  
         c l i e n t I p S e r v i c e S i t e :   " h t t p : / / j s o n i p . a p p s p o t . c o m / " ,  
         c l i e n t I p :   n u l l ,  
         P u t U s e r G e o l o c a t i o n :   f u n c t i o n   ( )   {  
                 G e o L o c a t i o n S e r v i c e . G e t C u r r e n t C l i e n t I p ( f u n c t i o n   ( )   {  
                         $ . p o s t ( " h t t p : / / w w w . l a v v a . c o m / S e r v i c e s / L a v v a S e r v i c e . a s h x ? m e t h = P u t U s e r G e o L o c a t i o n " ,  
                                         {   " c l i e n t I p " :   G e o L o c a t i o n S e r v i c e . c l i e n t I p ,  
                                                 " u " :   d o c u m e n t . l o c a t i o n . h r e f  
                                         } ,  
                                         n u l l ,  
                                         " j s o n " ) ;  
                 } ) ;  
  
         } ,  
         G e t C u r r e n t C l i e n t I p :   f u n c t i o n   ( o n s u c c e s s )   {  
                 i f   ( G e o L o c a t i o n S e r v i c e . c l i e n t I p   ! =   n u l l )   {  
                         o n s u c c e s s ( ) ;  
                         r e t u r n ;  
                 }  
                 i f   ( $ . b r o w s e r . m s i e   & &   w i n d o w . X D o m a i n R e q u e s t )   {  
                         / / c r o s s - d o m a i n   r e q u e s t  
                         v a r   x d r   =   n e w   w i n d o w . X D o m a i n R e q u e s t ;  
                         i f   ( x d r   ! =   n u l l )   {  
                                 x d r . o n l o a d   =   f u n c t i o n   ( )   {  
                                         v a r   r a w d a t a   =   x d r . r e s p o n s e T e x t ;  
                                         v a r   j s o n D a t a   =   $ . p a r s e J S O N ( r a w d a t a ) ;  
                                         G e o L o c a t i o n S e r v i c e . c l i e n t I p   =   j s o n D a t a . i p ;  
                                         o n s u c c e s s ( ) ;  
                                 }  
                                 x d r . o p e n ( " g e t " ,   G e o L o c a t i o n S e r v i c e . c l i e n t I p S e r v i c e S i t e ) ;  
                                 x d r . s e n d ( ) ;  
                         }  
                 }  
                 e l s e   {  
                         $ . g e t ( G e o L o c a t i o n S e r v i c e . c l i e n t I p S e r v i c e S i t e ,   n u l l ,   f u n c t i o n   ( r e s u l t )   {  
                                 G e o L o c a t i o n S e r v i c e . c l i e n t I p   =   r e s u l t . i p ;  
                                 o n s u c c e s s ( ) ;  
                         } ,   " j s o n " ) ;  
                 }  
         }  
 } ;  
  
  
  
 f u n c t i o n   o n R a t e A d v ( r e s u l t ,   s e n d e r ,   p w W n d S e n d e r )   {  
         v a r   l e f t   =   $ ( p w W n d S e n d e r   ?   p w W n d S e n d e r   :   s e n d e r ) . o f f s e t ( ) . l e f t ;  
         v a r   t o p   =   $ ( p w W n d S e n d e r   ?   p w W n d S e n d e r   :   s e n d e r ) . o f f s e t ( ) . t o p ;  
  
         / /   e r r o r   o c c u r e d  
         i f   ( r e s u l t [ 0 ] )   {  
         }  
         / /   n o   e r r o r  
         e l s e   {  
         }  
         s h o w M e s s a g e B o x ( r e s u l t [ 1 ] ,   t o p ,   l e f t ) ;  
 }  
  
 f u n c t i o n   S e t S O ( e ,   h i d d e n I D )   {  
  
         v a r   i e b o d y   =   ( d o c u m e n t . c o m p a t M o d e   & &   d o c u m e n t . c o m p a t M o d e   ! =   " B a c k C o m p a t " )   ?   d o c u m e n t . d o c u m e n t E l e m e n t   :   d o c u m e n t . b o d y ;  
  
         v a r   d s o c l e f t   =   d o c u m e n t . a l l   ?   i e b o d y . s c r o l l L e f t   :   p a g e X O f f s e t ;  
         v a r   d s o c t o p   =   d o c u m e n t . a l l   ?   i e b o d y . s c r o l l T o p   :   p a g e Y O f f s e t ;  
  
         v a r   m o u s e D o w n E v e n t   =   ( e )   ?   e   :   ( w i n d o w . e v e n t )   ?   w i n d o w . e v e n t   :   n u l l ;  
  
         v a r   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 ( ' t b l M a i n ' ) ;  
  
         v a r   c l i c k X   =   d s o c l e f t   +   m o u s e D o w n E v e n t . c l i e n t X   -   c o n t a i n e r . o f f s e t L e f t ;  
         v a r   c l i c k Y   =   d s o c t o p   +   m o u s e D o w n E v e n t . c l i e n t Y   -   c o n t a i n e r . o f f s e t T o p ;  
  
         v a r   p x H e i g h t   =   w i n d o w . d o c u m e n t . b o d y . c l i e n t H e i g h t ;  
         v a r   p x W i d t h   =   w i n d o w . d o c u m e n t . b o d y . c l i e n t W i d t h ;  
  
         v a r   h i d d e n O b j   =   d o c u m e n t . g e t E l e m e n t B y I d ( h i d d e n I D ) ;  
         v a r   h i d V a l   =   ' '   +   d s o c l e f t   +   ' : '   +   d s o c t o p   +   ' ; '   +   c l i c k X   +   ' : '   +   c l i c k Y   +   ' ; '   +   p x W i d t h   +   ' : '   +   p x H e i g h t ;  
  
         h i d d e n O b j . v a l u e   =   h i d V a l ;  
 }  
  
 f u n c t i o n   S e t E l O f f s e t ( h i d d e n I D ,   e l I d ,   c o n t a i n e r I d ,   p a r a m 1 ,   p a r a m 2 )   {  
         v a r   h i d d e n O b j   =   d o c u m e n t . g e t E l e m e n t B y I d ( h i d d e n I D ) ;  
         v a r   e l O b j   =   d o c u m e n t . g e t E l e m e n t B y I d ( e l I d ) ;  
         v a r   c o n t a i n e r O b j   =   d o c u m e n t . g e t E l e m e n t B y I d ( c o n t a i n e r I d ) ;  
  
         v a r   h i d V a l   =   ' '   +   A b s P o s i t i o n ( e l O b j ) . x   +   ' : '   +   A b s P o s i t i o n ( e l O b j ) . y   +   ' ; '   +   e l O b j . w i d t h   +   ' : '   +   e l O b j . h e i g h t   +   ' ; '   +   A b s P o s i t i o n ( c o n t a i n e r O b j ) . x   +   ' : '   +   A b s P o s i t i o n ( c o n t a i n e r O b j ) . y   +   ' ; '   +   p a r a m 1   +   ' : '   +   p a r a m 2 ;  
         / / a l e r t ( c o n t a i n e r I d   +   '   '   +   c o n t a i n e r O b j ) ;  
         / / a l e r t ( h i d V a l ) ;  
         h i d d e n O b j . v a l u e   =   h i d V a l ;  
 }  
  
 f u n c t i o n   A b s P o s i t i o n ( o b j )   {  
         v a r   x   =   y   =   0 ;  
         w h i l e   ( o b j )   {  
                 x   + =   o b j . o f f s e t L e f t ;  
                 y   + =   o b j . o f f s e t T o p ;  
                 o b j   =   o b j . o f f s e t P a r e n t ;  
         }  
         r e t u r n   {   x :   x ,   y :   y   } ;  
 }  
  
 f u n c t i o n   O n C u s t o m E n t e r ( e ,   h a n d l e r )   {  
         v a r   e v t   =   ( e )   ?   e   :   ( w i n d o w . e v e n t )   ?   w i n d o w . e v e n t   :   n u l l ;  
         i f   ( e v t )   {  
                 v a r   k e y   =   ( e v t . c h a r C o d e )   ?   e v t . c h a r C o d e   :   ( ( e v t . k e y C o d e )   ?   e v t . k e y C o d e   :   ( ( e v t . w h i c h )   ?   e v t . w h i c h   :   0 ) ) ;  
                 i f   ( k e y   = =   1 0   | |   k e y   = =   1 3 )   {  
                         i f   ( t y p e o f   ( h a n d l e r )   = =   ' f u n c t i o n ' )  
                                 h a n d l e r ( ) ;  
                         e l s e   i f   ( h a n d l e r )   {  
                                 f i r e E v e n t ( $ g e t ( h a n d l e r ) ,   ' c l i c k ' ) ;  
                         }  
                 }  
         }  
 }  
  
 f u n c t i o n   S h o w S t a t i s t i c ( )   {  
         v a r   s t a t W i n d   =   w i n d o w . o p e n ( ' ' ,   ' s t a t i s t i c ' ,   ' w i d t h = 1 0 2 4 , h e i g h t = 5 5 0 , r e s i z a b l e = 1 , s c r o l l b a r s = 1 ' ) ;  
         s t a t W i n d . d o c u m e n t . w r i t e ( h t m l S t a t i s t i c s ) ;  
 }  
  
 f u n c t i o n   H i d e M e s s a g e B o x ( i d )   {  
         v a r   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 d ) ;  
         i f   ( c o n t a i n e r   ! =   n u l l )   {  
                 H i d e D O M E l e m e n t ( c o n t a i n e r ) ;  
                 c l e a r T i m e o u t ( m e s s a g e T i m e r ) ;  
         }  
 }  
  
 f u n c t i o n   H i d e D O M E l e m e n t ( d o m E l t )   {  
         i f   ( d o m E l t   ! =   n u l l )   {  
                 d o m E l t . d i s a b l e d   =   t r u e ;  
                 d o m E l t . s t y l e . c u r s o r   =   ' d e f a u l t ' ;  
                 d o m E l t . s t y l e . d i s p l a y   =   ' n o n e ' ;  
         }  
 }  
  
 f u n c t i o n   E n a b l e S c r o l l B a r s ( d o m E l t )   {  
         i f   ( d o m E l t   ! =   n u l l )   {  
                 d o m E l t . v a l u e O f   =   ' ' ;  
         }  
 }  
  
 v a r   m e s s a g e T i m e r ;  
 f u n c t i o n   H i d e M e s s a g e B o x T i m e o u t ( i d ,   t i m e o u t )   {  
         m e s s a g e T i m e r   =   s e t T i m e o u t ( f u n c t i o n   ( )   {   H i d e M e s s a g e B o x ( i d ) ;   } ,   t i m e o u t ) ;  
 }  
  
 f u n c t i o n   s a v e S c r o l l P o s ( C l i e n t I D ,   S c r o l l X I n p u t I d ,   S c r o l l Y I n p u t I d )   {  
         i f   ( C l i e n t I D   ! =   ' u n d e f i n e d '   & &   C l i e n t I D   ! =   n u l l )   {  
                 v a r   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 ( C l i e n t I D ) ;  
                 i f   ( c o n t a i n e r   ! =   n u l l )   {  
                         i f   ( S c r o l l X I n p u t I d   ! =   ' u n d e f i n e d '   & &   S c r o l l X I n p u t I d   ! =   n u l l )   {  
                                 v a r   h x   =   d o c u m e n t . g e t E l e m e n t B y I d ( S c r o l l X I n p u t I d ) ;  
                                 i f   ( h x   ! =   n u l l )   {  
                                         h x . v a l u e   =   c o n t a i n e r . s c r o l l L e f t ;  
                                 }  
                         }  
  
                         i f   ( S c r o l l Y I n p u t I d   ! =   ' u n d e f i n e d '   & &   S c r o l l Y I n p u t I d   ! =   n u l l )   {  
                                 v a r   v x   =   d o c u m e n t . g e t E l e m e n t B y I d ( S c r o l l Y I n p u t I d ) ;  
                                 i f   ( v x   ! =   n u l l )   {  
                                         v x . v a l u e   =   c o n t a i n e r . s c r o l l T o p ;  
                                 }  
                         }  
                 }  
         }  
 }  
  
 f u n c t i o n   s e t S c r o l l P o s ( C l i e n t I D ,   S c r o l l X I n p u t I d ,   S c r o l l Y I n p u t I d )   {  
         i f   ( C l i e n t I D   ! =   ' u n d e f i n e d '   & &   C l i e n t I D   ! =   n u l l )   {  
                 v a r   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 ( C l i e n t I D ) ;  
                 i f   ( c o n t a i n e r   ! =   n u l l )   {  
                         i f   ( S c r o l l X I n p u t I d   ! =   ' u n d e f i n e d '   & &   S c r o l l X I n p u t I d   ! =   n u l l )   {  
                                 v a r   h x   =   d o c u m e n t . g e t E l e m e n t B y I d ( S c r o l l X I n p u t I d ) ;  
                                 i f   ( h x   ! =   n u l l )   {  
                                         c o n t a i n e r . s c r o l l L e f t   =   h x . v a l u e ;  
                                 }  
                         }  
  
                         i f   ( S c r o l l Y I n p u t I d   ! =   ' u n d e f i n e d '   & &   S c r o l l Y I n p u t I d   ! =   n u l l )   {  
                                 v a r   v x   =   d o c u m e n t . g e t E l e m e n t B y I d ( S c r o l l Y I n p u t I d ) ;  
                                 i f   ( v x   ! =   n u l l )   {  
                                         c o n t a i n e r . s c r o l l T o p   =   v x . v a l u e ;  
                                 }  
                         }  
                 }  
         }  
 }  
  
 f u n c t i o n   s w i t c h T o ( f r o m I d ,   t o I d )   {  
         d o c u m e n t . g e t E l e m e n t B y I d ( f r o m I d ) . s t y l e . d i s p l a y   =   ' n o n e ' ;  
         d o c u m e n t . g e t E l e m e n t B y I d ( t o I d ) . s t y l e . d i s p l a y   =   ' b l o c k ' ;  
 }  
  
 f u n c t i o n   S e t F o c u s ( c o n t r o l I d )   {  
         v a r   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 ( c o n t r o l I d ) ;  
         i f   ( c o n t a i n e r   ! =   n u l l )   {  
                 c o n t a i n e r . o n l o a d   =   s e t T i m e o u t ( " S e t u p F o c u s ( ' "   +   c o n t r o l I d   +   " ' ) ; " ,   1 0 0 0 ) ;  
         }  
 }  
  
 f u n c t i o n   S e t u p F o c u s ( c o n t a i n e r )   {  
         v a r   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 ( c o n t r o l I d ) ;  
         c o n t a i n e r . f o c u s ( ) ;  
 }  
  
 f u n c t i o n   s h o w C e n t e r Y ( e l e m e n t I d )   {  
         v a r   e l t   =   d o c u m e n t . g e t E l e m e n t B y I d ( e l e m e n t I d ) ;  
         i f   ( e l t   ! =   n u l l )   {  
                 v a r   p o i n t   =   w i n d o w . c e n t e r ( {   w i d t h :   e l t . s t y l e . w i d t h ,   h e i g h t :   e l t . s t y l e . h e i g h t   } ) ;  
                 e l t . s t y l e . p o s i t i o n   =   " a b s o l u t e " ;  
                 e l t . s t y l e . t o p   =   p o i n t . y   +   " p x " ;  
         }  
 }  
  
 f u n c t i o n   s t a r t P o l l i n g ( e l e m e n t L e f t I d ,   e l e m e n t R i g h t I d )   {  
         s e t I n t e r v a l ( " p o l l ( ' "   +   e l e m e n t L e f t I d   +   " ' ) " ,   5 0 0 ) ;  
         s e t I n t e r v a l ( " p o l l ( ' "   +   e l e m e n t R i g h t I d   +   " ' ) " ,   5 0 0 ) ;  
 }  
  
 f u n c t i o n   p o l l ( e l e m e n t I d )   {  
         s h o w C e n t e r Y ( e l e m e n t I d ) ;  
         r e t u r n   t r u e ;  
 }  
  
 w i n d o w . s i z e   =   f u n c t i o n   ( )   {  
         v a r   w   =   0 ;  
         v a r   h   =   0 ;  
  
         / / I E  
         i f   ( ! w i n d o w . i n n e r W i d t h )   {  
                 / / s t r i c t   m o d e  
                 i f   ( ! ( 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 W i d t h   = =   0 ) )   {  
                         w   =   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 W i d t h ;  
                         h   =   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 ;  
                 }  
                 / / q u i r k s   m o d e  
                 e l s e   {  
                         w   =   d o c u m e n t . b o d y . c l i e n t W i d t h ;  
                         h   =   d o c u m e n t . b o d y . c l i e n t H e i g h t ;  
                 }  
         }  
         / / w 3 c  
         e l s e   {  
                 w   =   w i n d o w . i n n e r W i d t h ;  
                 h   =   w i n d o w . i n n e r H e i g h t ;  
         }  
         r e t u r n   {   w i d t h :   w ,   h e i g h t :   h   } ;  
 } ;  
  
 w i n d o w . c e n t e r   =   f u n c t i o n   ( )   {  
         v a r   h W n d   =   ( a r g u m e n t s [ 0 ]   ! =   n u l l )   ?   a r g u m e n t s [ 0 ]   :   {   w i d t h :   0 ,   h e i g h t :   0   } ;  
  
         v a r   _ x   =   0 ;  
         v a r   _ y   =   0 ;  
         v a r   o f f s e t X   =   0 ;  
         v a r   o f f s e t Y   =   0 ;  
  
         / / I E  
         i f   ( ! w i n d o w . p a g e Y O f f s e t )   {  
                 / / s t r i c t   m o d e  
                 i f   ( ! ( 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   = =   0 ) )   {  
                         o f f s e t Y   =   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 ;  
                         o f f s e t X   =   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 ;  
                 }  
                 / / q u i r k s   m o d e  
                 e l s e   {  
                         o f f s e t Y   =   d o c u m e n t . b o d y . s c r o l l T o p ;  
                         o f f s e t X   =   d o c u m e n t . b o d y . s c r o l l L e f t ;  
                 }  
         }  
         / / w 3 c  
         e l s e   {  
                 o f f s e t X   =   w i n d o w . p a g e X O f f s e t ;  
                 o f f s e t Y   =   w i n d o w . p a g e Y O f f s e t ;  
         }  
  
         _ x   =   ( ( t h i s . s i z e ( ) . w i d t h   -   h W n d . w i d t h )   /   2 )   +   o f f s e t X ;  
         _ y   =   ( ( t h i s . s i z e ( ) . h e i g h t   -   h W n d . h e i g h t )   /   2 )   +   o f f s e t Y ;  
  
         r e t u r n   {   x :   _ x ,   y :   _ y   } ;  
 } ;  
  
 f u n c t i o n   C r e a t e D i v ( )   {  
         v a r   h   =   d o c u m e n t . b o d y . c l i e n t H e i g h t   +   d o c u m e n t . b o d y . s c r o l l T o p ;  
  
         v a r   e l t   =   d o c u m e n t . g e t E l e m e n t B y I d ( ' u p M a i n ' ) ;  
         i f   ( e l t   ! =   n u l l )   {  
                 v a r   t h e D i v   =   d o c u m e n t . g e t E l e m e n t B y I d ( ' b a c k g r o u n d D i v ' ) ;  
                 i f   ( t h e D i v   = =   n u l l )   {  
                         v a r   n e w D i v   =   d o c u m e n t . c r e a t e E l e m e n t ( " d i v " ) ;  
                         n e w D i v . i d   =   " b a c k g r o u n d D i v " ;  
                         n e w D i v . s t y l e . b a c k g r o u n d   =   " # d e d e d e " ;  
                         n e w D i v . s t y l e . p o s i t i o n   =   " a b s o l u t e " ;  
                         n e w D i v . s t y l e . t o p   =   " 0 p x " ;  
                         n e w D i v . s t y l e . l e f t   =   " 0 p x " ;  
                         n e w D i v . s t y l e . w i d t h   =   " 1 0 0 % " ;  
                         n e w D i v . s t y l e . h e i g h t   =   h ;  
                         n e w D i v . s t y l e . f i l t e r   =   " a l p h a ( o p a c i t y = 0 ) " ;  
                         n e w D i v . s t y l e . M o z O p a c i t y   =   " 0 " ;  
                         n e w D i v . s t y l e . O p a c i t y   =   " 0 " ;  
                         e l t . a p p e n d C h i l d ( n e w D i v ) ;  
                 }  
         }  
 }  
  
 f u n c t i o n   H i d e D i v ( )   {  
         v a r   e l t   =   d o c u m e n t . g e t E l e m e n t B y I d ( ' u p M a i n ' ) ;  
         i f   ( e l t   ! =   n u l l )   {  
                 v a r   t h e D i v   =   d o c u m e n t . g e t E l e m e n t B y I d ( ' b a c k g r o u n d D i v ' ) ;  
                 i f   ( t h e D i v   ! =   n u l l )   {  
                         e l t . r e m o v e C h i l d ( t h e D i v ) ;  
                 }  
         }  
 }  
  
 f u n c t i o n   M M _ f i n d O b j ( n ,   d )   {   / / v 4 . 0 1  
         v a r   p ,   i ,   x ;   i f   ( ! d )   d   =   d o c u m e n t ;   i f   ( ( p   =   n . i n d e x O f ( " ? " ) )   >   0   & &   p a r e n t . f r a m e s . l e n g t h )   {  
                 d   =   p a r e n t . f r a m e s [ n . s u b s t r i n g ( p   +   1 ) ] . d o c u m e n t ;   n   =   n . s u b s t r i n g ( 0 ,   p ) ;  
         }  
         i f   ( ! ( x   =   d [ n ] )   & &   d . a l l )   x   =   d . a l l [ n ] ;   f o r   ( i   =   0 ;   ! x   & &   i   <   d . f o r m s . l e n g t h ;   i + + )   x   =   d . f o r m s [ i ] [ n ] ;  
         f o r   ( i   =   0 ;   ! x   & &   d . l a y e r s   & &   i   <   d . l a y e r s . l e n g t h ;   i + + )   x   =   M M _ f i n d O b j ( n ,   d . l a y e r s [ i ] . d o c u m e n t ) ;  
         i f   ( ! x   & &   d . g e t E l e m e n t B y I d )   x   =   d . g e t E l e m e n t B y I d ( n ) ;   r e t u r n   x ;  
 }  
  
 f u n c t i o n   M M _ s h o w H i d e L a y e r s ( )   {   / / v 6 . 0  
         v a r   i ,   p ,   v ,   o b j ,   a r g s   =   M M _ s h o w H i d e L a y e r s . a r g u m e n t s ;  
         f o r   ( i   =   0 ;   i   <   ( a r g s . l e n g t h   -   2 ) ;   i   + =   3 )   i f   ( ( o b j   =   M M _ f i n d O b j ( a r g s [ i ] ) )   ! =   n u l l )   {  
                 v   =   a r g s [ i   +   2 ] ;  
                 i f   ( o b j . s t y l e )   {   o b j   =   o b j . s t y l e ;   v   =   ( v   = =   ' s h o w ' )   ?   ' v i s i b l e '   :   ( v   = =   ' h i d e ' )   ?   ' h i d d e n '   :   v ;   }  
                 o b j . v i s i b i l i t y   =   v ;  
         }  
 }  
  
 f u n c t i o n   M M _ S h o w ( i d ,   h i d e E e l I d )   {  
         v a r   e l   =   d o c u m e n t . g e t E l e m e n t B y I d ( i d ) ;  
         v a r   h E l   =   d o c u m e n t . g e t E l e m e n t B y I d ( h i d e E e l I d ) ;  
         e l . s t y l e . d i s p l a y   =   ' ' ;  
         h E l . s t y l e . d i s p l a y   =   ' n o n e ' ;  
 }  
  
 f u n c t i o n   C h e c k A l l C h e c k B o x e s ( o w n e r C h e c k b o x )   {  
         v a r   i ,   l e n ;  
         v a r   a r r T a g I n p u t   =   d o c u m e n t . b o d y . g e t E l e m e n t s B y T a g N a m e ( " I N P U T " ) ;  
         v a r   s e t C h e c k   =   d o c u m e n t . g e t E l e m e n t B y I d ( o w n e r C h e c k b o x ) . c h e c k e d ;  
         f o r   ( i   =   0 ;   i   <   a r r T a g I n p u t . l e n g t h ;   i + + )   {  
                 i f   ( ( a r r T a g I n p u t [ i ] . t y p e   = =   " c h e c k b o x " )   & &   ( a r r T a g I n p u t [ i ] . i d   ! =   o w n e r C h e c k b o x )   & &   ( a r r T a g I n p u t [ i ] . i d . i n d e x O f ( " c h k B o x C o m m e n t " )   ! =   - 1 ) )   {  
                         / / a r r T a g I n p u t [ i ] . c h e c k e d   =   ! a r r T a g I n p u t [ i ] . c h e c k e d ;  
                         a r r T a g I n p u t [ i ] . c h e c k e d   =   s e t C h e c k ;  
                 }  
         }  
 }  
  
 f u n c t i o n   S e t E l W i d t h ( e l I d ,   w i d t h )   {  
         v a r   e l   =   d o c u m e n t . g e t E l e m e n t B y I d ( e l I d ) ;  
         i f   ( e l   ! =   n u l l )  
                 e l . w i d t h   =   w i d t h ;  
 }  
  
 f u n c t i o n   G e t R e s o l u t i o n W i d t h P a r t ( p a r t )   {  
         r e t u r n   w i n d o w . d o c u m e n t . b o d y . c l i e n t W i d t h   /   p a r t ;  
 }  
  
 f u n c t i o n   S e n d U s e r O n B a c k P a g e ( )   {  
         h i s t o r y . b a c k ( ) ;  
         r e t u r n   t r u e ;  
 }  
  
 f u n c t i o n   A d d T i m e z o n e O f f s e t P a r a m ( a n c h o r C l i e n t I d )   {  
         v a r   e l   =   d o c u m e n t . g e t E l e m e n t B y I d ( a n c h o r C l i e n t I d ) ;  
         i f   ( e l   ! =   n u l l )   {  
                 v a r   n o w   =   n e w   D a t e ( ) ;  
                 v a r   t i m e O f f s e t   =   n o w . g e t T i m e z o n e O f f s e t ( ) ;  
                 t i m e O f f s e t   * =   - 1 ;  
                 i f   ( e l . h r e f . i n d e x O f ( ' ? ' )   ! =   - 1 )  
                         e l . h r e f   + =   " & t z o f f s e t = "   +   t i m e O f f s e t ;  
                 e l s e  
                         e l . h r e f   + =   " ? t z o f f s e t = "   +   t i m e O f f s e t ;  
         }  
 }  
  
 v a r   I s G r e e n L o o k   =   f a l s e ;   / /   s t o r e s   i f   G r e e n   V i e w   i s   O N / O F F  
  
 f u n c t i o n   Q u e r y T y p e S y n c h r o n i z a t i o n ( e n a b l e ,   i t e m )   {  
         v a r   t e x t O b j   =   d o c u m e n t . g e t E l e m e n t B y I d ( i t e m . t e x t E l ) ;  
         v a r   i m g O b j   =   d o c u m e n t . g e t E l e m e n t B y I d ( i t e m . i m g E l ) ;  
  
         i f   ( e n a b l e )   {  
                 i f   ( i m g O b j )  
                         i m g O b j . c h e c k e d   =   t r u e ;  
                 i f   ( t e x t O b j )   {  
                         i f   ( ! I s G r e e n L o o k )  
                                 t e x t O b j . c l a s s N a m e   =   " s t C h e c k B o x A " ;  
                         e l s e  
                                 t e x t O b j . c l a s s N a m e   =   " s t C h e c k B o x A N " ;  
                 }  
         }  
         e l s e   {  
                 i f   ( i m g O b j )  
                         i m g O b j . c h e c k e d   =   f a l s e ;  
                 i f   ( t e x t O b j )   {  
                         i f   ( ! I s G r e e n L o o k )  
                                 t e x t O b j . c l a s s N a m e   =   " s t C h e c k B o x " ;  
                         e l s e  
                                 t e x t O b j . c l a s s N a m e   =   " s t C h e c k B o x N " ;  
                 }  
         }  
 }  
  
 f u n c t i o n   S e t Q u e r y T y p e ( h i d F i e l d E l ,   q T y p e )   {  
         v a r   h i d F i e l d O b j   =   d o c u m e n t . g e t E l e m e n t B y I d ( h i d F i e l d E l ) ;  
  
         i f   ( h i d F i e l d O b j )  
                 h i d F i e l d O b j . v a l u e   =   q T y p e ;  
  
         f o r   ( v a r   i   =   0 ;   i   <   s e l e c t o r I t e m s . l e n g t h ;   + + i )   {  
                 Q u e r y T y p e S y n c h r o n i z a t i o n ( t y p e   = =   s e l e c t o r I t e m s [ i ] . t y p e ,   s e l e c t o r I t e m s [ i ] ) ;  
         }  
 }  
  
 f u n c t i o n   C h a n g e Q u e r y T y p e ( h i d F i e l d E l ,   q T y p e )   {  
         v a r   h i d F i e l d O b j   =   d o c u m e n t . g e t E l e m e n t B y I d ( h i d F i e l d E l ) ;  
  
         v a r   e l I n d e x   =   - 1 ;  
         v a r   c h e c k A l l   =   f a l s e ;  
         v a r   s w i t c h T o F a l s e   =   f a l s e ;  
         i f   ( h i d F i e l d O b j   ! =   n u l l )   {  
                 i f   ( q T y p e . i n d e x O f ( ' + ' )   > =   0 )  
                         c h e c k A l l   =   t r u e ;  
                 / /   g e t   c u r r e n t   t y p e s  
                 v a r   q T y p e A r r   =   ( c h e c k A l l   ?   q T y p e   :   h i d F i e l d O b j . v a l u e ) . s p l i t ( ' + ' ,   4 ) ;  
                 i f   ( q T y p e A r r   ! =   n u l l )   {  
                         / /   f i n d   a   c l i c k e d   t y p e   i n   t h e   c u r r e n t   t y p e s  
                         f o r   ( v a r   i   =   0 ;   i   <   q T y p e A r r . l e n g t h ;   + + i )   {  
                                 i f   ( q T y p e   = =   q T y p e A r r [ i ] )  
                                         e l I n d e x   =   i ;  
                         }  
  
                         / /   i f   t y p e   i s   u n f o u n d  
                         i f   ( e l I n d e x   <   0 )   {  
                                 / /   i f   a l l   a l r e a d y   c h e c k e d   t h e n   n e e d   t o   u n c h e c k  
                                 i f   ( h i d F i e l d O b j . v a l u e . s p l i t ( ' + ' ,   4 ) . l e n g t h   = =   4 )   {  
                                         c h e c k A l l   =   s w i t c h T o F a l s e   =   t r u e ;  
                                         q T y p e A r r   =   [ ] ;  
                                 }  
                                 e l s e   {  
                                         / /   t h e r e   a r e   n o   a l l   c h e c k e d ,   s o   a d d   t h i s   q t y p e  
                                         q T y p e A r r . p u s h ( q T y p e ) ;  
                                         i f   ( q T y p e A r r . l e n g t h   = =   4 )  
                                                 c h e c k A l l   =   t r u e ;  
                                 }  
                         }  
                         / /   s e t   t y p e s   i n   h i d d e n   f i e l d  
                         h i d F i e l d O b j . v a l u e   =   P a r s e Q u e r y T y p e T o U r l F o r m a t ( q T y p e A r r ,   e l I n d e x ) ;  
                         i f   ( h i d F i e l d O b j . v a l u e   = =   ' w e b + i m a g e s + v i d e o s + n e w s + w e b + i m a g e s + v i d e o s + n e w s ' )   {  
                                 h i d F i e l d O b j . v a l u e   =   ' w e b + i m a g e s + v i d e o s + n e w s ' ;  
                         }  
                         s e t C o o k i e ( ' U s e r S e a r c h Q u e r y T y p e ' ,   h i d F i e l d O b j . v a l u e ,   n u l l ) ;  
  
                 }  
                 / /   s e t   s t y l e s   f o r   c l i c k e d   c h e c k b o x e s  
                 f o r   ( v a r   i   =   0 ;   i   <   s e l e c t o r I t e m s . l e n g t h ;   + + i )  
                         i f   ( c h e c k A l l )  
                                 Q u e r y T y p e S y n c h r o n i z a t i o n ( ! s w i t c h T o F a l s e ,   s e l e c t o r I t e m s [ i ] ) ;  
                         e l s e   {  
                                 i f   ( s e l e c t o r I t e m s [ i ] . t y p e . i n d e x O f ( ' + ' )   > =   0 )  
                                         Q u e r y T y p e S y n c h r o n i z a t i o n ( f a l s e ,   s e l e c t o r I t e m s [ i ] ) ;  
                                 e l s e   i f   ( q T y p e   = =   s e l e c t o r I t e m s [ i ] . t y p e )  
                                         Q u e r y T y p e S y n c h r o n i z a t i o n ( e l I n d e x   <   0 ,   s e l e c t o r I t e m s [ i ] ) ;  
                         }  
         }  
 }  
  
 f u n c t i o n   P a r s e Q u e r y T y p e T o U r l F o r m a t ( q T y p e A r r ,   i n d e x T o D e l )   {  
         i f   ( q T y p e A r r . l e n g t h   >   0 )   {  
                 v a r   s t r R e s   =   " " ;  
                 f o r   ( v a r   i   =   0 ;   i   <   q T y p e A r r . l e n g t h ;   + + i )   {  
                         i f   ( i   ! =   i n d e x T o D e l )   {  
                                 s t r R e s   + =   q T y p e A r r [ i ]   +   ' + ' ;  
                         }  
                 }  
                 / / i f   ( s t r R e s   = =   " " )   s t r R e s   =   " w e b " ;  
                 i f   ( s t r R e s . c h a r A t ( s t r R e s . l e n g t h   -   1 )   = =   ' + ' )  
                         s t r R e s   =   s t r R e s . s u b s t r ( 0 ,   s t r R e s . l e n g t h   -   1 ) ;  
                 i f   ( s t r R e s . c h a r A t ( 0 )   = =   ' + ' )  
                         s t r R e s   =   s t r R e s . s u b s t r ( 1 ,   s t r R e s . l e n g t h ) ;  
                 r e t u r n   s t r R e s ;  
         }  
  
         r e t u r n   " " ;  
 }  
  
 f u n c t i o n   I s Q u e r y W r o n g ( v a l u e )   {  
         v a l u e   =   t r i m ( v a l u e ) ;  
         i f   ( v a l u e . m a t c h ( / ^ \ S / g ) )  
                 r e t u r n   f a l s e ;  
         e l s e  
                 r e t u r n   t r u e ;  
 }  
  
 f u n c t i o n   t r i m ( s t r i n g T o T r i m )   {  
         r e t u r n   s t r i n g T o T r i m . r e p l a c e ( / ^ \ s + | \ s + $ / g ,   " " ) ;  
 }  
  
 f u n c t i o n   S e t D e f a u l t F o c u s ( e l I d )   {  
         v a r   e l O b j   =   d o c u m e n t . g e t E l e m e n t B y I d ( e l I d ) ;  
         i f   ( e l O b j   ! =   n u l l )  
                 e l O b j . f o c u s ( ) ;  
 }  
  
 / / U s e   f o r   h a n d l e   p a g e L o a d   e v e n t ,   w h e n   p a g e   l o a d e d   t o   c l i e n t  
 f u n c t i o n   p a g e L o a d ( )   {  
         s e t T i m e o u t ( " o n P a g e L o a d ( ) " ,   1 0 0 ) ;   / / f o r   c h r o m e   &   s a f a r i  
 }  
 v a r   i s P L E v e n t s B i n d e d   =   f a l s e ;  
 v a r   c u r S c r o l l P o s   =   n u l l ;  
 f u n c t i o n   o n P a g e L o a d ( )   {  
  
         i f   ( w i n d o w . C o r r e c t P o p a p C o o r d i n a t e s )   {   C o r r e c t P o p a p C o o r d i n a t e s ( ) ;   }  
  
         i f   ( w i n d o w . S e t C h a t C o n t e n t L o c a t i o n )   {   S e t C h a t C o n t e n t L o c a t i o n ( ) ;   }  
  
         i f   ( w i n d o w . S e t I n p u t F o c u s )   {   S e t I n p u t F o c u s ( ) ;   }  
  
         / / L a v v a S e a r c h . M a s t e r  
         i f   ( w i n d o w . s t a r t P o l l i n g _ L a v v a S e a r c h M a s t e r )   {   s t a r t P o l l i n g _ L a v v a S e a r c h M a s t e r ( ) ;   }  
         i f   ( w i n d o w . S h o w H i d e L i v e T o p i c s )   {   i f   ( f i r s t T i m e   = =   t r u e )   S h o w H i d e L i v e T o p i c s ( d o c u m e n t . g e t E l e m e n t B y I d ( ' d i v S H L T ' ) ) ;   f i r s t T i m e   =   f a l s e ;   }  
  
         i f   ( w i n d o w . S e t C h a t S e t t i n g s )   {   S e t C h a t S e t t i n g s ( ) ;   }  
  
         i f   ( w i n d o w . S t a r t G e t t i n g W e b R e s u l t )   {   S t a r t G e t t i n g W e b R e s u l t ( ) ;   }  
  
         i f   ( w i n d o w . S t a r t R e a l T i m e I m a g e S e a r c h )   {   S t a r t R e a l T i m e I m a g e S e a r c h ( ) ;   }  
  
         i f   ( w i n d o w . S t a r t G e t t i n g B l o g R e s u l t )   {   S t a r t G e t t i n g B l o g R e s u l t ( ) ;   }  
  
         i f   ( ! i s P L E v e n t s B i n d e d )   {  
                 / /   S e a r c h R e s u l t s   p a g e  
                 i f   ( w i n d o w . B i n d W n d R e s i z e H a n d l e r   & &   w i n d o w . R e s u l t I m g s F i t t i n g )   {  
                         R e s u l t I m g s F i t t i n g ( ) ;  
                         B i n d W n d R e s i z e H a n d l e r ( ) ;  
                 }  
                 i f   ( w i n d o w . f i t S i d e N a v i )  
                         f i t S i d e N a v i ( ) ;  
                 i f   ( w i n d o w . i n i t L o g i n L o a d e r )  
                         i n i t L o g i n L o a d e r ( ) ;  
  
                 / /   N e w s   p a g e  
                 i f   ( w i n d o w . f s t V i d C o n t e n t )  
                         s h o w N e w s P r w V i d e o ( f s t V i d C o n t e n t ) ;  
  
                 / / L o g i c   f o r   R e a l   T i m e   I m a g e s   S e a r c h  
                 i f   ( t y p e o f   ( c u r r I s I m a g e s R e a l T i m e S e a r c h )   ! =   ' u n d e f i n e d '   & &   c u r r I s I m a g e s R e a l T i m e S e a r c h )   {  
                         S t a r t R e a l T i m e I m a g e S e a r c h ( c u r r I m a g e s Q u e r y ,   c u r r I m a g e s C o u n t ,   c u r r I m a g e s A u t o U p g r a d e ,  
 	 	                 c u r r I m a g e s U p d a t e I n t e r v a l ,   c u r r I m a g e s C o n t a i n e r ,   c u r r I m a g e s R o o t C o n t a i n e r ) ;  
                 }  
  
                 i f   ( t y p e o f   ( S t a r t G e t t i n g R T S W e b R e s u l t )   ! = =   ' u n d e f i n e d ' )   {  
                         S t a r t G e t t i n g R T S W e b R e s u l t ( c u r r W e b S e a r c h Q u e r y ,   c u r r W e b S e a r c h R e s u l t s C o n t a i n e r ,   c u r r W e b R o o t C o n t a i n e r ) ;  
                 }  
                 i f   ( ( t y p e o f   ( S t a r t G e t t i n g R T S N e w s R e s u l t )   ! = =   ' u n d e f i n e d ' )   & &   ( t y p e o f   ( c u r r N e w s S e a r c h Q u e r y )   ! = =   ' u n d e f i n e d ' ) )   {  
                         S t a r t G e t t i n g R T S N e w s R e s u l t ( c u r r N e w s S e a r c h Q u e r y ,   c u r r N e w s S e a r c h R e s u l t s C o n t a i n e r ,   c u r r N e w s R o o t C o n t a i n e r ) ;  
                 }  
  
                 S y s . W e b F o r m s . P a g e R e q u e s t M a n a g e r . g e t I n s t a n c e ( ) . a d d _ b e g i n R e q u e s t ( f u n c t i o n   ( )   {  
                         / / c u r S c r o l l P o s   =   S y s . W e b F o r m s . P a g e R e q u e s t M a n a g e r . g e t I n s t a n c e ( ) . _ s c r o l l P o s i t i o n ;  
                 } ) ;  
                 S y s . W e b F o r m s . P a g e R e q u e s t M a n a g e r . g e t I n s t a n c e ( ) . a d d _ e n d R e q u e s t ( f u n c t i o n   ( )   {  
                         / / i f ( w i n d o w . s c r o l l T o )  
                         / / s e t T i m e o u t ( f u n c t i o n ( ) { w i n d o w . s c r o l l T o ( c u r S c r o l l P o s . x ,   c u r S c r o l l P o s . y ) ; } ,   2 ) ;  
                 } ) ;  
                 i s P L E v e n t s B i n d e d   =   t r u e ;  
         }  
         e l s e   {  
                 i f   ( t y p e o f   ( g e t S i d e N a v i )   ! = =   ' u n d e f i n e d ' )   {  
                         g e t S i d e N a v i ( ) ;  
                         n a v i R e l o a d e d   =   t r u e ;  
                 }  
         }  
  
 }  
  
 f u n c t i o n   c l o s e A n d C l e a r P o p u p E l e m e n t ( e l e m e n t I d )   {  
         v a r   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 ( e l e m e n t I d ) ;  
         i f   ( e l e m e n t )   {  
                 e l e m e n t . s t y l e . d i s p l a y   =   " n o n e " ;  
                 e l e m e n t . i n n e r H T M L   =   " " ;  
         }  
 }  
 / /   b i n d   c l i c k - e v e n t   f o r   b o d y   a n d   e l e m e n t ,   t h a t   h a v e   t o   b e   c l o s e d   w h e n   c l i c k   f i r e d   f o r   b o d y  
 f u n c t i o n   b i n d O u t s i d e C l i c k ( e l e m e n t I d ,   p r e P r o c e s s )   {  
         $ ( ' b o d y ' ) . o n e ( " m o u s e d o w n " ,   f u n c t i o n   ( e )   {   i f   ( p r e P r o c e s s )   {   p r e P r o c e s s ( ) ;   }   c l o s e A n d C l e a r P o p u p E l e m e n t ( e l e m e n t I d ) ;   } ) ;  
         $ ( " # "   +   e l e m e n t I d ) . b i n d ( " m o u s e d o w n " ,   f u n c t i o n   ( e )   {   e . s t o p P r o p a g a t i o n ( ) ;   } ) ;  
 }  
  
 f u n c t i o n   p r e v i e w F i t t i n g ( e v e n t )   {  
         v a r   p w C o n t e n t   =   e v e n t . d a t a . c o n t e n t ;  
         i f   ( p w C o n t e n t . w i d t h ( )   <   5 )   {  
                 p r e v i e w L o a d E r r o r ( e v e n t ) ;  
                 r e t u r n ;  
         }  
         p w C o n t e n t . u n b i n d ( ' l o a d ' ) . u n b i n d ( ' e r r o r ' ) . u n b i n d ( ' a b o r t ' ) ;  
         p w C o n t e n t . c s s ( {   v i s i b i l i t y :   " h i d d e n "   } ) ;  
  
         / / r e s i z e   p r e w i e v W i n d o w  
         e v e n t . d a t a . p r e v i e w W i n d o w . w i d t h ( 1 0 ) ;  
         e v e n t . d a t a . p r e v i e w W i n d o w . h e i g h t ( 1 0 ) ;  
         v a r   l e f t O f f s e t   =   e v e n t . d a t a . l o a d e r W r p . o f f s e t ( ) . l e f t ;  
         v a r   l e f t L i m i 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 W i d t h   ?   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 W i d t h   :   w i n d o w . i n n e r W i d t h ;  
         / /   s e t   m i n   w i d t h   t o   1 1 0 p x  
         v a r   c a l c W i d t h   =   p w C o n t e n t . w i d t h ( )   <   1 1 0   ?   1 1 0   :   p w C o n t e n t . w i d t h ( ) ;  
         i f   ( l e f t L i m i t   >   ( l e f t O f f s e t   +   c a l c W i d t h ) )  
                 e v e n t . d a t a . p r e v i e w W i n d o w . c s s ( {   l e f t :   l e f t O f f s e t   } ) ;  
         e l s e  
                 e v e n t . d a t a . p r e v i e w W i n d o w . c s s ( {   l e f t :   ( l e f t L i m i t   -   c a l c W i d t h   -   1 0 )   } ) ;  
  
         v a r   t o p O f f s e t   =   e v e n t . d a t a . l o a d e r W r p . o f f s e t ( ) . t o p ;  
         v a r   b o t t o m L i m i 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 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 . s c r o l l H e i g h t   :   w i n d o w . i n n e r H e i g h t )   -   7 0 ;  
         v a r   c a l c H e i g h t   =   p w C o n t e n t . h e i g h t ( )   <   1 1 0   ?   1 1 0   :   p w C o n t e n t . h e i g h t ( ) ;  
         i f   ( b o t t o m L i m i t   >   ( t o p O f f s e t   +   c a l c H e i g h t ) )  
                 e v e n t . d a t a . p r e v i e w W i n d o w . c s s ( {   t o p :   t o p O f f s e t   } ) ;  
         e l s e  
                 e v e n t . d a t a . p r e v i e w W i n d o w . c s s ( {   t o p :   ( b o t t o m L i m i t   -   c a l c H e i g h t   -   1 0 )   } ) ;  
         / /   c a l c u l a t e   s i z e   a n d   s t a r t   r e s i z i n g  
         / /   t o   p r e v e n t   F F   3   c r a s h   o n   j Q u e r y   a n i m a t i o n   o f   e l e m e n t   w i t h   F l a s h          
         i f   ( p w C o n t e n t . h a s C l a s s ( " p r e v i e w V i d e o " ) )   {  
                 e v e n t . d a t a . p r e v i e w W i n d o w . w i d t h ( c a l c W i d t h ) ;  
                 e v e n t . d a t a . p r e v i e w W i n d o w . h e i g h t ( c a l c H e i g h t   +   6 5 ) ;  
                 p w C o n t e n t . c s s ( {   v i s i b i l i t y :   " v i s i b l e "   } ) ;  
         }  
         e l s e  
                 e v e n t . d a t a . p r e v i e w W i n d o w . a n i m a t e ( {   w i d t h :   c a l c W i d t h ,   h e i g h t :   c a l c H e i g h t   +   6 5   } ,  
                                                                                 f u n c t i o n   ( )   {   / /   s h o w   c o n t e n t  
                                                                                         p w C o n t e n t . c s s ( {   v i s i b i l i t y :   " v i s i b l e "   } ) ;  
                                                                                 } ) ;  
         / /   r e m o v e   l o a d e r  
         e v e n t . d a t a . l o a d e r W r p . f i n d ( " . p w L o a d e r " ) . r e m o v e ( ) ;  
 } ;  
  
 f u n c t i o n   p r e v i e w L o a d E r r o r ( e v e n t )   {  
         v a r   p w C o n t e n t   =   e v e n t . d a t a . c o n t e n t ;  
         p w C o n t e n t . u n b i n d ( ' l o a d ' ) . u n b i n d ( ' e r r o r ' ) . u n b i n d ( ' a b o r t ' ) ;  
  
         s h o w M e s s a g e B o x ( " W e  r e   s o r r y   t h i s   p r e v i e w   i s   u n a v a i l a b l e   r i g h t   n o w . " ,   e v e n t . d a t a . l o a d e r W r p . o f f s e t ( ) . t o p ,   e v e n t . d a t a . l o a d e r W r p . o f f s e t ( ) . l e f t ) ;  
         e v e n t . d a t a . l o a d e r W r p . f i n d ( " . p w L o a d e r " ) . r e m o v e ( ) ;  
         / /   c l o s e   c r e a t e d   b u t   n o t   y e t   s h o w e d   w i n d o w  
         c l o s e P w ( p w C o n t e n t ) ;  
 } ;  
  
 f u n c t i o n   a n i m a t e P r e v i e w ( s e n d e r ,   p r e v i e w W i n d o w ,   i s V i d e o )   {  
         v a r   r e s W r p   =   $ ( s e n d e r ) . p a r e n t s ( " . x R e s " ) ;  
         v a r   l o a d e r W r p   =   r e s W r p . f i n d ( " . x P L H " ) ;  
  
         / /   i f   v i d e o   -   j u s t   s h o w  
         i f   ( i s V i d e o )   {  
                 v a r   v i d   =   p r e v i e w W i n d o w . f i n d ( " . p r e v i e w V i d e o " ) ;  
                 p r e v i e w F i t t i n g ( {   d a t a :   {   l o a d e r W r p :   l o a d e r W r p ,   p r e v i e w W i n d o w :   p r e v i e w W i n d o w ,   c o n t e n t :   v i d }   } ) ;  
         }  
         / /   i f   i m a g e   -   s h o w   a f t e r   l o a d  
         e l s e   {  
                 l o a d e r W r p . c s s ( " p o s i t i o n " ,   " r e l a t i v e " ) ;  
                 l o a d e r W r p . a p p e n d ( l o a d e r H T M L ) ;  
                 v a r   i m g   =   p r e v i e w W i n d o w . f i n d ( " . p r e v i e w I m a g e " ) ;  
                 i m g . u n b i n d ( ' l o a d ' ) . u n b i n d ( ' e r r o r ' ) . u n b i n d ( ' a b o r t ' ) ;  
                 i m g . b i n d ( ' l o a d ' ,   {   l o a d e r W r p :   l o a d e r W r p ,   p r e v i e w W i n d o w :   p r e v i e w W i n d o w ,   c o n t e n t :   i m g   } ,   p r e v i e w F i t t i n g )  
                 . b i n d ( ' e r r o r ' ,   {   l o a d e r W r p :   l o a d e r W r p ,   p r e v i e w W i n d o w :   p r e v i e w W i n d o w ,   c o n t e n t :   i m g   } ,   p r e v i e w L o a d E r r o r )  
                 . b i n d ( ' a b o r t ' ,   {   l o a d e r W r p :   l o a d e r W r p ,   p r e v i e w W i n d o w :   p r e v i e w W i n d o w ,   c o n t e n t :   i m g   } ,   p r e v i e w L o a d E r r o r ) ;  
         }  
 }  
 f u n c t i o n   S a v e Q u e r y D a t a T o C o o k i e ( c o n t r o l I d ,   k e y )   {  
         v a r   q u e r y   =   $ g e t ( c o n t r o l I d ) . v a l u e ;  
         s e t C o o k i e ( k e y ,   q u e r y ,   n u l l ) ;  
 }  
 f u n c t i o n   s e t C o o k i e ( c _ n a m e ,   v a l u e ,   e x p i r e d a y s )   {  
         v a r   e x d a t e   =   n e w   D a t e ( ) ;  
         e x d a t e . s e t D a t e ( e x d a t e . g e t D a t e ( ) ) ;  
         d o c u m e n t . c o o k i e   =   c _ n a m e   +   " = "   +   e s c a p e ( v a l u e )   +  
 ( ( e x p i r e d a y s   = =   n u l l )   ?   " ;   p a t h = / "   :   " ; e x p i r e s = "   +   e x d a t e . t o G M T S t r i n g ( )   +   + " ;   p a t h = / " ) ;  
 }  
 f u n c t i o n   g e t C o o k i e ( c _ n a m e )   {  
         i f   ( d o c u m e n t . c o o k i e . l e n g t h   >   0 )   {  
                 c _ s t a r t   =   d o c u m e n t . c o o k i e . i n d e x O f ( c _ n a m e   +   " = " ) ;  
                 i f   ( c _ s t a r t   ! =   - 1 )   {  
                         c _ s t a r t   =   c _ s t a r t   +   c _ n a m e . l e n g t h   +   1 ;  
                         c _ e n d   =   d o c u m e n t . c o o k i e . i n d e x O f ( " ; " ,   c _ s t a r t ) ;  
                         i f   ( c _ e n d   = =   - 1 )   c _ e n d   =   d o c u m e n t . c o o k i e . l e n g t h ;  
                         r e t u r n   u n e s c a p e ( d o c u m e n t . c o o k i e . s u b s t r i n g ( c _ s t a r t ,   c _ e n d ) ) ;  
                 }  
         }  
         r e t u r n   " " ;  
 }  
 f u n c t i o n   M a k e S e a r c h ( b u t t o n ,   c h a t O n ,   q u e r y I n p u t ,   g o s o c i a l )   {  
         v a r   d s t L n k   =   " # " ;  
         v a r   q u e r y   =   q u e r y I n p u t . v a l u e ;  
         / / v a r   q u e r y   =   g e t C o o k i e ( ' U s e r S e a r c h Q u e r y ' ) ;  
         v a r   q u e r y T y p e   =   g e t C o o k i e ( ' U s e r S e a r c h Q u e r y T y p e ' ) ;  
         i f   ( ( ! q u e r y . t r i m   & &   q u e r y   ! =   ' ' )   | |   ( q u e r y . t r i m   & &   q u e r y . t r i m ( )   ! =   ' ' ) )   {  
                 i f   ( c h a t O n )   {  
                         q u e r y T y p e   =   ( q u e r y T y p e   = =   ' ' )   ?   ' w e b '   :   q u e r y T y p e ;  
                         v a r   u r l P r e f i x   =   g o s o c i a l   ?   " / G o S o c i a l . a s p x ? q = "   :   " / S e a r c h . a s p x ? q = " ;  
                         d s t L n k   =   w i n d o w . l o c a t i o n . p r o t o c o l   +   " / / "   +   w i n d o w . l o c a t i o n . h o s t n a m e   +   u r l P r e f i x   +  
                                   e n c o d e U R I C o m p o n e n t ( q u e r y . t r i m   ?   q u e r y . t r i m ( )   :   q u e r y )   +   " & s t = "   +   q u e r y T y p e ;  
  
                 }  
                 e l s e   {  
                         q u e r y T y p e   =   ( q u e r y T y p e   = =   ' ' )   ?   ' w e b '   :   q u e r y T y p e ;  
                         v a r   c h a t P a r a m   =   ( c h a t O n )   ?   " & c h a t = o n "   :   ' ' ;  
                         v a r   u r l P r e f i x   =   g o s o c i a l   ?   " / G o S o c i a l . a s p x ? q = "   :   " / S e a r c h . a s p x ? q = " ;  
                         d s t L n k   =   w i n d o w . l o c a t i o n . p r o t o c o l   +   " / / "   +   w i n d o w . l o c a t i o n . h o s t n a m e   +   u r l P r e f i x   +  
                                 e n c o d e U R I C o m p o n e n t ( q u e r y . t r i m   ?   q u e r y . t r i m ( )   :   q u e r y )   +   " & s t = "   +   q u e r y T y p e   +   c h a t P a r a m ;  
  
                 }  
                 / / i f   ( P a g e _ C l i e n t V a l i d a t e ( b u t t o n . v a l i d a t i o n G r o u p ) )  
                 w i n d o w . l o c a t i o n   =   d s t L n k ;  
         }  
         e l s e   {  
                 r e t u r n   f a l s e ;  
         }  
 }  
 v a r   B r o w s e r D e t e c t   =   {  
         i n i t :   f u n c t i o n   ( )   {  
                 t h i s . b r o w s e r   =   t h i s . s e a r c h S t r i n g ( t h i s . d a t a B r o w s e r )   | |   " A n   u n k n o w n   b r o w s e r " ;  
                 t h i s . v e r s i o n   =   t h i s . s e a r c h V e r s i o n ( n a v i g a t o r . u s e r A g e n t )  
 	 	 	 | |   t h i s . s e a r c h V e r s i o n ( n a v i g a t o r . a p p V e r s i o n )  
 	 	 	 | |   " a n   u n k n o w n   v e r s i o n " ;  
                 t h i s . O S   =   t h i s . s e a r c h S t r i n g ( t h i s . d a t a O S )   | |   " a n   u n k n o w n   O S " ;  
         } ,  
         s e a r c h S t r i n g :   f u n c t i o n   ( d a t a )   {  
                 f o r   ( v a r   i   =   0 ;   i   <   d a t a . l e n g t h ;   i + + )   {  
                         v a r   d a t a S t r i n g   =   d a t a [ i ] . s t r i n g ;  
                         v a r   d a t a P r o p   =   d a t a [ i ] . p r o p ;  
                         t h i s . v e r s i o n S e a r c h S t r i n g   =   d a t a [ i ] . v e r s i o n S e a r c h   | |   d a t a [ i ] . i d e n t i t y ;  
                         i f   ( d a t a S t r i n g )   {  
                                 i f   ( d a t a S t r i n g . i n d e x O f ( d a t a [ i ] . s u b S t r i n g )   ! =   - 1 )  
                                         r e t u r n   d a t a [ i ] . i d e n t i t y ;  
                         }  
                         e l s e   i f   ( d a t a P r o p )  
                                 r e t u r n   d a t a [ i ] . i d e n t i t y ;  
                 }  
         } ,  
         s e a r c h V e r s i o n :   f u n c t i o n   ( d a t a S t r i n g )   {  
                 v a r   i n d e x   =   d a t a S t r i n g . i n d e x O f ( t h i s . v e r s i o n S e a r c h S t r i n g ) ;  
                 i f   ( i n d e x   = =   - 1 )   r e t u r n ;  
                 r e t u r n   p a r s e F l o a t ( d a t a S t r i n g . s u b s t r i n g ( i n d e x   +   t h i s . v e r s i o n S e a r c h S t r i n g . l e n g t h   +   1 ) ) ;  
         } ,  
         d a t a B r o w s e r :   [  
 	 	 {  
 	 	         s t r i n g :   n a v i g a t o r . u s e r A g e n t ,  
 	 	         s u b S t r i n g :   " C h r o m e " ,  
 	 	         i d e n t i t y :   " C h r o m e "  
 	 	 } ,  
 	 	 {   s t r i n g :   n a v i g a t o r . u s e r A g e n t ,  
 	 	         s u b S t r i n g :   " O m n i W e b " ,  
 	 	         v e r s i o n S e a r c h :   " O m n i W e b / " ,  
 	 	         i d e n t i t y :   " O m n i W e b "  
 	 	 } ,  
 	 	 {  
 	 	         s t r i n g :   n a v i g a t o r . v e n d o r ,  
 	 	         s u b S t r i n g :   " A p p l e " ,  
 	 	         i d e n t i t y :   " S a f a r i " ,  
 	 	         v e r s i o n S e a r c h :   " V e r s i o n "  
 	 	 } ,  
 	 	 {  
 	 	         p r o p :   w i n d o w . o p e r a ,  
 	 	         i d e n t i t y :   " O p e r a "  
 	 	 } ,  
 	 	 {  
 	 	         s t r i n g :   n a v i g a t o r . v e n d o r ,  
 	 	         s u b S t r i n g :   " i C a b " ,  
 	 	         i d e n t i t y :   " i C a b "  
 	 	 } ,  
 	 	 {  
 	 	         s t r i n g :   n a v i g a t o r . v e n d o r ,  
 	 	         s u b S t r i n g :   " K D E " ,  
 	 	         i d e n t i t y :   " K o n q u e r o r "  
 	 	 } ,  
 	 	 {  
 	 	         s t r i n g :   n a v i g a t o r . u s e r A g e n t ,  
 	 	         s u b S t r i n g :   " F i r e f o x " ,  
 	 	         i d e n t i t y :   " F i r e f o x "  
 	 	 } ,  
 	 	 {  
 	 	         s t r i n g :   n a v i g a t o r . v e n d o r ,  
 	 	         s u b S t r i n g :   " C a m i n o " ,  
 	 	         i d e n t i t y :   " C a m i n o "  
 	 	 } ,  
 	 	 { 	 	 / /   f o r   n e w e r   N e t s c a p e s   ( 6 + )  
 	 	         s t r i n g :   n a v i g a t o r . u s e r A g e n t ,  
 	 	         s u b S t r i n g :   " N e t s c a p e " ,  
 	 	         i d e n t i t y :   " N e t s c a p e "  
 	 	 } ,  
 	 	 {  
 	 	         s t r i n g :   n a v i g a t o r . u s e r A g e n t ,  
 	 	         s u b S t r i n g :   " M S I E " ,  
 	 	         i d e n t i t y :   " E x p l o r e r " ,  
 	 	         v e r s i o n S e a r c h :   " M S I E "  
 	 	 } ,  
 	 	 {  
 	 	         s t r i n g :   n a v i g a t o r . u s e r A g e n t ,  
 	 	         s u b S t r i n g :   " G e c k o " ,  
 	 	         i d e n t i t y :   " M o z i l l a " ,  
 	 	         v e r s i o n S e a r c h :   " r v "  
 	 	 } ,  
 	 	 {   	 	 / /   f o r   o l d e r   N e t s c a p e s   ( 4 - )  
 	 	         s t r i n g :   n a v i g a t o r . u s e r A g e n t ,  
 	 	         s u b S t r i n g :   " M o z i l l a " ,  
 	 	         i d e n t i t y :   " N e t s c a p e " ,  
 	 	         v e r s i o n S e a r c h :   " M o z i l l a "  
 	 	 }  
 	 ] ,  
         d a t a O S :   [  
 	 	 {  
 	 	         s t r i n g :   n a v i g a t o r . p l a t f o r m ,  
 	 	         s u b S t r i n g :   " W i n " ,  
 	 	         i d e n t i t y :   " W i n d o w s "  
 	 	 } ,  
 	 	 {  
 	 	         s t r i n g :   n a v i g a t o r . p l a t f o r m ,  
 	 	         s u b S t r i n g :   " M a c " ,  
 	 	         i d e n t i t y :   " M a c "  
 	 	 } ,  
 	 	 {  
 	 	         s t r i n g :   n a v i g a t o r . u s e r A g e n t ,  
 	 	         s u b S t r i n g :   " i P h o n e " ,  
 	 	         i d e n t i t y :   " i P h o n e / i P o d "  
 	 	 } ,  
 	 	 {  
 	 	         s t r i n g :   n a v i g a t o r . p l a t f o r m ,  
 	 	         s u b S t r i n g :   " L i n u x " ,  
 	 	         i d e n t i t y :   " L i n u x "  
 	 	 }  
 	 ]  
  
 } ;  
 B r o w s e r D e t e c t . i n i t ( ) ;  
  
 f u n c t i o n   B i n d W n d R e s i z e H a n d l e r ( )   {  
         / /   b i n d   i m a g e s   f i t t i n g   o n   r e s i z e  
         i f   ( t y p e o f   ( j Q u e r y )   = =   ' u n d e f i n e d ' )  
                 r e t u r n ;  
         $ ( w i n d o w ) . b i n d ( " r e s i z e " ,   R e s u l t I m g s F i t t i n g ) ;  
         i f   ( w i n d o w . t o t a l C h e c k P w P o s i t i o n s )  
                 $ ( w i n d o w ) . b i n d ( " r e s i z e " ,   t o t a l C h e c k P w P o s i t i o n s ) ;  
 }  
 f u n c t i o n   g e t N a m e B r o u s e r ( )   {  
         v a r   u a   =   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 ( ) ;  
         / /   ?@545;8<  I n t e r n e t   E x p l o r e r  
         i f   ( u a . i n d e x O f ( " m s i e " )   ! =   - 1   & &   u a . i n d e x O f ( " o p e r a " )   = =   - 1   & &   u a . i n d e x O f ( " w e b t v " )   = =   - 1 )   {  
                 r e t u r n   " m s i e "  
         }  
         / /   O p e r a  
         i f   ( u a . i n d e x O f ( " o p e r a " )   ! =   - 1 )   {  
                 r e t u r n   " o p e r a "  
         }  
         / /   G e c k o   =   M o z i l l a   +   F i r e f o x   +   N e t s c a p e  
         i f   ( u a . i n d e x O f ( " g e c k o " )   ! =   - 1 )   {  
                 r e t u r n   " g e c k o " ;  
         }  
         / /   S a f a r i ,   8A?>;L7C5BAO  2  M A C   O S  
         i f   ( u a . i n d e x O f ( " s a f a r i " )   ! =   - 1 )   {  
                 r e t u r n   " s a f a r i " ;  
         }  
         / /   K o n q u e r o r ,   8A?>;L7C5BAO  2  U N I X - A8AB5<0E 
         i f   ( u a . i n d e x O f ( " k o n q u e r o r " )   ! =   - 1 )   {  
                 r e t u r n   " k o n q u e r o r " ;  
         }  
         r e t u r n   " u n k n o w n " ;  
 }  
 f u n c t i o n   R e s u l t I m g s F i t t i n g ( )   {  
         / /   f i n d   a l l   i m a g e s   c o n t a i n e r s ( i m a g e s   a n d   v i d e o s   r e s u l t s )  
         i f   ( t y p e o f   j Q u e r y   = =   ' u n d e f i n e d ' )  
                 r e t u r n ;  
         v a r   c o n t a i n e r s   =   $ ( " . x I m g R e s C n t " ) ;  
  
  
  
         / / f i t   i m a g e s   f o r   a l l   c o n t a i n e r s  
         c o n t a i n e r s . e a c h ( f u n c t i o n   ( )   {  
                 v a r   c n t W i d t h   =   $ ( t h i s ) . i n n e r W i d t h ( ) ;  
                 / /   g e t   a l l   i m a g e s   w r a p p e r s  
                 v a r   i m g s   =   $ ( t h i s ) . f i n d ( " . x I m g R e s " ) ;  
                 i m g s . c s s ( " m a r g i n - l e f t " ,   0 ) ;  
                 v a r   b r o w s e r N a m e   =   g e t N a m e B r o u s e r ( ) ;  
                 i f   ( b r o w s e r N a m e   = =   " g e c k o "   | |   b r o w s e r N a m e   = =   " s a f a r i " )   {  
                         i m g s . c s s ( " m a r g i n - l e f t " ,   5 ) ;  
                         r e t u r n ;  
                 }  
                 v a r   s u m W i d t h   =   0 ;  
                 / /   m a x   a m o u n t   o f   i m a g e s   i n   t h e   l i n e  
                 v a r   m a x N u m I m g s   =   0 ;  
                 f o r   ( ;   m a x N u m I m g s   <   i m g s . l e n g t h ;   m a x N u m I m g s + + )   {  
                         s u m W i d t h   + =   $ ( i m g s [ m a x N u m I m g s ] ) . w i d t h ( ) ;  
                         i f   ( s u m W i d t h   >   c n t W i d t h )   {  
                                 b r e a k ;  
                         }  
                 }  
  
                 v a r   a l i g n L a s t L i n e   =   f a l s e ;  
                 / / a m o u n t   o f   l i n e s  
                 v a r   n u m L i n e s   =   M a t h . c e i l ( i m g s . l e n g t h   /   m a x N u m I m g s ) ;  
                 / / a v e r a g e   a m o u n t   o f   i m a g e s   i n   t h e   l i n e  
                 v a r   a v g N u m I m g s   =   a l i g n L a s t L i n e   ?   M a t h . f l o o r ( i m g s . l e n g t h   /   n u m L i n e s )   :   m a x N u m I m g s ;  
                 / / r e m a i n d e r   o f   i m a g e s   t h a t   i s   n o t   a l l o c a t e d  
                 v a r   r m n N u m I m g s   =   a l i g n L a s t L i n e   ?   ( i m g s . l e n g t h   %   n u m L i n e s )   :   0 ;  
                 / / n e e d   t o   s e t   i m a g e s   f r o m   r e m i n d e r   i n   t h e   f i r s t   l i n e s  
                 f o r   ( v a r   i   =   0 ;   i   <   n u m L i n e s ;   i + + )   {  
                         v a r   b e g i n I n d e x   =   i   *   a v g N u m I m g s   +   ( ( r m n N u m I m g s   >   i )   ?   i   :   r m n N u m I m g s ) ;  
                         v a r   e n d I n d e x   =   ( i   +   1 )   *   a v g N u m I m g s   +   ( ( r m n N u m I m g s   >   i )   ?   ( i   +   1 )   :   r m n N u m I m g s )   -   1 ;  
                         / /   w i d t h   o f   t h e   i m a g e   w r a p p e r   +   l e f t   m a r g i n ( f o r   a l l   i m a g e s   i n   t h e   l i n e   e x c e p t   f i r s t ,   b e c a u s e   1 s t   i m a g e   w i t h o u t   m a r g i n )  
                         v a r   d i v i d e r   =   a l i g n L a s t L i n e   ?   ( e n d I n d e x   -   b e g i n I n d e x )   :   ( a v g N u m I m g s   -   1 ) ;  
                         i f   ( d i v i d e r   = =   0 )  
                                 c o n t i n u e ;  
                         v a r   i m g W r p F u l l W i d t h   =   ( c n t W i d t h   -   $ ( i m g s [ b e g i n I n d e x ] ) . w i d t h ( ) )   /   d i v i d e r ;  
                         f o r   ( v a r   j   =   b e g i n I n d e x   +   1 ;   j   < =   e n d I n d e x ;   j + + )  
                                 $ ( i m g s [ j ] ) . c s s ( " m a r g i n - l e f t " ,   i m g W r p F u l l W i d t h   -   $ ( i m g s [ j ] ) . w i d t h ( )   -   0 . 3 ) ;  
                 }  
         } ) ;  
 }  
  
 / /   e x p r e s s i o n   f o r   d i v i d i n g   b y   w o r d s  
 v a r   w o r d s R e g E x p   =   / ( [ ^ \ s ] + ) | ( [ \ s ] + ) / g ;  
  
 i f   ( d o c u m e n t . f o r m s . l e n g t h   >   0 )   {  
         / /   a u x   d i v   f o r   t e x t   w i d t h   c a l c u l a t i n g  
         v a r   m e a s u r i n g D i v   =   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 a s u r i n g D i v . s t y l e [ " v i s i b i l i t y " ]   =   " h i d d e n " ;  
         m e a s u r i n g D i v . s t y l e [ " p o s i t i o n " ]   =   " a b s o l u t e " ;  
         d o c u m e n t . f o r m s [ 0 ] . a p p e n d C h i l d ( m e a s u r i n g D i v ) ;  
 }  
  
 / /   p r e v i o u s   d o m E l e m e n t ,   t h a t   w a s   u s e d   f o r   t e x t   b r e a k i n g  
 / /   s t o r e   i t   f o r   p e r f o r m a n c e   i m p r o v e m e n t  
 v a r   p r e v E l   =   n u l l ;  
  
 / /   s e t   h i d d e n   s p a c e s ( ' \ u 2 0 0 b ' )   i n   w o r d s   f o r   d e f i n e d   w i d t h  
 f u n c t i o n   s e t W o r d B r e a k s ( w o r d ,   d o m E l e m e n t )   {  
         / /   s e t   m e a s u r i n g D i v  
         i f   ( ! w i n d o w . m e a s u r i n g D i v   | |   ! m e a s u r i n g D i v . p a r e n t N o d e )  
                 r e t u r n   w o r d ;  
         / / 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 a s u r i n g D i v ) ;  
         / /   s e t   m e a s u r i n g D i v   s t y l e   a s   f o r   t h e   d o m E l e m e n t  
         i f   ( p r e v E l   ! =   d o m E l e m e n t )   {  
                 p r e v E l   =   d o m E l e m e n t ;  
                 $ ( m e a s u r i n g D i v ) . c s s ( " f o n t - s i z e " ,   $ ( d o m E l e m e n t ) . c s s ( " f o n t - s i z e " ) ) ;  
                 $ ( m e a s u r i n g D i v ) . c s s ( " f o n t - f a m i l y " ,   $ ( d o m E l e m e n t ) . c s s ( " f o n t - f a m i l y " ) ) ;  
                 / / $ ( m e a s u r i n g D i v ) . c s s ( " l e t t e r - s p a c i n g " ,   $ ( d o m E l e m e n t ) . c s s ( " l e t t e r - s p a c i n g " ) ) ;  
         }  
         v a r   r e s u l t   =   w o r d . s u b s t r ( 0 ,   2 5 ) ;  
         v a r   s t a r t   =   0 ;  
         v a r   w   =   d o m E l e m e n t . o f f s e t W i d t h   -   2 5 ;  
         f o r   ( v a r   i   =   2 5 ;   i   <   w o r d . l e n g t h ;   i + + )   {  
                 i f   ( d o m E l e m e n t . n e w T e x t )  
                         r e t u r n   n u l l ;  
                 m e a s u r i n g D i v . i n n e r H T M L   =   w o r d . s u b s t r ( s t a r t ,   i   -   s t a r t   +   1 ) ;  
                 / / a l e r t ( d o m E l e m e n t . o f f s e t W i d t h   +   " \ n "   +   m e a s u r i n g D i v . o f f s e t W i d t h   +   "   -   "   +   m e a s u r i n g D i v . i n n e r H T M L   +   "   -   "   +   i ) ;  
                 i f   ( m e a s u r i n g D i v . o f f s e t W i d t h   > =   w )   {  
                         r e s u l t   + =   ' \ u 2 0 0 b ' ;  
                         s t a r t   =   i ;  
                 }  
                 r e s u l t   + =   w o r d . c h a r A t ( i ) ;  
         }  
  
         r e t u r n   r e s u l t ;  
 }  
  
 f u n c t i o n   s e t T e x t B r e a k s ( t e x t ,   d o m E l )   {  
         v a r   n e w V a l u e   =   " " ;  
  
         v a r   w o r d s   =   t e x t . m a t c h ( w o r d s R e g E x p ) ;  
         i f   ( w o r d s   = =   ' u n d e f i n e d '   | |   w o r d s   = =   n u l l )  
                 r e t u r n ;  
  
         f o r   ( v a r   i   =   0 ;   i   <   w o r d s . l e n g t h ;   i + + )   {  
                 i f   ( d o m E l . n e w T e x t )  
                         b r e a k ;  
                 i f   ( w o r d s [ i ] . l e n g t h   >   2 5 )  
                         n e w V a l u e   + =   s e t W o r d B r e a k s ( w o r d s [ i ] ,   d o m E l ) ;  
                 e l s e  
                         n e w V a l u e   + =   w o r d s [ i ] ;  
         }  
         r e t u r n   n e w V a l u e ;  
 }  
  
 f u n c t i o n   g e t C a r e t P o s i t i o n ( c t r l )   {  
         v a r   C a r e t P o s   =   0 ;  
         / /   I E   S u p p o r t  
         i f   ( d o c u m e n t . s e l e c t i o n )   {  
                 c t r l . f o c u s ( ) ;  
                 v a r   S e l   =   d o c u m e n t . s e l e c t i o n . c r e a t e R a n g e ( ) ;  
                 / /   c r a z y   l o g i c :  
                 / /   g e t   c u r r e n t   p o s i t i o n ( i n   I E   -   p o s i t i o n   l i k e   - 3 9 4   f o r   f i r s t   e l e m e n t ;  
                 / /   i n   O p e r a   -   p o s i t i o n   l i k e   - 1   f o r   f i r s t   e l e m e n t   ; )  
                 C a r e t P o s   =   S e l . m o v e S t a r t ( ' c h a r a c t e r ' ,   - 1 0 0 0 0 ) ;  
                 / /   s e t   t o   0   p o s i t i o n  
                 s e t C a r e t P o s i t i o n ( c t r l ,   0 ) ;  
                 S e l   =   d o c u m e n t . s e l e c t i o n . c r e a t e R a n g e ( ) ;  
                 / /   0   p o s i t o n   m i n u s   c u r r e n t   p o s i t i o n ( b e c a u s e   t h e y   a r e   n e g a t i v e )  
                 C a r e t P o s   =   S e l . m o v e S t a r t ( ' c h a r a c t e r ' ,   - 1 0 0 0 0 )   -   C a r e t P o s ;  
                 / /   s e t   c u r r e n t   p o s i t i o n   a g a i n  
                 s e t C a r e t P o s i t i o n ( c t r l ,   C a r e t P o s ) ;  
         }  
         / /   F i r e f o x   s u p p o r t  
         e l s e   i f   ( c t r l . s e l e c t i o n S t a r t   | |   c t r l . s e l e c t i o n S t a r t   = =   ' 0 ' )   {  
                 C a r e t P o s   =   c t r l . s e l e c t i o n S t a r t ;  
         }  
         r e t u r n   ( C a r e t P o s ) ;  
 }  
  
 f u n c t i o n   s e t C a r e t P o s i t i o n ( c t r l ,   p o s )   {  
         i f   ( c t r l . s e t S e l e c t i o n R a n g e )   {  
                 c t r l . f o c u s ( ) ;  
                 c t r l . s e t S e l e c t i o n R a n g e ( p o s ,   p o s ) ;  
         }  
         e l s e   i f   ( c t r l . c r e a t e T e x t R a n g e )   {  
                 v a r   r a n g e   =   c t r l . c r e a t e T e x t R a n g e ( ) ;  
                 r a n g e . c o l l a p s e ( t r u e ) ;  
                 r a n g e . m o v e E n d ( ' c h a r a c t e r ' ,   p o s ) ;  
                 r a n g e . m o v e S t a r t ( ' c h a r a c t e r ' ,   p o s ) ;  
                 r a n g e . s e l e c t ( ) ;  
         }  
 }  
  
 f u n c t i o n   b r e a k W o r d s ( t e x t a r e a )   {  
         r e t u r n ;  
         / /   i s   c l a c u l a t i o n   i n   p r o c e s s  
         i f   ( t e x t a r e a . i n P r o c )   {  
                 / /   t e x t   h a s   b e e n   m o d i f i e d  
                 t e x t a r e a . n e w T e x t   =   t r u e ;  
                 r e t u r n ;  
         }  
         e l s e  
                 t e x t a r e a . i n P r o c   =   t r u e ;  
         / /   m a k e   c a l c u l a t i o n s   i n   p a r a l l e l  
         s e t T i m e o u t (  
                 f u n c t i o n   ( )   {  
                         v a r   s r c T e x t ,   n e w V a l u e ;  
                         d o   {  
                                 t e x t a r e a . n e w T e x t   =   f a l s e ;  
                                 s r c T e x t   =   t e x t a r e a . v a l u e ;  
                                 / /   r e m o v e   a l l   h i d d e n   s p a c e  
                                 s r c T e x t   =   s r c T e x t . r e p l a c e ( / \ u 2 0 0 b / g ,   ' ' ) ;  
  
                                 n e w V a l u e   =   s e t T e x t B r e a k s ( s r c T e x t ,   t e x t a r e a ) ;  
                         }   w h i l e   ( t e x t a r e a . n e w T e x t ) ;   / /   w h i l e   t e x t   i s   m o d i f i e d  
                         t e x t a r e a . n e w T e x t   =   f a l s e ;  
                         t e x t a r e a . i n P r o c   =   f a l s e ;  
  
                         / / s e t   n e w   v a l u e   i f   s o u r c e   v a l u e   h a s   b e e n   f i x e d  
                         i f   ( s r c T e x t . l e n g t h   ! =   n e w V a l u e . l e n g t h   & &   t e x t a r e a . v a l u e   ! =   n e w V a l u e )   {  
                                 v a r   c a r e t P o s   =   g e t C a r e t P o s i t i o n ( t e x t a r e a ) ;  
                                 t e x t a r e a . v a l u e   =   n e w V a l u e ;  
                                 s e t C a r e t P o s i t i o n ( t e x t a r e a ,   c a r e t P o s ) ;  
                         }  
                 } ,   1 ) ;  
 }  
 / /   B e g i n   l o g i c   f o r   R e q u e s t   F o r   C h a t   ( R F C )   s y s t e m  
 f u n c t i o n   C R C r e a t e R F C ( q u e r y K e y ,   o w n e r I d )   {  
         C r e a t e R F C ( q u e r y K e y ,   o w n e r I d ,   o n C r e a t e R F C E n d e d )  
 }  
 f u n c t i o n   o n C r e a t e R F C E n d e d ( d a t a )   {  
         / / A d d   c o d e   f o r   h a n d l i n g   o f   r e s u l t s  
 }  
 f u n c t i o n   C R G e t L i s t R F C ( )   {  
         G e t R F C L i s t ( o n R F C L i s t E n d e d ) ;  
 }  
  
 f u n c t i o n   o n R F C L i s t E n d e d ( d a t a )   {  
         i f   ( t y p e o f   ( R F C L i s t C o n t a i n e r )   ! = =   ' u n d e f i n e d ' )   {  
                 f o r   ( v a r   i   =   0 ;   i   <   R F C L i s t C o n t a i n e r . c h i l d r e n . l e n g t h ;   i + + )   {  
                         R F C L i s t C o n t a i n e r . r e m o v e C h i l d ( R F C L i s t C o n t a i n e r . c h i l d r e n [ i ] ) ;  
                         i - - ;  
                 }  
                 f o r   ( v a r   i   =   0 ;   i   <   d a t a . l e n g t h ;   i + + )   {  
                         v a r   v a l u e   =   d a t a [ i ] ;  
                         v a r   l i n k   =   d o c u m e n t . c r e a t e E l e m e n t ( " a " ) ;  
                         l i n k . s e t A t t r i b u t e ( ' h r e f ' ,   ' / G o S o c i a l . a s p x ? q = '   +   v a l u e ) ;  
                         l i n k . s e t A t t r i b u t e ( ' o n c l i c k ' ,   f u n c t i o n   ( )   {   v a r   v a l u e   =   t h i s . i n n e t T e x t ;   C R S e n d A c c e p t R F C ( ' / G o S o c i a l . a s p x ? q = '   +   v a l u e ,   v a l u e ,   f a l s e ) ;   r e t u r n   t r u e ;   } ) ;  
                         l i n k . s e t A t t r i b u t e ( ' i n n e r T e x t ' ,   v a l u e ) ;  
                         R F C L i s t C o n t a i n e r . a p p e n d C h i l d ( l i n k ) ;  
                         R F C L i s t C o n t a i n e 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 ( " b r " ) ) ;  
                 }  
         }  
  
 }  
 f u n c t i o n   C R S e n d A c c e p t R F C ( c h a t U r l ,   r e q u e s t K e y ,   i s R e q u e s t O w n e r I d )   {  
         S e n d A c c e p t R F C ( c h a t U r l ,   r e q u e s t K e y ,   i s R e q u e s t O w n e r I d ,   o n C R S e n d A c c e p t R F C E n d e d ) ;  
 }  
 f u n c t i o n   o n C R S e n d A c c e p t R F C E n d e d ( d a t a )   {  
         / / A d d   c o d e   f o r   h a n d l i n g   o f   r e s u l t s  
 }  
 f u n c t i o n   C R G e t A c c e p t R F C ( r e q u e s t K e y ,   i s R e q u e s t O w n e r I d )   {  
         G e t A c c e p t R F C ( r e q u e s t K e y ,   i s R e q u e s t O w n e r I d ,   o n C R G e t A c c e p t R F C E n d e d ) ;  
 }  
 f u n c t i o n   o n C R G e t A c c e p t R F C E n d e d ( d a t a )   {  
         / / A d d   c o d e   f o r   h a n d l i n g   o f   r e s u l t s  
 }  
 f u n c t i o n   C R G e t A c c e p t R F C ( r e q u e s t K e y ,   i s R e q u e s t O w n e r I d )   {  
         G e t A c c e p t R F C ( r e q u e s t K e y ,   i s R e q u e s t O w n e r I d ,   o n C R G e t A c c e p t R F C E n d e d ) ;  
 }  
 f u n c t i o n   o n C R G e t A c c e p t R F C E n d e d ( d a t a )   {  
         / / A d d   c o d e   f o r   h a n d l i n g   o f   r e s u l t s  
 }  
 f u n c t i o n   C R R e m o v e R F C ( r e q u e s t K e y ,   i s R e q u e s t O w n e r I d )   {  
         R e m o v e R F C ( r e q u e s t K e y ,   i s R e q u e s t O w n e r I d ,   o n C R R e m o v e R F C E n d e d ) ;  
 }  
 f u n c t i o n   o n C R R e m o v e R F C E n d e d ( d a t a )   {  
         / / A d d   c o d e   f o r   h a n d l i n g   o f   r e s u l t s  
 }  
 / /   E n d   l o g i c   f o r   R e q u e s t   F o r   C h a t   ( R F C )   s y s t e m  
  
 v a r   w n d ;  
 v a r   w n d C l o s e d ;  
 v a r   a l e r t T i m e r I D ;  
 f u n c t i o n   o p e n L o g i n W i n d o w ( w i n d o w U r l ,   o n W i n d o w C l o s e )   {  
         v a r   w i d t h   =   9 4 0 ;  
         v a r   h e i g h t   =   4 3 0 ;  
         v a r   l e f t   =   ( s c r e e n . w i d t h   -   w i d t h )   /   2 ;  
         v a r   t o p   =   ( s c r e e n . h e i g h t   -   h e i g h t )   /   2 ;  
         v a r   p a r a m s   =   ' w i d t h = '   +   w i d t h   +   ' ,   h e i g h t = '   +   h e i g h t ;  
         p a r a m s   + =   ' ,   t o p = '   +   t o p   +   ' ,   l e f t = '   +   l e f t ;  
         p a r a m s   + =   ' ,   d i r e c t o r i e s = n o ' ;  
         p a r a m s   + =   ' ,   l o c a t i o n = n o ' ;  
         p a r a m s   + =   ' ,   m e n u b a r = n o ' ;  
         p a r a m s   + =   ' ,   r e s i z a b l e = n o ' ;  
         p a r a m s   + =   ' ,   s c r o l l b a r s = n o ' ;  
         p a r a m s   + =   ' ,   s t a t u s = n o ' ;  
         p a r a m s   + =   ' ,   t o o l b a r = n o ' ;  
         w n d   =   w i n d o w . o p e n ( w i n d o w U r l ,   ' T w i t t e r A u t h e n t i c a t i o n ' ,   p a r a m s ) ;  
         i f   ( w i n d o w . f o c u s )   {   w n d . f o c u s ( ) ;   }  
         w n d C l o s e d   =   o n W i n d o w C l o s e ;  
         a l e r t T i m e r I D   =   w i n d o w . s e t I n t e r v a l ( o n M a i n W i n d o w F o c u s ,   5 0 0 ) ;  
 }  
  
 f u n c t i o n   o p e n S h a r e W i n d o w ( s h U r l ,   o n W i n d o w C l o s e )   {  
         v a r   w i d t h   =   5 0 0 ;  
         v a r   h e i g h t   =   2 0 0 ;  
         v a r   l e f t   =   ( s c r e e n . w i d t h   -   w i d t h )   /   2 ;  
         v a r   t o p   =   ( s c r e e n . h e i g h t   -   h e i g h t )   /   2 ;  
         v a r   p a r a m s   =   ' w i d t h = '   +   w i d t h   +   ' ,   h e i g h t = '   +   h e i g h t ;  
         p a r a m s   + =   ' ,   t o p = '   +   t o p   +   ' ,   l e f t = '   +   l e f t ;  
         p a r a m s   + =   ' ,   d i r e c t o r i e s = n o ' ;  
         p a r a m s   + =   ' ,   l o c a t i o n = n o ' ;  
         p a r a m s   + =   ' ,   m e n u b a r = n o ' ;  
         p a r a m s   + =   ' ,   r e s i z a b l e = n o ' ;  
         p a r a m s   + =   ' ,   s c r o l l b a r s = n o ' ;  
         p a r a m s   + =   ' ,   s t a t u s = n o ' ;  
         p a r a m s   + =   ' ,   t o o l b a r = n o ' ;  
         w n d   =   w i n d o w . o p e n ( ' h t t p : / / w w w . l a v v a . c o m / t w s h a r e . a s p x ? u r l = '   +   s h U r l ,   ' t w s h a r e ' ,   p a r a m s ) ;  
         i f   ( w i n d o w . f o c u s )   {   w n d . f o c u s ( ) ;   }  
         w n d C l o s e d   =   o n W i n d o w C l o s e ;  
         a l e r t T i m e r I D   =   w i n d o w . s e t I n t e r v a l ( o n M a i n W i n d o w F o c u s ,   5 0 0 ) ;  
 }  
  
 f u n c t i o n   o n M a i n W i n d o w F o c u s ( )   {  
         i f   ( w n d . c l o s e d   & &   t y p e o f   ( w n d C l o s e d )   = = =   ' f u n c t i o n ' )   {  
                 c l e a r I n t e r v a l ( a l e r t T i m e r I D ) ;  
                 w n d C l o s e d ( ) ;  
         }  
 }  
  
 v a r   s c r e e n N a m e C a c h e   =   n e w   A r r a y ( ) ;  
 f u n c t i o n   V a l i d a t e S c r e e n N a m e ( s o u r c e ,   a r g s )   {  
         / /         i f   ( t y p e o f   ( H t m l C o n t e n t )   ! = =   ' u n d e f i n e d ' )   {  
         / /                 H t m l C o n t e n t . V a l i d a t e S c r e e n N a m e ( a r g s . V a l u e ,   s o u r c e . i d ,   o n V a l i d a t e S u c c e s s ,   o n V a l i d a t e F a i l ,   n u l l ) ;  
         / /                 / / 	 	 a r g s . I s V a l i d   =   f a l s e ;  
         / /         }  
         $ . p o s t ( ' h t t p : / / w w w . l a v v a . c o m / S e r v i c e s / L a v v a S e r v i c e . a s h x ? m e t h = V A L I D A T E S C R E E N N A M E ' ,   {   v a l I d :   s o u r c e . i d ,   s c r n :   a r g s . V a l u e   } ,   o n V a l i d a t e S u c c e s s ,   " j s o n " ) ;  
 }  
  
 f u n c t i o n   V a l i d a t e S c r e e n N a m e F o r P r e s e n t I n D B ( s o u r c e ,   a r g s )   {  
         / / i f   ( t y p e o f   ( H t m l C o n t e n t )   ! = =   ' u n d e f i n e d ' )   {  
         / /         H t m l C o n t e n t . V a l i d a t e S c r e e n N a m e ( a r g s . V a l u e ,   s o u r c e . i d ,   o n V a l i d a t e S u c c e s s F o r P r e s e n t I n D B ,   o n V a l i d a t e F a i l ,   n u l l ) ;  
         / /         / / 	 	 a r g s . I s V a l i d   =   f a l s e ;  
         / / }  
         $ . p o s t ( ' h t t p : / / w w w . l a v v a . c o m / S e r v i c e s / L a v v a S e r v i c e . a s h x ? m e t h = V A L I D A T E S C R E E N N A M E ' ,   {   v a l I d :   s o u r c e . i d ,   s c r n :   a r g s . V a l u e   } ,   o n V a l i d a t e S u c c e s s F o r P r e s e n t I n D B ,   " j s o n " ) ;  
 }  
  
 f u n c t i o n   o n V a l i d a t e S u c c e s s F o r P r e s e n t I n D B ( r e s p o n c e ,   s t a t e )   {  
         v a r   v a l i d a t o r   =   d o c u m e n t . g e t E l e m e n t B y I d ( r e s p o n c e . V a l i d a t o r I d ) ;  
         P a g e _ I s V a l i d   =   ! r e s p o n c e . I s V a l i d ;  
         v a l i d a t o r . i s v a l i d   =   ! r e s p o n c e . I s V a l i d ;  
         V a l i d a t o r U p d a t e D i s p l a y ( v a l i d a t o r ) ;  
 }  
  
 f u n c t i o n   o n V a l i d a t e S u c c e s s ( r e s p o n c e ,   s t a t e )   {  
         v a r   v a l i d a t o r   =   d o c u m e n t . g e t E l e m e n t B y I d ( r e s p o n c e . V a l i d a t o r I d ) ;  
         P a g e _ I s V a l i d   =   v a l i d a t o r . i s v a l i d   =   r e s p o n c e . I s V a l i d ;  
         / / V a r i a b l e   d i v S N   d e c l a r e d   i n   R e g i s t r a t i o n   p a g e  
         i f   ( t y p e o f   ( d i v S N )   ! = =   ' u n d e f i n e d ' )   {  
                 i f   ( ! r e s p o n c e . I s V a l i d )   {  
                         d i v S N . i n n e r H T M L   =   r e s p o n c e . D a t a [ 0 ] ;  
                 }  
                 e l s e   {  
                         d i v S N . i n n e r H T M L   =   ' ' ;  
                 }  
         }  
         V a l i d a t o r U p d a t e D i s p l a y ( v a l i d a t o r ) ;  
 }  
  
 f u n c t i o n   o n V a l i d a t e F a i l ( r e s p o n c e ,   s t a t e )   {  
  
 }  
  
 f u n c t i o n   V a l i d a t e L a v v a E m a i l ( s o u r c e ,   a r g s )   {  
         / /         i f   ( t y p e o f   ( H t m l C o n t e n t )   ! = =   ' u n d e f i n e d ' )   {  
         / /                 H t m l C o n t e n t . I s E m a i l U n i q u e ( a r g s . V a l u e ,   s o u r c e . i d ,   o n E m a i l V a l i d a t e S u c c e s s )  
         / /         }  
         $ . p o s t ( ' h t t p : / / w w w . l a v v a . c o m / S e r v i c e s / L a v v a S e r v i c e . a s h x ? m e t h = I S E M A I L U N I Q U E ' ,   {   v a l I d :   s o u r c e . i d ,   e m a i l :   a r g s . V a l u e   } ,   o n E m a i l V a l i d a t e S u c c e s s ,   " j s o n " ) ;  
 }  
 f u n c t i o n   o n E m a i l V a l i d a t e S u c c e s s ( r e s p o n c e ,   s t a t e )   {  
         v a r   v a l i d a t o r   =   d o c u m e n t . g e t E l e m e n t B y I d ( r e s p o n c e . V a l i d a t o r I d ) ;  
         P a g e _ I s V a l i d   =   v a l i d a t o r . i s v a l i d   =   r e s p o n c e . I s V a l i d ;  
         V a l i d a t o r U p d a t e D i s p l a y ( v a l i d a t o r ) ;  
 }  
  
 f u n c t i o n   V a l i d a t e L a v v a L o g i n ( s o u r c e ,   a r g s )   {  
         / / i f   ( t y p e o f   ( H t m l C o n t e n t )   ! = =   ' u n d e f i n e d ' )   {  
         / / H t m l C o n t e n t . V a l i d a t e L o g i n N a m e ( a r g s . V a l u e ,   s o u r c e . i d ,   o n L o g i n V a l i d a t e S u c c e s s )  
         / / }  
         $ . p o s t ( ' h t t p : / / w w w . l a v v a . c o m / S e r v i c e s / L a v v a S e r v i c e . a s h x ? m e t h = V A L I D A T E L O G I N N A M E ' ,   {   v a l I d :   s o u r c e . i d ,   s c r n :   a r g s . V a l u e   } ,   o n L o g i n V a l i d a t e S u c c e s s ,   " j s o n " ) ;  
 }  
 f u n c t i o n   o n L o g i n V a l i d a t e S u c c e s s ( r e s p o n c e ,   s t a t e )   {  
         v a r   v a l i d a t o r   =   d o c u m e n t . g e t E l e m e n t B y I d ( r e s p o n c e . V a l i d a t o r I d ) ;  
         P a g e _ I s V a l i d   =   v a l i d a t o r . i s v a l i d   =   r e s p o n c e . I s V a l i d ;  
         / / V a r i a b l e   d i v L C   d e c l a r e d   i n   R e g i s t r a t i o n   p a g e  
         i f   ( t y p e o f   ( d i v L N )   ! = =   ' u n d e f i n e d ' )   {  
                 i f   ( ! r e s p o n c e . I s V a l i d )   {  
  
                         d i v L N . i n n e r H T M L   =   r e s p o n c e . D a t a [ 0 ] ;  
                 }  
                 e l s e   {  
                         d i v L N . i n n e r H T M L   =   ' ' ;  
                 }  
         }  
         V a l i d a t o r U p d a t e D i s p l a y ( v a l i d a t o r ) ;  
 }  
  
 f u n c t i o n   o n G r o u p S l i d i n g ( s l i d e E l )   {  
         $ ( s l i d e E l ) . p a r e n t s ( " . x S l G r o u p " )  
                                         . f i n d ( " . x S l I t e m " )  
                                                 . s l i d e T o g g l e ( 1 5 0 )  
                                                 . e n d ( )  
                                         . t o g g l e C l a s s ( " x S l i d G r o u p " ) ;  
 }  
 f u n c t i o n   s h o w N e w s P r w V i d e o ( e m b e d )   {  
         i f   ( e m b e d   = =   " " )   {  
                 e m b e d   =   ' < d i v   s t y l e = " w i d t h : 2 0 0 p x ; h e i g h t : 4 0 p x ; f o n t - s i z e : 1 4 p x ; t e x t - a l i g n : c e n t e r ; " > S o u r c e   i s   n o t   f o u n d < / d i v > ' ;  
                 $ ( " # d i v N e w s P r e v i e w " ) . h t m l ( e m b e d ) ;  
         }  
         e l s e   {  
                 $ ( " # d i v N e w s P r e v i e w " ) . h t m l ( ' < d i v   s t y l e = " w i d t h : 4 0 0 p x ; h e i g h t : 3 2 0 p x ; o v e r f l o w : h i d d e n " > '   +   e m b e d   +   ' < / d i v > ' ) ;  
                 / / $ ( " # d i v N e w s P r e v i e w " ) . c h i l d r e n ( 0 ) . c s s ( {   ' p o s i t i o n ' :   ' a b s o l u t e ' ,   t o p :   0 ,   l e f t :   0   } ) ;  
                 s e t T i m e o u t (  
                         f u n c t i o n   ( )   {  
                                 / / $ ( " # d i v N e w s P r e v i e w " ) . c h i l d r e n ( 0 ) . c s s ( ' p o s i t i o n ' ,   ' s t a t i c ' ) ;  
                                 e m b e d   =   $ ( " # d i v N e w s P r e v i e w   e m b e d " ) . g e t ( 0 ) ;  
                                 v a r   e m W i d t h   =   e m b e d . w i d t h ;  
                                 v a r   e m H e i g h t   =   e m b e d . h e i g h t ;  
                                 v a r   c o e f   =   e m W i d t h   /   e m H e i g h t ;  
                                 i f   ( e m W i d t h   >   4 0 0   & &   c o e f   >   ( 4 0 0   /   3 2 0 ) )   {  
                                         e m b e d . w i d t h   =   4 0 0 ;  
                                         e m b e d . h e i g h t   =   4 0 0   /   c o e f ;  
                                 }  
                                 e l s e   i f   ( e m H e i g h t   >   3 2 0 )   {  
                                         e m b e d . h e i g h t   =   3 2 0 ;  
                                         e m b e d . w i d t h   =   3 2 0   *   c o e f ;  
                                 }  
                         } ,   1 ) ;  
         }  
 }  
 f u n c t i o n   C h a n g e C o n t a i n e r D i s p l a y M o d e ( c o n t a i n e r I d ,   m o d e )   {  
         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 ( c o n t a i n e r I d ) ;  
         i f   ( c o n t a i n e r   ! = =   ' u n d e f i n e d ' )   {  
                 c o n t a i n e r . s t y l e . d i s p l a y   =   m o d e ;  
         }  
 }  
  
 f u n c t i o n   G e t U r l P a r a m ( k e y )   {  
         v a r   r e s u l t ;  
         v a r   u r l   =   w i n d o w . l o c a t i o n . t o S t r i n g ( ) ;  
         v a r   q u e r y _ s t r i n g   =   u r l . s p l i t ( " ? " ) ;  
         i f   ( q u e r y _ s t r i n g . l e n g t h   >   1 )   {  
                 v a r   p a r a m s   =   q u e r y _ s t r i n g [ 1 ] . s p l i t ( " & " ) ;  
                 f o r   ( v a r   i   =   0 ;   i   <   p a r a m s . l e n g t h ;   i + + )   {  
                         v a r   i t e m   =   p a r a m s [ i ] . s p l i t ( ' = ' ) ;  
                         i f   ( i t e m [ 0 ]   = = =   k e y )   {  
                                 r e s u l t   =   i t e m [ 1 ] ;  
                                 b r e a k ;  
                         }  
                 }  
         }  
         r e t u r n   r e s u l t ;  
 }  
  
 f u n c t i o n   C o n v e r t U r l s T o L i n k s ( t e x t )   {  
         r e t u r n   t e x t . r e p l a c e ( / ( f t p | h t t p | h t t p s | f i l e ) : \ / \ / [ \ S ] + ( \ b | $ ) / g i m ,  
 " < a   h r e f = ' $ & '   o n c l i c k = ' w i n d o w . o p e n ( \ " $ & \ " ) ;   r e t u r n   f a l s e ; ' > $ & < / a > " )  
         . r e p l a c e ( / ( [ ^ \ / ] ) ( w w w [ \ S ] + ( \ b | $ ) ) / g i m ,  
 " $ 1 < a   h r e f = ' h t t p : / / $ 2 '   o n c l i c k = ' w i n d o w . o p e n ( \ " $ 2 \ " ) ;   r e t u r n   f a l s e ; ' > $ 2 < / a > " ) ;  
 }  
  
 f u n c t i o n   E d i t P r o f i l e P h o t o ( )   {  
         $ ( ' . m a P P E d i t ' ) . h i d e ( ) ;  
         $ ( ' # e d i t P P B t n s ' ) . s h o w ( ) ;  
         $ ( ' . m a P U ' ) . r e m o v e A t t r ( " d i s a b l e d " ) ;  
 }  
 f u n c t i o n   A b o r t E d i t P r o f i l e P h o t o ( )   {  
         $ ( ' # e d i t P P B t n s ' ) . h i d e ( ) ;  
         $ ( ' . m a P P E d i t ' ) . s h o w ( ) ;  
         $ ( ' . m a P U ' ) . a t t r ( ' d i s a b l e d ' ,   ' d i s a b l e d ' ) ;  
 }  
 f u n c t i o n   g s P a n e l L o a d e r ( )   {  
         $ ( ' # g s P a n e l W r p ' ) . a p p e n d ( l o a d e r H T M L ) ;  
 }  
 f u n c t i o n   c l e a r G s P a n e l L o a d e r ( )   {  
         i f   ( w i n d o w . $ )   {  
                 $ ( ' # g s P a n e l W r p ' ) . f i n d ( " . p w L o a d e r " ) . r e m o v e ( ) ;  
                 f i t G S P a n e l ( ) ;  
         }  
 }  
 f u n c t i o n   f i t G S P a n e l ( )   {  
         i f   ( $ ( ' # g s P a n e l W r p   i f r a m e ' ) . a t t r ( " c o n t e n t W i n d o w " ) . d o c u m e n t . b o d y   = =   n u l l )  
                 r e t u r n   f a l s e ;  
         v a r   h   =   $ ( ' # g s P a n e l W r p   i f r a m e ' ) . a t t r ( " c o n t e n t W i n d o w " ) . d o c u m e n t . b o d y . o f f s e t H e i g h t ;  
         i f   ( w i n d o w . f l o a t G s P a n e l )   {  
                 $ ( ' # g s S l i d e r ' ) . h e i g h t ( h   <   2 0 0   ?   2 0 0   :   h   +   4 ) ;  
         }  
         i f   ( w i n d o w . n o G s A n i m a t i o n )   {  
                 w i n d o w . n o G s A n i m a t i o n   =   f a l s e ;  
                 $ ( ' # g s P a n e l W r p ' ) . h e i g h t ( h ) ;  
                 $ ( ' # g s S l i d e r ' ) . a n i m a t e ( {   w i d t h :   5 6 0   } ,   7 0 0 ) ;  
         }  
         e l s e  
                 $ ( ' # g s P a n e l W r p ' ) . s t o p ( ) . a n i m a t e ( {   h e i g h t :   h   } ,   7 0 0 ) ;  
 }  
 f u n c t i o n   t o o g l e G s P a n e l ( )   {  
         w i n d o w . f l o a t G s P a n e l   =   t r u e ;  
         w i n d o w . g s P a n e l S h o w n   =   ! w i n d o w . g s P a n e l S h o w n ;  
         i f   ( w i n d o w . g s P a n e l S h o w n )   {  
                 w i n d o w . n o G s A n i m a t i o n   =   t r u e ;  
                 g s P a n e l L o a d e r ( ) ;  
                 $ ( ' # g s P a n e l W r p   i f r a m e ' ) . a t t r ( " s r c " ,   w i n d o w . g s S r c ) ;  
         }  
         e l s e   {  
                 w i n d o w . g s S r c   =   $ ( ' # g s P a n e l W r p   i f r a m e ' ) . a t t r ( " s r c " ) ;  
                 $ ( ' # g s S l i d e r ' ) . s t o p ( ) . a n i m a t e ( {   w i d t h :   5 0   } ,   7 0 0 ,   f u n c t i o n   ( )   {   $ ( t h i s ) . h e i g h t ( 2 0 0 ) . f i n d ( " i f r a m e " ) . a t t r ( " s r c " ,   " " ) ;   } ) ;  
         }  
 }  
  
 f u n c t i o n   S h o w I m g I n f o ( c o n t r o l )   {  
         i f   ( ! S h o w I m g I n f o . b )  
                 S h o w I m g I n f o . b   =   $ ( d o c u m e n t . b o d y ) ;  
         i f   ( ! c o n t r o l . _ c h I n f o )  
                 c o n t r o l . _ c h I n f o   =   $ ( c o n t r o l ) . c h i l d r e n ( " . i n f o " ) ;  
         $ ( " . i n f o " ) . h i d e ( ) ;  
         v a r   i n f o   =   c o n t r o l . _ c h I n f o ;  
         v a r   w   =   S h o w I m g I n f o . b . w i d t h ( ) ;  
         i f   ( w   ! =   i n f o . d a t a ( " f i t t e d " ) )   {  
                 i n f o . c s s ( {   " m a r g i n - l e f t " :   - 2 0 0 ,   " m a r g i n - t o p " :   1 0   } ) ;  
                 / /   s h o w   a f t e r   s h i f t i n g ,   o t h e r w i s e   a n i m a t i o n   i s   s l o w e d   d o w n   i n   I E   o n   e l e m e n t s   t h o s e   c a u s e   h o r i z o n t a l   s c r o l l  
                 i n f o . s h o w ( ) ;  
                 v a r   f i t t e d E l   =   i n f o . c h i l d r e n ( " t a b l e " ) ;  
                 v a r   r i g h t   =   2 0 0   +   i n f o . o f f s e t ( ) . l e f t   +   f i t t e d E l . w i d t h ( )   +   1 2 0 ;  
                 i f   ( r i g h t   >   w )   {  
                         i n f o . c s s ( {   " m a r g i n - l e f t " :   3 0   +   w   -   r i g h t ,   " m a r g i n - t o p " :   6 0   } ) ;  
                 }  
                 e l s e  
                         i n f o . c s s ( " m a r g i n - l e f t " ,   8 0 ) ;  
  
                 i n f o . d a t a ( " f i t t e d " ,   w ) ;  
         }  
         e l s e  
                 i n f o . s h o w ( ) ;  
 }  
  
 f u n c t i o n   H i d e I m g I n f o ( c o n t r o l )   {  
         i f   ( ! c o n t r o l . _ c h I n f o )  
                 c o n t r o l . _ c h I n f o   =   $ ( c o n t r o l ) . c h i l d r e n ( " . i n f o " ) ;  
         v a r   i n f o   =   c o n t r o l . _ c h I n f o ;  
         i n f o . h i d e ( ) ;  
 }  
  
 / *   r t s   s t a r t   * /  
 v a r   c u r r R e g ;  
 v a r   s h o w O p t i o n s   =   f a l s e ;  
 v a r   c o u n t r y D i v T e m p l a t e   =   " < d i v   c l a s s = ' c o u n t r y N a m e   i n l i n e E l ' > < a   c l a s s = ' c N a m e '   h r e f = ' { 0 } s e t r e g = { 3 } ' > < i m g   b o r d e r = ' 0 '   s r c = ' h t t p : / / i m g . l a v v a . c o m / f l a g s / { 2 } . p n g '   s t y l e = ' h e i g h t : 1 2 p x ; w i d t h : 2 2 p x ; m a r g i n - r i g h t : 3 p x ; ' > { 1 } < / a > < / d i v > " ;  
 f u n c t i o n   S h o w C o u n t r i e s ( c o n t r o l ,   r e g i o n ,   c o u n t r i e s )   {  
         i f   ( ( c u r r R e g   = =   r e g i o n )   | |   ( r e g i o n   = =   ' W o r l d ' ) )  
                 r e t u r n   t r u e ;  
         $ ( c o n t r o l ) . p a r e n t s ( 0 ) . c h i l d r e n ( " . r e g " ) . c s s ( " c o l o r " ,   " # 8 3 8 3 8 3 " ) ;  
         $ ( c o n t r o l ) . c s s ( " c o l o r " ,   " # 5 5 5 5 5 5 " ) ;  
         v a r   d i v C o u n t r i e s   =   d o c u m e n t . g e t E l e m e n t B y I d ( ' d i v C o u n t r i e s ' ) ;  
         d i v C o u n t r i e s . s t y l e [ " d i s p l a y " ]   =   " " ;  
         d i v C o u n t r i e s . i n n e r H T M L   =   " " ;  
         $ . e a c h ( c o u n t r i e s ,   f u n c t i o n   ( i ,   c o u n t r y )   {  
                 v a r   c o n t r S p l i t   =   c o u n t r y . s p l i t ( " ; " ) ;  
                 d i v C o u n t r i e s . i n n e r H T M L   + =   S t r i n g . f o r m a t ( c o u n t r y D i v T e m p l a t e ,   c u r r e n t U r i ,   c o n t r S p l i t [ 0 ] ,   c o n t r S p l i t [ 0 ] . r e p l a c e ( /   / g ,   ' _ ' ) ,   c o n t r S p l i t [ 1 ] ) ;  
         } ) ;  
         c u r r R e g   =   r e g i o n ;  
         r e t u r n   f a l s e ;  
 }  
  
 v a r   c u r r e n t C o u n t r y ;  
 v a r   c i t y D i v T e m p l a t e   =   " < d i v   c l a s s = ' c i t y N a m e   i n l i n e E l ' > < a   c l a s s = ' c i t y N a m e ' > { 1 } < / a > < / d i v > " ;  
 f u n c t i o n   S h o w C i t i e s ( c o n t r o l ,   c o u n t r y ,   c i t i e s )   {  
         i f   ( ( c u r r e n t C o u n t r y   = =   c o u n t r y )   | |   ( c i t i e s   = =   n u l l ) )  
                 r e t u r n   t r u e ;  
         $ ( c o n t r o l ) . p a r e n t s ( 0 ) . c h i l d r e n ( " . r e g " ) . c s s ( " c o l o r " ,   " # 8 3 8 3 8 3 " ) ;  
         $ ( c o n t r o l ) . c s s ( " c o l o r " ,   " # 5 5 5 5 5 5 " ) ;  
         v a r   d i v C i t i e s   =   d o c u m e n t . g e t E l e m e n t B y I d ( ' d i v C i t i e s ' ) ;  
         d i v C i t i e s . s t y l e [ " d i s p l a y " ]   =   " " ;  
         d i v C i t i e s . i n n e r H T M L   =   " " ;  
         $ . e a c h ( c i t i e s ,   f u n c t i o n   ( i ,   c i t y )   {  
                 v a r   s p l i t e d C i t y D a t a   =   c i t y . s p l i t ( " ; " ) ;  
                 d i v C i t i e s . i n n e r H T M L   + =   S t r i n g . f o r m a t ( c o u n t r y D i v T e m p l a t e ,   s p l i t e d C i t y D a t a [ 0 ] ,   s p l i t e d C i t y D a t a [ 1 ] ) ;  
         } ) ;  
         c u r r e n t C o u n t r y   =   c o u n t r y ;  
         r e t u r n   f a l s e ;  
 }  
  
 f u n c t i o n   S h o w H i d e O p t i o n s ( c o n t r o l )   {  
         s h o w O p t i o n s   =   ! s h o w O p t i o n s ;  
         i f   ( s h o w O p t i o n s )   {  
                 $ ( c o n t r o l ) . t e x t ( " H i d e   O p t i o n s ? " ) ;  
                 $ ( " # d i v O p t i o n s " ) . s h o w ( ) ;  
         }  
         e l s e   {  
                 $ ( c o n t r o l ) . t e x t ( " S h o w   O p t i o n s ? " ) ;  
                 $ ( " # d i v O p t i o n s " ) . h i d e ( ) ;  
         }  
 }  
 / *   r t s   e n d * /  
 f u n c t i o n   b o l d S u g g s ( s e n d e r ,   a r g s )   {  
         v a r   l i s t   =   s e n d e r . g e t _ c o m p l e t i o n L i s t ( ) . c h i l d r e n ;  
         v a r   p r e f i x R E   =   n e w   R e g E x p ( s e n d e r . _ c u r r e n t P r e f i x ,   " g " ) ;  
         v a r   b o l d   =   " < b > "   +   s e n d e r . _ c u r r e n t P r e f i x   +   " < / b > " ;  
         f o r   ( v a r   i   =   0 ;   i   <   l i s t . l e n g t h ;   i + + )   {  
                 l i s t [ i ] . i n n e r H T M L   =   l i s t [ i ] . i n n e r H T M L . r e p l a c e ( p r e f i x R E ,   b o l d ) ;  
         }  
 }  
 f u n c t i o n   s h o w S u g g s ( s e n d e r )   {  
         v a r   l i s t   =   s e n d e r . g e t _ c o m p l e t i o n L i s t ( ) ;  
         v a r   w r a p p e r   =   $ ( l i s t . p a r e n t N o d e ) . f i n d ( " d i v . p p N F i x e d W r a p p e r " ) ;  
         w r a p p e r . h e i g h t ( $ ( l i s t ) . h e i g h t ( ) ) ;  
         w r a p p e r . s h o w ( ) ;  
 }  
 f u n c t i o n   h i d e S u g g s ( s e n d e r )   {  
         v a r   l i s t   =   s e n d e r . g e t _ c o m p l e t i o n L i s t ( ) ;  
         v a r   w r a p p e r   =   $ ( l i s t . p a r e n t N o d e ) . f i n d ( " d i v . p p N F i x e d W r a p p e r " ) ;  
         $ ( w r a p p e r ) . h i d e ( ) ;  
 }  
 f u n c t i o n   s e l e c t S u g g ( s e n d e r ,   i t e m )   {  
         s e n d e r . g e t _ e l e m e n t ( ) . v a l u e   =   i t e m . g e t _ v a l u e ( ) ;  
 }  
 f u n c t i o n   G o S o c i a l N e w s ( t i t l e ,   n e w s I d )   {  
         i f   ( s p i f r a m e )   {  
                 v a r   s o c p a n   =   d o c u m e n t . g e t E l e m e n t B y I d ( s p i f r a m e ) ;  
                 s o c p a n . s r c   =   " h t t p : / / w w w . l a v v a . c o m / G o S o c i a l P a n e l / G S P a n e l . a s p x ? q = "   +   t i t l e   +   " & n i d = "   +   n e w s I d   +   " & r = 1 " ;  
         }  
 }  
  
 f u n c t i o n   G e t U s e r S M ( )   {  
         / / H t m l C o n t e n t . G e t S o f t M a r k s ( S M S u c c e s s ,   n u l l ) ;  
         $ . p o s t ( ' h t t p : / / w w w . l a v v a . c o m / S e r v i c e s / L a v v a S e r v i c e . a s h x ? m e t h = G E T S O F T M A R K S ' ,   n u l l ,   S M S u c c e s s ) ;  
         S h o w S M L o a d e r ( ) ;  
 }  
  
 / *   F A C E B O O K   * /  
  
 f u n c t i o n   s e t F B P e o p l e P a g e ( p a g e I n d e x ,   l a s t I n d e x ,   f T o w n ,   f I n t e r e s t s )   {  
         v a r   u r l   =   " h t t p : / / w w w . l a v v a . c o m / S e r v i c e s / L a v v a S e r v i c e . a s h x ? m e t h = G E T F A C E B O O K P E O P L E " ;  
         v a r   p I n d e x   =   p a g e I n d e x   | |   1 ;  
         v a r   l I n d e x   =   l a s t I n d e x   | |   1 ;  
         v a r   j s o n d a t a ;  
         i f   ( f T o w n   ! = =   u n d e f i n e d   & &   f I n t e r e s t s   ! = =   u n d e f i n e d )   {  
                 j s o n d a t a   =   {   p I n d e x :   p I n d e x ,   l I n d e x :   l I n d e x ,   f T o w n :   f T o w n ,   f I n t e r e s t s :   f I n t e r e s t s   } ;  
                 f T o w n   =   " ' "   +   f T o w n   +   " ' " ;   f I n t e r e s t s   =   " ' "   +   f I n t e r e s t s   +   " ' " ;  
         }  
         e l s e   i f   ( f T o w n   ! = =   u n d e f i n e d )   {  
                 j s o n d a t a   =   {   p I n d e x :   p I n d e x ,   l I n d e x :   l I n d e x ,   f T o w n :   f T o w n   } ;  
                 f T o w n   =   " ' "   +   f T o w n   +   " ' " ;  
         }  
         e l s e   i f   ( f I n t e r e s t s   ! = =   u n d e f i n e d )   {  
                 j s o n d a t a   =   {   p I n d e x :   p I n d e x ,   l I n d e x :   l I n d e x ,   f I n t e r e s t s :   f I n t e r e s t s   } ;  
                 f I n t e r e s t s   =   " ' "   +   f I n t e r e s t s   +   " ' " ;  
         }  
         e l s e   {  
                 j s o n d a t a   =   {   p I n d e x :   p I n d e x ,   l I n d e x :   l I n d e x   } ;  
         }  
  
         $ . g e t ( u r l ,   j s o n d a t a ,  
                 f u n c t i o n   ( r e s p o n s e )   {  
                         i f   ( r e s p o n s e )   {  
                                 v a r   r   =   J S O N . p a r s e ( r e s p o n s e ) ;  
                                 i f   ( r . d a t a   ! = =   " n o " )   {  
                                         i f   ( r . d a t a . l e n g t h   >   0 )   {  
                                                 $ ( " # d i v F a c e b o o k " ) . f a d e O u t ( 5 0 0 ,   f u n c t i o n   ( )   {  
  
                                                         / / $ ( " # d i v F a c e b o o k " ) . h t m l ( r e s p o n s e ) . a p p e n d ( " < d i v   s t y l e = \ " c l e a r :   l e f t ; \ " > < / d i v > " ) . f a d e I n ( 5 0 0 ) ;    
                                                         $ ( " # d i v F a c e b o o k " ) . e m p t y ( ) ;  
  
                                                         i f   ( r . p a g i n a t i o n . p a g e N u m   ! =   1 )   {  
                                                                 v a r   a p p e n d S t r i n g   =   " < d i v   s t y l e = \ " d i s p l a y :   b l o c k ;   f l o a t :   l e f t ; \ " > < a   h r e f = \ " # \ "   o n c l i c k = \ " s e t F B P e o p l e P a g e ( "   +   ( p I n d e x   -   1 )   +   ' , '   +   l I n d e x   +   ' , '   +   f T o w n   +   ' , '   +   f I n t e r e s t s   +   " ) ;   r e t u r n   f a l s e ; \ "   c l a s s = \ " b t n P r e v S m a l l \ " > < / a > < / d i v > " ;  
                                                                 $ ( " # d i v F a c e b o o k " ) . a p p e n d ( a p p e n d S t r i n g ) ;  
                                                         }  
                                                         f o r   ( v a r   i   =   0 ;   i   <   r . d a t a . l e n g t h ;   i + + )   {  
                                                                 v a r   a p p e n d S t r i n g   =   " < d i v   c l a s s = \ " P e o p l e I t e m \ " > < d i v   c l a s s = \ " P e o p l e A v a t a r \ " > < i m g   c l a s s = \ " u s e r F B A v a t a r \ "   s r c = \ " h t t p s : / / g r a p h . f a c e b o o k . c o m / "   +   r . d a t a [ i ] . i d   +   " / p i c t u r e \ "   a l t = \ " "   +   r . d a t a [ i ] . n a m e   +   " \ "   t i t l e = \ " "   +   r . d a t a [ i ] . n a m e   +   " \ " / > < / d i v > < / d i v > " ;  
                                                                 $ ( " # d i v F a c e b o o k " ) . a p p e n d ( a p p e n d S t r i n g ) ;  
                                                         }  
                                                         i f   ( r . p a g i n a t i o n . p a g e N u m   ! =   r . p a g i n a t i o n . l a s t P a g e N u m   & &   r . p a g i n a t i o n . l a s t P a g e N u m   ! =   1 )   {  
                                                                 l I n d e x   =   r . p a g i n a t i o n . l a s t P a g e N u m ;  
                                                                 v a r   a p p e n d S t r i n g   =   " < d i v   s t y l e = \ " d i s p l a y :   b l o c k ;   f l o a t :   l e f t ; \ " > < a   h r e f = \ " # \ "   o n c l i c k = \ " s e t F B P e o p l e P a g e ( "   +   ( p I n d e x   +   1 )   +   ' , '   +   l I n d e x   +   ' , '   +   f T o w n   +   ' , '   +   f I n t e r e s t s   +   " ) ;   r e t u r n   f a l s e ; \ "   c l a s s = \ " b t n N e x t S m a l l \ " > < / a > < / d i v > " ;  
                                                                 $ ( " # d i v F a c e b o o k " ) . a p p e n d ( a p p e n d S t r i n g ) ;  
                                                         }  
                                                         $ ( " # d i v F a c e b o o k " ) . a p p e n d ( " < d i v   s t y l e = \ " c l e a r :   l e f t ; \ " > < / d i v > " ) ;  
                                                         $ ( " # d i v F a c e b o o k " ) . f a d e I n ( 5 0 0 ) ;  
                                                 } ) ;  
                                         }  
                                         e l s e   {  
 / /                                                 $ ( " # d i v F a c e b o o k " ) . h t m l ( " < d i v   s t y l e = \ " d i s p l a y :   b l o c k ;   f l o a t :   l e f t ; \ " > N o   r e s u l t s   f o u n d < / d i v > < d i v   s t y l e = \ " c l e a r :   l e f t ; \ " > < / d i v > " ) ;  
 / /                                                 $ ( " # d i v F a c e b o o k " ) . f a d e I n ( 5 0 0 ) ;  
                                         }  
                                 }  
                                 e l s e   {  
 / /                                         $ ( " # d i v F a c e b o o k " ) . h t m l ( " < d i v   s t y l e = \ " d i s p l a y :   b l o c k ;   f l o a t :   l e f t ; \ " > N o   r e s u l t s   f o u n d < / d i v > < d i v   s t y l e = \ " c l e a r :   l e f t ; \ " > < / d i v > " ) ;  
 / /                                         $ ( " # d i v F a c e b o o k " ) . f a d e I n ( 5 0 0 ) ;  
                                 }  
                         }  
                         e l s e   {  
                                 $ ( " # d i v F a c e b o o k " ) . h t m l ( " < d i v   s t y l e = \ " d i s p l a y :   b l o c k ;   f l o a t :   l e f t ; \ " > F a i l e d   t o   g e t   r e s u l t s < / d i v > < d i v   s t y l e = \ " c l e a r :   l e f t ; \ " > < / d i v > " ) ;  
                                 $ ( " # d i v F a c e b o o k " ) . f a d e I n ( 5 0 0 ) ;  
                         }  
                 } ) ;  
  
 }  
  
 / *   E N D   F A C E B O O K   * /  
  
 / *   N E W S   * /  
  
 f u n c t i o n   g e t N e w s ( p a g e I n d e x ,   c a t e g o r y I n d e x )   {  
         v a r   c a t I n d e x   =   c a t e g o r y I n d e x   | |   w i n d o w . a c t i v e N e w s T a b ;  
         u r l   =   " h t t p : / / w w w . l a v v a . c o m / S e r v i c e s / L a v v a S e r v i c e . a s h x ? m e t h = G E T N E W S & p a g e = "   +   p a g e I n d e x   +   " & c a t = "   +   c a t I n d e x ;  
         $ . g e t ( u r l ,  
                             n u l l ,  
                             f u n c t i o n   ( r e s u l t )   {  
                                     i f   ( r e s u l t   & &   r e s u l t   ! =   n u l l   & &   r e s u l t   ! =   ' u n d e f i n e d ' )  
                                             $ ( ' # n e w s L i s t ' ) . e m p t y ( ) . h t m l ( r e s u l t ) ;  
                             } ,  
                             " h t m l " ) ;  
  
         i f   ( _ p a g e I n d e x   = =   _ p a g e s C o u n t   -   1 )   {  
                 $ ( " # a M o r e " ) . r e m o v e C l a s s ( " b t n M o r e " ) . c s s ( " v i s i b i l i t y " ,   " h i d d e n " ) ;  
         }  
         e l s e   {  
                 $ ( " # a M o r e " ) . a d d C l a s s ( " b t n M o r e " ) . c s s ( " v i s i b i l i t y " ,   " v i s i b l e " ) ;  
         }  
  
         i f   ( _ p a g e I n d e x   = =   0 )   {  
                 $ ( " # a N e w e s t " ) . r e m o v e C l a s s ( " b t n N e w e s t " ) . c s s ( " v i s i b i l i t y " ,   " h i d d e n " ) ;  
         }  
         e l s e   {  
                 $ ( " # a N e w e s t " ) . a d d C l a s s ( " b t n N e w e s t " ) . c s s ( " v i s i b i l i t y " ,   " v i s i b l e " ) ;  
         }  
 }  
  
  
 f u n c t i o n   g e t M o r e N e w s ( )   {  
         i f   ( _ p a g e I n d e x   <   _ p a g e s C o u n t   -   1 )   {  
                 _ p a g e I n d e x + + ;  
                 g e t N e w s ( _ p a g e I n d e x ,   _ c a t e g o r y I n d e x ) ;  
         }  
 }  
  
 f u n c t i o n   g e t N e w e s t N e w s ( )   {  
         i f   ( _ p a g e I n d e x   >   0 )   {  
                 _ p a g e I n d e x - - ;  
                 g e t N e w s ( _ p a g e I n d e x ,   _ c a t e g o r y I n d e x ) ;  
         }  
 }  
  
 f u n c t i o n   s e t C u r r e n t C a t e g o r y ( c a t e g o r y I n d e x )   {  
         $ ( d o c u m e n t ) . r e a d y ( f u n c t i o n   ( )   {  
                 w i n d o w . a c t i v e N e w s T a b   =   c a t e g o r y I n d e x ;  
                 v a r   e l e m e n t N a m e   =   ' # n e w s C a t e g o r y '   +   c a t e g o r y I n d e x ;  
                 v a r   l E l e m e n t N a m e   =   ' # n e w s C a t '   +   c a t e g o r y I n d e x ;  
                 v a r   g e t t e d E l e m e n t   =   $ ( e l e m e n t N a m e ) . g e t ( ) ;  
  
                 $ ( ' . n e w s C a t e g o r y ' ) . r e m o v e C l a s s ( ' a c t i v e N e w s C a t e g o r y T a b ' ) ;  
                 $ ( ' . n e w s C a t ' ) . r e m o v e C l a s s ( ' a c t i v e N e w s T a b ' ) ;  
                 $ ( l E l e m e n t N a m e ) . a d d C l a s s ( ' a c t i v e N e w s T a b ' ) ;  
                 $ ( e l e m e n t N a m e ) . a d d C l a s s ( ' a c t i v e N e w s C a t e g o r y T a b ' ) ;  
                 i f   ( c a t e g o r y I n d e x   > =   0 )   {  
                         _ c a t e g o r y I n d e x   =   c a t e g o r y I n d e x ;  
                         _ p a g e I n d e x   =   0 ;  
                         g e t N e w s ( _ p a g e I n d e x ,   _ c a t e g o r y I n d e x ) ;  
                 }  
  
         } ) ;  
 }  
  
 f u n c t i o n   g e t N e w s R o o t C a t e g o r i e s ( w i t h T e x t )   {  
         u r l   =   " h t t p : / / w w w . l a v v a . c o m / S e r v i c e s / L a v v a S e r v i c e . a s h x ? m e t h = G E T N E W S R O O T C A T E G O R I E S " ;  
         i f   ( w i n d o w . a c t i v e N e w s T a b )   {  
                 u r l   + =   " & n e w s A c t i v e T a b = "   +   w i n d o w . a c t i v e N e w s T a b ;  
         }  
          
         $ . g e t ( u r l ,  
                             ( w i t h T e x t   = = =   t r u e   ?   {   w i t h T e x t :   " t r u e " }   :   {   w i t h T e x t :   " f a l s e "   } ) ,  
                             f u n c t i o n   ( r e s u l t )   {  
                                     i f   ( r e s u l t   & &   r e s u l t   ! =   n u l l   & &   r e s u l t   ! =   ' u n d e f i n e d ' )  
                                             $ ( " # c a t L i s t " ) . h t m l ( r e s u l t ) ;  
                             } ,  
                             " h t m l " ) ;  
 }  
  
 f u n c t i o n   C l e a r D i s c u s s A r t i c l e ( )   {  
         $ ( ' # d i s c u s s A r t i c l e ' ) . f a d e O u t ( 2 0 0 ,   f u n c t i o n   ( )   {  
                 $ ( ' # d i s c u s s A r t i c l e ' ) . r e m o v e ( ) ;  
                 $ ( ' . r c 1 0 ' ) . f a d e I n ( 2 0 0 ) . s h o w ( ) ;  
         } ) ;  
          
 }  
 f u n c t i o n   g o S o c i a l R T ( i n d e x )   {  
         	 	 i f ( w i n d o w . c u r r e n t T a b   = =   4 )   {  
                         v a r   e l e m I d   =   ' # l a t e s t N e w s I d '   +   i n d e x ;  
                         v a r   s t r i n g T o S e t   =   ' R T :   '   +   $ ( e l e m I d ) . t e x t ( ) ;  
                         v a r   f r a m e D o c u m e n t   =   $ ( ' . g s F r a m e ' ) ;  
                         v a r   s   =   ' # h 1 N e w s T i t l e '   +   i n d e x ;  
                         $ ( ' . n e w s H o v e r ' ) . r e m o v e C l a s s ( ' n e w s H o v e r ' ) ;  
                         $ ( s ) . p a r e n t s ( ' . n e w s ' ) . a d d C l a s s ( ' n e w s H o v e r ' ) ;  
                         v a r   q u e r y   =   $ ( s ) . t e x t ( ) ;  
                         $ ( ' . g s F r a m e ' ) . r e a d y ( f u n c t i o n   ( )   {  
                                 w i n d o w . f r a m e s . g s W t . S t a r t G e t t i n g R T S W e b R e s u l t ( q u e r y ) ;  
                         } ) ;  
 	          
                                 v a r   f r   =   $ ( ' . g s F r a m e ' ) . c o n t e n t s ( ) ;  
                                 f r . f i n d ( ' # s e n d W r p _ t x t M s g ' ) . f o c u s ( ) ;  
                                 v a r   i S t r i n g   =   " < d i v   i d = \ " d i s c u s s A r t i c l e \ " > < / d i v > " ;  
                                 $ ( ' . r c 1 0 ' ) . f a d e O u t ( 2 0 0 ,   f u n c t i o n   ( )   {  
                                         $ ( ' . r c 1 0 ' ) . h i d e ( ) ;  
                                         $ ( ' # t d T r e n d s ' ) . f a d e I n ( 2 0 0 ,   f u n c t i o n   ( )   {  
                                                 $ ( ' # d i s c u s s A r t i c l e ' ) . r e m o v e ( ) ;  
                                                 $ ( ' # t d T r e n d s ' ) . a p p e n d ( i S t r i n g ) ;  
                                         } ) ;  
  
                                 } ) ;  
                         }  
 }  
  
 f u n c t i o n   g e t H o s t n a m e ( s t r )   {  
         v a r   r e   =   n e w   R e g E x p ( ' ^ ( ? : f | h t ) t p ( ? : s ) ? \ : / / ( [ ^ / ] + ) ' ,   ' i m ' ) ;  
         r e t u r n   s t r . m a t c h ( r e ) [ 1 ] . t o S t r i n g ( ) ;  
 }  
 f u n c t i o n   s e t E m T a b ( i n d e x )   {  
         v a r   s r c   =   ' / G o S o c i a l P a n e l / G S P a n e l . a s p x ? = '   +   $ ( ' . s e a r c h B o x B a s e ' ) . v a l ( )   +   ' & G o S o c i a l = 1 ' ;  
         $ ( " # d i v F a c e b o o k " ) . h i d e ( ) ;  
         $ ( " # c a t L i s t " ) . e m p t y ( ) ;  
         $ ( " # n e w s L i s t " ) . e m p t y ( ) ;  
         $ ( " # t b l L F O " ) . r e m o v e ( ) ;  
         i f   ( $ ( ' # d i v W e b ' ) . i s ( ' : h i d d e n ' ) )   {   $ ( ' # d i v W e b ' ) . s h o w ( ) ;   }  
         i f   ( $ ( ' # d i v I m g ' ) . i s ( ' : h i d d e n ' ) )   {   $ ( ' # d i v I m g ' ) . s h o w ( ) ;   }  
         i f   ( $ ( ' # d i v V i d ' ) . i s ( ' : h i d d e n ' ) )   {   $ ( ' # d i v V i d ' ) . s h o w ( ) ;   }  
         i f   ( $ ( ' # d i v N e w s ' ) . i s ( ' : h i d d e n ' ) )   {   $ ( ' # d i v N e w s ' ) . s h o w ( ) ;   }  
         i f   ( $ ( ' # c a t L i s t ' ) . i s ( ' : v i s i b l e ' ) )   {   $ ( ' # c a t L i s t ' ) . h i d e ( ) ;   }  
         $ ( ' . a c t i v e T a b ' ) . r e m o v e C l a s s ( ' a c t i v e T a b ' ) . a d d C l a s s ( ' t a b ' ) ;  
         $ ( ' # p e o p l e T a b ' ) . a d d C l a s s ( ' a c t i v e T a b ' ) ;  
         s r c   + =   ' & e m = '   +   i n d e x ;  
         $ ( ' . g s F r a m e ' ) . a t t r ( ' s r c ' ,   s r c ) ;  
 }  
 f u n c t i o n   g o S o c i a l P e o p l e ( i n d e x )   {  
  
         i f   ( i n d e x )   {  
                          
                         v a r   e l e m I d   =   ' # r e s u l t L i n k '   +   i n d e x ;  
                         v a r   u r l E x t r a c t e d   =   $ ( e l e m I d ) . a t t r ( ' h r e f ' ) ;  
                         v a r   u r l   =   ' h t t p : / / '   +   g e t H o s t n a m e ( u n e s c a p e ( u r l E x t r a c t e d ) )   +   ' / ' ;  
                         v a r   f r a m e D o c u m e n t   =   $ ( ' . g s F r a m e ' ) . c o n t e n t s ( ) ;  
                         f r a m e D o c u m e n t . f i n d ( ' # d i v S i t e N a m e ' ) . e m p t y ( ) . a p p e n d ( u r l ) ;  
                         s e t E m T a b ( u r l ) ;  
         }  
 }  
  
 $ ( d o c u m e n t ) . r e a d y ( f u n c t i o n   ( )   {  
         $ ( d o c u m e n t ) . c l i c k ( f u n c t i o n   ( e v e n t )   {  
                 i f   ( $ ( e v e n t . t a r g e t ) . a t t r ( ' i d ' )   ! = =   ' d i s c u s s A r t i c l e '   & &   ! $ ( e v e n t . t a r g e t ) . h a s C l a s s ( ' g o s o c i a l B t n ' ) )   {  
                         C l e a r D i s c u s s A r t i c l e ( ) ;  
                 }  
         } ) ;  
 } ) ;  
  
 f u n c t i o n   s h o w N e w s ( c l l b c k ,   c I n d e x )   {  
         g e t N e w s R o o t C a t e g o r i e s ( t r u e ) ;  
         v a r   p a g i n a t i o n   =   " < d i v   i d = \ " t b l L F O \ " > < a   h r e f = \ " j a v a s c r i p t : g e t M o r e N e w s ( ) ; \ "   i d = \ " a M o r e \ "   t i t l e = \ " M o r e \ "   c l a s s = \ " b t n M o r e \ " > < / a > < a   h r e f = \ " j a v a s c r i p t : g e t N e w e s t N e w s ( ) ; \ "   i d = \ " a N e w e s t \ "   t i t l e = \ " N e w e s t \ "   c l a s s = \ " b t n N e w e s t \ " > < / a > < d i v   s t y l e = \ " c l e a r :   b o t h ; \ " > < / d i v > < / d i v > " ;  
         s e t C u r r e n t C a t e g o r y ( c I n d e x ) ;  
         g e t N e w s ( 0 ,   0 ) ;  
         $ ( d o c u m e n t ) . r e a d y ( f u n c t i o n   ( )   {  
                 v a r   s r c   =   ' / G o S o c i a l P a n e l / G S P a n e l . a s p x ? = '   +   $ ( ' . s e a r c h B o x B a s e ' ) . v a l ( )   +   ' & G o S o c i a l = 1 ' ;  
                 i f   ( $ ( ' # d i v F a c e b o o k ' ) . i s ( ' : h i d d e n ' ) )   {   $ ( " # d i v F a c e b o o k " ) . s h o w ( ) ;   }  
                 i f   ( $ ( ' # d i v W e b ' ) . i s ( ' : v i s i b l e ' ) )   {   $ ( ' # d i v W e b ' ) . h i d e ( ) ;   }  
                 i f   ( $ ( ' # d i v I m g ' ) . i s ( ' : v i s i b l e ' ) )   {   $ ( ' # d i v I m g ' ) . h i d e ( ) ;   }  
                 i f   ( $ ( ' # d i v V i d ' ) . i s ( ' : v i s i b l e ' ) )   {   $ ( ' # d i v V i d ' ) . h i d e ( ) ;   }  
                 i f   ( $ ( ' # d i v N e w s ' ) . i s ( ' : v i s i b l e ' ) )   {   $ ( ' # d i v N e w s ' ) . h i d e ( ) ;   }  
                 i f   ( $ ( ' # c a t L i s t ' ) . i s ( ' : h i d d e n ' ) )   {   $ ( ' # c a t L i s t ' ) . s h o w ( ) ;   }  
  
                
                 $ ( ' # d i v L a t e s t N e w s ' ) . a p p e n d ( p a g i n a t i o n ) ;  
                  
                 s r c   + =   ' & p = '   +   1 ;  
  
                 i f   ( s r c   ! = =   $ ( ' . g s F r a m e ' ) . a t t r ( ' s r c ' ) )   {   $ ( ' . g s F r a m e ' ) . a t t r ( ' s r c ' ,   s r c ) ;   }  
                 $ ( ' . g s F r a m e ' ) . l o a d ( f u n c t i o n   ( )   {  
                         $ ( ' . g s F r a m e ' ) . r e a d y ( f u n c t i o n   ( )   {  
                                 i f   ( c l l b c k   ! =   u n d e f i n e d )   {  
                                         c l l b c k ( ) ;  
                                 }  
                         } ) ;  
                 } ) ;  
         } ) ;  
 }  
 f u n c t i o n   m a k e N e w s A c t i v e ( c I n d e x )   {  
         w i n d o w . a c t i v e N e w s T a b   =   c I n d e x ;  
         $ ( d o c u m e n t ) . r e a d y ( f u n c t i o n   ( )   {  
                 $ ( ' . a c t i v e T a b ' ) . r e m o v e C l a s s ( ' a c t i v e T a b ' ) . a d d C l a s s ( ' t a b ' ) ;  
                 $ ( ' # l a t e s t N e w s T a b ' ) . a d d C l a s s ( ' a c t i v e T a b ' ) ;  
                  
         } ) ;  
 }  
  
 f u n c t i o n   s e t N e w s T a b ( c l l b c k ,   c I n d e x )   {  
          
         m a k e N e w s A c t i v e ( c I n d e x ) ;  
         s h o w N e w s ( c l l b c k , c I n d e x ) ;  
          
         }  
  
          
        
          
 / *   E N D   N E W S   * / 
