ÿþv a r   s e r v i c e s H a s h   =   n e w   A r r a y ( )  
 s e r v i c e s H a s h [ " Q " ]   =   " Q u i c k   C o l l e c t "  
 s e r v i c e s H a s h [ " P " ]   =   " P r e p a i d   S e r v i c e s "  
  
 v a r   c o u n t r y H a s h   =   n e w   A r r a y ( )  
 v a r   r e v C o u n t r y H a s h   =   n e w   A r r a y ( )  
 v a r   c u r r e n c i e s H a s h   =   n e w   A r r a y ( )  
 v a r   r e v C u r r e n c i e s H a s h   =   n e w   A r r a y ( )  
 v a r   c o u n t r y C u r r e n c i e s H a s h   =   n e w   A r r a y ( )  
 v a r   o p t i o n s H a s h   =   n e w   A r r a y ( )  
 v a r   c o u n t r y O p t i o n s H a s h   =   n e w   A r r a y ( )  
  
 v a r   p l u r a l   =   t r u e  
 v a r   s i n g u l a r   =   f a l s e  
 v a r   i n E n g l i s h   =   t r u e  
  
 v a r   r e g E x p   =   n e w   R e g E x p ( " &   " )  
 f o r   ( v a r   i   =   0 ;   i   <   c o u n t r y N a m e s . l e n g t h ;   i + + )   {  
 	 v a r   i n t l C o u n t r y N a m e   =   c o u n t r y N a m e s [ i ] [ 1 ] . r e p l a c e ( r e g E x p ,   " & " )  
 	 v a r   e n C o u n t r y N a m e   =   c o u n t r y N a m e s [ i ] [ 2 ] . r e p l a c e ( r e g E x p ,   " & " ) . t o U p p e r C a s e ( )  
 	 c o u n t r y H a s h [ c o u n t r y N a m e s [ i ] [ 0 ] ]   =   [ i n t l C o u n t r y N a m e ,   e n C o u n t r y N a m e ]  
 	 r e v C o u n t r y H a s h [ e n C o u n t r y N a m e ]   =   c o u n t r y N a m e s [ i ] [ 0 ]  
 	 r e v C o u n t r y H a s h [ i n t l C o u n t r y N a m e ]   =   c o u n t r y N a m e s [ i ] [ 0 ]  
 }  
  
 f o r   ( v a r   i   =   0 ;   i   <   c u r r e n c y N a m e s . l e n g t h ;   i + + )   {  
 	 c u r r e n c i e s H a s h [ c u r r e n c y N a m e s [ i ] [ 0 ] ]   =   [ c u r r e n c y N a m e s [ i ] [ 1 ] ,   c u r r e n c y N a m e s [ i ] [ 2 ] ,   c u r r e n c y N a m e s [ i ] [ 3 ] ]  
 	 r e v C u r r e n c i e s H a s h [ c u r r e n c y N a m e s [ i ] [ 1 ] ]   =   c u r r e n c y N a m e s [ i ] [ 0 ]  
 	 r e v C u r r e n c i e s H a s h [ c u r r e n c y N a m e s [ i ] [ 2 ] ]   =   c u r r e n c y N a m e s [ i ] [ 0 ]  
 }  
 f o r   ( v a r   i   =   0 ;   i   <   c o u n t r y C u r r e n c i e s . l e n g t h ;   i + + )   {  
 	 i f   ( c o u n t r y H a s h [ c o u n t r y C u r r e n c i e s [ i ] [ 0 ] ]   = =   n u l l )   c o n t i n u e  
 	 c o u n t r y C u r r e n c i e s H a s h [ c o u n t r y C u r r e n c i e s [ i ] [ 0 ] ]   =   c o u n t r y C u r r e n c i e s [ i ] [ 1 ]  
 }  
 f o r   ( v a r   i   =   0 ;   i   <   o p t i o n N a m e s . l e n g t h ;   i + + )   {  
 	 o p t i o n s H a s h [ o p t i o n N a m e s [ i ] [ 0 ] ]   =   o p t i o n N a m e s [ i ] [ 1 ]  
 }  
 f o r   ( v a r   i   =   0 ;   i   <   c o u n t r y O p t i o n s . l e n g t h ;   i + + )   {  
 	 c o u n t r y O p t i o n s H a s h [ c o u n t r y O p t i o n s [ i ] [ 0 ] ]   =   c o u n t r y O p t i o n s [ i ] [ 1 ]  
 }  
  
 f u n c t i o n   g e t C o u n t r y C o d e ( c o u n t r y )   {  
 	 i f   ( c o u n t r y   = =   " S A O   T O M E   A N D   P R I N C I P E "   )   r e t u r n   " S T "  
 	 i f   ( c o u n t r y   = =   " C Y P R U S   N O R T H E R N "   )   r e t u r n   " C 2 "  
 	 i f   ( c o u n t r y   = =   " "   | |   r e v C o u n t r y H a s h [ c o u n t r y ]   = =   n u l l )   r e t u r n   " "  
 	 e l s e   r e t u r n   r e v C o u n t r y H a s h [ c o u n t r y ]  
 }  
  
 f u n c t i o n   g e t C o u n t r y N a m e ( c o u n t r y C o d e ,   i n E n g l i s h )   {  
 	 i f   ( c o u n t r y C o d e   = =   " "   | |   c o u n t r y H a s h [ c o u n t r y C o d e ]   = =   n u l l )   r e t u r n   " "  
 	 e l s e   i f   ( i n E n g l i s h   = =   t r u e )   r e t u r n   c o u n t r y H a s h [ c o u n t r y C o d e ] [ 1 ]  
 	 e l s e   r e t u r n   c o n v e r t E n t i t i e s ( c o u n t r y H a s h [ c o u n t r y C o d e ] [ 0 ] )  
 }  
  
 f u n c t i o n   g e t C o u n t r y C u r r e n c i e s ( c o u n t r y C o d e )   {  
 	 v a r   c o u n t r y C u r r e n c i e s  
 	 i f   ( c o u n t r y C o d e   = =   " "   | |   ( c o u n t r y C u r r e n c i e s   =   c o u n t r y C u r r e n c i e s H a s h [ c o u n t r y C o d e ] )   = =   n u l l )   r e t u r n   n u l l  
 	 v a r   c u r r e n c i e s   =   n e w   A r r a y ( )  
 	 v a r   c u r r e n c i e s H a s h   =   n e w   A r r a y ( )  
 	 f o r   ( v a r   i   =   0 ;   i   <   c o u n t r y C u r r e n c i e s . l e n g t h ;   i + + )   {  
 	 	 i f   ( c u r r e n c i e s H a s h [ c o u n t r y C u r r e n c i e s [ i ] ]   = =   n u l l )   {  
 	 	 	 c u r r e n c i e s H a s h [ c o u n t r y C u r r e n c i e s [ i ] ]   =   t r u e  
 	 	 	 c u r r e n c i e s [ c u r r e n c i e s . l e n g t h ]   =   c o u n t r y C u r r e n c i e s [ i ]  
 	 	 }  
 	 }  
 	 r e t u r n   c u r r e n c i e s  
 }  
  
 f u n c t i o n   g e t D e f a u l t C o u n t r y C u r r e n c y ( c o u n t r y C o d e )   {  
 	 i f   ( c o u n t r y C o d e   = =   " " )   {  
 	 	 r e t u r n   " U S D "  
 	 }   e l s e   i f   ( c o u n t r y C u r r e n c i e s H a s h [ c o u n t r y C o d e ]   = =   n u l l )   {  
 	 	 i f   ( c o u n t r y C o d e   = =   " C A " )   r e t u r n   " C A D "  
 	 	 e l s e   r e t u r n   " U S D "  
 	 }  
 	 e l s e   r e t u r n   c o u n t r y C u r r e n c i e s H a s h [ c o u n t r y C o d e ] [ 0 ]  
 }  
  
 f u n c t i o n   g e t C o u n t r y O p t i o n s ( c o u n t r y C o d e )   {  
 	 i f   ( c o u n t r y C o d e   = =   " " )   r e t u r n   " "  
 	 v a r   o p t i o n s A r r a y   =   c o u n t r y O p t i o n s H a s h [ c o u n t r y C o d e ]  
 	 i f   ( o p t i o n s A r r a y   = =   n u l l )   r e t u r n   [ " A G T " ]  
 	 e l s e   r e t u r n   o p t i o n s A r r a y  
 }  
  
 f u n c t i o n   g e t C u r r e n c y C o d e ( c u r r e n c y N a m e )   {  
 	 i f   ( c u r r e n c y N a m e   = =   " "   | |   r e v C u r r e n c i e s H a s h [ c u r r e n c y N a m e ]   = =   n u l l )   r e t u r n   " "  
 	 e l s e   r e t u r n   r e v C u r r e n c i e s H a s h [ c u r r e n c y N a m e ]  
 }  
  
 f u n c t i o n   g e t C u r r e n c y N a m e ( c u r r e n c y C o d e ,   p l u r a l )   {  
 	 i f   ( c u r r e n c y C o d e   = =   " "   | |   c u r r e n c i e s H a s h [ c u r r e n c y C o d e ]   = =   n u l l )   r e t u r n   " "  
 	 e l s e   i f   ( p l u r a l   = =   t r u e )   r e t u r n   c u r r e n c i e s H a s h [ c u r r e n c y C o d e ] [ 1 ]  
 	 e l s e   r e t u r n   c u r r e n c i e s H a s h [ c u r r e n c y C o d e ] [ 0 ]  
 }  
  
 f u n c t i o n   g e t C u r r e n c y S y m b o l ( c u r r e n c y C o d e )   {  
 	 i f   ( c u r r e n c y C o d e   = =   " "   | |   c u r r e n c i e s H a s h [ c u r r e n c y C o d e ]   = =   n u l l )   r e t u r n   " "  
 	 e l s e   i f   ( c u r r e n c i e s H a s h [ c u r r e n c y C o d e ] [ 2 ]   ! =   n u l l )   r e t u r n   c u r r e n c i e s H a s h [ c u r r e n c y C o d e ] [ 2 ]  
 	 e l s e   r e t u r n   " "  
 }  
  
 f u n c t i o n   g e t L a n g u a g e N a m e ( l a n g u a g e C o d e )   {  
 	 i f   ( l a n g u a g e C o d e   = =   " "   | |   l a n g u a g e H a s h [ l a n g u a g e C o d e ]   = =   n u l l )   r e t u r n   " "  
 	 e l s e   r e t u r n   l a n g u a g e H a s h [ l a n g u a g e C o d e ]  
 }  
  
 f u n c t i o n   g e t O p t i o n N a m e ( o p t i o n C o d e )   {  
 	 i f   ( o p t i o n C o d e   = =   " "   | |   o p t i o n s H a s h [ o p t i o n C o d e ]   = =   n u l l )   r e t u r n   " "  
 	 e l s e   r e t u r n   o p t i o n s H a s h [ o p t i o n C o d e ]  
 }  
  
 f u n c t i o n   p l a c e L o c a l C u r r e n c y F i r s t ( c u r r e n c y A r r a y )   {  
 	 v a r   o r i g C o u n t r y   =   f i e l d s [ " O R I G _ C O U N T R Y " ]  
 	 i f   ( o r i g C o u n t r y   ! =   n u l l )   {  
 	 	 o r i g C o u n t r y   =   o r i g C o u n t r y . g e t V a l u e ( )  
 	 }   e l s e   {  
 	 	 o r i g C o u n t r y   =   g e t R e g i o n ( )  
 	 }  
 	 v a r   l o c a l C u r r e n c y   =   g e t D e f a u l t C o u n t r y C u r r e n c y ( o r i g C o u n t r y )  
 	 v a r   p r u n e d A r r a y   =   [ l o c a l C u r r e n c y ]  
 	 i f   ( c u r r e n c y A r r a y   ! =   n u l l )   {  
 	 	 f o r   ( v a r   i   =   0 ;   i   <   c u r r e n c y A r r a y . l e n g t h ;   i + + )   {  
 	 	 	 i f   ( c u r r e n c y A r r a y [ i ]   ! =   n u l l   & &   c u r r e n c y A r r a y [ i ]   ! =   l o c a l C u r r e n c y )   {  
 	 	 	 	 p r u n e d A r r a y [ p r u n e d A r r a y . l e n g t h ]   =   c u r r e n c y A r r a y [ i ]  
 	 	 	 }  
 	 	 }  
 	 }  
 	 r e t u r n   p r u n e d A r r a y  
 }  
  
 f u n c t i o n   c o n v e r t E n t i t i e s ( d a t a )   {  
 	 v a r   r e g E x p   =   n e w   R e g E x p ( " & # ( [ ^ ; ] * ) ; " ,   " g " )  
 	 v a r   m a t c h A r r a y   =   r e g E x p . e x e c ( d a t a )  
 	 i f   ( m a t c h A r r a y   ! =   n u l l   & &   m a t c h A r r a y . l e n g t h   >   1 )   {  
 	 	 f o r   ( v a r   i   =   1 ;   i   <   m a t c h A r r a y . l e n g t h ;   i + + )   {  
 	 	 	 v a r   r e   =   n e w   R e g E x p ( " & # "   +   m a t c h A r r a y [ i ]   +   " ; " ,   " g " )  
 	 	 	 d a t a   =   d a t a . r e p l a c e ( r e ,   S t r i n g . f r o m C h a r C o d e ( m a t c h A r r a y [ i ] ) )  
 	 	 }  
 	 }  
 	 r e t u r n   d a t a  
 }  
 
