function InitAddress(provID, cityID, countryID, urlPrefix){

    var handUrl = urlPrefix + "Handler/Address.ashx?n=";
    
    $("#" + provID).html("<option value=''>请选择省份</option>");
    $.getJSON(handUrl + Math.random(), {
        allid: 0
    }, function(json){
        for (var index in json) {
            $("<option>").attr("value", json[index].ID).html(json[index].Name).appendTo($("#" + provID));
        }
    })
    
    $("#" + provID).change(function(){
        $("#" + cityID).html("<option value=''>请选择市</option>");
        $("#" + countryID).html("<option value=''>请选择区</option>");
        if ($(this).val() != "") {
            $.getJSON(handUrl + Math.random(), {
                proid: escape($(this).val())
            }, function(json){
                for (var index in json) {
                    $("<option>").attr("value", json[index].ID).html(json[index].Name).appendTo($("#" + cityID));
                }
            });
        }
    })
    $("#" + cityID).change(function(){
        $("#" + countryID).html("<option value=''>请选择区</option>");
        if ($(this).val() != "") {
            $.getJSON(handUrl + Math.random(), {
                cityid: escape($(this).val())
            }, function(json){
                for (var index in json) {
                    $("<option>").attr("value", json[index].ID).html(json[index].Name).appendTo($("#" + countryID));
                }
            });
        }
    })
}

function showHDFK(){
    var id = $("#selCounty").val();
    var img_html = "<img src='http://image.369518.com/36936site/images/img_public/loading3.gif' /> 正在查询，请稍后..."
    $("#show").html(img_html);
    $.get("/Help/kdfk_area.aspx", {
        areaId: id
    }, function(data){
        $("#show").html(data);
    });
}
//
function ChangeProvince(cityID,selectValue,MachtResultValue)
{	
	var handUrl = "/Handler/Address.ashx?n=";
	$("#"+cityID).empty();
	//alert($("#"+cityID).html())
	$("#" + cityID).html("<option value=''>请选择市区</option>");
	$.getJSON(handUrl,{proID:selectValue},function(json){
		for(var index in json)
		{
			$("<option>").attr("value",json[index].ID).attr("selected",function(){
							if(json[index].Name==MachtResultValue)
			{
				return "selected"; 
			}
			return;
			}).html(json[index].Name).appendTo($("#"+cityID));
		}
	})
}
function ChangeCity(countyID,selectValue,MachtResultValue)
{	
	var handUrl = "/Handler/Address.ashx?n=";
	$("#"+countyID).empty();
	//alert($("#"+countyID).html())
	$("#" + countyID).html("<option value=''>请选择市区</option>");
	$.getJSON(handUrl,{cityID:selectValue},function(json){
		for(var index in json)
		{
			$("<option>").attr("value",json[index].ID).attr("selected",function(){
							if(json[index].Name==MachtResultValue)
			{
				return "selected"; 
			}
			return;
			}).html(json[index].Name).appendTo($("#"+countyID));
		}
	})
}
function InitAddressByValue(provID, proValue, cityID, cityValue, countryID, countyValue, urlPrefix){
    var handUrl = urlPrefix + "Handler/Address.ashx?n=";
	
	$("#" + provID).html("<option value=''>请选择省份</option>");
    $.getJSON(handUrl + Math.random(), {
        allid: 0
    }, function(json){
		//alert("s")
        for (var index in json) {
            $("<option>").attr("value", json[index].ID).attr("selected",function(){
				if(json[index].Name==proValue)
				{
					$.getJSON(handUrl+ Math.random(),{proId:json[index].ID},function(json){
						for(var index in json){
							$("<option>").attr("value",json[index].ID).attr("selected",function(){
								if(cityValue==json[index].Name)
								{
									$.getJSON(handUrl+ Math.random(),{cityId:json[index].ID},function(json){
										for(var index in json)
										{
											$("<option>").attr("value",json[index].ID).attr("selected",function(){
												if(countyValue==json[index].Name)
												{
													return "selected";
												}
												return;
											}).html(json[index].Name).appendTo($("#"+countryID))
										}
									})
									return "selected";
								}
								return;
							}).html(json[index].Name).appendTo($("#"+cityID))
						}
					})
					return "selected";
				}
				return;
			}).html(json[index].Name).appendTo($("#" + provID));
        }
    })
    
}
