//##########################################################################################

//place our event hook
window.onload = function() {
	//find the new topic buttons
	var CountryDD = PageTemplate.GetNodesByAttribute("data-field","country").GetNode();
	if(CountryDD) {
		CountryDD.onchange = function(Event) {
			Event = BrowserWindow.GetEvent(Event);
			ShowHideRadiusSearch(CountryDD);
		};
	}
	
	//call on first load
	ShowHideRadiusSearch(CountryDD);
};

//##########################################################################################

function ShowHideRadiusSearch(CountryDD) {
	var RadiusSearch = PageTemplate.GetNodesByAttribute("data-label","radius_search").GetNode();
	if(CountryDD[CountryDD.selectedIndex].getAttribute("data-field") == "has_postal_codes") {
		RadiusSearch.className = "radius_search";
	}
	else {
		if(CountryDD[CountryDD.selectedIndex].getAttribute("data-field") == "divider") {
			for(var i = 0 ; i < CountryDD.options.length ; i++) {
				if(CountryDD.options[i].value == "us") {
					CountryDD.selectedIndex = i;
					RadiusSearch.className = "radius_search";
					break;
				}
			}
		}
		else {
			RadiusSearch.className = "radius_search_hidden";
		}
	}
}

//##########################################################################################