﻿function HotelCity() {
    this.value = new HotelCity_DATA('1').value;
  
    var checkresult=GetRadioCheck();
    if(checkresult=="2")
    {
      this.value = new HotelCity_DATA('2').value;
    }
    this.get = getSZM;
}
 function GetRadioCheck()
  {
  if(document.getElementById("hotelArea1")!=null)
  {
       var asd =document.getElementById("hotelArea1");
     
       if(asd.checked)
       {document.getElementById("txtCity").value="上海(SHA)";
           return "1";
           
       }
       var asd1 =document.getElementById("hotelArea2");
       if(asd1.checked)
       { document.getElementById("txtCity").value="香港(HKG)";
         return "2";
        
       }       
       }
  }
function getSZM(key) {
    var array = new Array();
    var index = 0;
    for (var i = 0; i < this.value.length; i++) {
        for (var j = 0; j < this.value[i].length; j++) {
            if (this.value[i][j].toUpperCase().indexOf(key.toUpperCase()) == 0) {
                array[index] = new Array();
                array[index][0] = this.value[i][0].substring(0, 1).toUpperCase() + " - " + this.value[i][1] + " (" + this.value[i][2].toUpperCase() + ")";
                array[index][1] = this.value[i][1] + "(" + this.value[i][2].toUpperCase() + ")";
                index++;
                break;
            }
        }
    }
    return array;
}
function doKeyIn(key, selectId, selectDivId) {
    var city = new HotelCity();
    var value = city.get(key);
    if (value == null || value.length == 0) {
        return;
    }
    var selectValue = document.getElementById(selectId);
    rmvSelect(selectValue);
    document.getElementById(selectDivId).style.display = "block";
    for (var i = 0; i < value.length; i++) {
        var opt = new Option(value[i][0], value[i][1]);
        selectValue.options.add(opt);
    }
}
function doSelectIn(selectValue, txtId, selectDivId) {
    document.getElementById(txtId).value = selectValue.value;
    rmvSelect(selectValue);
    document.getElementById(selectDivId).style.display = "none";
}
function rmvSelect(selectValue) {
    for (var i = selectValue.options.length - 1; i >= 0; i--) {
        selectValue.options.remove(i);
    }
}
function doChange(txt, selectId, selectDivId) {
    var selectValue = document.getElementById(selectId);
    var count = selectValue.options.length;
    if (count != 1) {
        txt.value = "";
//        alert("请选择城市！");
    } else {
        txt.value = selectValue.options[0].value;
        rmvSelect(selectValue);
        document.getElementById(selectDivId).style.display = "none";
    }
}

