
function GetHotelList(){
  return document.getElementById('hotel_list');
}

function GetCityList(){
  return document.getElementById('city_list');
}

function GetTypesList(){
  return document.getElementById('hoteltype_list');
}


function FillHotels( resp ){
  var arr = eval( resp.responseText );
  GetHotelList().disabled = false;
  GetHotelList().options.length = 0;

  var option = document.createElement('OPTION');
      option.value = 0;
      option.innerHTML = 'Любой';
      GetHotelList().appendChild(option);

  for(var i=0;i<arr.length; i++ ){
  var option = document.createElement('OPTION');
      option.value = arr[i].id;
      option.innerHTML = arr[i].name;
      GetHotelList().appendChild(option);  	
  }
}

function srchHotel(){
	GetHotelList().options.length = 0;
	GetHotelList().disabled = true;
	var option = document.createElement('OPTION');
	option.value = 0;
	option.innerHTML = 'Поиск...';
	GetHotelList().appendChild(option);


	var city_id = GetCityList().value;
	var hoteltype_id = GetTypesList().value;

	var req = new Ajax.Request('/rpc/srchHotel.php',
			{
			method: 'get',
			parameters: 'city='+city_id+'&hoteltype='+hoteltype_id+'&format=js',
			onComplete: function(transport) { 
				  if (200 == transport.status)  FillHotels( transport );
			} 
		});	
}