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", 24624422, 1.0000000000], ["CAD", 24624386, 1.0460200000], ["EUR", 24624393, 0.8017490000], ["GBP", 24624394, 0.6750230000], ["AUD", 24624384, 0.9969860000], ["HKD", 24624395, 8.3415200000], ["SGD", 24624417, 1.3539600000], ["PHP", 24624411, 45.8542000000], ["THB", 24624418, 32.8997000000], ["PLN", 24624412, 3.4095700000], ["DKK", 24624391, 6.0469300000], ["LTL", 24624403, 2.8081500000], ["SEK", 24624416, 7.1639500000], ["CZK", 24624390, 20.4034000000], ["CLP", 24624388, 519.1470000000], ["HUF", 24624396, 234.6970000000], ["LVL", 24624404, 0.5675450000], ["TWD", 24624420, 31.8156000000], ["OMR", 24624409, 0.4141020000], ["PEN", 24624410, 2.8834300000], ["BRL", 24624385, 1.8477200000], ["JPY", 24624400, 85.1497000000], ["COP", 24624389, 1912.2800000000], ["EGP", 24624392, 6.4960600000], ["INR", 24624399, 52.9471000000], ["ILS", 24624398, 4.0314200000], ["ARS", 24624383, 4.6849100000], ["QAR", 24624413, 3.9165600000], ["SAR", 24624415, 4.0335800000], ["KRW", 24624401, 1214.0800000000], ["NOK", 24624407, 6.1065100000], ["MXN", 24624406, 13.7986000000], ["TRY", 24624419, 1.8842900000], ["CHF", 24624387, 0.9817220000], ["IDR", 24624397, 9738.7100000000], ["KWD", 24624402, 0.2992060000], ["AED", 24624382, 3.9504400000], ["UAH", 24624421, 8.6158800000], ["NZD", 24624408, 1.2942300000], ["RUB", 24624414, 32.0319000000], ["ZAR", 24624423, 8.3394800000]);
var intlLCP = new Array(["SK", 1.2500000000, 4788], ["GR", 1.2500000000, 4788], ["HU", 1.2500000000, 4788], ["IE", 1.2500000000, 4788], ["IT", 1.2500000000, 4788], ["LT", 1.2500000000, 4788], ["LU", 1.2500000000, 4788], ["LV", 1.2500000000, 4788], ["MC", 1.2500000000, 4788], ["MT", 1.2500000000, 4788], ["NL", 1.2500000000, 4788], ["PL", 1.2500000000, 4788], ["PT", 1.2500000000, 4788], ["RO", 1.2500000000, 4788], ["SE", 1.2500000000, 4788], ["SI", 1.2500000000, 4788], ["CY", 1.2500000000, 4788], ["BG", 1.2500000000, 4788], ["BE", 1.2500000000, 4788], ["AT", 1.2500000000, 4788], ["GB", 1.2500000000, 4788], ["CA", 1.1000000000, 511], ["SG", 1.2000000000, 527], ["AU", 1.2000000000, 527], ["HK", 1.1500000000, 528], ["CZ", 1.2500000000, 4788], ["DE", 1.2500000000, 4788], ["DK", 1.2500000000, 4788], ["EE", 1.2500000000, 4788], ["ES", 1.2500000000, 4788], ["FI", 1.2500000000, 4788], ["FR", 1.2500000000, 4788]);

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++;
		}
	}
}


