
/*
	These scripts power the active region selector. 
	Whether or not a given region is currently selected is stored in the associative
	"regions" array; so, if you want to know, for instance, if Central Asia is selected,
	you can check regions['Central Asia'] for the answer.
	
	Other than that, this should be fairly self-explanatory.  Keep in mind that these
	methods often change the style classes of items in the DOM; the style classes
	are references to styles found in the regionSelector.css file.
*/

var all = false;
var regions = {"NAm":false, "EU":false, "NWAs":false, "CAs":false, "NEAs":false, 
"CAm":false, "AF":false, "ME":false, "SEAs":false, "AU":false, "SAm":false, 
"AN":false, "OC":false, "WC":false, "All":false};


function click_all() {
	document.getElementById('ta').value = "";
	if (all) {
		for (i in regions) {
			document.getElementById("label_" + i).className="mouseoff";
			regions[i] = false;
			}
	}
	else {
		for (i in regions) {
			document.getElementById("label_" + i).className="selected";
			regions[i] = true;
			document.getElementById('ta').value ="All";
			}
	}
	all = !all;
}

function click(region) {
	if (!all) {	
		if (regions[region.id]) {
			document.getElementById("label_" + region.id).className="mouseover";		
		}
		else {
			document.getElementById("label_" + region.id).className="mouseover_selected";		
		}
		regions[region.id] = !regions[region.id];
		var ta = document.getElementById('ta');
		ta.value = "";
		for (i in regions) {
			if (regions[i]) {
				document.getElementById('ta').value += i;
				document.getElementById('ta').value += " ";
				}
			}
	} 
}

function regionToLabel(region) {
	return document.getElementById("label_" + region.id);
}

function mouseover(region) {
	if (regions[region.id]) {
		document.getElementById("label_" + region.id).className="mouseover_selected";	
		}
	else {
		document.getElementById("label_" + region.id).className="mouseover";
	}
}

function mouseoff(region) {
	if (regions[region.id]) {
		document.getElementById("label_" + region.id).className="selected";
		}
	else {
		document.getElementById("label_" + region.id).className="mouseoff";
	} 
}

