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", 24433940, 1.0000000000], ["CAD", 24433904, 1.0428800000], ["EUR", 24433911, 0.7989110000], ["GBP", 24433912, 0.6672080000], ["AUD", 24433902, 0.9796690000], ["HKD", 24433913, 8.3399100000], ["SGD", 24433935, 1.3383600000], ["PHP", 24433929, 45.4294000000], ["THB", 24433936, 33.0503000000], ["PLN", 24433930, 3.3780600000], ["DKK", 24433909, 6.0232600000], ["LTL", 24433921, 2.7980400000], ["SEK", 24433934, 7.1594300000], ["CZK", 24433908, 20.1173000000], ["CLP", 24433906, 512.4790000000], ["HUF", 24433914, 234.3530000000], ["LVL", 24433922, 0.5672230000], ["TWD", 24433938, 31.7597000000], ["OMR", 24433927, 0.4141130000], ["PEN", 24433928, 2.8920400000], ["BRL", 24433903, 1.8522400000], ["JPY", 24433918, 81.6821000000], ["COP", 24433907, 1918.7000000000], ["EGP", 24433910, 6.4944500000], ["INR", 24433917, 52.8719000000], ["ILS", 24433916, 3.9761500000], ["ARS", 24433901, 4.6650100000], ["QAR", 24433931, 3.9162400000], ["SAR", 24433933, 4.0335800000], ["KRW", 24433919, 1200.0500000000], ["NOK", 24433925, 6.1851300000], ["MXN", 24433924, 13.5977000000], ["TRY", 24433937, 1.8799800000], ["CHF", 24433905, 0.9815080000], ["IDR", 24433915, 9561.2600000000], ["KWD", 24433920, 0.2983450000], ["AED", 24433900, 3.9503400000], ["UAH", 24433939, 8.6373900000], ["NZD", 24433926, 1.2829600000], ["RUB", 24433932, 32.0055000000], ["ZAR", 24433941, 8.1192100000]);
var intlLCP = new Array(["LV", 1.2500000000, 4784], ["MC", 1.2500000000, 4784], ["MT", 1.2500000000, 4784], ["NL", 1.2500000000, 4784], ["PL", 1.2500000000, 4784], ["PT", 1.2500000000, 4784], ["RO", 1.2500000000, 4784], ["SE", 1.2500000000, 4784], ["SI", 1.2500000000, 4784], ["CY", 1.2500000000, 4784], ["BG", 1.2500000000, 4784], ["BE", 1.2500000000, 4784], ["AT", 1.2500000000, 4784], ["GB", 1.2500000000, 4784], ["CA", 1.1000000000, 515], ["HK", 1.1500000000, 517], ["SG", 1.2000000000, 518], ["AU", 1.2000000000, 518], ["CZ", 1.2500000000, 4784], ["DE", 1.2500000000, 4784], ["DK", 1.2500000000, 4784], ["EE", 1.2500000000, 4784], ["ES", 1.2500000000, 4784], ["FI", 1.2500000000, 4784], ["FR", 1.2500000000, 4784], ["SK", 1.2500000000, 4784], ["GR", 1.2500000000, 4784], ["HU", 1.2500000000, 4784], ["IE", 1.2500000000, 4784], ["IT", 1.2500000000, 4784], ["LT", 1.2500000000, 4784], ["LU", 1.2500000000, 4784]);

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


