
 function LoadCityList (CountryId)
  {
   CityList = document.getElementById("CityList");
   CityList.disabled = true;
   CityList.length   = 0;
   AddOption (CityList, 'загрузка...', '0');

   XHttp = new XmlHttpRequest("POST", "/partners/index.php?event=ajax_get_city_list");
   XHttp.SetRequestFunction(FillSityList);
   XHttp.Send("CountryId="+CountryId);
  }


 function FillSityList ()
  {
   /*
   Res = window.location.href.match(/search\/\d+-(\d+)-\d/);
   if (Res)
    {
     CityId = Res[1];
    } else { CityId = null; }
   */

   if (XHttp.State()=='completed')
    {
     CityList = document.getElementById("CityList");
     CityList.length = 0;
     OptionItems = XHttp.Response().split('\n');
     AddOption (CityList, "любой", 0);

     for (i=0; i<OptionItems.length; i++)
      {
       OptionArr = OptionItems[i].split(';');
       AddOption (CityList, OptionArr[1], OptionArr[0]);
       /*
       if (CityId!=null)
        {
         if (CityId==OptionArr[0])
          {
           CityList.options[CityList.length-1].selected = true;
          }
        }
       */
      }

     CityList.disabled = false;
    }
  }


 function AddOption (Element, Text, Value)
  {
   if (document.createElement)
    {
     var newOption   = document.createElement("OPTION");
     newOption.text  = Text;
     newOption.value = Value;
     (Element.options.add) ? Element.options.add(newOption) : Element.add(newOption, null);
    }
   else
    {
     Element.options[Element.length+1] = new Option(Value, Text, false, false);
    }
  }

