var xmlHttp;
function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}

function sendRequest1(url) {
    createXMLHttpRequest();
    xmlHttp.onreadystatechange = county1;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
    
}
function selectProvince1() {
    var province = document.getElementById("city1").value;
    if(province=="0"){
        clearcounty1();
        return;
    }
    
    var url = "/wuliu/pages/city/county.shtml?reservedAction=countylist&province=" + province;
    sendRequest1(url);
}

function county1() {
	
    if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
        var dataObj = xmlHttp.responseXML;
//      var citysObj = dataObj.getElementsByTagName("citys")[0];
        var countyObj = dataObj.getElementsByTagName("countys")[0] ;
        //alert(countyObj);
        var countyChild = countyObj.childNodes;
        var length = countyChild.length;
        var countySelect1=document.getElementById("county1");
        var leng=countySelect1.length;
        if(leng>0){
            clearcounty1();
        }
       
        for (var i = 0; i < length; i++) {
            var text = countyChild[i].getElementsByTagName("countyname")[0].firstChild.nodeValue;
            var optionObj1 = createOption1();
            var optionText = document.createTextNode(text);
            var optionValue=countyChild[i].getElementsByTagName("countyid")[0].firstChild.nodeValue;
            optionObj1.value=optionValue;
            optionObj1.appendChild(optionText);
            countySelect1.appendChild(optionObj1); 
        }
    }
}

function createOption1() {
    var optionObj = document.createElement("option");
    return optionObj;
}

function clearcounty1(){
   var citySelect=document.getElementById("county1");
   var citys=citySelect.childNodes;
    var length=citySelect.length;
    for(var i=0;i<length;i++){
        citySelect.removeChild(citys[0]);
    }
}
