var sl={
suoding:false,  //强制锁定
slmax:0,  //数量上限
danjia:100,  //单价
renwu:"",  //何种计算任务
obj:null,  //绑定哪个物品
wporck:"包裹", //分析最后操纵包裹还是仓库
open:function(fun1,fun2,wporck){
sl.renwu=fun1;if(fun2!=null){sl.wporck="包裹"
if(wporck==rpg.ck)sl.wporck="仓库";
sl.obj=fun2;var getwp1=xml.getwp(sl.obj.xml_node,sl.obj.xml_name)  //获得该物品属性
}
if(sl.renwu=="典当"){sl_title.innerText="卖出数量确认"
sl.slmax=sl.obj.shuliang;sl.danjia=Math.ceil(wpzb.getjiage(getwp1)/2);
slhr.style.width=sldiv.offsetWidth*sl.slmax;sldiv.scrollLeft=sldiv.scrollWidth;
}else if(sl.renwu=="购物"){sl_title.innerText="买进数量确认"
sl.slmax=getwp1.getAttribute("max");if(sl.slmax==null)sl.slmax=1;
sl.danjia=getwp1.getAttribute("hj")!=null?getwp1.getAttribute("hj"):wpzb.getjiage(getwp1);
slhr.style.width=sldiv.offsetWidth*sl.slmax;sldiv.scrollLeft=0;
}else if(sl.renwu=="分割"){sl_title.innerText="分割数量确认"
sl.slmax=sl.obj.shuliang-1;sl.danjia=wpzb.getjiage(getwp1);
slhr.style.width=sldiv.offsetWidth*sl.slmax;sldiv.scrollLeft=0;
}else if(sl.renwu=="兑换"){sl_title.innerText="黄金兑换确认"
sl.slmax=Math.floor(rpg.hj);sl.danjia=4000;
slhr.style.width=sldiv.offsetWidth*sl.slmax;sldiv.scrollLeft=0;
}else if(sl.renwu=="打包"){sl_title.innerText="黄金打包数量"
sl.slmax=Math.floor(rpg.hj);sl.danjia=100;
slhr.style.width=sldiv.offsetWidth*sl.slmax;sldiv.scrollLeft=0;
}else if(sl.renwu=="存款"){sl_title.innerText="银行储蓄神魔币"
sl.slmax=Math.floor(rpg.glod/100);sl.danjia=100;
slhr.style.width=sldiv.offsetWidth*sl.slmax;sldiv.scrollLeft=sldiv.scrollWidth/4
}else if(sl.renwu=="取款"){sl_title.innerText="银行支取神魔币"
sl.slmax=Math.floor(rpg.cunkuan/100);sl.danjia=100;
slhr.style.width=sldiv.offsetWidth*sl.slmax;sldiv.scrollLeft=sldiv.scrollWidth/4;
}else if(sl.renwu=="注资"){sl_title.innerText="给公会注资发展"
sl.slmax=Math.floor(rpg.glod/100);sl.danjia=100;
slhr.style.width=sldiv.offsetWidth*sl.slmax;sldiv.scrollLeft=sldiv.scrollWidth/4
}
sl.gundong();
sl_kuang.style.left=event.x;sl_kuang.style.top=event.y;
if(sl_kuang.offsetLeft+sl_kuang.offsetWidth>bodywid)sl_kuang.style.left=bodywid-sl_kuang.offsetWidth
if(sl_kuang.offsetTop+sl_kuang.offsetHeight>bodyhei)sl_kuang.style.top=bodyhei-sl_kuang.offsetHeight
sl_kuang.style.visibility="visible";sl.suoding=true
},
gundong:function(anniu){  //滚动条操控数量
if(anniu=="scrollbarLeft"){sldiv.scrollLeft=0;}
if(anniu=="scrollbarRight"){sldiv.scrollLeft=sldiv.scrollWidth}
var max=sldiv.scrollWidth,value1=sldiv.scrollLeft,dan=sldiv.offsetWidth
if(sltext.oldvalue!=round((value1+dan)/dan)){
sltext.value=round((value1+dan)/dan);sl.heji();}
},
heji:function(){  //总价
var shu1=sl.danjia*sltext.value
if(shu1.toString().indexOf(".")!=-1)shu1=shu1.toFixed(1);
try{slfont.innerText="总价:"+shu1
}catch(e){slfont.innerText="总价:无效"}
},
queren:function(){  //确认
var num=new Number(sltext.value)
if(num==0||isNaN(num)||num<0)return gdtext(event.x,event.y,"必须是数字,且值不能小于等于0")
if(num>sl.slmax)return gdtext(event.x,event.y,"超出最大值 "+sl.slmax)
if(num.toString().indexOf(".")!=-1)return gdtext(event.x,event.y,"禁止包含小数点")
var wporck=rpg.wp;if(sl.wporck=="仓库")wporck=rpg.ck
sl.close();if(sl.renwu=="典当"){
wporck[sl.obj.weizhi]=sl.obj.xml_node+"="+sl.obj.xml_name+"="+(sl.slmax-num);
if(sl.slmax-num<=0)wporck[sl.obj.weizhi]=null;
rpg.glod+=sl.danjia*num;
}else if(sl.renwu=="购物"){
if(xml.getwp(sl.obj.xml_node,sl.obj.xml_name).getAttribute("hj")!=null){
if(sl.danjia*num>rpg.hj)return lt.help("你没有足够的黄金购买此物")
if(wp_add(sl.obj.xml_node,sl.obj.xml_name,num)!=true)return;rpg.hj-=sl.danjia*num;
lt.help("消费黄金 "+sl.danjia*num+" 两,购买了 "+num+" "+sl.obj.xml_name);
}else{
if(sl.danjia*num>rpg.glod)return lt.help("你的钱不够结账")
if(wp_add(sl.obj.xml_node,sl.obj.xml_name,num)!=true)return;rpg.glod-=sl.danjia*num;
lt.help("消费金币 "+sl.danjia*num+" 元,购买了 "+num+" "+sl.obj.xml_name);
}
}else if(sl.renwu=="分割"){
var kexing="否";for(var i=0;i<rpg.wp.length;i++){if(rpg.wp[i]==null){kexing=i;break;}}
if(kexing=="否")return gdtext(event.x,event.y,"包裹已满,无法分割!")
rpg.wp[i]=sl.obj.xml_node+"="+sl.obj.xml_name+"="+num
wporck[sl.obj.weizhi]=sl.obj.xml_node+"="+sl.obj.xml_name+"="+(sl.slmax+1-num);wpzb.moveobj=null;
}else if(sl.renwu=="兑换"){
rpg.hj-=num;rpg.glod+=sl.danjia*num;lt.help("兑换金币成功!")
}else if(sl.renwu=="打包"){
if(sl.danjia*num>rpg.glod)return lt.help("你的钱不够手续费")
if(wp_add("wp","黄金包",num)!=true)return;rpg.glod-=sl.danjia*num;rpg.hj-=num;
lt.help("打包了 "+num+" 两黄金,可用于玩家间交易");
}else if(sl.renwu=="存款"){
if(sl.danjia*num+rpg.cunkuan>parseInt(atmshangxian.innerText.substr(1)))return lt.help("存款余额不能大于存储上限!");
rpg.glod-=sl.danjia*num;rpg.cunkuan+=sl.danjia*num;atmyue.innerText=rpg.cunkuan;lt.help("你使用ATM存款机储蓄了"+(sl.danjia*num)+"元");
}else if(sl.renwu=="取款"){
rpg.glod+=sl.danjia*num;rpg.cunkuan-=sl.danjia*num;atmyue.innerText=rpg.cunkuan;lt.help("你使用ATM取款机提取了"+(sl.danjia*num)+"元");
}else if(sl.renwu=="注资"){
rpg.glod-=sl.danjia*num;gh.zichan+=sl.danjia*num;gh.open();
}
if(sl.wporck=="包裹")wpzb.wupin();if(sl.wporck=="仓库")sd.xuanxiang();gx_rpg();
},
close:function(){  //关闭
sl_kuang.style.visibility="hidden";sl.suoding=false;wpzb.moveobj=null;
}
}