function getBgColors() {
		allColors = new Array();
		for (i=0; i<199; i++) {
			mydiv = document.getElementById("country"+i);
			divcolor = mydiv.style.backgroundColor;
			allColors.push(divcolor);
		}
	}
	
	function clearCountries(checkColor) {
		colorCodes = new Array();
		for (i=0; i<5; i++) {
			codeColorsDiv = document.getElementById("legendColors"+i);
			codeColors = codeColorsDiv.style.backgroundColor;
			colorCodes.push(codeColors);
		}

		for (i=0; i<199; i++) {
			mydiv = document.getElementById("country"+i);
			divcolor = mydiv.style.backgroundColor;
			if (checkColor != 5) {
				if (allColors[i] != colorCodes[checkColor]) {
					mydiv.style.background = "#333333";
				} else {
					mydiv.style.background = allColors[i];
				}
			} else {
				mydiv.style.background = allColors[i];
			}
		}	
	}
	
	function randOrd()	{
		return (Math.round(Math.random())-0.5); 
	}
	
	function reOrderSpectrum(order, index) {		
		allCountries = new Array("palestine", "mongolia", "korea-south", "korea-north", "japan", "taiwan", "hong-kong", "philippines", "palau", "micronesia", "marshall-islands", "nauru", "tuvalu", "kiribati", "samoa", "tonga", "fiji", "vanuatu", "new-zealand", "australia", "solomon-islands", "papau-new-guinea", "east-timor", "brunei", "malaysia", "bangladesh", "indonesia", "sri-lanka", "india", "singapore", "cambodia", "vietnam", "laos", "thailand", "burma-myanmar", "bhutan", "maldives", "nepal", "china", "kyrgyzstan", "tajikistan", "pakistan", "afghanistan", "uzbekistan", "turkmenistan", "cape-verde", "ireland", "united-kingdom", "mauritius", "seychelles", "comoros", "madagascar", "lesotho", "swaziland", "south-africa", "namibia", "botswana", "zimbabwe", "mozambique", "tanzania", "malawi", "zambia", "angola", "sao-tome-principe", "congo", "democratic-republic-of-congo", "gabon", "zaire", "burundi", "rwanda", "uganda", "kenya", "somalia", "djibouti", "ethiopia", "eritrea", "sudan", "central-african-republic", "cameroon", "equatorial-guinea", "nigeria", "chad", "libya", "niger", "benin", "togo", "ghana", "burkina-faso", "mali", "cote-d-lvoire", "liberia", "guinea", "sierra-leone", "guinea-bassau", "gambia", "senegal", "mauritania", "western-sahara", "morocco", "algeria", "malta", "tunisia", "egypt", "oman", "united-arab-emirates", "qatar", "bahrain", "kuwait", "yemen", "saudi-arabia", "iran", "iraq", "jordan", "israel", "lebanon", "syria", "cyprus", "turkey", "azerbaijan", "armenia", "georgia", "kazakhstan", "russia", "ukraine", "moldova", "romania", "greece", "macedonia", "albania", "montenegro", "serbia", "bosnia-herzegovina", "croatia", "san-marino", "slovenia", "slovakia", "czech-republic", "hungary", "austria", "liechtenstein", "italy", "switzerland", "andora", "monaco", "portugal", "spain", "france", "belgium", "luxembourg", "netherlands", "denmark", "germany", "poland", "belarus", "lithuania", "latvia", "estonia", "finland", "sweden", "norway", "iceland", "greenland", "st-vincent-grenadines", "trinidad-tobago", "barbados", "grenada", "st-lucia", "dominica", "antigua-barbuda", "st-kitts-nevis", "dominican-republic", "haiti", "jamaica", "bahamas", "cuba", "uraguay", "paraguay", "argentina", "bolivia", "chile", "brazil", "french-guiana", "suriname", "guyana", "venezuela", "peru", "ecuador", "columbia", "panama", "costa-rica", "el-salvador", "nicaragua", "honduras", "guatemala", "belize", "mexico", "united-states", "canada", "usa");
		allCountries = allCountries.sort(randOrd);
		mydiv = document.getElementById(allCountries[0] + index);
		if (mydiv) {
		if (order == "byColor") {
			colorCodes = new Array();
			for (i=0; i<5; i++) {
				codeColorsDiv = document.getElementById("legendColors"+i);
				codeColors = codeColorsDiv.style.backgroundColor;
				colorCodes.push(codeColors);
			}
			divCounter = 0;
			for (j=0; j<5; j++) {
				for (i=0; i<199; i++) {
					mydiv = document.getElementById(allCountries[i] + index);
					divcolor = mydiv.style.backgroundColor;
					if (divcolor == colorCodes[j]) {
						document.getElementById(allCountries[i] + index).style["left"] = ((divCounter * 4) + divCounter) + "px";
						divCounter++;
					}
				}
			}
		}
		if (order == "byCountry") {
			
			idNames = new Array();
			idNames = allCountries;
			idNames.sort();
			divCounter = 0;
			for (i=0; i<199; i++) {
				document.getElementById(idNames[i] + index).style["left"] = ((divCounter * 4) + divCounter) + "px";
				divCounter++;
			}
		}
		}
	}
	
	function orderAll() {
		for (c=0; c<9; c++) {
			reOrderSpectrum('byColor', c);
		}
	}
