$.get("https://ipinfo.io", function(response) {
	const countryLoc = response.country;
	const cityLoc = response.city;
	document.getElementById('countryLoc').innerHTML = countryLoc;
	document.getElementById('cityLoc').innerHTML = cityLoc;

	const currentUrl = window.location.href;
	let targetUrl = "https://shop.trendmicro-apac.com/";
	let locationName = "APAC";

	if (countryLoc == "AU") {
		targetUrl = "https://shop.trendmicro.com.au/";
		locationName = "Australia";
	} else if (countryLoc == "NZ") {
		targetUrl = "https://shop.trendmicro.co.nz/";
		locationName = "New Zealand";
	} else if (countryLoc == "SG") {
		targetUrl = "https://shop.sg.trendmicro-apac.com/";
		locationName = "Singapore";
	} else if (countryLoc == "MY") {
		targetUrl = "https://shop.my.trendmicro-apac.com/";
		locationName = "Malaysia";
	} else if (countryLoc == "PH") {
		targetUrl = "https://shop.ph.trendmicro-apac.com/";
		locationName = "Philippines";
	} else if (countryLoc == "IN") {
		targetUrl = "https://shop.in.trendmicro-apac.com/";
		locationName = "India";
	} else if (countryLoc == "ID") {
		targetUrl = "https://shop.id.trendmicro-apac.com/";
		locationName = "Indonesia";
	} else if (countryLoc == "TH") {
		targetUrl = "https://shop.th.trendmicro-apac.com/";
		locationName = "Thailand";
	} else if (countryLoc == "VN") {
		targetUrl = "https://shop.vn.trendmicro-apac.com/";
		locationName = "Vietnam";
	} else if (countryLoc == "AE") {
		targetUrl = "https://shop.mmea.trendmicro.com/en_ae/";
		locationName = "United Arab Emirates";
	} else if (countryLoc == "EG") {
		targetUrl = "https://shop.mmea.trendmicro.com/en_eg/";
		locationName = "Egypt";
	} else if (countryLoc == "IL") {
		targetUrl = "https://shop.mmea.trendmicro.com/en_il/";
		locationName = "Israel";
	} else if (countryLoc == "KW") {
		targetUrl = "https://shop.mmea.trendmicro.com/en_kw/";
		locationName = "Kuwait";
	} else if (countryLoc == "OM") {
		targetUrl = "https://shop.mmea.trendmicro.com/en_om/";
		locationName = "Oman";
	} else if (countryLoc == "SA") {
		targetUrl = "https://shop.mmea.trendmicro.com/en_sa/";
		locationName = "Saudi Arabia";
	} else if (countryLoc == "ZA") {
		targetUrl = "https://shop.mmea.trendmicro.com/en_za/";
		locationName = "South Africa";
	} else if (countryLoc == "TR") {
		targetUrl = "https://shop.mmea.trendmicro.com/tr_tr/";
		locationName = "Turkiye";
	} else if (countryLoc == "RU") {
		targetUrl = "https://shop.mmea.trendmicro.com/ru_ru/";
		locationName = "Russia";
	} else if (countryLoc == "US") {
		targetUrl = "https://shop.trendmicro.com/en_us/";
		locationName = "United States";
	} else if (countryLoc == "CA") {
		targetUrl = "https://shop.trendmicro.com/en_ca/";
		locationName = "Canada";
	} else if (countryLoc == "BR") {
		targetUrl = "https://shop.trendmicro.com/en_us/";
		locationName = "Brazil";
	} else if (countryLoc == "MX") {
		targetUrl = "https://shop.trendmicro.com/en_us/";
		locationName = "Mexico";
	} else if (countryLoc == "BE") {
		targetUrl = "https://shop.trendmicro.com/en_gb/";
		locationName = "Belgium";
	} else if (countryLoc == "CZ") {
		targetUrl = "https://shop.trendmicro.com/en_gb/";
		locationName = "Czech Republic";
	} else if (countryLoc == "DK") {
		targetUrl = "https://shop.trendmicro.com/en_gb/";
		locationName = "Denmark";
	} else if (countryLoc == "FI") {
		targetUrl = "https://shop.trendmicro.com/en_gb/";
		locationName = "Finland";
	} else if (countryLoc == "FR") {
		targetUrl = "https://shop.trendmicro.com/en_gb/";
		locationName = "France";
	} else if (countryLoc == "DE") {
		targetUrl = "https://shop.trendmicro.com/en_gb/";
		locationName = "Germany";
	} else if (countryLoc == "IE") {
		targetUrl = "https://shop.trendmicro.com/en_gb/";
		locationName = "Ireland";
	} else if (countryLoc == "IT") {
		targetUrl = "https://shop.trendmicro.com/en_gb/";
		locationName = "Italy";
	} else if (countryLoc == "NL") {
		targetUrl = "https://shop.trendmicro.com/en_gb/";
		locationName = "Netherlands";
	} else if (countryLoc == "NO") {
		targetUrl = "https://shop.trendmicro.com/en_gb/";
		locationName = "Norway";
	} else if (countryLoc == "PL") {
		targetUrl = "https://shop.trendmicro.com/en_gb/";
		locationName = "Poland";
	} else if (countryLoc == "ES") {
		targetUrl = "https://shop.trendmicro.com/en_gb/";
		locationName = "Spain";
	} else if (countryLoc == "SE") {
		targetUrl = "https://shop.trendmicro.com/en_gb/";
		locationName = "Sweden";
	} else if (countryLoc == "GB") {
		targetUrl = "https://shop.trendmicro.com/en_gb/";
		locationName = "United Kingdom";
	} else if (countryLoc == "UK") {
		targetUrl = "https://shop.trendmicro.com/en_gb/";
		locationName = "United Kingdom";
	}

	document.getElementById('locLink').href = targetUrl;
	document.getElementById('loc').innerHTML = locationName;

	if (currentUrl !== targetUrl) {
		document.getElementById('regionbar').style.display = 'block';
	}
}, "jsonp");