var gongcheng={
editfile:"",editfilename:"",
exp2open:function(){  //刷新工程浏览器
if(gongcheng.editfile==""){
gongchengbutton[0].disabled=true;gongchengbutton[1].disabled=true;gongchengbutton[2].disabled=true;
gongchengtitle.innerText="你必须先打开一个地图文件，才能进行地图工程的开发。";gongchengzhushi.innerText="";
}else{
gongchengtitle.innerText=gongcheng.editfile;fsoxml.load(gongcheng.editfile);if(fsoxml.parseError.errorCode!=0)return gongcheng.editfile="";
var tempxml=fsoxml.getElementsByTagName("n"),ops=[]
for(var i=0;i<tempxml.length;i++)ops[i]="<option>"+tempxml[i].getAttribute("name");
gongchengselect.outerHTML='<select size="16" style="width:100%" id="gongchengselect">'+ops.join("")+'</select>';
gongchengbutton[0].disabled=false;gongchengbutton[1].disabled=false;gongchengbutton[2].disabled=false;
gongchengzhushi.innerText="共 "+tempxml.length+" 张地图，工程文件总大小 "+(fsoobj.getfile(gongcheng.editfile).size/1024).toFixed(2)+ "KB";
if(gongchengselect.options.length>0)gongchengselect.options[0].selected=true
}
},
openditu:function(){  //打开地图
if(gongchengselect.options.length==0)return alert("地图列表为0个,请先新建一副空白地图,才能打开");
var txt1=gongchengselect.options[gongchengselect.selectedIndex].text
if(!confirm("这样将中止目前正编辑中的地图数据,请注意保存!\n\n你确定要打开已有地图[ "+txt1+" ]进行编辑??"))return;
sm3.loaddt(gongcheng.editfilename,txt1);xdk.style.display="none";bianji.clearundo();
explorer2.style.visibility="hidden";sd_mark=false;
},
newditu:function(){   //建新地图
dtdom.load("server/ditu/"+gongcheng.editfilename+".xml");
var len1=round(random()*100),newdt=dtdom.createElement("n");
newdt.setAttribute("wid","5000");newdt.setAttribute("hei","5000");
newdt.setAttribute("bgsound","1.mid");newdt.setAttribute("name","地图临时名"+len1)
newdt.setAttribute("dimian","img/background/xin1.jpg");
newdt.setAttribute("guishu","newdt"+len1);
dtdom.getElementsByTagName("document")[0].insertBefore(newdt,dtdom.getElementsByTagName("document")[0].firstChild);
dtdom.save(dtdom.url);gongcheng.exp2open();
},
delditu:function(){  //删除地图
if(gongchengselect.options.length==0)return alert("地图列表为0个,无法删除");
if(!confirm("你确实要删除和清空这幅地图??慎重,以后无法恢复!"))return;
dtdom.load("server/ditu/"+gongcheng.editfilename+".xml");
for(var i=0;i<dtdom.getElementsByTagName("n").length;i++){
if(dtdom.getElementsByTagName("n")[i].getAttribute("name")!=gongchengselect.options[gongchengselect.selectedIndex].text)continue;
dtdom.getElementsByTagName("document")[0].removeChild(dtdom.getElementsByTagName("n")[i]);break;
}
dtdom.save(dtdom.url);gongcheng.exp2open();
}
}