var geoSelectionV=new Object();var $=null;geoSelectionV={currentGeoChildsData:new Array(),currentGeoData:new Array(),domainList:new Array(),currentLevel:1,selectionIdPre:"geo_level",includeGeoLayerPre:"level",geoInputName:"geo_code",lastGeolevel:5,firstGeoLevel:1,rootPath:"./",initDomain:"cunwu",geoLayerId:"geo_selection",firstLevelCanChange:true,initGeoSelection:function(a){$=jQuery.noConflict();this.currentGeoData[0]=0;if(typeof a=="undefined"){a=0}var d=$.getYoyoJSON("?ctl=ajax_geo&act=get_init_geo_tree&geo_code="+a+"&start_level="+this.firstGeoLevel);for(var b=0;b<d.length;b++){if(d[b].child.length==0){continue}var h=typeof d[b].current.id=="undefined"?0:d[b].current.id;var f=d[b].child[0].parent_id;var e=typeof d[b].current.level=="undefined"?this.firstGeoLevel+b:d[b].current.level;if(d[b].child!=null){this.currentGeoChildsData[f]=d[b].child}this.buildNewSelection(this.currentGeoChildsData[f],e,h);if(this.currentLevel<e&&h>0){this.currentLevel=e}}for(var c=1;c<=5;c++){if(c<this.firstGeoLevel||c>this.lastGeolevel){$("#"+this.includeGeoLayerPre+c).hide()}}if(typeof(a)!="undefined"&&a>0&&this.firstLevelCanChange==false){$("#"+this.selectionIdPre+this.firstGeoLevel).attr("disabled","disabled")}$("#"+this.geoLayerId).find("select").each(function(g){g+=1;$(this).change(function(){var k=geoSelectionV.currentGeoData[$(this).val()];var m=geoSelectionV.domainList[$(this).val()];if(typeof m!="undefined"&&m!=null){geoSelectionV.initDomain=m}if(g<geoSelectionV.lastGeolevel){for(var j=g+1;j<=geoSelectionV.lastGeolevel;j++){$("#"+geoSelectionV.selectionIdPre+j).empty()}if($(this).val()!=0){var l=geoSelectionV.getGeoChildByParentId($(this).val());geoSelectionV.buildNewSelection(l,g+1)}}geoSelectionV.currentLevel=1;for(var j=geoSelectionV.firstGeoLevel;j<=geoSelectionV.lastGeolevel;j++){if($("#"+geoSelectionV.selectionIdPre+j).val()>0){geoSelectionV.currentLevel=j}}$("input[name="+geoSelectionV.geoInputName+"]").val(geoSelectionV.currentGeoData[$("#"+geoSelectionV.selectionIdPre+geoSelectionV.currentLevel).val()]);try{if(geoSelectionV.currentLevel==5){$("#to_village_button").get(0).disabled=false}else{$("#to_village_button").attr("disabled","disabled")}}catch(n){}})});$("input[name="+this.geoInputName+"]").val(this.currentGeoData[$("#"+this.selectionIdPre+this.currentLevel).val()])},getGeoChildByParentId:function(b){if(typeof(this.currentGeoChildsData[b])!="undefined"){return this.currentGeoChildsData[b]}else{var a=$.getYoyoJSON("?ctl=ajax_geo&act=get_geo_by_parent_id&parent_id="+b);this.currentGeoChildsData[b]=a;return this.currentGeoChildsData[b]}},buildNewSelection:function(e,f,a){var d=$("#"+this.selectionIdPre+f);d.empty();d.append("<option value='0'>请选择</option>");for(var c=0;c<e.length;c++){if(e[c].token!=3&&f==5){var b=" disabled='disabled' "}else{b=""}if(e[c].id==a){this.currentLevel=f;d.append("<option value='"+e[c].id+"'"+b+" selected='selected'>"+e[c].display_name+"</option>")}else{d.append("<option value='"+e[c].id+"'"+b+">"+e[c].display_name+"</option>")}this.currentGeoData[e[c].id]=e[c].geo_code;if(e[c].token==3){this.domainList[e[c].id]=e[c].domain}}}};