// Append thickbox querystring to end so it knows to use the thickbox template
// Only want this to happen for js enabled browsers
var link = $('.change-country a');
$('.change-country a').each(function(){
	var link = $(this);
	link.attr('href', link.attr('href') + '?thickbox=1');
});

// trigger the country selector if not done this before
var visited = readCookie('umg_ecommerce_country');
if (!visited) {
	$(document).ready(function(){
		$('#country-selector').trigger('click');
		//document.cookie = 'umg_ecommerce=1; path=/';
	});
}


// http://www.quirksmode.org/js/cookies.html
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
