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", 24474989, 1.0000000000], ["CAD", 24474953, 1.0481100000], ["EUR", 24474960, 0.8004180000], ["GBP", 24474961, 0.6702450000], ["AUD", 24474951, 0.9929710000], ["HKD", 24474962, 8.3430200000], ["SGD", 24474984, 1.3526600000], ["PHP", 24474978, 45.7197000000], ["THB", 24474985, 33.1901000000], ["PLN", 24474979, 3.4202200000], ["DKK", 24474958, 6.0351000000], ["LTL", 24474970, 2.8029800000], ["SEK", 24474983, 7.1553500000], ["CZK", 24474957, 20.5605000000], ["CLP", 24474955, 512.6940000000], ["HUF", 24474963, 238.2250000000], ["LVL", 24474971, 0.5678670000], ["TWD", 24474987, 31.7705000000], ["OMR", 24474976, 0.4141240000], ["PEN", 24474977, 2.8909600000], ["BRL", 24474952, 1.8553600000], ["JPY", 24474967, 82.4562000000], ["COP", 24474956, 1908.0300000000], ["EGP", 24474959, 6.4928300000], ["INR", 24474966, 53.1408000000], ["ILS", 24474965, 4.0093800000], ["ARS", 24474950, 4.6723200000], ["QAR", 24474980, 3.9164500000], ["SAR", 24474982, 4.0336900000], ["KRW", 24474968, 1208.8700000000], ["NOK", 24474974, 6.1923300000], ["MXN", 24474973, 13.7267000000], ["TRY", 24474986, 1.8960100000], ["CHF", 24474954, 0.9823680000], ["IDR", 24474964, 9668.8100000000], ["KWD", 24474969, 0.2983670000], ["AED", 24474949, 3.9504400000], ["UAH", 24474988, 8.6341600000], ["NZD", 24474975, 1.2989200000], ["RUB", 24474981, 32.2156000000], ["ZAR", 24474990, 8.2717200000]);
var intlLCP = new Array(["CA", 1.1000000000, 507], ["HK", 1.1500000000, 509], ["AU", 1.2000000000, 510], ["SG", 1.2000000000, 510], ["CZ", 1.2500000000, 4786], ["DE", 1.2500000000, 4786], ["DK", 1.2500000000, 4786], ["EE", 1.2500000000, 4786], ["ES", 1.2500000000, 4786], ["FI", 1.2500000000, 4786], ["FR", 1.2500000000, 4786], ["SK", 1.2500000000, 4786], ["GR", 1.2500000000, 4786], ["HU", 1.2500000000, 4786], ["IE", 1.2500000000, 4786], ["IT", 1.2500000000, 4786], ["LT", 1.2500000000, 4786], ["LU", 1.2500000000, 4786], ["LV", 1.2500000000, 4786], ["MC", 1.2500000000, 4786], ["MT", 1.2500000000, 4786], ["NL", 1.2500000000, 4786], ["PL", 1.2500000000, 4786], ["PT", 1.2500000000, 4786], ["RO", 1.2500000000, 4786], ["SE", 1.2500000000, 4786], ["SI", 1.2500000000, 4786], ["CY", 1.2500000000, 4786], ["BG", 1.2500000000, 4786], ["BE", 1.2500000000, 4786], ["AT", 1.2500000000, 4786], ["GB", 1.2500000000, 4786]);

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


