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

