    $(document).ready(function(){    
        cityArea();
        $('.ddldisplay').hover(
		    function(){return false;},
		    function(){$(this).children("div").hide();$('.ddldisplay').toggle(
			function() { $(this).children("div").show(); },
			function() { $(this).children("div").hide(); }
		);}
		);
    });
    function cityArea() {
        $.ajax({
            url: "js/area.xml", //地址
            type: "GET",
            dataType: "xml",
            error: function(xdata) { alert("fail:"); },
            success: function(xdata) {
                if ($(xdata) != null) {
                    $("#ddlSheng div").html("");
                    for (var i = 0; i < $(xdata).find("address > province").length; i++) {
                        $("#ddlSheng div").append("<a href='javascript:;'>" + $(xdata).find("address > province:eq(" + i + ")").attr("name") + "</a>"); ;
                    }
                }
                //下面是下拉框
                $(".ddldisplay").toggle(
                        function() { $(this).children("div").show(); },
                        function() { $(this).children("div").hide(); }
                );
                $("#ddlSheng a").click(function() {
                    $(this).parents(".ddldisplay").find("span").text($(this).text());
                    $("#hid2").val($("#txtSheng").text());
                    var provinceName = $(this).parent().prev().text();
                    $("#ddlShi div").html("");
                    //根据省查找该省的所有下级市
                    for (var i = 0; i < $(xdata).find("address > province[name='" + provinceName + "'] > city").length; i++) {
                        $("#ddlShi div").append("<a href='javascript:;'>" + $(xdata).find("address > province[name='" + provinceName + "'] > city:eq(" + i + ")").attr("name") + "</a>");
                    }
                    $(this).parents(".ddldisplay").find("div").hide();
                    $("#ddlShi a").click(function() {
                        var provinceName = $("#ddlSheng").find("span").text(); //省
                        var cityName = $(this).text(); //市
                        $("#ddlShi span").text(cityName);
                        $("#hid2").val($("#txtSheng").text()+'-'+$("#txtShi").text());
                        var country = $(xdata).find("address > province[name='" + provinceName + "'] > city[name='" + cityName + "'] > country");
                        var len = country.length;
                        $("#ddlQu div").html("");
                        for (var i = 0; i < len; i++) {
                            var countryName = $(xdata).find("address > province[name='" + provinceName + "'] > city[name='" + cityName + "'] > country:eq(" + i + ")").attr("name");
                            $("#ddlQu div").append("<a href='javascript:;'>" + countryName + "</a>");
                        }
                        $(this).parents(".ddldisplay").find("div").hide();
                        $("#ddlQu a").click(function() {
                            $("#ddlQu span").text($(this).text());
                            $("#hid2").val($("#txtSheng").text()+'-'+$("#txtShi").text()+'-'+$("#txtqu").text());
                        });                        
                    });
                });
                
            }
        });
    }
