var bLocalTest = (document.URL.toString().substr(0, 4) == 'file');

var strProductKey = 'SHOP_CART';
var aoShopProducts = new Array();

var aoShopShipping = new Array();

var nShopShipping = 0;
aoShopShipping[nShopShipping++] = new ShopShipping(nShopShipping, true, 3);						// shipping price for CD ROM - EUR and USD
aoShopShipping[nShopShipping++] = new ShopShipping(nShopShipping, true, 1.4, 6, 10);			// shipping price for Users Guide - EUR
aoShopShipping[nShopShipping++] = new ShopShipping(nShopShipping, true, 2, 9, 15);				// shipping price for Users Guide - USD
aoShopShipping[nShopShipping++] = new ShopShipping(nShopShipping, false, 7, 24, 24);			// shipping price for +SmartHand - EUR
aoShopShipping[nShopShipping++] = new ShopShipping(nShopShipping, false, 8, 30, 30);			// shipping price for +SmartHand - USD


var nShopProduct = 0;

aoShopProducts[nShopProduct++] = new ShopProduct("TrainController 7.0 Bronze", '1770000001', 99, 'EUR');
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController 7.0 Silver", '1670000001', 299, 'EUR');
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController 7.0 Gold",   '0170000001', 449, 'EUR');
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Version 7.0 -> 7.0 Silver (Stick)", '1670167001', 0, 'EUR');
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Version 5.8 -> 7.0 Silver", '1670165801', 49, 'EUR');
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Version 5.0/5.5 -> 7.0 Silver", '1670165001', 199, 'EUR');
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Bronze -> 7.0 Silver", '1670177001', 249, 'EUR');
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Version 5.8/Silver -> 7.0 Gold",   '0170167001', 199, 'EUR');
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Version 5.0/5.5 -> 7.0 Gold",   '0170165001', 349, 'EUR');
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Bronze -> 7.0 Gold",   '0170177001', 399, 'EUR');

aoShopProducts[nShopProduct++] = new ShopProduct("Rocomotion -> TrainController 7.0 Bronze", '1770075901', 79, 'EUR');
aoShopProducts[nShopProduct++] = new ShopProduct("Rocomotion -> TrainController 7.0 Silver", '1670075901', 264, 'EUR');
aoShopProducts[nShopProduct++] = new ShopProduct("Rocomotion -> TrainController 7.0 Gold", '0170075901', 399, 'EUR');

aoShopProducts[nShopProduct++] = new ShopProduct("TrainProgrammer 7.0", '137625', 55, 'EUR');
aoShopProducts[nShopProduct++] = new ShopProduct("TrainProgrammer 4 or 5 -> 7.0", '0270025801', 24.75, 'EUR');

aoShopProducts[nShopProduct++] = new ShopProduct("+SmartHand Starter Set-RS232", '300124696', 239, 'EUR', aoShopShipping[3], true);
aoShopProducts[nShopProduct++] = new ShopProduct("+SmartHand Starter Set-USB", '300124692', 239, 'EUR', aoShopShipping[3]);
aoShopProducts[nShopProduct++] = new ShopProduct("+SmartHand Handregler/Handheld", '300124693', 199, 'EUR', aoShopShipping[3]);
aoShopProducts[nShopProduct++] = new ShopProduct("+SmartHand Anschlusseinheit/PlugPanel", '300124695', 36, 'EUR', aoShopShipping[3]);
aoShopProducts[nShopProduct++] = new ShopProduct("+SmartHand PC-Interface RS232", '300124702', 39, 'EUR', aoShopShipping[3]);
aoShopProducts[nShopProduct++] = new ShopProduct("+SmartHand PC-Interface USB", '300124703', 39, 'EUR', aoShopShipping[3]);
aoShopProducts[nShopProduct++] = new ShopProduct("+SmartHand Mobile", '1170000001', 24.75, 'EUR');

aoShopProducts[nShopProduct++] = new ShopProduct("+Net Start Set", '300024290', 115, 'EUR');
aoShopProducts[nShopProduct++] = new ShopProduct("+Net Extension", '300042489', 69, 'EUR');
aoShopProducts[nShopProduct++] = new ShopProduct("+Net/D Start Set", '300024293', 149, 'EUR');
aoShopProducts[nShopProduct++] = new ShopProduct("+Net/D Extension", '300042488', 89, 'EUR');

aoShopProducts[nShopProduct++] = new ShopProduct("+4DSound", '300043117', 115, 'EUR');

aoShopProducts[nShopProduct++] = new ShopProduct("TrainMonitor 4.7", '137626', 55, 'EUR');

aoShopProducts[nShopProduct++] = new ShopProduct("Railroad & Co. CD ROM", '300133239', 9.95, 'EUR', aoShopShipping[0]);

aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Gold und Silver Programmbeschreibung (schwarz/weiß)", '0170991101', 23, 'EUR', aoShopShipping[1]);
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Gold und Silver Programmbeschreibung (farbig)", '0170991401', 53, 'EUR', aoShopShipping[1]);
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Bronze Programmbeschreibung (schwarz/weiß)", '1770991101', 16, 'EUR', aoShopShipping[1]);
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Bronze Programmbeschreibung (farbig)", '1770991401', 39, 'EUR', aoShopShipping[1]);
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Gold and Silver Users Guide (black and white)", '0170990101', 23, 'EUR', aoShopShipping[1]);
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Gold and Silver Users Guide (colored)", '0170990401', 53, 'EUR', aoShopShipping[1]);
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Bronze Users Guide (black and white)", '1770990101', 16, 'EUR', aoShopShipping[1]);
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Bronze Users Guide (colored)", '1770990401', 39, 'EUR', aoShopShipping[1]);

aoShopProducts[nShopProduct++] = new ShopProduct("TrainController 7.0 Bronze", '1770000002', 129, 'USD');
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController 7.0 Silver", '1670000002', 389, 'USD');
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController 7.0 Gold",   '0170000002', 584, 'USD');
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Version 7.0 -> 7.0 Silver (Stick)", '1670167002', 0, 'USD');
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Version 5.8 -> 7.0 Silver", '1670165802', 64, 'USD');
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Version 5.0/5.5 -> 7.0 Silver", '1670165002', 259, 'USD');
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Bronze -> 7.0 Silver", '1670177002', 324, 'USD');
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Version 5.8/Silver -> 7.0 Gold",   '0170167002', 259, 'USD');
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Version 5.0/5.5 -> 7.0 Gold",   '0170165002', 454, 'USD');
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Bronze -> 7.0 Gold",   '0170177002', 519, 'USD');

aoShopProducts[nShopProduct++] = new ShopProduct("Rocomotion -> TrainController 7.0 Bronze", '1770075902', 99, 'USD');
aoShopProducts[nShopProduct++] = new ShopProduct("Rocomotion -> TrainController 7.0 Silver", '1670075902', 339, 'USD');
aoShopProducts[nShopProduct++] = new ShopProduct("Rocomotion -> TrainController 7.0 Gold", '0170075902', 519, 'USD');

aoShopProducts[nShopProduct++] = new ShopProduct("TrainProgrammer 7.0", '203728', 69, 'USD');
aoShopProducts[nShopProduct++] = new ShopProduct("TrainProgrammer 4 or 5 -> 7.0", '0270025802', 32.25, 'USD');

aoShopProducts[nShopProduct++] = new ShopProduct("+SmartHand Starter Set-RS232", '300124701', 279, 'USD', aoShopShipping[4], true);
aoShopProducts[nShopProduct++] = new ShopProduct("+SmartHand Starter Set-USB", '300124698', 279, 'USD', aoShopShipping[4]);
aoShopProducts[nShopProduct++] = new ShopProduct("+SmartHand Handheld", '300124699', 229, 'USD', aoShopShipping[4]);
aoShopProducts[nShopProduct++] = new ShopProduct("+SmartHand PlugPanel", '300124700', 45, 'USD', aoShopShipping[4]);
aoShopProducts[nShopProduct++] = new ShopProduct("+SmartHand PC Interface RS232", '300124704', 49, 'USD', aoShopShipping[4]);
aoShopProducts[nShopProduct++] = new ShopProduct("+SmartHand PC Interface USB", '300124705', 49, 'USD', aoShopShipping[4]);
aoShopProducts[nShopProduct++] = new ShopProduct("+SmartHand Mobile", '1170000002', 32.25, 'USD');

aoShopProducts[nShopProduct++] = new ShopProduct("+Net Start Set", '300024291', 149, 'USD');
aoShopProducts[nShopProduct++] = new ShopProduct("+Net Extension", '300042490', 89, 'USD');

aoShopProducts[nShopProduct++] = new ShopProduct("+4DSound", '300043118', 149, 'USD');

aoShopProducts[nShopProduct++] = new ShopProduct("TrainMonitor 4.7", '203729', 69, 'USD');

aoShopProducts[nShopProduct++] = new ShopProduct("Railroad & Co. CD ROM (price does not include shipping)", '300133238', 11.95, 'USD', aoShopShipping[0]);

aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Gold und Silver Programmbeschreibung (schwarz/weiß)", '0170991102', 29, 'USD', aoShopShipping[2]);
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Gold und Silver Programmbeschreibung (farbig)", '0170991402', 69, 'USD', aoShopShipping[2]);
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Bronze Programmbeschreibung (schwarz/weiß)", '1770991102', 21, 'USD', aoShopShipping[2]);
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Bronze Programmbeschreibung (farbig)", '1770991402', 52, 'USD', aoShopShipping[2]);
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Gold and Silver Users Guide (black and white)", '0170990102', 29, 'USD', aoShopShipping[2]);
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Gold and Silver Users Guide (colored)", '0170990402', 69, 'USD', aoShopShipping[2]);
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Bronze Users Guide (black and white)", '1770990102', 21, 'USD', aoShopShipping[2]);
aoShopProducts[nShopProduct++] = new ShopProduct("TrainController Bronze Users Guide (colored)", '1770990402', 52, 'USD', aoShopShipping[2]);

var astrDict = new Array();
astrDict[1] = new Object();
astrDict[2] = new Object();


astrDict[1]["MWST_TEXT"] = 'Orders from the European Union include 19% TAX/VAT';
astrDict[2]["MWST_TEXT"] = 'F&uuml;r Bewohner der EU sind im Preis 19% MwSt. enthalten';
astrDict[1]["MWST_TRANSMIT"] = 'Orders from the European Union include 19%25 TAX/VAT';
astrDict[2]["MWST_TRANSMIT"] = 'F&uuml;r Bewohner der EU sind im Preis 19%25 MwSt. enthalten';
astrDict[1]["CARTEMPTY"] = 'You do not have any items in your cart.';
astrDict[2]["CARTEMPTY"] = 'Es befinden sich keine Artikel in Ihrem Warenkorb.';
astrDict[1]["CONTINUESHOPPING"] = '<< Continue Shopping';
astrDict[2]["CONTINUESHOPPING"] = '<< Einkauf fortsetzen';
astrDict[1]["CHECKOUT"] = 'Checkout';
astrDict[2]["CHECKOUT"] = 'Zur Kasse';
astrDict[1]["UPDATE"] = 'Update';
astrDict[2]["UPDATE"] = 'Aktualisieren';
astrDict[1]["CANCEL"] = 'Cancel';
astrDict[2]["CANCEL"] = 'Abbrechen';
astrDict[1]["LAN"] = 'US';
astrDict[2]["LAN"] = 'DE';
astrDict[1]["POS"] = 'Pos.';
astrDict[2]["POS"] = 'Pos.';
astrDict[1]["PRODUCT"] = 'Product';
astrDict[2]["PRODUCT"] = 'Produkt';
astrDict[1]["QUANTITY"] = 'Quantity';
astrDict[2]["QUANTITY"] = 'Anzahl';
astrDict[1]["PRICE"] = 'Price per Unit';
astrDict[2]["PRICE"] = 'Einzelpreis';
astrDict[1]["SUBTOTAL"] = 'Sub Total';
astrDict[2]["SUBTOTAL"] = 'Zwischensumme';
astrDict[1]["TOTAL"] = 'Total';
astrDict[2]["TOTAL"] = 'Gesamtpreis';
astrDict[1]["NETPRICE"] = 'Net Price';
astrDict[2]["NETPRICE"] = 'Netto';
astrDict[1]["VAT"] = 'VAT';
astrDict[2]["VAT"] = 'MwSt.';
astrDict[1]["FULLPRICE"] = 'Full Price';
astrDict[2]["FULLPRICE"] = 'Brutto';
astrDict[1]['SHIPPING'] = 'Shipping & Handling';
astrDict[2]['SHIPPING'] = 'Versandkosten';
astrDict[1]["REMOVE"] = 'Remove';
astrDict[2]["REMOVE"] = 'L&ouml;schen';
astrDict[1]["PAGEDIRUNSECURE"] = 'http://www.freiwald.com/pages';
astrDict[2]["PAGEDIRUNSECURE"] = 'http://www.freiwald.com/seiten';
astrDict[1]["IMAGEDIR"] = '../images';
astrDict[2]["IMAGEDIR"] = '../bilder';
astrDict[1]["MSG_UNKNOWNPRODUCT"] = 'Unknown Product. Please report error to Freiwald Software.';
astrDict[2]["MSG_UNKNOWNPRODUCT"] = 'Unbekanntes Produkt. Bitte melden Sie den Fehler an Freiwald Software.';
astrDict[1]["MSG_INCONSISTENTCURRENCY"] = 'You are about to add an item to the cart,\nthat is to be paid with another currency than the items already stored in the cart.\nDo you want to remove the already stored items from the card?';
astrDict[2]["MSG_INCONSISTENTCURRENCY"] = 'Sie sind dabei, einen Artikel in den Warenkorb zu legen,\nder in anderer Währung bezahlt wird, als bereits abgelegte Artikel.\nSollen die bereits abgelegten Artikel gelöscht werden?';
astrDict[1]["MSG_NOCOOKIEBASKET"] = 'The use of cookies must be enabled to access the shopping cart.\nAs long as cookies are disabled,\nyou can only add one item to your cart for instant checkout.';
astrDict[2]["MSG_NOCOOKIEBASKET"] = 'Die Verwendung von Cookies muss freigeschaltet sein, um auf den Warenkorb zugreifen zu können.\nSolange Cookies gesperrt sind, kann immer nur ein einiziger Artikel zur sofortigen Bezahlung zwischengespeichert werden.';

// payment services

var strShareIt = '1';
var strUOS = '2';
var strInhouse = '3';

// payment methods

var strBankTransfer = '1';
var strCreditCard = '2';
var strPayPal = '3';
var strGiroPay = '4';
var strSofortUeberweisung = '5';

function ShopShipping(nID, bOncePerPosition, nShippingCostsG, nShippingCostsE, nShippingCostsW)
{
	this.m_nID = ((typeof nID) != 'undefined') ? nID : nID + 1;
	this.m_bOncePerPosition = ((typeof bOncePerPosition) != 'undefined') ? bOncePerPosition : false;
	this.m_nShippingCostsG = ((typeof nShippingCostsG) != 'undefined') ? nShippingCostsG : 0;
	this.m_nShippingCostsE = ((typeof nShippingCostsE) != 'undefined') ? nShippingCostsE : this.m_nShippingCostsG;	
	this.m_nShippingCostsW = ((typeof nShippingCostsW) != 'undefined') ? nShippingCostsW : this.m_nShippingCostsE;	
}


function ShopCalcShippingByCountry(oShippingCosts, strCountry)
{
	if (strCountry.toUpperCase() == 'DE')
	{
		return oShippingCosts.m_nShippingCostsG;
	}
	else if (ShopIsEURO(strCountry))
	{
		return oShippingCosts.m_nShippingCostsE;
	}	

	return oShippingCosts.m_nShippingCostsW;
}


function ShopCalcShipping(nProduct, nCount, strCountry)
{
	if (aoShopProducts[nProduct].m_oShippingCosts.m_nShippingCostsG == 0)
	{
		return 0;
	}

	if (aoShopProducts[nProduct].m_oShippingCosts.m_bOncePerPosition)
	{
		return ShopCalcShippingByCountry(aoShopProducts[nProduct].m_oShippingCosts, strCountry) * nCount;
	}

	for (var p = 0; p < aoShopProducts.length; p++)
	{
		if (p == nProduct)
		{
			break;
		}

		if (ShopGetProdCount(aoShopProducts[p].m_strID) != 0)
		{
			if (aoShopProducts[p].m_oShippingCosts.m_nID == aoShopProducts[nProduct].m_oShippingCosts.m_nID)
			{
				return 0;		// already accounted
			}
		}
	}

	return ShopCalcShippingByCountry(aoShopProducts[nProduct].m_oShippingCosts, strCountry);
}


function ShopProduct(strName, strID, nPrice, strCurrency, oShippingCosts, bNotAvailable)
{
	this.m_strName = strName;
	this.m_strID = strID;
	this.m_strShareItID = strID;
	this.m_nPrice = nPrice;
	this.m_oShippingCosts = ((typeof oShippingCosts) != 'undefined') ? oShippingCosts : new ShopShipping();		
	this.m_strCurrency = strCurrency;
	this.m_bNotAvailable = bNotAvailable;
}


function ShopAdd(nLan, strProductID)
{
	if (bLocalTest)
	{
		location.href='cart.htm?mode=addproduct&product=' + strProductID;
	}
	else
	{
		location.href='https://secure.freiwald.com/' + ((nLan == 2) ? 'seiten' : 'pages') + '/cart.htm?mode=addproduct&product=' + strProductID;
	}
}



function ShopDoAdd(nLan, strProductID)
{
	// check, whether the product ID is valid:

	var nIndex = ShopGetProdIndex(strProductID);

	if (nIndex < 0)
	{
		alert(astrDict[nLan]["MSG_UNKNOWNPRODUCT"]);
		return;
	}

	var strNewCurrency = aoShopProducts[nIndex].m_strCurrency;

	// check, whether the currency matches:

	for (var p = 0; p < aoShopProducts.length; p++)
	{
		if (ShopGetProdCount(aoShopProducts[p].m_strID) != 0)
		{
			if (strNewCurrency != aoShopProducts[p].m_strCurrency)
			{
				if (!confirm(astrDict[nLan]["MSG_INCONSISTENTCURRENCY"]))
				{
					document.location.href = "cart.htm";
					return;
				}
				else
				{
					for (var q = 0; q < aoShopProducts.length; q++)
					{
						if (ShopGetProdCount(aoShopProducts[q].m_strID) != 0)
						{
							ShopChange(aoShopProducts[q].m_strID, 0);
						}
					}
				}
			}
		}
	}

	var nCount = ShopGetProdCount(strProductID);

	if (nCount < 0)
	{
		nCount = 0;
	}

	nCount++;

	ShopChange(strProductID, nCount);

//	document.location.href = "cart.htm";
}




function ShopChange(strProductID, nCount)
{
	var nIndex = ShopGetProdIndex(strProductID);
	var strShop = InputRead(strProductKey);
	var strCount = '';

	if (strShop.length != 2*aoShopProducts.length)
	{
		strShop = '';

		for (var p = 0; p < aoShopProducts.length; p++)
		{
			strShop += '00';
		}
	}

	if (nCount < 10)
	{
		strCount = '0' + nCount;
	}
	else if (nCount < 99)
	{
		strCount = nCount;
	}
	else
	{
		strCount = '99';
	}

	strShop = strShop.substring(0, nIndex * 2) + strCount + strShop.substring((nIndex + 1) * 2 , strShop.length);
	SessionWrite(strProductKey, strShop);
}



function ShopGetProdCount(strProductID)
{
	var strShop = InputRead(strProductKey);

	if (strShop == '')
	{
		return 0;
	}

	var nIndex = ShopGetProdIndex(strProductID);

	var strCount = strShop.substring(nIndex * 2, (nIndex + 1) * 2);

	if (strCount.substring(0, 1) == '0')
	{
		strCount = strCount.substring(1, 2);
	}

	var nCount = parseInt(strCount);

	if (nCount == 99)
	{
		return -1;
	}

	return nCount;
}


function ShopGetCurrency()
{
	for (var p = 0; p < aoShopProducts.length; p++)
	{
		var nCount = ShopGetProdCount(aoShopProducts[p].m_strID);
		
		if (nCount > 0)
		{
			return aoShopProducts[p].m_strCurrency;	
		}	
	}

	return aoShopProducts[0].m_strCurrency;
}



function ShopRefresh(bReload)
{
	var nItemCount = parseInt(document.forms["CART"]["ITEMCOUNT"].value);

	for (var p = 0; p < nItemCount; p++)
	{
		var strProductID = document.forms["CART"]["ID" + p.toString()].value;
		var nCount = parseInt(document.forms["CART"]["COUNT" + p.toString()].value);

		if (document.forms["CART"]["DELETE" + p.toString()].checked == true)
		{
			document.forms["CART"]["DELETE" + p.toString()].checked = false;
			nCount = 0;
		}

		ShopChange(strProductID, nCount);
	}

	if (bReload)
	{
		ShopReload();
	}
}


function ShopReload(strParam)
{
	var strRef = 'cart.htm';
	
	if ((typeof strParam) != 'undefined')
	{
		location.href = strRef + '?' + strParam;
	}
	else
	{
		location.replace(strRef);
	}
}


function ShopDelete(strProductID)
{
	CookieChange(strProductID, 0);
}



function ShopGetProdIndex(strProductID)
{
	for (var p = 0; p < aoShopProducts.length; p++)
	{
		if (strProductID == aoShopProducts[p].m_strID)
		{
			return p;
		}
	}

	return -1;
}


function ShopCreateOrderNumber()
{
	var dDate = new Date();
	return (dDate.getTime()) % (36*365*24*60*60*1000);
}


function ShopChangeSpecialChars(s)
{
	for (var c = 0; c < s.length; c++)
	{
		if (encodeURI(s.substring(c, c+1)) == '%C3%A4')
		{
			s = s.substring(0, c) + 'ae' + s.substring(c+1, s.length);
		}
		else if (encodeURI(s.substring(c, c+1)) == '%C3%B6')
		{
			s = s.substring(0, c) + 'oe' + s.substring(c+1, s.length);
		}
		else if (encodeURI(s.substring(c, c+1)) == '%C3%BC')
		{
			s = s.substring(0, c) + 'ue' + s.substring(c+1, s.length);
		}
		else if (encodeURI(s.substring(c, c+1)) == '%C3%84')
		{
			s = s.substring(0, c) + 'Ae' + s.substring(c+1, s.length);
		}
		else if (encodeURI(s.substring(c, c+1)) == '%C3%96')
		{
			s = s.substring(0, c) + 'Oe' + s.substring(c+1, s.length);
		}
		else if (encodeURI(s.substring(c, c+1)) == '%C3%9C')
		{
			s = s.substring(0, c) + 'Ue' + s.substring(c+1, s.length);
		}
		else if (encodeURI(s.substring(c, c+1)) == '%C3%9F')
		{
			s = s.substring(0, c) + 'ss' + s.substring(c+1, s.length);
		}
	}

	return s;
}


function ShopRound(x)
{
	x *= 100;
	x = Math.round(x);
	x /= 100;
	return x;
}

var aoCountry;

function ShopCountry(strEnglish, strGerman, strID, bEU, bMain)
{
	this.m_strEnglish = strEnglish;
	this.m_strGerman = strGerman;
	this.m_strID = strID;
	this.m_bEU = ((typeof bEU) != 'undefined') ? bEU : false;
	this.m_bMain = ((typeof bMain) != 'undefined') ? bMain : false;
}


function ShopInitCountries()
{
	if ((typeof aoCountry) == 'undefined')
	{
		aoCountry = new Array();

		var nCountry = 0;

		aoCountry[nCountry++] = new ShopCountry('Afghanistan', 'Afghanistan', 'AF'); 
		aoCountry[nCountry++] = new ShopCountry('Åland Islands', 'Åland-Inseln', 'AX');
		aoCountry[nCountry++] = new ShopCountry('Albania', 'Albanien', 'AL');
		aoCountry[nCountry++] = new ShopCountry('Algeria', 'Algerien', 'DZ');
		aoCountry[nCountry++] = new ShopCountry('American Samoa', 'Amerikanisch-Samoa', 'AS');
		aoCountry[nCountry++] = new ShopCountry('Andorra', 'Andorra', 'AD');
		aoCountry[nCountry++] = new ShopCountry('Angola', 'Angola', 'AO');
		aoCountry[nCountry++] = new ShopCountry('Anguilla', 'Anguilla', 'AI');
		aoCountry[nCountry++] = new ShopCountry('Antarctica', 'Antarktis', 'AQ');
		aoCountry[nCountry++] = new ShopCountry('Antigua and Barbuda', 'Antigua und Barbuda', 'AG');
		aoCountry[nCountry++] = new ShopCountry('Argentina', 'Argentinien', 'AR');
		aoCountry[nCountry++] = new ShopCountry('Armenia', 'Armenien', 'AM');
		aoCountry[nCountry++] = new ShopCountry('Aruba', 'Aruba', 'AW');
		aoCountry[nCountry++] = new ShopCountry('Australia', 'Australien', 'AU');
		aoCountry[nCountry++] = new ShopCountry('Austria', 'Österreich', 'AT', true, true);
		aoCountry[nCountry++] = new ShopCountry('Azerbaijan', 'Aserbaidschan', 'AZ');
		aoCountry[nCountry++] = new ShopCountry('Bahamas', 'Bahamas', 'BS');
		aoCountry[nCountry++] = new ShopCountry('Bahrain', 'Bahrain', 'BH');
		aoCountry[nCountry++] = new ShopCountry('Bangladesh', 'Bangladesch', 'BD');
		aoCountry[nCountry++] = new ShopCountry('Barbados', 'Barbados', 'BB');
		aoCountry[nCountry++] = new ShopCountry('Belarus', 'Weissrussland', 'BY');
		aoCountry[nCountry++] = new ShopCountry('Belgium', 'Belgien', 'BE', true);
		aoCountry[nCountry++] = new ShopCountry('Belize', 'Belize', 'BZ');
		aoCountry[nCountry++] = new ShopCountry('Benin', 'Benin', 'BJ');
		aoCountry[nCountry++] = new ShopCountry('Bermuda', 'Bermuda', 'BM');
		aoCountry[nCountry++] = new ShopCountry('Bhutan', 'Bhutan', 'BT');
		aoCountry[nCountry++] = new ShopCountry('Bolivia', 'Bolivien', 'BO');
		aoCountry[nCountry++] = new ShopCountry('Bosnia and Herzegovina', 'Bosnien und Herzegowvina', 'BA');
		aoCountry[nCountry++] = new ShopCountry('Botswana', 'Botswana', 'BW');
		aoCountry[nCountry++] = new ShopCountry('Bouvet Island', 'Bouvet Inseln', 'BV');
		aoCountry[nCountry++] = new ShopCountry('Brazil', 'Brasilien', 'BR');
		aoCountry[nCountry++] = new ShopCountry('British Indian Ocean Territory', 'Britisches Territorium im Indischen Ozean', 'IO');
		aoCountry[nCountry++] = new ShopCountry('Brunei Darussalam', 'Brunei Darussalam', 'BN');
		aoCountry[nCountry++] = new ShopCountry('Bulgaria', 'Bulgarien', 'BG', true);
		aoCountry[nCountry++] = new ShopCountry('Burkina Faso', 'Burkina Faso', 'BF');
		aoCountry[nCountry++] = new ShopCountry('Burundi', 'Burundi', 'BI');
		aoCountry[nCountry++] = new ShopCountry('Cambodia', 'Kambodscha', 'KH');
		aoCountry[nCountry++] = new ShopCountry('Cameroon', 'Kamerun', 'CM');
		aoCountry[nCountry++] = new ShopCountry('Canada', 'Kanada', 'CA');
		aoCountry[nCountry++] = new ShopCountry('Canary Islands', 'Kanarische Inseln', 'IC');
		aoCountry[nCountry++] = new ShopCountry('Cape Verde', 'Kap Verde', 'CV');
		aoCountry[nCountry++] = new ShopCountry('Cayman Islands', 'Kaimaninseln', 'KY');
		aoCountry[nCountry++] = new ShopCountry('Central African Republic', 'Zentralafrikanische Republik', 'CF');
		aoCountry[nCountry++] = new ShopCountry('Ceuta', 'Ceuta', 'EA');
		aoCountry[nCountry++] = new ShopCountry('Chad', 'Tschad', 'TD');
		aoCountry[nCountry++] = new ShopCountry('Chile', 'Chile', 'CL');
		aoCountry[nCountry++] = new ShopCountry('China', 'China', 'CN');
		aoCountry[nCountry++] = new ShopCountry('Christmas Island', 'Weihnachtsinsel', 'CX');
		aoCountry[nCountry++] = new ShopCountry('Cocos (Keeling) Islands', 'Kokosinseln', 'CC');
		aoCountry[nCountry++] = new ShopCountry('Colombia', 'Kolumbien', 'CO');
		aoCountry[nCountry++] = new ShopCountry('Comoros', 'Komoren', 'KM');
		aoCountry[nCountry++] = new ShopCountry('Congo, Dem. Republic', 'Kongo, Dem. Republik', 'CD');
		aoCountry[nCountry++] = new ShopCountry('Congo, Republic', 'Kongo, Republik', 'CG');
		aoCountry[nCountry++] = new ShopCountry('Cook Islands', 'Cookinseln', 'CK');
		aoCountry[nCountry++] = new ShopCountry('Costa Rica', 'Costa Rica', 'CR');
		aoCountry[nCountry++] = new ShopCountry('Cote d\'Ivoire', 'Elfenbeinküste', 'CI');
		aoCountry[nCountry++] = new ShopCountry('Croatia', 'Kroatien', 'HR');
		aoCountry[nCountry++] = new ShopCountry('Cyprus', 'Zypern', 'CY', true);
		aoCountry[nCountry++] = new ShopCountry('Cyprus (unregulated area)', 'Zypern (unregulated area)', 'X1');
		aoCountry[nCountry++] = new ShopCountry('Czech Republic', 'Tschechische Republik', 'CZ', true);
		aoCountry[nCountry++] = new ShopCountry('Denmark', 'Dänemark', 'DK', true);
		aoCountry[nCountry++] = new ShopCountry('Djibouti', 'Dschibuti', 'DJ');
		aoCountry[nCountry++] = new ShopCountry('Dominica', 'Dominika', 'DM');
		aoCountry[nCountry++] = new ShopCountry('Dominican Republic', 'Dominikanische Republik', 'DO');
		aoCountry[nCountry++] = new ShopCountry('East-Timor', 'Osttimor', 'TL');
		aoCountry[nCountry++] = new ShopCountry('Ecuador', 'Ecuador', 'EC');
		aoCountry[nCountry++] = new ShopCountry('Egypt', 'Ägypten', 'EG');
		aoCountry[nCountry++] = new ShopCountry('El Salvador', 'El Salvador', 'SV');
		aoCountry[nCountry++] = new ShopCountry('Equatorial Guinea', 'Äquatorial-Guinea', 'XX');
		aoCountry[nCountry++] = new ShopCountry('Eritrea', 'Eritrea', 'ER');
		aoCountry[nCountry++] = new ShopCountry('Estonia', 'Estland', 'EE', true);
		aoCountry[nCountry++] = new ShopCountry('Ethiopia', 'Äthiopien', 'ET');
		aoCountry[nCountry++] = new ShopCountry('Falkland Islands', 'Falklandinseln', 'FK');
		aoCountry[nCountry++] = new ShopCountry('Faroe Islands', 'Färöer', 'FO');
		aoCountry[nCountry++] = new ShopCountry('Fiji', 'Fidschi', 'FJ');
		aoCountry[nCountry++] = new ShopCountry('Finland', 'Finnland', 'FI', true);
		aoCountry[nCountry++] = new ShopCountry('France', 'Frankreich', 'FR', true, true);
		aoCountry[nCountry++] = new ShopCountry('French Guiana', 'Französisch Guyana', 'GF');
		aoCountry[nCountry++] = new ShopCountry('French Polynesia', 'Französisch Polynesien', 'PF');
		aoCountry[nCountry++] = new ShopCountry('French Southern Territories', 'Französische Süd- und Antarktisgebiete', 'TF');
		aoCountry[nCountry++] = new ShopCountry('Gabon', 'Gabun', 'GA');
		aoCountry[nCountry++] = new ShopCountry('Gambia', 'Gambia', 'GM');
		aoCountry[nCountry++] = new ShopCountry('Georgia', 'Georgien', 'GE');
		aoCountry[nCountry++] = new ShopCountry('Germany', 'Deutschland', 'DE', true, true);
		aoCountry[nCountry++] = new ShopCountry('Ghana', 'Ghana', 'GH');
		aoCountry[nCountry++] = new ShopCountry('Gibraltar', 'Gibraltar', 'GI');
		aoCountry[nCountry++] = new ShopCountry('Greece', 'Griechenland', 'GR', true);
		aoCountry[nCountry++] = new ShopCountry('Greenland', 'Grönland', 'GL');
		aoCountry[nCountry++] = new ShopCountry('Grenada', 'Grenada', 'GD');
		aoCountry[nCountry++] = new ShopCountry('Guadeloupe', 'Guadaloupe', 'GP');
		aoCountry[nCountry++] = new ShopCountry('Guam', 'Guam', 'GU');
		aoCountry[nCountry++] = new ShopCountry('Guatemala', 'Guatemala', 'GT');
		aoCountry[nCountry++] = new ShopCountry('Guernsey', 'Guernsey', 'GG');
		aoCountry[nCountry++] = new ShopCountry('Guinea', 'Guinea', 'GN');
		aoCountry[nCountry++] = new ShopCountry('Guinea-Bissau', 'Guinea-Bissau', 'GW');
		aoCountry[nCountry++] = new ShopCountry('Guyana', 'Guyana', 'GY');
		aoCountry[nCountry++] = new ShopCountry('Haiti', 'Haiti', 'HT');
		aoCountry[nCountry++] = new ShopCountry('Heard Island and McDonald Islands', 'Heard- und McDonald-Inseln', 'HM');
		aoCountry[nCountry++] = new ShopCountry('Honduras', 'Honduras', 'HN');
		aoCountry[nCountry++] = new ShopCountry('Hong Kong', 'Hongkong', 'HK');
		aoCountry[nCountry++] = new ShopCountry('Hungary', 'Ungarn', 'HU', true);
		aoCountry[nCountry++] = new ShopCountry('Iceland', 'Island', 'IS');
		aoCountry[nCountry++] = new ShopCountry('India', 'Indien', 'IN');
		aoCountry[nCountry++] = new ShopCountry('Indonesia', 'Indonesien', 'ID');
		aoCountry[nCountry++] = new ShopCountry('Iraq', 'Irak', 'IQ');
		aoCountry[nCountry++] = new ShopCountry('Ireland', 'Irland', 'IE', true);
		aoCountry[nCountry++] = new ShopCountry('Isle Of Man', 'Insel Man', 'IM');
		aoCountry[nCountry++] = new ShopCountry('Israel', 'Israel', 'IL');
		aoCountry[nCountry++] = new ShopCountry('Italy', 'Italien', 'IT', true);
		aoCountry[nCountry++] = new ShopCountry('Jamaica', 'Jamaika', 'JM');
		aoCountry[nCountry++] = new ShopCountry('Japan', 'Japan', 'JP');
		aoCountry[nCountry++] = new ShopCountry('Jersey', 'Jersey', 'JE');
		aoCountry[nCountry++] = new ShopCountry('Jordan', 'Jordanien', 'JO');
		aoCountry[nCountry++] = new ShopCountry('Kazakhstan', 'Kasachstan', 'KZ');
		aoCountry[nCountry++] = new ShopCountry('Kenya', 'Kenia', 'KE');
		aoCountry[nCountry++] = new ShopCountry('Kiribati', 'Kiribati', 'KI');
		aoCountry[nCountry++] = new ShopCountry('Korea, South', 'Südkorea', 'KR');
		aoCountry[nCountry++] = new ShopCountry('Kuwait', 'Kuwait', 'KW');
		aoCountry[nCountry++] = new ShopCountry('Kyrgyzstan', 'Kirgisistan', 'KG');
		aoCountry[nCountry++] = new ShopCountry('Laos', 'Laos', 'LA');
		aoCountry[nCountry++] = new ShopCountry('Latvia', 'Lettland', 'LV', true);
		aoCountry[nCountry++] = new ShopCountry('Lebanon', 'Libanon', 'LB');
		aoCountry[nCountry++] = new ShopCountry('Lesotho', 'Lesotho', 'LS');
		aoCountry[nCountry++] = new ShopCountry('Liberia', 'Liberia', 'LR');
		aoCountry[nCountry++] = new ShopCountry('Liechtenstein', 'Liechtenstein', 'LI');
		aoCountry[nCountry++] = new ShopCountry('Lithuania', 'Litauen', 'LT', true);
		aoCountry[nCountry++] = new ShopCountry('Luxembourg', 'Luxemburg', 'LU', true);
		aoCountry[nCountry++] = new ShopCountry('Macau', 'Macao', 'MO');
		aoCountry[nCountry++] = new ShopCountry('Macedonia (Former Yugoslav Republic)', 'Mazedonien, ehem. jugoslawische Republik', 'MK');
		aoCountry[nCountry++] = new ShopCountry('Madagascar', 'Madagaskar', 'MG');
		aoCountry[nCountry++] = new ShopCountry('Malawi', 'Malawi', 'MW');
		aoCountry[nCountry++] = new ShopCountry('Malaysia', 'Malaysia', 'MY');
		aoCountry[nCountry++] = new ShopCountry('Maldives', 'Malediven', 'MV');
		aoCountry[nCountry++] = new ShopCountry('Mali', 'Mali', 'ML');
		aoCountry[nCountry++] = new ShopCountry('Malta', 'Malta', 'MT', true);
		aoCountry[nCountry++] = new ShopCountry('Marshall Islands', 'Marshallinseln', 'MH');
		aoCountry[nCountry++] = new ShopCountry('Martinique', 'Martinique', 'MQ');
		aoCountry[nCountry++] = new ShopCountry('Mauritania', 'Mauretanien', 'MR');
		aoCountry[nCountry++] = new ShopCountry('Mauritius', 'Mauritius', 'MU');
		aoCountry[nCountry++] = new ShopCountry('Mayotte', 'Mayotte', 'YT');
		aoCountry[nCountry++] = new ShopCountry('Mexico', 'Mexiko', 'MX');
		aoCountry[nCountry++] = new ShopCountry('Micronesia', 'Mikronesien', 'FM');
		aoCountry[nCountry++] = new ShopCountry('Moldova', 'Moldavien', 'MD');
		aoCountry[nCountry++] = new ShopCountry('Monaco', 'Monaco', 'MC');
		aoCountry[nCountry++] = new ShopCountry('Mongolia', 'Mongolei', 'MN');
		aoCountry[nCountry++] = new ShopCountry('Montserrat', 'Montserrat', 'MS');
		aoCountry[nCountry++] = new ShopCountry('Morocco', 'Marokko', 'MA');
		aoCountry[nCountry++] = new ShopCountry('Mozambique', 'Mozambique', 'MZ');
		aoCountry[nCountry++] = new ShopCountry('Myanmar', 'Myanmar', 'MM');
		aoCountry[nCountry++] = new ShopCountry('Namibia', 'Namibia', 'NA');
		aoCountry[nCountry++] = new ShopCountry('Nauru', 'Nauru', 'NR');
		aoCountry[nCountry++] = new ShopCountry('Nepal', 'Nepal', 'NP');
		aoCountry[nCountry++] = new ShopCountry('Netherlands', 'Niederlande', 'NL', true, true);
		aoCountry[nCountry++] = new ShopCountry('Netherlands Antilles', 'Niderländische Antillen', 'AN');
		aoCountry[nCountry++] = new ShopCountry('New Caledonia', 'Neukaledonien', 'NC');
		aoCountry[nCountry++] = new ShopCountry('New Zealand', 'Neuseeland', 'NZ');
		aoCountry[nCountry++] = new ShopCountry('Nicaragua', 'Nicaragua', 'NI');
		aoCountry[nCountry++] = new ShopCountry('Niger', 'Niger', 'NE');
		aoCountry[nCountry++] = new ShopCountry('Nigeria', 'Nigeria', 'NG');
		aoCountry[nCountry++] = new ShopCountry('Niue', 'Niue', 'NU');
		aoCountry[nCountry++] = new ShopCountry('Norfolk Island', 'Norfolkinsel', 'NF');
		aoCountry[nCountry++] = new ShopCountry('Northern Mariana Islands', 'Nördliche Marianen', 'MP');
		aoCountry[nCountry++] = new ShopCountry('Norway', 'Norwegen', 'NO');
		aoCountry[nCountry++] = new ShopCountry('Oman', 'Oman', 'OM');
		aoCountry[nCountry++] = new ShopCountry('Pakistan', 'Pakistan', 'PK');
		aoCountry[nCountry++] = new ShopCountry('Palau', 'Palau', 'PW');
		aoCountry[nCountry++] = new ShopCountry('Palestinian Territory', 'Palästinensische Autonomiegebiete', 'PS');
		aoCountry[nCountry++] = new ShopCountry('Panama', 'Panama', 'PA');
		aoCountry[nCountry++] = new ShopCountry('Papua New Guinea', 'Papua-Neuguinea', 'PG');
		aoCountry[nCountry++] = new ShopCountry('Paraguay', 'Paraguay', 'PY');
		aoCountry[nCountry++] = new ShopCountry('Peru', 'Peru', 'PE');
		aoCountry[nCountry++] = new ShopCountry('Philippines', 'Philippinen', 'PH');
		aoCountry[nCountry++] = new ShopCountry('Pitcairn Islands', 'Pitcairninseln', 'PN');
		aoCountry[nCountry++] = new ShopCountry('Poland', 'Polen', 'PL', true);
		aoCountry[nCountry++] = new ShopCountry('Portugal', 'Portugal', 'PT', true);
		aoCountry[nCountry++] = new ShopCountry('Puerto Rico', 'Puerto Rico', 'PR');
		aoCountry[nCountry++] = new ShopCountry('Qatar', 'Katar', 'QA');
		aoCountry[nCountry++] = new ShopCountry('Reunion', 'Reunion', 'RE');
		aoCountry[nCountry++] = new ShopCountry('Romania', 'Rumänien', 'RO', true);
		aoCountry[nCountry++] = new ShopCountry('Russia', 'Russland', 'RU');
		aoCountry[nCountry++] = new ShopCountry('Rwanda', 'Ruanda', 'RW');
		aoCountry[nCountry++] = new ShopCountry('Samoa', 'Samoa', 'WS');
		aoCountry[nCountry++] = new ShopCountry('San Marino', 'San Marino', 'SM');
		aoCountry[nCountry++] = new ShopCountry('Sao Tome and Principe', 'Sao Tome und Principe', 'ST');
		aoCountry[nCountry++] = new ShopCountry('Saudi Arabia', 'Saudi Arabien', 'SA');
		aoCountry[nCountry++] = new ShopCountry('Senegal', 'Senegal', 'SN');
		aoCountry[nCountry++] = new ShopCountry('Serbia and Montenegro', 'Serbien und Montenegro', 'RS');
		aoCountry[nCountry++] = new ShopCountry('Seychelles', 'Seychellen', 'SC');
		aoCountry[nCountry++] = new ShopCountry('Sierra Leone', 'Sierra Leone', 'SL');
		aoCountry[nCountry++] = new ShopCountry('Singapore', 'Singapur', 'SG');
		aoCountry[nCountry++] = new ShopCountry('Slovakia', 'Slowakei', 'SK', true);
		aoCountry[nCountry++] = new ShopCountry('Slovenia', 'Slowenien', 'SI', true);
		aoCountry[nCountry++] = new ShopCountry('Solomon Islands', 'Salomoninseln', 'SB');
		aoCountry[nCountry++] = new ShopCountry('Somalia', 'Somalia', 'SO');
		aoCountry[nCountry++] = new ShopCountry('South Africa', 'Südafrika', 'ZA');
		aoCountry[nCountry++] = new ShopCountry('South Georgia and Sandwich Islands', 'Südgeorgien und die Südlichen Sandwichinseln', 'GS');
		aoCountry[nCountry++] = new ShopCountry('Spain', 'Spanien', 'ES', true);
		aoCountry[nCountry++] = new ShopCountry('Sri Lanka', 'Sri Lanka', 'LK');
		aoCountry[nCountry++] = new ShopCountry('St. Helena', 'St. Helena', 'SH');
		aoCountry[nCountry++] = new ShopCountry('St. Kitts and Nevis', 'St. Kitts und Nevis', 'KN');
		aoCountry[nCountry++] = new ShopCountry('St. Lucia', 'St. Lucia', 'LC');
		aoCountry[nCountry++] = new ShopCountry('St. Pierre and Miquelon', 'St. Pierre und Miquelon', 'PM');
		aoCountry[nCountry++] = new ShopCountry('St. Vincent and the Grenadines', 'St. Vincent und die Grenadinen', 'VC');
		aoCountry[nCountry++] = new ShopCountry('Suriname', 'Surinam', 'SR');
		aoCountry[nCountry++] = new ShopCountry('Svalbard', 'Svalbard', 'SJ');
		aoCountry[nCountry++] = new ShopCountry('Swaziland', 'Swasiland', 'SZ');
		aoCountry[nCountry++] = new ShopCountry('Sweden', 'Schweden', 'SE', true);
		aoCountry[nCountry++] = new ShopCountry('Switzerland', 'Schweiz', 'CH', false, true);
		aoCountry[nCountry++] = new ShopCountry('Taiwan', 'Taiwan', 'TW');
		aoCountry[nCountry++] = new ShopCountry('Tajikistan', 'Tadschikistan', 'TJ');
		aoCountry[nCountry++] = new ShopCountry('Tanzania', 'Tansania', 'TZ');
		aoCountry[nCountry++] = new ShopCountry('Thailand', 'Thailand', 'TH');
		aoCountry[nCountry++] = new ShopCountry('Togo', 'Togo', 'TG');
		aoCountry[nCountry++] = new ShopCountry('Tokelau', 'Tokelau', 'TK');
		aoCountry[nCountry++] = new ShopCountry('Tonga', 'Tonga', 'TO');
		aoCountry[nCountry++] = new ShopCountry('Trinidad and Tobago', 'Trinidad und Tobago', 'TT');
		aoCountry[nCountry++] = new ShopCountry('Tunisia', 'Tunesien', 'TN');
		aoCountry[nCountry++] = new ShopCountry('Turkey', 'Türkei', 'TR');
		aoCountry[nCountry++] = new ShopCountry('Turkmenistan', 'Turkmenistan', 'TM');
		aoCountry[nCountry++] = new ShopCountry('Turks and Caicos Islands', 'Turks- und Caicosinseln', 'TC');
		aoCountry[nCountry++] = new ShopCountry('Tuvalu', 'Tuvalu', 'TV');
		aoCountry[nCountry++] = new ShopCountry('Uganda', 'Uganda', 'UG');
		aoCountry[nCountry++] = new ShopCountry('Ukraine', 'Ukraine', 'UA');
		aoCountry[nCountry++] = new ShopCountry('United Arab Emirates', 'Vereinigte Arabische Emirate', 'AE');
		aoCountry[nCountry++] = new ShopCountry('United Kingdom', 'Großbritannien', 'GB', true, true);
		aoCountry[nCountry++] = new ShopCountry('Uruguay', 'Uruguay', 'UY');
		aoCountry[nCountry++] = new ShopCountry('USA', 'USA', 'US', false, true);
		aoCountry[nCountry++] = new ShopCountry('US Minor Outlying Islands', 'US Minor Outlying Islands', 'UM');
		aoCountry[nCountry++] = new ShopCountry('Uzbekistan', 'Usbekistan', 'UZ');
		aoCountry[nCountry++] = new ShopCountry('Vanuatu', 'Vanuatu', 'VU');
		aoCountry[nCountry++] = new ShopCountry('Vatican City State', 'Vatikan', 'VA');
		aoCountry[nCountry++] = new ShopCountry('Venezuela', 'Venezuela', 'VE');
		aoCountry[nCountry++] = new ShopCountry('Viet Nam', 'Vietnam', 'VN');
		aoCountry[nCountry++] = new ShopCountry('Virgin Islands (British)', 'Britische Jungferninseln', 'VG');
		aoCountry[nCountry++] = new ShopCountry('Virgin Islands (U.S.)', 'Amerikanische Jungferninseln', 'VI');
		aoCountry[nCountry++] = new ShopCountry('Wallis und Futuna', 'Wallis and Futuna', 'WF');
		aoCountry[nCountry++] = new ShopCountry('Western Sahara', 'Westsahara', 'EH');
		aoCountry[nCountry++] = new ShopCountry('Yemen', 'Jemen', 'YE');
		aoCountry[nCountry++] = new ShopCountry('Zambia', 'Sambia', 'ZM');
		aoCountry[nCountry++] = new ShopCountry('Zimbabwe', 'Simbabwe', 'ZW');
	}
}


function ShopSortCountries(oCountries, nLan)
{
	ShopInitCountries();

	if (oCountries.length <= 1)
	{
		return oCountries;
	}

	var oPivot = oCountries[Math.floor(oCountries.length / 2)];
	var strPivot = (nLan == 2) ? oPivot.m_strGerman : oPivot.m_strEnglish;

	switch (strPivot.charAt(0))
	{
		case 'Ä':
		{
			strPivot = 'Ae' + strPivot.substr(1);
			break;
		}
		case 'Ö':
		{
			strPivot = 'Oe' + strPivot.substr(1);
			break;
		}
		case 'Å':
		{
			strPivot = 'Ao' + strPivot.substr(1);
			break;
		}
	}

	var oLess = new Array();
	var oGreater = new Array();

	for (var i = 0; i < oCountries.length; i++)
	{
		if (i == Math.floor(oCountries.length / 2))
		{
			continue;
		}

		var strCheck = (nLan == 2) ? oCountries[i].m_strGerman : oCountries[i].m_strEnglish;

		switch (strCheck.charAt(0))
		{
			case 'Ä':
			{
				strCheck = 'Ae' + strCheck.substr(1);
				break;
			}
			case 'Ö':
			{
				strCheck = 'Oe' + strCheck.substr(1);
				break;
			}
			case 'Å':
			{
				strCheck = 'Ao' + strCheck.substr(1);
				break;
			}
		}

		if (strCheck < strPivot)
		{
			oLess[oLess.length] = oCountries[i];
		}
		else
		{
			oGreater[oGreater.length] = oCountries[i];
		}
	}

	oLess = ShopSortCountries(oLess, nLan);	
	oLess[oLess.length] = oPivot;

	return oLess.concat(ShopSortCountries(oGreater, nLan));
}


function ShopFillCountryList(nLan, strSelID, bHighlight)
{
	document.write('<OPTION VALUE=""');

	if (bHighlight)
	{
		document.write(' style="color:#FF0000;"');
	}

	document.write('>');

	if (nLan == 2)
	{
		document.write('&ndash;&ndash;&gt; Bitte auswählen</OPTION>');
	}
	else
	{
		document.write('&ndash;&ndash;&gt; Please choose</OPTION>');
	}

	ShopInitCountries();
	aoCountry = ShopSortCountries(aoCountry, nLan);

	var bSelected = false;

	for (var c = 0; c < aoCountry.length; c++)
	{
		if (aoCountry[c].m_bMain)
		{
			var strSelected = '';

			if (aoCountry[c].m_strID == strSelID)
			{
				strSelected = ' SELECTED';
				bSelected = true;
			}			

			document.write('<OPTION VALUE="' + aoCountry[c].m_strID + '"' + strSelected + '>' + ((nLan == 2) ? aoCountry[c].m_strGerman : aoCountry[c].m_strEnglish) + '</OPTION>');
		}
	}

	if (nLan == 2)
	{
		document.write('<OPTION VALUE="">------- Alle Länder -------</OPTION>');
	}
	else
	{
		document.write('<OPTION VALUE="">------- All Countries -------</OPTION>');
	}

	for (var c = 0; c < aoCountry.length; c++)
	{
		var strSelected = '';

		if ((!bSelected) && (aoCountry[c].m_strID == strSelID))
		{
			strSelected = ' SELECTED';
		}			

		document.write('<OPTION VALUE="' + aoCountry[c].m_strID + '"' + strSelected + '>' + ((nLan == 2) ? aoCountry[c].m_strGerman : aoCountry[c].m_strEnglish) + '</OPTION>');
	}
}


function ShopFindCountry(strID)
{
	ShopInitCountries();

	for (var c = 0; c < aoCountry.length; c++)
	{
		if (aoCountry[c].m_strID == strID)
		{
			return aoCountry[c];
		}
	}
}



function ShopIsEU(strID)
{
	if (strID == '')
	{
		return false;
	}

	ShopInitCountries();

	var oCountry = ShopFindCountry(strID);
	return oCountry.m_bEU;
}




function ShopIsEURO(strID)
{
	return (ShopIsEU(strID) || (strID.toUpperCase() == 'CH') || (strID.toUpperCase() == 'NO'));
}



function ShopCalcNet(nTotalPrice, strCountry)
{
	if (ShopIsEU(strCountry))
	{
		return ShopRound(nTotalPrice / 1.19);
	}
	else
	{
		return nTotalPrice;
	}
}


function ShopCalcVat(nTotalPrice, strCountry)
{
	return ShopRound(nTotalPrice - ShopCalcNet(nTotalPrice, strCountry));
}


function ShopFormatAmount(nAmount)
{
	var s = ShopRound(nAmount);
	s = 'a' + s;
	s = s.substring(1,s.length);
	if (s.indexOf('.') == 0) s = '0'+ s;
	else if ((s.indexOf('.') != -1) && (s.indexOf('.') == s.length - 2)) s += '0';
	else if (s.indexOf('.') == -1) s += '.00';
	return s;
}



function ShopShowPrice(nLan, strProduct, strInfo)
{
	var doc = document;
	var p = ShopGetProdIndex(strProduct);

	doc.write('<td align="center" nowrap="nowrap">');

	var strCountryID = InputRead("SHOP_COUNTRY");	

	if (strCountryID == "")
	{	
		return;
	}

	if (strProduct == '0')
	{
		doc.write('N/A');
	}
	else if (p < 0)
	{
		doc.write('Error');
	}	
	else
	{
		doc.write(ShopFormatAmount(aoShopProducts[p].m_nPrice) + ' ' + aoShopProducts[p].m_strCurrency);

		if (ShopIsEU(strCountryID))
		{
			doc.write("<small>" + ((nLan == 2) ? "   inkl. Mwst." : "   incl. VAT") + "</small>");
		}

		if (aoShopProducts[p].m_oShippingCosts.m_nShippingCostsG != 0)
		{
			var strShipping = (nLan == 2) ? 'zzgl. Versandkosten' : 'plus Shipping & Handling';
			strShipping = strShipping += ' [<u><span style="cursor:pointer;cursor:hand;" OnClick="javascript:window.open(\'shipping.htm\',\'\',\'width=500,height=300,scrollbars=yes,resizable=yes\');">Info</span></u>]';

			if ((typeof strInfo) != 'undefined')
			{
				strInfo = strShipping + '<br>' + strInfo;
			}	
			else
			{
				strInfo = strShipping;
			}	
		}	
	}

	if ((typeof strInfo) != 'undefined')
	{
		doc.write('<br>' + strInfo);
	}
		
	doc.write('</td>');	
}



function ShopShowProduct(nLan, strProdEUR, strProdUSD, nUpgrade, strInfo)
{
	var doc = document;

	var strCountryID = InputRead("SHOP_COUNTRY");	

	if (strCountryID == "")
	{	
		doc.write('<td></td><td></td>');
		return;
	}

	var strProduct = ShopIsEURO(strCountryID) ? strProdEUR : strProdUSD;

	var p = ShopGetProdIndex(strProduct);

	ShopShowPrice(nLan, strProduct, strInfo);

	if (strProduct == '0')
	{
		doc.write('<td></td>');
	}
	else if (aoShopProducts[p].m_bNotAvailable)
	{
		doc.write('<td align="center" nowrap="nowrap">');
		doc.write((nLan == 2) ? 'Zur Zeit nicht lieferbar.' : 'Currently not available.');
		doc.write('</td>');
		return;	
	}	
	else
	{
		var strAlt = (nLan == 2) ? 'In den Warenkorb' : 'Order';
		var strDir = (nLan == 2) ? 'bilder' : 'images';
		doc.write('<td align="center" nowrap="nowrap">');

		if (nUpgrade == 1)
		{
			doc.write('<style="text-align: center;"><a href="upgrade.htm?EU=' + (ShopIsEU(strCountryID) ? '1' : '0') + '">'); 
			doc.write('<img src="../' + strDir + '/b_addtocart.gif" border="0" alt="' + strAlt + '"' + 'title="' + strAlt + '"' + '></a><');
 		} 
		else if (nUpgrade == 2)
		{
			doc.write('<style="text-align: center;"><a href="roco.htm?EU=' + (ShopIsEU(strCountryID) ? '1' : '0') + '&ID=' + strProduct + '">'); 
			doc.write('<img src="../' + strDir + '/b_addtocart.gif" border="0" alt="' + strAlt + '"' + 'title="' + strAlt + '"' + '></a><');
 		} 
		else
		{
			doc.write('<img src="../' + strDir + '/b_addtocart.gif" border="0" alt="' + strAlt + '"');
			doc.write('title="' + strAlt + '" onclick="ShopAdd(' + nLan + ', \'' + strProduct + '\')"');
		}

		doc.write('style="cursor: pointer;"> </td>');
	}
}



function ShopOrder(nLan, strID, strProdTo, strProdFrom, nFrom, nTo, strCountry)
{
	if (strID == '')	
	{
		if (nFrom == '')
		{
			if (strProdTo == 'TrainController')
			{
				strID = (!ShopIsEURO(strCountry)) ? '203724' : '106631';
			}	
			else if (strProdTo == 'TrainProgrammer')
			{
				strID = (!ShopIsEURO(strCountry)) ? '203728' : '137625';
			}	
			else if (strProdTo == '+4DSound')
			{
				strID = (!ShopIsEURO(strCountry)) ? '300043118' : '300043117';
			}	
			else if (strProdTo == '+Net')
			{
				strID = (!ShopIsEURO(strCountry)) ? '300024291' : '300024290';
			}	
			else if (strProdTo == '+Net/D')
			{
				if (!ShopIsEURO(strCountry))
				{
					alert((nLan == 2) ? "Dieses Produkt ist in Ihrem Land leider nicht verfügbar." : "Sorry. This product is not available in your country.");
					return;
				}
				
				strID = (!ShopIsEURO(strCountry)) ? '300024291' : '300024293';
			}	
		}	
		else if (nFrom == 55)
		{
			strID = (!ShopIsEURO(strCountry)) ? '203725' : '106632';
		}
		else if (nFrom == 50)
		{
			strID = (!ShopIsEURO(strCountry)) ? '203727' : '203721';
		}	
		else if ((nFrom >= 40) && (nFrom <= 49))
		{
			strID = (!ShopIsEURO(strCountry)) ? '203726' : '149291';
		}	
	}
	else
	{	
		strID = ShopCorrectCurrencyInID(strID, strCountry);
	}

	ShopAdd(nLan, strID);
}



function ShopCorrectCurrencyInID(strID, strCountry)
{
	return strID.substring(0, strID.length - 1) + ((ShopIsEURO(strCountry)) ? '1' : '2');
}




function ShopCalcService(strPayment, strCC)
{
	var strService = strInhouse

	if (strPayment == strBankTransfer)
	{
		strService = strInhouse;
	}	
	else if (strPayment == strPayPal)
	{
		strService = strInhouse;
	}
	else if (strPayment == strGiroPay)
	{
		strService = strUOS;
	}
	else if (strPayment == strSofortUeberweisung)
	{
		strService = strUOS;
	}
	else if(strPayment == strCreditCard) 	
	{
		strService = strShareIt;

		if ((strCC == 'M') || (strCC == 'V'))
		{
			var bUseUOS = true;		// true: UOS; false: ShareIt
			
			if (bLocalTest || bUseUOS)	
			{
				strService = strUOS;	// use UOS
			}	
		}
		else if (strCC == '')
		{
			strService = '';
		}
	}

	return strService;
}



function ShopCheckout(nLan)
{
	// called, when the user presses the checkout button in the cart page:

	ShopRefresh(false);
	location.replace('checkout.htm?REGISTER=0');
}




function ShopCreateRefShareIt(nLan, strCountry)
{
	var strRef = 'https://secure.shareit.com/shareit/checkout.html?backlink=http%3A%2F%2Fwww.freiwald.com%2F' + ((nLan <= 1) ? 'pages' : 'seiten') + '%2Fregister.htm&cookies=0';

	strRef += '&cart=0';
	strRef += '&languageid=' + nLan.toString();

	var nItemCount = 0;

	var strCurrency;

	var strProductID = 300274770;	

	var nTotalPrice = 0;
	var nTotalShippingCosts = 0;

	var strCurrency;

	for (var p = 0; p < aoShopProducts.length; p++)
	{
		var nCount = ShopGetProdCount(aoShopProducts[p].m_strID);
		
		if (nCount != 0)
		{
			if (nCount < 0)
			{
				nCount = 0;
			}	

			nTotalPrice += nCount*aoShopProducts[p].m_nPrice;
			nTotalPrice += ShopCalcShipping(p, nCount, strCountry)
		}	
	}

	for (var p = 0; p < aoShopProducts.length; p++)
	{
		var nCount = ShopGetProdCount(aoShopProducts[p].m_strID);

		if (nCount < 0)
		{
			nCount = 0;
		}		

		if (nCount != 0)
		{
			nItemCount++;	
			strCurrency = aoShopProducts[p].m_strCurrency;	
		}	
	}

	if (nItemCount > 0)
	{
		strRef += '&currencies=' + strCurrency;
		strRef += '&PRODUCT[' + strProductID + ']=1&PRODUCTPRICE[' + strProductID + ']='+ nTotalPrice.toString() + strCurrency + ',G';	

		strRef += '&SALUTATION=' + InputRead('SHOP_SALUTATION');
		strRef += '&FIRSTNAME=' + InputRead('SHOP_FIRSTNAME');
		strRef += '&LASTNAME=' + InputRead('SHOP_LASTNAME');
		strRef += '&D_STREET1=' + InputRead('SHOP_STREET');
		strRef += '&D_STREET2=' + InputRead('SHOP_STREET2');
		strRef += '&D_POSTALCODE=' + InputRead('SHOP_POSTALCODE');
		strRef += '&D_CITY=' + InputRead('SHOP_CITY');

		if (InputRead('SHOP_COUNTRY') == 'DE')
		{
			strRef += '&D_COUNTRY_ID=' + '4';
		}
		else if (InputRead('SHOP_COUNTRY') == 'CH')
		{
			strRef += '&D_COUNTRY_ID=' + '39';
		}
		else if (InputRead('SHOP_COUNTRY') == 'US')
		{
			strRef += '&D_COUNTRY_ID=' + '400';
		}
		else
		{
			strRef += '&D_COUNTRY_ID=' + '999';
		}	

		strRef += '&PHONE=' + InputRead('SHOP_PHONE');
		strRef += '&EMAIL=' + InputRead('SHOP_EMAIL');
		strRef += '&EMAIL_CONFIRM=' + InputRead('SHOP_EMAIL');
		strRef += '&PAYMENTTYPE_ID=CCA';		// preselect credit card as payment method

		strRef=encodeURI(strRef);
	}

	return strRef;		
}





function ShopCheckoutShareIt(nLan, bReplace, bAddPersonal)
{
	return;

	// used for products with individual product IDs:

	var strRef = 'https://secure.shareit.com/shareit/checkout.html?backlink=http%3A%2F%2Fwww.freiwald.com%2F' + ((nLan <= 1) ? 'pages' : 'seiten') + '%2Fregister.htm&cookies=0';

	strRef += '&cart=1';
	strRef += '&languageid=' + nLan.toString();

	var nItemCount = 0;

	var strCurrency;

	for (var p = 0; p < aoShopProducts.length; p++)
	{
		var nCount = ShopGetProdCount(aoShopProducts[p].m_strID);

		if (nCount < 0)
		{
			nCount = 0;
		}		

		if (nCount != 0)
		{
			nItemCount++;	
			strCurrency = aoShopProducts[p].m_strCurrency;	
			strRef += '&PRODUCT[' + aoShopProducts[p].m_strShareItID + ']=' + nCount.toString();
		}	
	}

	if (nItemCount > 0)
	{
		strRef += '&currencies=' + strCurrency;

		if (bAddPersonal)
		{
			strRef += '&SALUTATION=' + CookieRead('SHOP_SALUTATION');
			strRef += '&FIRSTNAME=' + CookieRead('SHOP_FIRSTNAME');
			strRef += '&LASTNAME=' + CookieRead('SHOP_LASTNAME');
			strRef += '&D_STREET1=' + CookieRead('SHOP_STREET');
			strRef += '&D_STREET2=' + CookieRead('SHOP_STREET2');
			strRef += '&D_POSTALCODE=' + CookieRead('SHOP_POSTALCODE');
			strRef += '&D_CITY=' + CookieRead('SHOP_CITY');
			strRef += '&D_COUNTRY_ID=' + CookieRead('SHOP_COUNTRY');
			strRef += '&PHONE=' + CookieRead('SHOP_PHONE');
			strRef += '&EMAIL=' + CookieRead('SHOP_EMAIL');
			strRef += '&EMAIL_CONFIRM=' + CookieRead('SHOP_EMAIL');
		}

		strRef=encodeURI(strRef);

		if (bReplace)
		{
			location.replace(strRef);
		}
		else
		{
			location.href = strRef;
		}
	}

	return strRef;		
}


function ShopCheckoutPayPal(nLan)
{
	if (nLan == 0)
	{
		nLan == 1;
	}

	var strRef = 'https://www.paypal.com/cgi-bin/webscr?business=paypal@freiwald.com';
//	var strRef = 'https://www.sandbox.paypal.com/cgi-bin/webscr?business=musterhaendler@musterhaendler.de';

	strRef += '&amp;cmd=_cart&amp;upload=1';
//	strRef += '&amp;tax_cart=' + '100';
	strRef += '&amp;lc=' + astrDict[nLan]["LAN"];

	var nItemCount = 0;
	var strCurrency;

	for (var p = 0; p < aoShopProducts.length; p++)
	{
		var nCount = ShopGetProdCount(aoShopProducts[p].m_strID);

		if (nCount < 0)
		{
			nCount = 0;
		}		

		if (nCount != 0)
		{
			nItemCount++;	
			strRef += '&amp;item_name_' + nItemCount.toString() + '=' + aoShopProducts[p].m_strName;
			strRef += '&amp;item_number_' + nItemCount.toString() + '=' + aoShopProducts[p].m_strID;
			strRef += '&amp;amount_' + nItemCount.toString() + '=' + aoShopProducts[p].m_nPrice.toString();
			strRef += '&amp;quantity_' + nItemCount.toString() + '=' + nCount.toString();
			strRef += '&amp;on0_' + nItemCount.toString() + '=' + astrDict[nLan]["MWST_TRANSMIT"];
			strCurrency = aoShopProducts[p].m_strCurrency;	
		}	
	}

	if (nItemCount > 0)
	{
		window.open(strRef);
		strRef += '&amp;currency_code=' + strCurrency;
//		location.href = strRef;
	}

	return strRef;		
}




function ShopShowCartTable(nLan, bAllowChanging, strCountry)
{
	var doc = document;

	var nTotalPrice = 0;
	var nTotalShippingCosts = 0;
	var nPosition = 0;
	var nItemCount = 0;

	var strCurrency;

	for (var p = 0; p < aoShopProducts.length; p++)
	{
		var nCount = ShopGetProdCount(aoShopProducts[p].m_strID);
		
		if (nCount != 0)
		{
			nItemCount++;	

			if (nCount < 0)
			{
				nCount = 0;
			}	

			strCurrency = aoShopProducts[p].m_strCurrency;	
	
			nPosition++;

			var nItemPrice = aoShopProducts[p].m_nPrice;
			var nSubTotal = nItemPrice * nCount;
			nTotalPrice += nSubTotal;
			
			doc.write('<tr>');

			doc.write('<td align="center">' + nPosition.toString() + '</td>');
			doc.write('<td>' + aoShopProducts[p].m_strName + '</td>');

			if (bAllowChanging)
			{
				doc.write('<input type="hidden" name="ID' + (nPosition - 1).toString() + '" value="' + aoShopProducts[p].m_strID + '">' + '</td>');
				doc.write('<td align="center">' + '<input type="text" size="2" maxlength="2" name="COUNT' + (nPosition - 1).toString() + '" value="' + nCount.toString() + '">' + '</td>');

				doc.write('<td align="right" nowrap>' + '* ' + ShopFormatAmount(nItemPrice) + ' ' + strCurrency + '</td>');
				doc.write('<td align="right" nowrap>' + ShopFormatAmount(nSubTotal) + ' ' + strCurrency + '</td>');
				doc.write('<td align="center">' + '<input type="checkbox" name="DELETE' + (nPosition - 1).toString() + '" value="">' + '</td>');
			}
			else
			{
				nTotalShippingCosts += ShopCalcShipping(p, nCount, strCountry); 	

				doc.write('<td align="center">' + nCount.toString() + '</td>');
				doc.write('<td align="right" nowrap>' + ShopFormatAmount(ShopCalcNet(nSubTotal, strCountry)) + ' ' + strCurrency + '</td>');
				doc.write('<td align="right" nowrap>' + ShopFormatAmount(ShopCalcVat(nSubTotal, strCountry)) + ' ' + strCurrency + '</td>');
				doc.write('<td align="right" nowrap>' + ShopFormatAmount(nSubTotal) + ' ' + strCurrency + '</td>');
			}

			doc.write('</tr>');
		}	
	}

	if (nTotalShippingCosts > 0)
	{	
		nPosition++;
		nTotalPrice += nTotalShippingCosts;

		doc.write('<tr>');

		doc.write('<td align="center">' + nPosition.toString() + '</td>');
		doc.write('<td>' + astrDict[nLan]['SHIPPING'] + '</td>');

		if (bAllowChanging)
		{
//			doc.write('<input type="hidden" name="ID' + (nPosition - 1).toString() + '" value="' + aoShopProducts[p].m_strID + '">' + '</td>');
			doc.write('<td align="center">' + '</td>');

			doc.write('<td align="right" nowrap>' + '</td>');
			doc.write('<td align="right" nowrap>' + ShopFormatAmount(nTotalShippingCosts) + ' ' + strCurrency + '</td>');
			doc.write('<td align="center">' + '</td>');
		}
		else
		{
			doc.write('<td align="center">' + '</td>');
			doc.write('<td align="right" nowrap>' + ShopFormatAmount(ShopCalcNet(nTotalShippingCosts, strCountry)) + ' ' + strCurrency + '</td>');
			doc.write('<td align="right" nowrap>' + ShopFormatAmount(ShopCalcVat(nTotalShippingCosts, strCountry)) + ' ' + strCurrency + '</td>');
			doc.write('<td align="right" nowrap>' + ShopFormatAmount(nTotalShippingCosts) + ' ' + strCurrency + '</td>');
		}

		doc.write('</tr>');	
	}

	if (bAllowChanging)
	{
		doc.write('<tr>');
		doc.write('<td colspan="6" align="left" style="font-size:10px;">' + '* ' + astrDict[nLan]['MWST_TEXT'] + '</td>');
		doc.write('</tr>');

		doc.write('<tr>');
		doc.write('<td colspan="6" width="100%" align="right" valign="middle" style="border-right: 0;">' + '<img src="' + astrDict[nLan]["IMAGEDIR"] + '/b_update.gif" border="0" alt="' + astrDict[nLan]["UPDATE"] + '" title="' + astrDict[nLan]["UPDATE"] + '" style="cursor:pointer;cursor:hand;" onClick="ShopRefresh(true)">' + '</td>');
		doc.write('</tr>');
	}

	doc.write('<tr>');
	doc.write('<td colspan="5" width="100%" align="right" valign="middle" style="border-right: 0;">' + '<img src="../images/car_arrow.gif" border="0" alt="Gesamt" title="Gesamt">' + '</td>');
	doc.write('<td nowrap align="right" valign="middle" style="font-weight:bold; border-left: 0;">' + astrDict[nLan]["TOTAL"] + ': ' + ShopFormatAmount(nTotalPrice) + ' ' + strCurrency + '</td>');
	doc.write('</tr>');

	doc.write('<input type="hidden" name="ITEMCOUNT" value="' + nItemCount.toString() + '">' + '</td>');
}


function ShopShowCart(nLan, bAllowChanging, strCountry)
{
	if (navigator.cookieEnabled != true)
	{
		alert(astrDict[nLan]["MSG_NOCOOKIEBASKET"]);

		if (ParameterRead('mode') == "addproduct")
		{
			var strRef = 'https://secure.shareit.com/shareit/cart.html';
			strRef += '?PRODUCT[' + ParameterRead('product') + ']=1';
			strRef += '&languageid=' + nLan;
			strRef += '&backlink=http://www.freiwald.com/' + ((nLan==2) ? 'seiten' : 'pages') + '/register.htm';
	//		strRef += '&cookies=1';
			strRef += '&currencies=' + ((nLan==2) ? 'EUR' : 'USD');
			location.href = strRef;
			return;
		}
	}

	if (ParameterRead('mode') == "addproduct")
	{
		ShopDoAdd(nLan, ParameterRead('product'));
	}

	if ((typeof bAllowChanging) == 'undefined')
	{
		bAllowChanging = true;
	}

	var doc = document;
	var nItemCount = 0;

	var bShowPaymentBox = (ParameterRead('mode') == "checkpayment") ? true : false;

	if (!bAllowChanging)
	{
		bShowPaymentBox = false;
	}

	for (var p = 0; p < aoShopProducts.length; p++)
	{
		var nCount = ShopGetProdCount(aoShopProducts[p].m_strID);
		if (nCount != 0)
		{
			nItemCount++;
		}

		if (nItemCount > 0)
		{
			break;
		}
	}
	if (nItemCount == 0)
	{
		doc.write('<br><span style="color:red;">' + astrDict[nLan]["CARTEMPTY"] + '<br><br></span>');
	}
	else
	{
		if (bAllowChanging)
		{
			doc.write('<form name="CART">');
		}

		doc.write('<table border="1" cellspacing="0" class="texttable">');
			doc.write('<tbody>');
				doc.write('<tr>');
					doc.write('<td nowrap="nowrap">');
					doc.write('<center><b>' + astrDict[nLan]["POS"] + '</b></center>');
					doc.write('</td>');

					doc.write('<td nowrap="nowrap">');
					doc.write('<b>' + astrDict[nLan]["PRODUCT"] + '</b>');
					doc.write('</td>');

					doc.write('<td nowrap="nowrap">');
					doc.write('<center><b>' + astrDict[nLan]["QUANTITY"] + '</b></center>');
					doc.write('</td>');

					doc.write('<td align="right" nowrap="nowrap">');
					doc.write('<b>' + astrDict[nLan][bAllowChanging ? "PRICE" : "NETPRICE"] + '</b>');
					doc.write('</td>');

					doc.write('<td align="right" nowrap="nowrap">');
					doc.write('<b>' + astrDict[nLan][bAllowChanging ? "SUBTOTAL" : "VAT"] + '</b>');
					doc.write('</td>');

					
					if (bAllowChanging)
					{				
						doc.write('<td nowrap="nowrap"  width="10%">');
						doc.write('<center><b>' + astrDict[nLan]["REMOVE"] + '</b></center>');
					}
					else
					{				
						doc.write('<td align="right" nowrap="nowrap" width="10%">');
						doc.write('<b>' + astrDict[nLan]["FULLPRICE"] + '</b>');
					}
					
					doc.write('</td>');

				doc.write('</tr>');
		
			ShopShowCartTable(nLan, bAllowChanging, strCountry);

			doc.write('</tbody>');
		doc.write('</table>');

		if (bAllowChanging)
		{
			doc.write('</form>');
		}

		if (bAllowChanging)
		{
			doc.write('<table width="100%" cellspacing="10" border="0">');
				doc.write('<tbody>');
					doc.write('<tr>');

						doc.write('<td nowrap="nowrap" width="33%" align="left">');
						doc.write('<a href="' + astrDict[nLan]["PAGEDIRUNSECURE"] + '/register.htm">' + astrDict[nLan]["CONTINUESHOPPING"] + '</a>');
						doc.write('</td>');

						doc.write('<td nowrap="nowrap" width="34%" align="center">');
						doc.write('<img src="' + astrDict[nLan]["IMAGEDIR"] + '/b_checkout.gif" border="0" alt="' + astrDict[nLan]["CHECKOUT"] + '" title="' + astrDict[nLan]["CHECKOUT"] + '" ');
						if (!bShowPaymentBox)
						{
							doc.write('  style="cursor:pointer;cursor:hand;" onClick="ShopCheckout(' + nLan.toString() + ')">');	
						}
						doc.write('</td>');

						doc.write('<td nowrap="nowrap" width="34%" align="center">');
						doc.write('</td>');

					doc.write('</tr>');

				doc.write('</tbody>');
			doc.write('</table>');

			if (bShowPaymentBox)
			{
//				ShopShowPaymentBox(nLan);	// no longer available
			}
		}
	}
}



function ShopCheckRocomotionLicense(strCode)
{
	if (strCode.length != 4 + 1 + 4 + 1 + 4 + 1 + 4 + 1 + 4)
	{
		return false;
	}	

	var i;

	for (i = 0; i < 4; i++)
	{
		var c = i*5 + 4;

		if (strCode.substring(c, c+1) != '-')
		{
			return false;
		}
	}

	for (i = 0; i < 9; i++)
	{
		if (i == 4) i++;

		if (!isalpha(strCode.substring(i,i+1)))
		{
			return false;
		}
	}

	if ((strCode.substring(10,14) != "RM85") &&
		(strCode.substring(10,14) != "RM32"))
	{
		return false;
	}

	for (i = 15; i < 24; i++)
	{
		if (i == 19) i++;

		if (!isalnum(strCode.substring(i,i+1)))
		{
			return false;
		}
	}

	return true;
}