

function addOption (oListbox, text, value, isDefaultSelected, isSelected)
{
  var oOption = document.createElement("option");
  oOption.appendChild(document.createTextNode(text));
  oOption.setAttribute("value", value);

  if (isDefaultSelected) oOption.defaultSelected = true;
  else if (isSelected) oOption.selected = true;

  oListbox.appendChild(oOption);
}

function clearSelect(oListbox)
{
  for (var i=oListbox.options.length-1; i >= 0; i--)
  {
      oListbox.remove(i);
  }
};

function onShowCityList( selected_city_id ) {
	var objSelectCountry = document.getElementById("Pr_Country");
	var objSelectCity = document.getElementById("city_id");
	var i = 0;
	var selected_country = 0;
	var count_items = 0;
	var tmp_selected_city = false;

	if ( objSelectCountry.selectedIndex != -1)
	{
		selected_country = objSelectCountry.options[objSelectCountry.selectedIndex].value;

		if ( selected_country != 0 )
		{
			if (self.document.getElementById('city_block').style.display == "none"){
				self.document.getElementById('city_block').style.display = "inline";
			}

			clearSelect(objSelectCity);

			count_items = country_cities[selected_country].length;

			for (var i=0; i <= count_items - 1; i++)
			{
				if (country_cities[selected_country][i] == selected_city_id) tmp_selected_city = true;
				else tmp_selected_city = false;
				addOption(objSelectCity, country_cities[selected_country][i], country_cities[selected_country][i], tmp_selected_city);
			}
		}
		else {
			if (self.document.getElementById('city_block').style.display == "inline"){
				self.document.getElementById('city_block').style.display = "none";
			}
		}
	}
}

