function getIntlElement(id) {
	return (document.getElementById ? document.getElementById(id) : (document.all ? document.all[id] : (document.layers ? document.layers[id] : null)));
}

function getIntlCookie(c) {
	if (document.cookie.length > 0) {
		var s = document.cookie.indexOf(c + "=");

		if (s > -1) {
			s = s + c.length + 1;

			var e = document.cookie.indexOf(";", s);

			return unescape(document.cookie.substring(s, (e != -1 ? e : document.cookie.length)));
		}
	}

	return null;
}

var sIntlCookie = getIntlCookie("intl_s");
var pIntlCookie = getIntlCookie("intl_p");
var fxRate;
var lcp;
var intlCountry;
var intlCurrency;
var intlExchangeRates = new Array(["USD", 24516059, 1.0000000000], ["CAD", 24516023, 1.0469600000], ["EUR", 24516030, 0.8035110000], ["GBP", 24516031, 0.6733520000], ["AUD", 24516021, 0.9899110000], ["HKD", 24516032, 8.3391500000], ["SGD", 24516054, 1.3579300000], ["PHP", 24516048, 45.9994000000], ["THB", 24516055, 33.1686000000], ["PLN", 24516049, 3.4153800000], ["DKK", 24516028, 6.0576800000], ["LTL", 24516040, 2.8143800000], ["SEK", 24516053, 7.1608300000], ["CZK", 24516027, 20.4518000000], ["CLP", 24516025, 516.7810000000], ["HUF", 24516033, 237.3100000000], ["LVL", 24516041, 0.5701260000], ["TWD", 24516057, 31.8296000000], ["OMR", 24516046, 0.4140920000], ["PEN", 24516047, 2.8877300000], ["BRL", 24516022, 1.8446000000], ["JPY", 24516037, 82.7744000000], ["COP", 24516026, 1912.5500000000], ["EGP", 24516029, 6.4910000000], ["INR", 24516036, 53.0978000000], ["ILS", 24516035, 4.0192800000], ["ARS", 24516020, 4.6753300000], ["QAR", 24516050, 3.9164500000], ["SAR", 24516052, 4.0334700000], ["KRW", 24516038, 1211.1300000000], ["NOK", 24516044, 6.1421100000], ["MXN", 24516043, 13.6880000000], ["TRY", 24516056, 1.9020300000], ["CHF", 24516024, 0.9849490000], ["IDR", 24516034, 9695.6900000000], ["KWD", 24516039, 0.2988190000], ["AED", 24516019, 3.9504400000], ["UAH", 24516058, 8.6395400000], ["NZD", 24516045, 1.2906600000], ["RUB", 24516051, 32.2245000000], ["ZAR", 24516060, 8.3015100000]);
var intlLCP = new Array(["CA", 1.1000000000, 505], ["AU", 1.2000000000, 529], ["SG", 1.2000000000, 529], ["HK", 1.1500000000, 530], ["CZ", 1.2500000000, 4787], ["DE", 1.2500000000, 4787], ["DK", 1.2500000000, 4787], ["EE", 1.2500000000, 4787], ["ES", 1.2500000000, 4787], ["FI", 1.2500000000, 4787], ["FR", 1.2500000000, 4787], ["SK", 1.2500000000, 4787], ["GR", 1.2500000000, 4787], ["HU", 1.2500000000, 4787], ["IE", 1.2500000000, 4787], ["IT", 1.2500000000, 4787], ["LT", 1.2500000000, 4787], ["LU", 1.2500000000, 4787], ["LV", 1.2500000000, 4787], ["MC", 1.2500000000, 4787], ["MT", 1.2500000000, 4787], ["NL", 1.2500000000, 4787], ["PL", 1.2500000000, 4787], ["PT", 1.2500000000, 4787], ["RO", 1.2500000000, 4787], ["SE", 1.2500000000, 4787], ["SI", 1.2500000000, 4787], ["CY", 1.2500000000, 4787], ["BG", 1.2500000000, 4787], ["BE", 1.2500000000, 4787], ["AT", 1.2500000000, 4787], ["GB", 1.2500000000, 4787]);

function getIntlValue(n, c) {
	n += "=";

	var iN = c.indexOf(n);

	if (iN > -1) {
		var iV = c.indexOf(";", iN);

		if (iV == -1)
			iV = c.length;

		return c.substring(iN + n.length, iV);
	}

	return null;
}

if ((sIntlCookie && sIntlCookie.length > 0) || (pIntlCookie && pIntlCookie.length > 0)) {
	var intlCookie = (sIntlCookie && sIntlCookie.length > 0 ? sIntlCookie : pIntlCookie);

	intlCountry = getIntlValue("country", intlCookie);
	intlCurrency = getIntlValue("currency", intlCookie);
	fxRate = getIntlValue("exchangeRate", intlCookie);
	lcp = getIntlValue("lcp", intlCookie);
}

if (intlCountry && intlCurrency && !fxRate) {
	var pCookieValue;

	for (var i = 0; i < intlExchangeRates.length; i++)
		if (intlExchangeRates[i][0] == intlCurrency) {
			pCookieValue = ";quoteId=" + intlExchangeRates[i][1] + ";exchangeRate=" + intlExchangeRates[i][2];
			fxRate = intlExchangeRates[i][2];

			for (var j = 0; j < intlLCP.length; j++)
				if (intlLCP[j][0] == intlCountry) {
					pCookieValue += ";lcp=" + intlLCP[j][1] + ";lcpRuleId=" + intlLCP[j][2];
					lcp = intlLCP[j][1];
					break;
				}

			break;
		}

	if (pCookieValue)
		document.cookie = "intl_s=" + escape("country=" + intlCountry + ";currency=" + intlCurrency + pCookieValue) + "; path=/";
}

if (fxRate && intlCurrency)
	document.write("<style type=\"text/css\">.hide4Intl {display: none;}</style>");

function getIntlPrice(p) {
	if (fxRate && intlCurrency) {
		var nP = "";

		for (var i = 0; i < p.length; i++)
			if (p.charAt(i) == '.' || isNaN(p.charAt(i)) == false)
				nP += p.charAt(i);

		if (nP != "" && isNaN(nP) == false)
			return intlCurrency + "&nbsp;" + ((new Number(nP) * new Number(fxRate)) * (lcp ? new Number(lcp) : 1)).toFixed(2);

		return null;
	} else
		return p;
}

function displayIntlPricing() {
	if (fxRate && intlCurrency) {
		var pI = 0;
		var pE;

		while ((pE = getIntlElement("price" + pI))) {
			var p = pE.innerHTML;
			var r = p.indexOf(" - ");
			var p1 = getIntlPrice((r == -1 ? p : p.substring(0, r)));
			var p2 = (r == -1 ? null : getIntlPrice(p.substring(r + 3, p.length)));

			if (p1 != null)
				pE.innerHTML = p1 + (p2 ? " - " + p2 : "");

			pI++;
		}
	}
}


