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", 24372358, 1.0000000000], ["CAD", 24372322, 1.0481100000], ["EUR", 24372329, 0.8052190000], ["GBP", 24372330, 0.6699060000], ["AUD", 24372320, 0.9917640000], ["HKD", 24372331, 8.3419500000], ["SGD", 24372353, 1.3408300000], ["PHP", 24372347, 45.8381000000], ["THB", 24372354, 33.1794000000], ["PLN", 24372348, 3.4247300000], ["DKK", 24372327, 6.0710200000], ["LTL", 24372339, 2.8205200000], ["SEK", 24372352, 7.2249300000], ["CZK", 24372326, 20.4905000000], ["CLP", 24372324, 515.9210000000], ["HUF", 24372332, 237.9990000000], ["LVL", 24372340, 0.5718470000], ["TWD", 24372356, 31.7575000000], ["OMR", 24372345, 0.4140810000], ["PEN", 24372346, 2.8931100000], ["BRL", 24372321, 1.8507300000], ["JPY", 24372336, 80.8975000000], ["COP", 24372325, 1929.7600000000], ["EGP", 24372328, 6.4933700000], ["INR", 24372335, 52.3718000000], ["ILS", 24372334, 3.9904500000], ["ARS", 24372319, 4.6590900000], ["QAR", 24372349, 3.9165600000], ["SAR", 24372351, 4.0334700000], ["KRW", 24372337, 1204.3500000000], ["NOK", 24372343, 6.2543900000], ["MXN", 24372342, 13.7777000000], ["TRY", 24372355, 1.8864400000], ["CHF", 24372323, 0.9845190000], ["IDR", 24372333, 9658.0500000000], ["KWD", 24372338, 0.2985710000], ["AED", 24372318, 3.9504400000], ["UAH", 24372357, 8.6454600000], ["NZD", 24372344, 1.2943800000], ["RUB", 24372350, 32.5130000000], ["ZAR", 24372359, 8.2167600000]);
var intlLCP = new Array(["CA", 1.1000000000, 513], ["AD", 1.2000000000, 514], ["SM", 1.2000000000, 514], ["SK", 1.2000000000, 514], ["AT", 1.2000000000, 514], ["BE", 1.2000000000, 514], ["BG", 1.2000000000, 514], ["CY", 1.2000000000, 514], ["CZ", 1.2000000000, 514], ["DE", 1.2000000000, 514], ["DK", 1.2000000000, 514], ["EE", 1.2000000000, 514], ["ES", 1.2000000000, 514], ["FI", 1.2000000000, 514], ["FR", 1.2000000000, 514], ["GB", 1.2000000000, 514], ["GI", 1.2000000000, 514], ["GR", 1.2000000000, 514], ["HU", 1.2000000000, 514], ["IE", 1.2000000000, 514], ["IS", 1.2000000000, 514], ["IT", 1.2000000000, 514], ["LI", 1.2000000000, 514], ["LT", 1.2000000000, 514], ["LU", 1.2000000000, 514], ["LV", 1.2000000000, 514], ["MC", 1.2000000000, 514], ["MT", 1.2000000000, 514], ["NL", 1.2000000000, 514], ["PL", 1.2000000000, 514], ["PT", 1.2000000000, 514], ["RO", 1.2000000000, 514], ["SE", 1.2000000000, 514], ["SI", 1.2000000000, 514], ["SG", 1.2000000000, 531], ["AU", 1.2000000000, 531], ["HK", 1.1500000000, 532]);

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


