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