function addimg(imgsrc,imgid,imgwid,imghei,imgmartop,imgtouming){  //输图函数
var tempimg="<img src='../image/"+imgsrc+"'"
if(imgid!="null")tempimg+=" id='"+imgid+"'"
if(imgwid!="null")tempimg+=" width='"+imgwid+"'"
if(imghei!="null")tempimg+=" height='"+imghei+"'"
if(imgmiti!=null){  //有迷题
tempimg+=" mitivalue='"+imgmiti+"'";imgmiti=null
}
if(varimgneirong!=null){  //有谈话
tempimg+=" tanhua='"+varimgneirong+"' dongzuo='"+varimgdongzuo+"'"
varimgneirong=null;varimgdongzuo=null;
}
if(imgmartop==1){tempimg+=" style='margin-top:7'"}
if(imgtouming==1)tempimg+=" style='filter:chroma(color=white)'"
tempimg+=">"
return tempimg;
}
var varimgneirong=null,varimgdongzuo=null,imgmiti=null;  //临时剧情/迷题存储
var ddrditu=new Array(60);  //内存地图
function fanbianyi(num){  //反编译
var temptu=""
for(var i=0;i<td1.length;i++){
var tempd=td1[i].ditu
if(tempd!=null){  //原先有物件
var tempv=td1[i].value
if(tempd.indexOf("shikong")!=-1){temptu+=tempd+",";continue;}
if(tempv==11){temptu+="11,";continue;}
else if(tempv==13){temptu+="13,";continue;}
if(!td1[i].firstChild&&tempv!=1){  //物件变动为0
if(tempv!=9&&tempv!=10)temptu+="0,"
}else{  //原物未动
if(tempv!=9&&tempv!=10&&tempv!=1){
if(td1[i].firstChild.id=="img1"){temptu+="0,";continue;}  //rpg不在楼梯,为空
}
temptu+=tempd+","
}
}else{  //本身为0
temptu+="0,"
}
ddrditu[num]=temptu.substr(0,temptu.length-1)  //去末尾,号
}
}        //地图反编译-over
function ditugx(shangxia){  //输图
if(time1!=null){clearInterval(time1);time1=null;}
shutusuoding=true
rpgceng.innerText=ceng+"-"+ceng2;
var tempt=getxml("ceng"+ceng,2).replace(/\|[0-9]+\|/g,",").replace(/\n/g,"")  //getxml
var tempt0=tempt.split(",,,,,")

if(shangxia=="上楼"){
intd=parseInt(tempt0[0])
if(ceng!=1){  //非首加载第一层,记录上层变动.
fanbianyi(ceng-1)
}
}else if(shangxia=="下楼"){
intd=parseInt(tempt0[1])
fanbianyi(ceng+1)
}else{  //楼层传送
intd=parseInt(tempt0[0])
}
if(soundnum==0){bgsound1.src="../backsound/"+tempt0[2];bgsound1.loop=-1}
jihao.innerText=tempt0[3]

var temp3="";  //网格初始化
fufrom.style.backgroundImage="url('../image/daolu/lu"+tempt0[4]+".gif')"
zuolan.style.backgroundImage="url('../image/bgimg/lan"+tempt0[4]+".gif')"
for(var j=0;j<tdlie+2;j++){temp3+="<tr>"
for(var i=0;i<tdlie+2;i++){
if(j==0||j==tdlie+1){temp3+=("<td background='../image/daolu/bian"+tempt0[4]+".gif'></td>");continue;}
if(i==0||i==tdlie+1){temp3+=("<td background='../image/daolu/bian"+tempt0[4]+".gif'></td>");continue;}
temp3+=("<td id=td1></td>");
}temp3+="</tr>"}
fufrom.style.visibility="hidden"
fufrom.innerHTML="<table width=100% height=100% bordercolor=white cellspacing=0 cellpadding=0 border=0 id=from1 style='table-layout:fixed;'>"+temp3+"</table>"

if(ddrditu[ceng]==null){  //xml地图
tempt=tempt0[5].split(",")
}else{  //内存地图
tempt=ddrditu[ceng].split(",")
}

for(var i=0;i<tempt.length;i++){
if(tempt[i]==0)continue;
td1[i].ditu=tempt[i];  //用于反编译.

if(tempt[i].indexOf("+++miti")!=-1){  //是迷题
imgmiti=tempt[i].replace(/\d+\+\+\+/,"")
tempt[i]=tempt[i].replace(/\+\+\+.+/g,"")
}
if(tempt[i].indexOf("+++juqing")!=-1){  //是谈话内容+动作
var tempstr=tempt[i].replace(/\d+\+\+\+juqing/,"")
var tempstr2=getxml("jq"+tempstr,1).split("tempvalue")
if(tempstr2.length==1){  //只有内容,没动作
varimgneirong=tempstr2[0].replace(/\n/g,"");varimgdongzuo="没动作"
}else{
varimgneirong=tempstr2[1].replace(/\n/g,"");varimgdongzuo=tempstr2[0]
}
tempt[i]=tempt[i].replace(/\+\+\+.+/g,"")
}

if(tempt[i]==1){td1[i].style.backgroundImage="url('../image/daolu/qiang"+tempt0[4]+".gif')";td1[i].value=1} //输路
else if(tempt[i]==11){td1[i].style.backgroundImage="url('../image/daolu/anqiang"+tempt0[4]+".gif')";td1[i].value=11}
else if(tempt[i]==13){td1[i].style.backgroundImage="url('../image/daolu/xianjing2.gif')";td1[i].value=13}
else if(tempt[i].indexOf("shikong")!=-1){td1[i].style.background="black url('../image/daolu/shikong.gif') no-repeat scroll 50%";td1[i].value=tempt[i];}
else{  //解析XML
if (yuansuxml(tempt[i])==null)continue;
var tempy=yuansuxml(tempt[i]).split(",,,")
td1[i].innerHTML=addimg(tempy[0],tempy[1],tempy[2],tempy[3],tempy[4],tempy[5]);
if(tempy[6]!="null")td1[i].value=tempy[6]
}

}
yousex==true?temp1="boy"+katong:temp1="girl"+katong
var temph1=td1[intd].innerHTML
if(temph1==""){td1[intd].innerHTML="&nbsp;<img width=140 height=160 src='../image/yongshi/"+temp1+".png' id=img1 style='position:absolute;clip:rect(0 25% 25% 0);'>"
img1.style.left=img1.offsetLeft-21;
}else{
td1[intd].innerHTML+="<img width=140 height=160 src='../image/yongshi/"+temp1+".png' id=img1 style='position:absolute;clip:rect(0 25% 25% 0);'>"
img1.style.left=img1.offsetLeft-32;img1.style.top=img1.offsetTop
}
img1left=img1.offsetLeft;img1top=img1.offsetTop;
if(ceng==1)document.title="神魔对决1-正义的审判 - 游戏中"
setTimeout("suoding=false;pksouding=false;shutusuoding=false;",200)
fufrom.style.visibility="visible";
}