var targetSelect;

function showProvince(targetSel,http,def)
{ 
//	var xzjh = $("#xzj").attr("value");
//	if(xzjh!=1){
//		$("#bbrnum").attr("value","0");
//		//$("#raidoiscard").attr("checked","checked");
//		if($("#protypeid").attr("value")==23){
//		 $("#jihuodiv03").slideUp();
//		}
//		 $("#pronum").attr("value","1");
//		 genggaijg(1,'qdj','totaljg');
//	}
    targetSelect = document.getElementById(targetSel);
   
    $.ajax({
       type: "POST",
       url: http,
       data: null,
       dataType: "xml",
       success: function(xml){
            removeAllOpt(targetSelect);
           
            property = $(xml).find("item");
           
            if(targetSelect.options.length >= 0) {
                targetSelect.options[0] = new Option();
                targetSelect.options[0].value = "0";
                targetSelect.options[0].text = "请选择";
            }
           
            if(property.length >0){//对应的省份有城市信息则显示
                for (var i=0,x=1;i<property.length;i++,x++)
                {
                    name = $("name",property[i]).text();
                    value = $("value",property[i]).text();
                    targetSelect.options[x] = new Option();
                    targetSelect.options[x].value = value;
                    targetSelect.options[x].text = name;
                    if (value == def) {
                    	targetSelect.options[x].selected = "selected";
                    }
                }
            }
        }
    });
}

function index_showProvince(targetSel,http,proid,cityid,cityname,citySel)
{ 
    targetSelect = document.getElementById(targetSel);
    $.ajax({
       type: "POST",
       url: http,
       data: null,
       dataType: "xml",
       success: function(xml){
            removeAllOpt(targetSelect);
            
            property = $(xml).find("item");
            
            if(cityid!=null&&cityid.length>0){
            	
	            var tagrcitySel = document.getElementById(citySel);
	            removeAllOpt(tagrcitySel);
	            if(tagrcitySel.options.length >= 0) {
	                tagrcitySel.options[0] = new Option();
	                tagrcitySel.options[0].value = cityid;
	                tagrcitySel.options[0].text = cityname;
	            }
            }
            
            if(targetSelect.options.length >= 0) {
                targetSelect.options[0] = new Option();
                targetSelect.options[0].value = "0";
                targetSelect.options[0].text = "请选择";
            }
           
            if(property.length >0){//对应的省份有城市信息则显示
            	
                for (var i=0,x=1;i<property.length;i++,x++)
                {
                    name = $("name",property[i]).text();
                    value = $("value",property[i]).text();
                    targetSelect.options[x] = new Option();
                    targetSelect.options[x].value = value;
                    targetSelect.options[x].text = name;
                    if(parseInt(proid)==parseInt(value)){
                   		targetSelect.options[x].selected="selected";
                    }
                }
            }
        }
    });
}

function showCity(sourceSel,targetSel,http)
{
    var prov = document.getElementById(sourceSel);
	var sendData = "provinceId=" + prov.options[prov.selectedIndex].value;
	 var provincename =  prov.options[prov.selectedIndex].text;
	 $("#provincename").attr("value",provincename);
	 $("#provinceids").attr("value",prov.options[prov.selectedIndex].value);
	 $("#wuliucomid").attr("value","");
	 $("#wuliucomname").attr("value","");
    targetSelect = document.getElementById(targetSel);
    $.ajax({
       type: "POST",
       url: http,
       data: sendData,
       dataType: "xml",
       success: function(xml){
            removeAllOpt(targetSelect);
           
            property = $(xml).find("item");
           
            if(targetSelect.options.length >= 0) {
                targetSelect.options[0] = new Option();
                targetSelect.options[0].value = "0";
                targetSelect.options[0].text = "请选择";
            }
           
            if(property.length >0){//对应的省份有城市信息则显示
                for (var i=0,x=1;i<property.length;i++,x++)
                {
                    name = $("name",property[i]).text();
                    value = $("value",property[i]).text();
                    targetSelect.options[x] = new Option();
                    targetSelect.options[x].value = value;
                    targetSelect.options[x].text = name;
                }
            }
        }
    });
}


function showZone(sourceSel,targetSel,http)
{
    var prov = document.getElementById(sourceSel);
	var sendData = "cityId=" + prov.options[prov.selectedIndex].value;
	var cityname =  prov.options[prov.selectedIndex].text;
	 $("#cityname").attr("value",cityname);
    targetSelect = document.getElementById(targetSel);
    $.ajax({
       type: "POST",
       url: http,
       data: sendData,
       dataType: "xml",
       success: function(xml){
            removeAllOpt(targetSelect);
           
            property = $(xml).find("item");
           
            if(targetSelect.options.length >= 0) {
                targetSelect.options[0] = new Option();
                targetSelect.options[0].value = "0";
                targetSelect.options[0].text = "请选择";
            }
           
            if(property.length >0){//对应的省份有城市信息则显示
                for (var i=0,x=1;i<property.length;i++,x++)
                {
                    name = $("name",property[i]).text();
                    value = $("value",property[i]).text();
                    targetSelect.options[x] = new Option();
                    targetSelect.options[x].value = value;
                    targetSelect.options[x].text = name;
                }
            }
        }
    });
}

function removeAllOpt(sel) {
    sel.options.length = 0;
}
