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