$(document).ready( function() {
	var region = $("input[name = 'region']").val();
	set_active_currency_link(region);
});

function update_prices_redirects(region) {
	var to_go = window.location.href.replace(/region=(eur|us|uk)/, "region=" + region);
	if (!to_go.match(/region=(eur|us|uk)/)) {
		to_go = to_go + "&region=" + region;
	}

	//Store the selected region in a cookie for future visits
	document.cookie = "selected_currency_region=" + region;
	window.location.replace(to_go);
}

function set_active_currency_link(region) {
	var links = $("table[id = 'currency-select'] td");
	links.each( function() {
		if ($(this).attr("id") == region) {
			$(this).attr("class", "active-currency");		
		} else {
			$(this).attr("class", "");
		}
	});
}

function get_currency_symbol(region) {
	if (region == "eur") {
		return "&euro;";
	} else if(region == "us") {
		return "$";
	} else if(region == "uk") {
		return "&pound;";
	}
}

