var sm3={
rekuang:function(){  //更新地图矿物
if(document.getElementById("fmkuang")!=null){  //如有,则清空矿
while(fmkuang.length>0){
fmkuang[0].removeNode()
}
}
var kw1=0,allkw=kuang  //矿处理
if(allkw=="")return;
allkw=allkw.split(",");kw1=allkw.length
for(var i=0;i<kw1;i++){var allkw2=allkw[i].split("=")
for(var j=0;j<allkw2[1];j++){
var htm=document.createElement("IMG");htm.style.cursor="hand";htm.id="fmkuang";
htm.style.left=round(fmwid*random());htm.style.top=round(fmhei*random());htm.style.zIndex=18000;
htm.onmousemove=function(){showtmk('正常游戏时,矿石的位置与样式完全随机,此时修改=0用途')}
htm.src="img/wp/"+xml.getwp("wp",allkw2[0]).getAttribute("src");fm1.appendChild(htm);
}}  //end 2 for
},
medingwei:function(){  //刷新围绕主角定位视图
var mewid=me.offsetWidth,mehei=me.offsetHeight
fmleft=bodywid/2+-huichengx-(mewid/2);fmtop=bodyhei/2+-huichengy-(mehei/2)
me.style.left=round(bodywid/2+(-fmleft)-(mewid/2));me.style.top=round(bodyhei/2+(-fmtop)-(mehei/2));
fm1.style.left=fmleft;fm1.style.top=fmtop;me.style.visibility="visible";
selobj=null;xdk.style.display="none";
},
hjy:function(){  //环境乐播放
if(hjy=="")return;if(round(random()*40)>1)return;  //越1-40秒内,平均20秒,才执行
var src1="";switch(hjy){
case "鸟语花香":src1="niao1.wav,niao2.wav,niao3.wav,niao4.wav,niao5.wav,niao6.wav,all_chan.wav";break;
case "神秘诡异":src1="shenmi1.mp3,shenmi2.mp3,all_shui1.mp3,all_youyuan.wav,all_mao2.wav";break;
case "海洋世界":src1="hai1.mp3,hai2.mp3";break;
case "寂静夜晚":src1="time_ye1.wav,time_ye2.wav,time_ye3.wav,time_ye4.wav,time_all.wav,all_mao1.wav";break;
case "雨一直下":src1="xiayu1.mp3,xiayu2.wav,xiayu3.mp3";break;
case "动物王国":src1="dongwu1.wav,dongwu2,wav,dongwu3,wav,all_lang.wav,all_ma.wav,all_yang.wav,all_youyuan.wav";break;
case "荒凉之地":src1="huangliang1.wav,huangliang2.wav,all_dadiao.wav,all_lang.wav,all_wuya.wav";break;
case "喧闹都市":src1="dushi1.mp3,dushi2.mp3";break;
case "科学机器":src1="jiqi1.wav,jiqi2.wav,jiqi3.wav,jiqi4.wav,jiqi5.wav";break;
case "激烈战场":src1="zhanchang1.wav,zhanchang2.wav,zhanchang3.wav,zhanchang4.wav,zhanchang5.wav,zhanchang6.wav";break;
}
bgsound2.src="bgsound/bgsound2/"+src1.split(",")[Math.floor(src1.split(",").length*random())];
bgsound2.loop=round(random()*3)
},
loaddt:function(dtwenjian1,dtname1){  //装载地图
dtwenjian=dtwenjian1;dtname=dtname1;fm1.innerHTML=me.outerHTML //初始化地图全局变量,记录当前场景名称  //初始化框架

dtdom.load("server/ditu/"+dtwenjian+".xml");var tempdom=dtdom.getElementsByTagName("n")
var xml1=null;for(var i=0;i<tempdom.length;i++){
if(tempdom[i].getAttribute("name")==dtname){xml1=tempdom[i];break;}
}

yinyue=xml1.getAttribute("bgsound");
migong=xml1.getAttribute("migong")==null?false:true;
bgimg=xml1.getAttribute("dimian");guishu=xml1.getAttribute("guishu")
huichengx=xml1.getAttribute("morenx")==null?"":xml1.getAttribute("morenx");
huichengy=xml1.getAttribute("moreny")==null?"":xml1.getAttribute("moreny");
hjy=xml1.getAttribute("hjy")==null?"":xml1.getAttribute("hjy");
if(hjy=="")bgsound2.src="";
jinfei=xml1.getAttribute("fei")=="禁止"?true:false;
bodywid=document.body.offsetWidth;bodyhei=document.body.offsetHeight
bgsound1.src="bgsound/"+yinyue;fm1.style.backgroundImage="url('"+bgimg+"')";

fmwid=xml1.getAttribute("wid");fmhei=xml1.getAttribute("hei");
fm1.style.width=fmwid;fm1.style.height=fmhei
if(huichengx!=""&huichengy!=""){sm3.medingwei()}else{
fmleft=-(fmwid/2-(bodywid/2));fmtop=-(fmhei/2-(bodyhei/2));
fm1.style.left=fmleft;fm1.style.top=fmtop;me.style.visibility="hidden"
}


kuang=xml1.getAttribute("kuang")==null?"":xml1.getAttribute("kuang");
sm3.rekuang()


gws="";gwmax=0;  //初始化场景怪物资料
if(xml1.getAttribute("gw")!=null&&xml1.getAttribute("gwmax")>0){
gwmax=parseInt(xml1.getAttribute("gwmax"));gws=xml1.getAttribute("gw")
}

var xml2=xml1.childNodes
for(var i=0;i<xml2.length;i++){
var id1=xml2[i].getAttribute("id")
if(id1=="aqq"||id1=="exit"||id1=="pb"||id1=="shui"||id1=="xj"){  //安全区,出口,屏蔽
var htm=document.createElement("div");htm.id=id1;
htm.style.left=xml2[i].getAttribute("x");htm.style.top=xml2[i].getAttribute("y")
var twid1=xml2[i].getAttribute("wid"),thei1=xml2[i].getAttribute("hei")
if(id1=="aqq"){htm.style.border="3 dotted lime";htm.move=14}
else if(id1=="pb"){htm.move=4;
htm.style.backgroundColor=xml2[i].getAttribute("col")!=null?xml2[i].getAttribute("col"):"black";
if(xml2[i].getAttribute("bg")!=null){htm.style.backgroundImage="url('img/background/"+xml2[i].getAttribute("bg")+"')";htm.bg=xml2[i].getAttribute("bg")}
htm.style.border="3 outset "+htm.style.backgroundColor;
if(xml2[i].getAttribute("col")!=null)htm.col=htm.style.backgroundColor
}else if(id1=="shui"){
htm.style.backgroundImage="url('img/background/shui"+Math.ceil((new Date().getHours()+1)/6)+".gif')";htm.move=5
}else if(id1=="xj"){
htm.move=6;htm.bgimg=xml2[i].getAttribute("bgimg");
htm.style.backgroundImage="url('img/"+htm.bgimg+"')";
htm.xjshanghai=xml2[i].getAttribute("xjshanghai")
htm.xjsunshi=xml2[i].getAttribute("xjsunshi")
}else if(id1=="exit"){
htm.style.fontSize="15px";htm.style.fontWeight="bold"
htm.style.textAlign="center";htm.style.color="Red";htm.style.backgroundImage="url('img/background/liuxing2.gif')"
htm.style.border="1 solid gray";htm.move=15;
htm.exitto=xml2[i].getAttribute("exitto");
htm.exitx=xml2[i].getAttribute("exitx");htm.exity=xml2[i].getAttribute("exity");
htm.innerHTML="前往↓<p></p>"+htm.exitto.split("+-=-+")[1]
}
htm.style.width=twid1;htm.style.height=thei1;
if(xml2[i].getAttribute("z")!=null){htm.style.zIndex=xml2[i].getAttribute("z");htm.z=xml2[i].getAttribute("z")}
if(xml2[i].getAttribute("dong")!=null){htm.fanwei=xml2[i].getAttribute("fanwei");htm.dong=true;}
if(xml2[i].getAttribute("yincang")!=null){htm.yincang=xml2[i].getAttribute("yincang");}
if(xml2[i].getAttribute("ciyuan")!=null){htm.ciyuan=xml2[i].getAttribute("ciyuan");}
fm1.appendChild(htm);
continue;
}
var htm=document.createElement("img")  //路障,NPC,boos
if(id1=="npc"||id1=="boos"){
htm.style.cursor="hand";htm.oldx=parseInt(xml2[i].getAttribute("x"));htm.oldy=parseInt(xml2[i].getAttribute("y"));
if(id1=="npc"&&xml2[i].getAttribute("pub")!=null){switch(xml2[i].getAttribute("pub")){
case "传送":htm.name1="传送妹";htm.src="img/npc/mpc1.gif";htm.face1="lihui/chuansong_small.gif";htm.msg="jq0_1";break;
case "商店":htm.name1="商店姐";htm.src="img/npc/mpc2.gif";break;
case "仓库":htm.name1="仓库妹";htm.src="img/npc/mpc3.gif";break;
case "技能":htm.name1="技能姐";htm.src="img/npc/mpc4.gif";htm.face1="lihui/jineng_small.gif";htm.msg="jq0_4";break;
case "强化":htm.name1="强化妹";htm.src="img/npc/mpc5.gif";htm.face1="lihui/qianghua_small.gif";htm.msg="jq0_3";break;
case "锻制":htm.name1="锻制妹";htm.src="img/npc/mpc6.gif";htm.face1="lihui/duanzhi_small.gif";htm.msg="jq0_2";break;

case "精炼":htm.name1="风云舞";htm.src="img/gw/anhei13.gif";htm.face1="lihui/fyw_small.gif";htm.msg="jq0_6";break;
case "掉换":htm.name1="万华妹";htm.src="img/gw/wj10.gif";htm.face1="lihui/wanhua_small.gif";htm.msg="jq0_15";break;
case "任务-暗黑兄弟会":htm.name1="暗黑兄弟会委托";htm.src="img/gw/anhei12.gif";htm.face1="lihui/qingguo_small.gif";htm.msg="jq0_7";break;
case "任务-新选组":htm.name1="新选组委托";htm.src="img/gw/hani4.gif";htm.face1="lihui/hani3_small.gif";htm.msg="jq0_8";break;
case "任务-圣堂天团":htm.name1="圣堂天团委托";htm.src="img/gw/shengyu12.gif";htm.face1="lihui/shengtangnv_small.gif";htm.msg="jq0_9";break;
case "任务-帝国军团":htm.name1="帝国军团委托";htm.src="img/gw/diguo8.gif";htm.face1="lihui/shangshan_small.gif";htm.msg="jq0_10";break;
case "任务-地狱魔军":htm.name1="地狱魔军委托";htm.src="img/gw/mojun14.gif";htm.face1="lihui/xitisi_small.gif";htm.msg="jq0_11";break;
case "任务-俺样公会":htm.name1="梅尔菲";htm.src="img/gw/wj9.gif";htm.face1="lihui/canmouzhang_small.gif";htm.msg="jq0_14";break;
}htm.pub=xml2[i].getAttribute("pub")}
if(htm.msg==null)htm.msg=xml2[i].getAttribute("msg")==null?"":xml2[i].getAttribute("msg");
if(htm.name1==null&&xml2[i].getAttribute("name1")!=null)htm.name1=xml2[i].getAttribute("name1")
if(xml2[i].getAttribute("face")!=null)htm.face1=xml2[i].getAttribute("face")
if(id1=="boos"){htm.boosis=xml2[i].getAttribute("boosis");htm.shouxia=xml2[i].getAttribute("shouxia")==null?"":xml2[i].getAttribute("shouxia");htm.killxs=xml2[i].getAttribute("killxs");
try{var thegw=gwdom.getElementsByTagName(htm.boosis.split("=")[1])[0];htm.src="img/gw/"+thegw.getAttribute("src");}catch(e){htm.src="img/gw/boss1.gif"}
}}


if(xml2[i].getAttribute("src")!=null)htm.src="img/"+xml2[i].getAttribute("src");
htm.id=id1;htm.style.left=xml2[i].getAttribute("x");htm.style.top=xml2[i].getAttribute("y");
if(xml2[i].getAttribute("move")!=null)htm.move=xml2[i].getAttribute("move");
if(xml2[i].getAttribute("z")!=null){htm.style.zIndex=xml2[i].getAttribute("z");htm.z=xml2[i].getAttribute("z")}
if(xml2[i].getAttribute("wid")!=null)htm.style.width=xml2[i].getAttribute("wid");
if(xml2[i].getAttribute("hei")!=null)htm.style.height=xml2[i].getAttribute("hei");
if(xml2[i].getAttribute("dong")!=null){htm.fanwei=xml2[i].getAttribute("fanwei");htm.dong=true;}
if(xml2[i].getAttribute("yincang")!=null){htm.yincang=xml2[i].getAttribute("yincang");}
if(xml2[i].getAttribute("ciyuan")!=null){htm.ciyuan=xml2[i].getAttribute("ciyuan");}
fm1.appendChild(htm);
}


xdt.keyi=true;sm3.loadxdt();gxxinxi();
},
loadxdt:function(){  //装载小地图
var thelen1=fm1.children.length;xdt_yuansushu.innerText=(thelen1-1)+"个";
if(thelen1>80&&xdt.keyi!=true)return;

var tempobj=xdt.children  //初始化小地图,保留xdtxinxi,xdtkuang,minrpg
while(tempobj.length>3)xdt.removeChild(tempobj[3])
if(me.style.visibility=="hidden"){minrpg.style.visibility="hidden"}else{
minrpg.style.left=me.offsetLeft/(fmwid/xdtwid);minrpg.style.top=me.offsetTop/(fmhei/xdthei);
var tempw=xdtwid/(fmwid/me.offsetWidth),temph=xdthei/(fmhei/me.offsetHeight)
minrpg.style.width=tempw<4?4:tempw;minrpg.style.height=temph<4?4:temph;minrpg.style.zIndex=20000;
minrpg.style.visibility="visible";
}

for(var i=0;i<thelen1;i++){
var obj=fm1.children[i],id1=obj.id
var small=document.createElement('div')
small.style.fontSize="1px";
if(id1=="dl"||id1=="pb"){small.style.backgroundColor="#555555";}
else if(id1=="fmkuang"){small.style.backgroundColor="orange";small.style.zIndex=5;}
else if(id1=="npc"){obj.getAttribute("pub")!=null?small.style.backgroundColor="lime":small.style.backgroundColor="yellow";}
else if(id1=="shui"){small.style.backgroundColor="#6464FF"}
else if(id1=="xj"){small.style.backgroundColor="#FF6464"}
else if(id1=="aqq"){small.style.border="1 dotted lime"}

small.style.left=obj.offsetLeft/(fmwid/xdtwid);
small.style.top=obj.offsetTop/(fmhei/xdthei);
var tempw=xdtwid/(fmwid/obj.offsetWidth),temph=xdthei/(fmhei/obj.offsetHeight)
small.style.width=tempw<3?3:tempw;
small.style.height=temph<3?3:temph;small.style.zIndex=obj.style.zIndex;

if(id1=="exit"){
small.style.width=12;small.style.height=12;small.style.backgroundImage='url("img/ico/exit.gif")';
}else if(id1=="boos"){
small.style.width=12;small.style.height=12;small.style.backgroundImage='url("img/ico/kulou.gif")';
}
if(obj.yincang!=null)small.style.display="none";

xdt.appendChild(small)


if(id1=="exit"){  //后续友好视图定位处理
if(small.offsetTop+small.offsetHeight>xdt.offsetHeight)small.style.top=xdt.offsetHeight-small.offsetHeight
if(small.offsetLeft+small.offsetWidth>xdt.offsetWidth)small.style.left=xdt.offsetWidth-small.offsetWidth
}
}  //end for
xdt.keyi=false
}
}

xdt.go=setInterval(function(){xdt.keyi=true;sm3.loadxdt();
},10000)  //10秒自动更新小地图