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