function locationSelected(oList){
	switch(oList.id){
		case "mnuRegions":
			var curform = oList.form; // get the containing form
			var newvalue = oList.name + "=" + oList.options[oList.selectedIndex].value;
			clearCombo(curform.mnuCountries); // clear the downstream list
			clearCombo(curform.mnuStates); // clear the downstream list
			clearCombo(curform.mnuCities); // clear the downstream list
			fillCombo(curform.mnuCountries, newvalue); // fill the downstream list
  			break
		case "mnuRegionsSearch": // from search.php page.  When mnuRegions is empty, fill mnuCoutries with all Countries.
			var curform = oList.form; // get the containing form
			var newvalue = "mnuRegions=" + oList.options[oList.selectedIndex].value;
			clearCombo(curform.mnuCountries); // clear the downstream list
			clearCombo(curform.mnuStates); // clear the downstream list
			clearCombo(curform.mnuCities); // clear the downstream list
			fillComboArray(curform.mnuCountries, newvalue); // fill the downstream list
  			break
		case "mnuCountries":
			var curform = oList.form; // get the containing form
			var newvalue = oList.name + "=" + oList.options[oList.selectedIndex].value;
			clearCombo(curform.mnuStates); // clear the downstream list
			fillCombo(curform.mnuStates, newvalue); // fill the downstream list
			clearCombo(curform.mnuCities); // clear the downstream list
			fillCombo(curform.mnuCities, newvalue); // fill the downstream list
			break
		case "mnuStates":
			var curform = oList.form; // get the containing form
			var newvalue = oList.name + "=" + oList.options[oList.selectedIndex].value;
			clearCombo(curform.mnuCities); // clear the downstream list
			fillCombo(curform.mnuCities, newvalue); // fill the downstream list
			addCountryCities(curform);
			break
	}
}
function clearCombo(oList){
  for (var i = oList.options.length - 1; i > 0; i--){
    oList.options[i] = null;
  }
  oList.selectedIndex = 0;
}
function fillCombo(oList, vValue){
  if (vValue != "" && assocArray[vValue] && assocArray[vValue][oList.id]){
    var arrX = assocArray[vValue][oList.id];
    for (var i = 0; i < arrX.length; i = i + 2){
      oList.options[oList.options.length] = new Option(arrX[i + 1], arrX[i]);
    }
  } else oList.options[oList.options.length] = new Option("None found", "");
}
function fillComboArray(oList, vValue){
  if (vValue != "" && assocArray[vValue] && assocArray[vValue][oList.id]){
    var arrX = assocArray[vValue][oList.id];
    for (var i = 0; i < arrX.length; i = i + 2){
      oList.options[oList.options.length] = new Option(arrX[i + 1], arrX[i]);
    }
  } else {
		arrX = countriesArray;
		for (var i = 0; i < arrX.length; i = i + 2) {
	    	oList.options[oList.options.length] = new Option(arrX[i + 1], arrX[i]);
    	}
  }
}
function addCountryCities(curform){
	var oList = curform.mnuCountries;
	var newvalue = oList.name + "=" + oList.options[oList.selectedIndex].value;
	if (newvalue != "" && assocArray[newvalue][curform.mnuCities.id]){ // Only do this if Country has Cities
		curform.mnuCities.options[curform.mnuCities.length] = new Option("--------", "");
		fillCombo(curform.mnuCities, newvalue);
	}
}
function selectCombo(oList, vValue) {
	if(vValue > 0) {
		for (var i = 1; i < oList.options.length; i++) {
			if (oList.options[i].value == vValue) {
				oList.selectedIndex = i;
			}
		}
	}
}
