var VAT = 0.175;

function $c(msg) {
	if(typeof console != 'undefined') console.log(msg);
}

function getPageSize() {        
     var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	return [pageWidth,pageHeight];
}

var ShowModal = Behavior.create({
	initialize: function() {
		this.background = $('modal-window-background');
		this.win = $('container2');
	},
	onclick: function() {	
		var arrayPageSize = getPageSize();
        this.background.setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' }).show();
		
		var arrayPageScroll = document.viewport.getScrollOffsets();
		var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 10);
		this.win.setStyle({ top: lightboxTop + 'px' }).show();
		return false;
	}
});

var HideModal = Behavior.create({
	onclick: function() {
		$('modal-window-background').hide();
		$('container2').hide();
		$('wholesale-modal').hide();
		return false;
	}
});

var SuggestField = Behavior.create({
	initialize: function(options) {
		this.options = options;
	},
	onfocus: function(e) {
		var element = e.element();
		if(element.value == this.options.suggest) element.value = '';
		else if(element.value == '') element.value = this.options.suggest;
	},
	onblur: function(e) {
		var element = e.element();
		if(element.value == '') element.value = this.options.suggest;
	}
});

var options = {};
var HandleProductSelect = Behavior.create({
	initialize: function() {
		//$c('HandleProductSelect.initialize');
		this.componentSelect = $('component_id_select');
		this.optionSelect = $('option_id_select');
		this.quantitySelect = $('quantity_select');
		this.noStockMessage = $('no-stock-message');
		this.addToCartButton = $('add-to-cart-button');
		this.data = $('product-stock-json').value;
		this.stockData = $('product-stock-json').value.evalJSON();
		
		this.firstOptionsOption = '<option value="">Choose an option</option>';
		this.firstQuantityOption = '<option value="">Select Quantity</option>';
	},
	onchange: function(e) {
		//$c('HandleProductSelect.onchange');
		var target = $(e.target);
		
		if(target == this.componentSelect) return this._handleComponentSelect(target);
		if(target == this.optionSelect) return this._handleOptionSelect(target);
		if(target == this.quantitySelect) return this._handleQuantitySelect(target);
	},
	_handleComponentSelect: function(s) {
		//$c('HandleProductSelect._handleComponentSelect');
		//If the select is set to default, hide the other selects
		if(s.value == '') {
			if(this.optionSelect) { 
				this.optionSelect.value = '';
				this.optionSelect.disable();
			}
	
			this.quantitySelect.value = '';			
			this._disableQuantitySelect();
			
			this.noStockMessage.hide();
		} else {
			if(this.optionSelect) {
				var options = this._buildOptionSelect(s.value);
				this.optionSelect.update(options);
				this.quantitySelect.value = '';
				this.optionSelect.disable();
				if(options != this.firstOptionsOption) {
					this.optionSelect.enable();
					this.noStockMessage.hide();
				} else {
					this.optionSelect.disable();
					this.noStockMessage.show();
				}
			} else {				
				var options = this._buildQuantitySelect();
				this.quantitySelect.update(options);
				if(options == this.firstQuantityOption) {
					this.noStockMessage.show();
					this._disableQuantitySelect();
				} else {
					this.noStockMessage.hide();
					this.quantitySelect.enable();
				}
			}
		}
	},
	_handleOptionSelect: function(s) {
		//$c('HandleProductSelect._handleOptionSelect');
		if(s.value == '') {
			this.quantitySelect.value = '';
			this._disableQuantitySelect();			
			this.noStockMessage.hide();
		} else {
			$c('arg');
			$c(this._buildQuantitySelect());
			this.quantitySelect.update(this._buildQuantitySelect());
			$c(this.quantitySelect);
			this.quantitySelect.enable();
		}
	},
	_handleQuantitySelect: function(s) {
		//$c('HandleProductSelect._handleQuantitySelect');		
		if(s.value == '') {
			this._disableSubmitButton();
		} else {
			this._enableSubmitButton();
		}
	},
	_buildOptionSelect: function(componentId) {
		//$c('HandleProductSelect._buildOptionSelect');
		this._buildOptionData(componentId);
		var optionHtml = this.firstOptionsOption;
		
		for(optionId in options) {
			if(options[optionId][0]) optionHtml += '<option value="' + optionId + '">' + options[optionId][0] + '</option>';
		}

		//return (optionHtml == '') ? false : '<option value="">Choose an option</option>' + optionHtml;
		return optionHtml;
	},
	_buildOptionData: function(componentId) {
		//$c('HandleProductSelect._buildOptionData');
		options = {};
				
		if(componentId == 0) {			
			for(componentId in this.stockData) {
				this.stockData[componentId].each(function(o) {					
					if(o.option_stock > 0) {
						if(typeof(options[o.option_id])  == 'undefined') {
							options[o.option_id] = [o.option_title, o.option_stock];
						} else if(options[o.option_id][0]) {
							if(o.option_stock < options[o.option_id][0]) options[o.option_id] = [o.option_title, o.option_stock];
						} else if(!options[o.option_id][0]) {
							options[o.option_id] = [false, 0];
						}
					} else {
						options[o.option_id] = [false, 0];
					}
				});				
			}
		} else {
			//$c(this.stockData[componentId]);
			this.stockData[componentId].each(function(o) {
				if(o.option_stock > 0) options[o.option_id] = (o.option_stock > 0) ? [o.option_title, o.option_stock] : [false, 0];
			});
		}
		
		return options;
	},
	_buildQuantitySelect: function() {
		//$c('HandleProductSelect._buildQuantitySelect');
		var optionHtml = this.firstQuantityOption;
		var maxQuantity = 5;
		
		if(options.hasOwnProperty(this.optionSelect.value)) {
			if(this.optionSelect) {
				$c(options);
				$c(this.optionSelect.value);
				maxQuantity = (options[this.optionSelect.value][1] < 5) ? options[this.optionSelect.value][1] : 5;
			} else {				
				if(this.componentSelect.value == '0') {		
					for(componentId in this.stockData) {						
						if(this.stockData[componentId][0].option_stock < maxQuantity) maxQuantity = this.stockData[componentId][0].option_stock;
					}
				} else {
					var os = this.stockData[this.componentSelect.value * 1][0].option_stock
					maxQuantity = (os < 5) ? os : 5;
				}
			}
		}		
		for(var i = 1; i <= maxQuantity; i++) {
			optionHtml += '<option value="' + i +'">' + i + '</option>';
		}
		
		return optionHtml;
	},
	_disableSubmitButton: function() {
		this.addToCartButton.disable();
		this.addToCartButton.addClassName('add-to-cart-button-disabled');
	},
	_enableSubmitButton: function() {
		this.addToCartButton.enable();
		this.addToCartButton.removeClassName('add-to-cart-button-disabled');
	},
	_disableQuantitySelect: function() {
		this.quantitySelect.disable();
		this._disableSubmitButton();
	}
});

var LoadFlashAndSubmitPas = Behavior.create({
	initialize: function() {
		new Lightbox();
		
		if($('flashcontent')) {			
			var so = new SWFObject("/slideshow.swf", "gallery", "694", "403", "6", "#ffffff"); 
			so.addParam("wmode", "transparent");
			so.write("flashcontent");			
		}
			
		if(document.body.id == 'pas-page') {
			//$c('pas');
			$('hsbc-form').submit();
		}
	}
});

function setShippingCost() {
	var countryCode = $('order-use-ba-for-sa').checked ? $('order-ba-country').value : $('order-sa-country').value;
	var cartItemQuantity = $F($('cart-item-quantity'));
	cartItemQuantity = cartItemQuantity > 3 ? 3 : cartItemQuantity;
	var shippingCost;
	var subTotal = $('cart-sub-total-value').value * 1;
	var total;
	var vatRate = $('cart-vat-value').value * 1;
	var vat;
	
	if(ukCountries.keys().indexOf(countryCode) != -1) {
		shippingCost = $('uk-shipping-cost').value;
	} else if(eurCountries.keys().indexOf(countryCode) != -1) {	
		shippingCost = $('eur-shipping-cost-' + cartItemQuantity).value;
	} else {
		shippingCost = $('global-shipping-cost-' + cartItemQuantity).value;
	}
	shippingCost = shippingCost * 1;
	vat = (subTotal + shippingCost) * vatRate;
	total = subTotal + shippingCost + vat;
	
	$('cart-shipping').update(formatCurrency(shippingCost));
	$('cart-shipping2').update(formatCurrency(shippingCost));
	//$('cart-vat').update(formatCurrency(vat));
	$('cart-total').update(formatCurrency(total));
	$('cart-total2').update(formatCurrency(total));
}

function formatCurrency(amount) {
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return '&pound;' + s;	
}

var ToggleOrderShippingAddress = Behavior.create({
	initialize: function() {
		
	},
	onclick: function() {
		this._toggleShippingAddress('order');	
	},
	_toggleShippingAddress: function(prefix) {
		//$c('ToggleOrderShippingAddress._toggleShippingAddress');
		var c = $(prefix + '-use-ba-for-sa').checked;
		$(prefix + '-form').getElements().select(function(n) { return n.id.startsWith(prefix + '-sa-') }).invoke(c ? 'disable' : 'enable');
		var requiredString = ' <span class="required">*</span>';
		if(c) {
			$$('#' + prefix + '-form-shipping-address div.error').invoke('addClassName', 'old-error');
			$$('#' + prefix + '-form-shipping-address div.old-error').invoke('toggleClassName', 'error');
			var street1Label = $(prefix + '-sa-street1').previous().innerHTML.replace(requiredString, '');
			$(prefix + '-sa-street1').previous().update(street1Label);
			var postcodeLabel = $(prefix + '-sa-postcode').previous().innerHTML.replace(requiredString, '');
			$(prefix + '-sa-postcode').previous().update(postcodeLabel);
		} else {
			$$('#' + prefix + '-form-shipping-address div.old-error').invoke('toggleClassName', 'error');
			var street1Label = $(prefix + '-sa-street1').previous().innerHTML + ($(prefix + '-sa-street1').previous().innerHTML.match(/\*/) ? '' : requiredString);
			$(prefix + '-sa-street1').previous().update(street1Label);
			var postcodeLabel = $(prefix + '-sa-postcode').previous().innerHTML + ($(prefix + '-sa-postcode').previous().innerHTML.match(/\*/) ? '' : requiredString);
			$(prefix + '-sa-postcode').previous().update(postcodeLabel);
		}
	}
});

var UpdateShippingCost = Behavior.create({
	initialize: function() {
		
	},
	onchange: function() {
		//$c('UpdateShippingCost.onchange');
		setShippingCost();
	}
});

var WholesaleFormHandler = Behavior.create({
	initialize: function() {
		this._addQtyBehaviors();
	},
	_addQtyBehaviors: function() {
		Event.addBehavior({
			'.qty-input': QtyHandler(this)
		});
	},
	onsubmit: function() {

		return false;
	}
});


var FormSubmitLink = Behavior.create({
	initialize: function() {
	},
	onclick: function() {
		//$c( $('order-form') );
		if($('agree-terms-checkbox').checked) document.wholesaleorderform.submit();
		return false;
	}
});


var ShowWholesaleModal = Behavior.create({
	initialize: function() {
	},
	onclick: function() {
		$('wholesale-modal').show();
		
		var modalHeight = document.height;
		modalHeight = getPageSize();
		$('modal-window-background').setStyle({ width: modalHeight[0] + 'px', height: modalHeight[1] + 'px' });
		$('modal-window-background').show();
		$('wholesale-modal').setStyle({ width: modalHeight[0] + 'px' });
		
		var scrolloffsets = document.viewport.getScrollOffsets();
		
		var wholesaleModalTopPosition = scrolloffsets.top + (document.viewport.getHeight() / 4);
		
		//dont forget the px
		wholesaleModalTopPosition = wholesaleModalTopPosition + "px"
		
		$('wholesale-modal').setStyle({ top: wholesaleModalTopPosition });
		
		return false;
	}
});

var CopyAddresses = Behavior.create({
	initialize: function() {
	},
	onclick: function() {
		if($('same-addresses').checked){
			previous_del_address = $('order-delivery-address').getValue();
			$('order-delivery-address').setValue($('order-invoice-address').getValue());
		}else{
			if($('order-invoice-address').getValue() == $('order-delivery-address').getValue()){
				$('order-delivery-address').setValue(previous_del_address);
			}
		}
	}
});

var QtyHandler = Behavior.create({
	initialize: function(wholesaleFormHandler) {
		this.wholesaleFormHandler = wholesaleFormHandler;
		if(!(Prototype.Browser.IE)){
			this.onchange({});
		}
	},
	onchange: function($e) {
		
		if(this.element.id == "order-greetingcards-bb-x"  || this.element.id == "order-greetingcards-btb-x"  || this.element.id == "order-greetingcards-cc-x"  || this.element.id == "order-greetingcards-hh-x"  || this.element.id == "order-greetingcards-ll-x"  || this.element.id == "order-greetingcards-mtm-x"  || this.element.id == "order-greetingcards-oo-x"  || this.element.id == "order-greetingcards-pp-x"  || this.element.id == "order-greetingcards-mmo-x"  ){
			//normal
		}else{
			if(this.element.value == '1') this.element.value = '2';
		}
		
		var splitId = this.element.id.split('-');

		splitId.pop();
		var rowName = splitId.join('-');

		splitId.pop();
		var itemName = splitId.join('-');
				
		var rowQty = $$('#wholesale-form #' + rowName + '-row .qty-input').pluck('value').inject(0, function(acc, n) { return acc + n*1; });
		
		var rowPrice = ($(rowName + '-price').value * 1) * rowQty;
		var rowVAT = 0;
		
		if($(rowName + '-qty')) $(rowName + '-qty').update(rowQty);
		$(rowName + '-qty-input').value = rowQty;

		if($(rowName + '-vat')) {
			rowVAT = rowPrice * VAT;
			$(rowName + '-vat').update(formatCurrency(rowVAT));
			$(rowName + '-vat-input').value = rowVAT;
		}
		
		$(rowName + '-total').update(formatCurrency(rowPrice + rowVAT));
		$(rowName + '-total-input').value = rowPrice + rowVAT;

		
		var itemQty = $$('#wholesale-form #' + itemName + ' .row-qty-input').pluck('value').inject(0, function(acc, n) { return acc + n*1; });
		if($(rowName + '-vat')) var itemVAT = $$('#wholesale-form #' + itemName + ' .row-vat-input').pluck('value').inject(0, function(acc, n) { return acc + n*1; });
		var itemTotal = $$('#wholesale-form #' + itemName + ' .row-total-input').pluck('value').inject(0, function(acc, n) { return acc + n*1; });
		
		$(itemName + '-qty-total').update(itemQty);
		$(itemName + '-total').update(formatCurrency(itemTotal));

		$(itemName + '-total-input').value = itemTotal;
		if($(rowName + '-vat')) $(itemName + '-vat-input').value = itemVAT;
		
		
		var vatTotal = $$('#wholesale-form .vat-input').pluck('value').inject(0, function(acc, n) { return acc + n*1; });
		$('vat-total').update(formatCurrency(vatTotal));
		
		var grandTotal = $$('#wholesale-form .total-input').pluck('value').inject(0, function(acc, n) { return acc + n*1; });
		$('grand-total').update(formatCurrency(grandTotal));
		
		$('subtotal-total').update(formatCurrency(grandTotal - vatTotal));
		
		//update modal window infomation
		$('modal-grand-total').update(formatCurrency(grandTotal));
		if(grandTotal > 250){
			$('submit-form-link').show();
			$('order-must-be').hide();
			$('or-place-order').show();
			$('agree-terms').show();
		}else{
			$('submit-form-link').hide();
			$('order-must-be').show();
			$('or-place-order').hide();
			$('agree-terms').hide();
		}
		
		if(grandTotal > 300){
			$('free-postage-note').hide();
		}else{
			$('free-postage-note').show();
		}
		
		$('grand-total-item').value = grandTotal;
		$('vat-total-item').value = vatTotal;
		$('subtotal-total-item').value = grandTotal - vatTotal;
		
	}
});


Event.addBehavior({
	'body': LoadFlashAndSubmitPas,
	'#submit-photo-button': ShowModal,
	'#modal-window-background': HideModal,
	'#go-back': HideModal,
	'input#username': SuggestField({ suggest: 'Username' }),
	'input#password': SuggestField({ suggest: 'Password' }),
	'#component_id_select': HandleProductSelect,
	'#option_id_select': HandleProductSelect,
	'#quantity_select': HandleProductSelect,
	'input#order-use-ba-for-sa': ToggleOrderShippingAddress,
	'#order-ba-country': UpdateShippingCost,
	'#order-sa-country': UpdateShippingCost,
	'#wholesale-form': WholesaleFormHandler,
	'#submit-form-link': FormSubmitLink,
	'#show-modal': ShowWholesaleModal,
	'#same-addresses' : CopyAddresses
});

$('agree-terms-checkbox')

var ukCountries = $H({
	'826': 'United Kingdom'
});

var eurCountries = $H({
	'040': 'Austria',	
	'008': 'Albania',
	'112': 'Belarus',
	'056': 'Belgium',
	'070': 'Bosnia and Herzegovina',
	'100': 'Bulgaria',
	'191': 'Croatia',
	'203': 'Czech Republic',
	'196': 'Cyprus',
	'208': 'Denmark',
	'233': 'Estonia', 
	'246': 'Finland',
	'250': 'France',
	'268': 'Georgia',
	'276': 'Germany',
	'292': 'Gibraltar',
	'300': 'Greece',
	'348': 'Hungary',
	'352': 'Iceland',
	'372': 'Ireland',
	'833': 'Isle Of Man',
	'380': 'Italy',
	'428': 'Latvia',
	'438': 'Liechtenstein',
	'440': 'Lithuania',
	'442': 'Luxembourg',
	'807': 'Macedonia',
	'249': 'Metropolitan France',
	'498': 'Moldova',
	'492': 'Monaco',
	'528': 'Netherlands',		
	'578': 'Norway',
	'616': 'Poland',
	'620': 'Portugal',
	'642': 'Romania',
	'643': 'Russia',
	'891': 'Serbia and Montenegro',
	'703': 'Slovakia',
	'705': 'Slovenia',
	'752': 'Sweden',
	'756': 'Switzerland',
	'792': 'Turkey',
	'804': 'Ukraine',
	'826': 'United Kingdom',
	'336': 'Vatican City'
});

var globalCountries = $H({
	'004': 'Afghanistan',
	'012': 'Algeria',
	'016': 'American Samoa',
	'020': 'Andorra',
	'024': 'Angola',
	'660': 'Anguilla',
	'010': 'Antarctica', 
	'028': 'Antigua and Barbuda',
	'032': 'Argentina',
	'051': 'Armenia',
	'533': 'Aruba',
	'036': 'Australia',
	'031': 'Azerbaijan',
	'044': 'Bahamas',
	'048': 'Bahrain',
	'050': 'Bangladesh',
	'052': 'Barbados',
	'084': 'Belize',
	'204': 'Benin',
	'060': 'Bermuda',
	'064': 'Bhutan',
	'068': 'Bolivia',
	'072': 'Botswana',
	'074': 'Bouvet Island',
	'076': 'Brazil',
	'086': 'British Indian Ocean Territory',
	'092': 'British Virgin Islands',
	'096': 'Brunei',
	'854': 'Burkina Faso',
	'108': 'Burundi',
	'116': 'Cambodia',
	'120': 'Cameroon',
	'124': 'Canada',
	'132': 'Cape Verde',
	'136': 'Cayman Islands',
	'140': 'Central African Republic',
	'148': 'Chad',
	'830': 'Channel Islands',
	'152': 'Chile',
	'156': 'China',
	'162': 'Christmas Island',
	'166': 'Cocos (Keeling) Islands',
	'170': 'Colombia',
	'174': 'Comoros',
	'178': 'Congo, Democratic Republic of', 
	'180': 'Congo, Republic of (Zaire)',
	'184': 'Cook Islands',
	'188': 'Costa Rica',
	'384': 'Cote D’Ivoire',
	'192': 'Cuba',
	'262': 'Djibouti',
	'212': 'Dominica',
	'214': 'Dominican Republic',
	'626': 'East Timor',
	'218': 'Ecuador',
	'818': 'Egypt',
	'222': 'El Salvador',
	'226': 'Equatorial Guinea',
	'232': 'Eritrea',
	'231': 'Ethiopia',
	'238': 'Falkland Islands (Malvinas)',
	'234': 'Faroe Islands',
	'583': 'Federated States of Micronesia',
	'242': 'Fiji',
	'254': 'French Guiana',
	'258': 'French Polynesia',
	'260': 'French Southern Territories',
	'266': 'Gabon',
	'270': 'Gambia', 
	'288': 'Ghana',
	'304': 'Greenland', 
	'308': 'Grenada',
	'312': 'Guadeloupe',
	'316': 'Guam',
	'320': 'Guatemala',
	'324': 'Guinea',
	'624': 'Guinea-Bissau',
	'328': 'Guyana',
	'332': 'Haiti',
	'334': 'Heard Island and McDonald Is.',
	'340': 'Honduras',
	'344': 'Hong Kong',
	'356': 'India',
	'360': 'Indonesia',
	'364': 'Iran',
	'368': 'Iraq',
	'376': 'Israel',
	'388': 'Jamaica',
	'392': 'Japan',
	'400': 'Jordan',
	'398': 'Kazakhstan',
	'404': 'Kenya',
	'296': 'Kiribati',
	'414': 'Kuwait',
	'417': 'Kyrgyzstan',
	'418': 'Laos',
	'422': 'Lebanon',
	'426': 'Lesotho',
	'430': 'Liberia',
	'434': 'Libya',
	'446': 'Macau',
	'450': 'Madagascar',
	'454': 'Malawi',
	'458': 'Malaysia',
	'462': 'Maldives',
	'466': 'Mali',
	'470': 'Malta',
	'584': 'Marshall Islands',
	'474': 'Martinique',
	'478': 'Mauritania',
	'480': 'Mauritius',
	'175': 'Mayotte',
	'484': 'Mexico',
	'496': 'Mongolia',
	'500': 'Montserrat',
	'504': 'Morocco',
	'508': 'Mozambique',
	'104': 'Myanmar',
	'516': 'Namibia',
	'520': 'Nauru',
	'524': 'Nepal',
	'530': 'Netherlands Antilles',
	'540': 'New Caledonia',
	'554': 'New Zealand',
	'558': 'Nicaragua',
	'562': 'Niger',
	'566': 'Nigeria',
	'570': 'Niue',
	'574': 'Norfolk Island',
	'408': 'North Korea',
	'580': 'Northern Mariana Islands',
	'512': 'Oman',
	'586': 'Pakistan',
	'585': 'Palau',
	'275': 'Palestinian Territory',
	'591': 'Panama',
	'598': 'Papua New Guinea',
	'600': 'Paraguay',
	'604': 'Peru',
	'608': 'Philippines',
	'612': 'Pitcairn',
	'630': 'Puerto Rico',
	'634': 'Qatar',
	'638': 'Reunion',
	'646': 'Rwanda',
	'882': 'Samoa',
	'674': 'San Marino',
	'678': 'Sao Tome and Principe',
	'682': 'Saudia Arabia',
	'686': 'Senegal',
	'690': 'Seychelles',
	'694': 'Sierra Leone',
	'702': 'Singapore',
	'090': 'Solomon Islands',
	'706': 'Somalia',
	'710': 'South Africa',
	'239': 'South Georgia and the SSI',
	'410': 'South Korea',
	'724': 'Spain',
	'144': 'Sri Lanka',
	'654': 'St. Helena',
	'659': 'St. Kitts and Nevis',
	'662': 'St. Lucia',
	'666': 'St. Pierre and Miquelon',
	'670': 'St. Vincent and the Grenadines',
	'736': 'Sudan',
	'740': 'Suriname',
	'744': 'Svalbard and Jan Mayen Islands',
	'748': 'Swaziland',
	'760': 'Syria',
	'158': 'Taiwan',
	'762': 'Tajikistan',
	'834': 'Tanzania',
	'764': 'Thailand',
	'768': 'Togo',
	'772': 'Tokelau',
	'776': 'Tonga',
	'780': 'Trinidad and Tobago',
	'788': 'Tunisia',
	'795': 'Turkmenistan',
	'796': 'Turks and Caicos Islands',
	'798': 'Tuvalu',
	'850': 'U.S. Virgin Islands',
	'800': 'Uganda',
	'784': 'United Arab Emirates',
	'840': 'United States',
	'581': 'United States MOI',
	'858': 'Uruguay',
	'860': 'Uzbekistan',
	'548': 'Vanuatu',
	'862': 'Venezuela',
	'704': 'Vietnam',
	'876': 'Wallis and Futuna Islands',
	'732': 'Western Sahara',
	'887': 'Yemen',
	'894': 'Zambia',
	'716': 'Zimbabwe'
});
