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", 24413418, 1.0000000000], ["CAD", 24413382, 1.0458100000], ["EUR", 24413389, 0.8083490000], ["GBP", 24413390, 0.6706690000], ["AUD", 24413380, 0.9841240000], ["HKD", 24413391, 8.3403300000], ["SGD", 24413413, 1.3426600000], ["PHP", 24413407, 45.6337000000], ["THB", 24413414, 33.3192000000], ["PLN", 24413408, 3.4266800000], ["DKK", 24413387, 6.0952100000], ["LTL", 24413399, 2.8309500000], ["SEK", 24413412, 7.2388000000], ["CZK", 24413386, 20.4787000000], ["CLP", 24413384, 518.2860000000], ["HUF", 24413392, 239.2890000000], ["LVL", 24413400, 0.5736760000], ["TWD", 24413416, 31.8027000000], ["OMR", 24413405, 0.4140810000], ["PEN", 24413406, 2.8920400000], ["BRL", 24413381, 1.8567500000], ["JPY", 24413396, 81.4276000000], ["COP", 24413385, 1922.9000000000], ["EGP", 24413388, 6.4944500000], ["INR", 24413395, 52.9257000000], ["ILS", 24413394, 4.0155100000], ["ARS", 24413379, 4.6635000000], ["QAR", 24413409, 3.9164500000], ["SAR", 24413411, 4.0335800000], ["KRW", 24413397, 1203.6000000000], ["NOK", 24413403, 6.2507400000], ["MXN", 24413402, 13.6579000000], ["TRY", 24413415, 1.8899900000], ["CHF", 24413383, 0.9900040000], ["IDR", 24413393, 9625.7900000000], ["KWD", 24413398, 0.2989800000], ["AED", 24413378, 3.9504400000], ["UAH", 24413417, 8.6384700000], ["NZD", 24413404, 1.2892600000], ["RUB", 24413410, 32.2378000000], ["ZAR", 24413419, 8.1534200000]);
var intlLCP = new Array(["CA", 1.1000000000, 519], ["HK", 1.1500000000, 521], ["AU", 1.2000000000, 522], ["SG", 1.2000000000, 522], ["CZ", 1.2500000000, 4785], ["DE", 1.2500000000, 4785], ["DK", 1.2500000000, 4785], ["EE", 1.2500000000, 4785], ["ES", 1.2500000000, 4785], ["FI", 1.2500000000, 4785], ["FR", 1.2500000000, 4785], ["SK", 1.2500000000, 4785], ["GR", 1.2500000000, 4785], ["HU", 1.2500000000, 4785], ["IE", 1.2500000000, 4785], ["IT", 1.2500000000, 4785], ["LT", 1.2500000000, 4785], ["LU", 1.2500000000, 4785], ["LV", 1.2500000000, 4785], ["MC", 1.2500000000, 4785], ["MT", 1.2500000000, 4785], ["NL", 1.2500000000, 4785], ["PL", 1.2500000000, 4785], ["PT", 1.2500000000, 4785], ["RO", 1.2500000000, 4785], ["SE", 1.2500000000, 4785], ["SI", 1.2500000000, 4785], ["CY", 1.2500000000, 4785], ["BG", 1.2500000000, 4785], ["BE", 1.2500000000, 4785], ["AT", 1.2500000000, 4785], ["GB", 1.2500000000, 4785]);

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


