
var teambattle_sel_userid="";var teambattle_sel_sceneid="";var get_is_busy=false;sanguoCls_choose_mainphoto=function(){try{var actor=$("actorselect").value;var url="/modules/sanguo.php?act=getactor&actor="+actor;}catch(e){var source_uid=arguments[0];var url="/modules/sanguo.php?act=getactor&actor=0&source_uid="+source_uid;}
pop_w=new Popup({contentType:1,isReloadOnClose:false,width:610,height:495,isSupportDraging:false,isHaveTitle:false});pop_w.setContent("title","更换角色");pop_w.setContent("contentUrl",url);pop_w.build();pop_w.show();}
sanguoCls_selfJoin=function(level_up){var pars="act=selfjoin";var par=[];par.push(pars);pars=par.join("&");var url="/ajax/sanguo.php";var ajax=new Ajax.Request(url,{method:'post',parameters:pars,onComplete:function(e){var temp=eval("("+e.responseText+")");if(temp.rtn_code=="nosession"){login_user_ajax();}else if(temp.rtn_code=="2"){fk_alert("你已经开通过三国了",250,50);}else if(temp.rtn_code=="0"){if(typeof level_up!="undefined"&&level_up!="")
window.location="/modules/sanguo.php?_m=1&level_up="+level_up;else
window.location="/modules/sanguo.php?_m=1";}else{fk_alert("系统错误!",250,50);}}});}
sanguoCls_req_teambattle_self=function(){var url="/ajax/sanguo.php";var par=[];var pars="act=req_teambattle_self";par.push(pars);pars=par.join("&");loadCls.Begin('btn_req_teambattle_self');new Ajax.Request(url,{method:"post",parameters:pars,onComplete:function(e){loadCls.End();var temp=eval("("+e.responseText+")");if(temp.rtn_code=="nosession"){login_user_ajax();}else if(temp.rtn_code=="0"){pop_w=new Popup({contentType:1,isReloadOnClose:false,width:500,height:470,isSupportDraging:true});pop_w.setContent("title","我要争霸");pop_w.setContent("contentUrl","/modules/sanguo.php?act=reqteambattle_tip");pop_w.build();pop_w.show();}else if(temp.rtn_code=="1"){fk_alert("我已经加入过争霸了！",250,50);}else if(temp.rtn_code=="2"){fk_alert("需要有部下才能玩游戏此环节哦~<p><a href='/modules/sanguo.php?act=attack'>现在就去战斗多俘虏几个部下！</a></p>");}else if(temp.rtn_code=="3"){var url="/modules/sanguo.php?act=getbuzubing";pop_w=new Popup({contentType:1,isReloadOnClose:false,width:430,height:300,isSupportDraging:true,isHaveTitle:true});pop_w.setContent("title","士兵不足提醒");pop_w.setContent("contentUrl",url);pop_w.build();pop_w.show();}else if(temp.rtn_code=="11"){var content="我军尚不足4级，无力争霸中原。不过如果上级参加了争霸，我们也可以支援TA一臂之力！";if(pop_w){pop_w.close();}
pop_w=new Popup({contentType:2,isReloadOnClose:false,width:350,height:50,isSupportDraging:false});pop_w.setContent("title","提示信息");pop_w.setContent("contentHtml","<div style='margin-top:35px;margin-bottom:40px;margin-left:30px;font-size:14px'>"+content+"</div>");if(typeof autoclose=="undefined"||autoclose==true){pop_w.setContent("time_out",4000);}
pop_w.build();pop_w.show();}else if(temp.rtn_code=="12"){var content="敌军尚不足4级，放TA一马吧！";if(pop_w){pop_w.close();}
pop_w=new Popup({contentType:2,isReloadOnClose:false,width:350,height:50,isSupportDraging:false});pop_w.setContent("title","提示信息");pop_w.setContent("contentHtml","<div style='margin-top:35px;margin-bottom:40px;margin-left:30px;font-size:14px'>"+content+"</div>");if(typeof autoclose=="undefined"||autoclose==true){pop_w.setContent("time_out",4000);}
pop_w.build();pop_w.show();}}});}
function sanguoCls_doteamBattle(){var url="/ajax/sanguo.php";var par=[];var pars="act=doteambattle";par.push(pars);pars="sid="+teambattle_sel_sceneid;par.push(pars);pars="uid="+teambattle_sel_userid;par.push(pars);pars=par.join("&");new Ajax.Request(url,{method:"post",parameters:pars,onComplete:function(e){var temp=eval("("+e.responseText+")");if(parent.sanguoCls.pop_w)parent.sanguoCls.pop_w.close();if(temp.rtn_code=="nosession"){login_user_ajax();}else if(temp.rtn_code=="0"){fk_alert("我成功参加团战了！");location.href=top.taskCls.addTaskToUrl("/modules/sanguo.php?act=teambattledetail&sid="+temp.content+"&_m=1",temp.task_check);}else if(temp.rtn_code=="1"){fk_alert("我已经加入过争霸了！");}else if(temp.rtn_code=="2"){fk_alert("TA已经加入过争霸了！");}else if(temp.rtn_code=="3"){fk_alert("需要有部下才能玩游戏此环节哦~<p><a href='/modules/sanguo.php?act=attack'>现在就去战斗多俘虏几个部下！</a></p>");}else if(temp.rtn_code=="4"||temp.rtn_code=="9"){fk_alert("你们是上下级关系，无法争霸！");}else if(temp.rtn_code=="5"){var url="/modules/sanguo.php?act=getbuzubing";pop_w=new Popup({contentType:1,isReloadOnClose:false,width:430,height:300,isSupportDraging:true,isHaveTitle:true});pop_w.setContent("title","士兵不足提醒");pop_w.setContent("contentUrl",url);pop_w.build();pop_w.show();}else if(temp.rtn_code=="6"){fk_alert("TA还没有手下将领，无法战斗！");}else if(temp.rtn_code=="7"){fk_alert("TA正在使用隐身，等TA隐身失效时再来决战或救部下吧！买照妖镜立刻就能打TA o(∩_∩)o...");}else if(temp.rtn_code=="8"){fk_alert("TA的士兵不够了！");}else if(temp.rtn_code=="10"){fk_alert("不能和自己争霸！");}else if(temp.rtn_code=="11"){var content="我军尚不足4级，无力争霸中原。不过如果上级参加了争霸，我们也可以支援TA一臂之力！";if(pop_w){pop_w.close();}
pop_w=new Popup({contentType:2,isReloadOnClose:false,width:350,height:50,isSupportDraging:false});pop_w.setContent("title","提示信息");pop_w.setContent("contentHtml","<div style='margin-top:35px;margin-bottom:40px;margin-left:30px;font-size:14px'>"+content+"</div>");if(typeof autoclose=="undefined"||autoclose==true){pop_w.setContent("time_out",4000);}
pop_w.build();pop_w.show();}else if(temp.rtn_code=="12"){var content="敌军尚不足4级，放TA一马吧！";if(pop_w){pop_w.close();}
pop_w=new Popup({contentType:2,isReloadOnClose:false,width:350,height:50,isSupportDraging:false});pop_w.setContent("title","提示信息");pop_w.setContent("contentHtml","<div style='margin-top:35px;margin-bottom:40px;margin-left:30px;font-size:14px'>"+content+"</div>");if(typeof autoclose=="undefined"||autoclose==true){pop_w.setContent("time_out",4000);}
pop_w.build();pop_w.show();}else{fk_alert("系统错误！");}}});}
function sanguoCls_req_teambattle_target(uid,obj,sceneId){var url="/ajax/sanguo.php";var par=[];var pars="act=req_teambattle_target";par.push(pars);pars="uid="+uid;par.push(pars);pars=par.join("&");loadCls.Begin(obj);new Ajax.Request(url,{method:"post",parameters:pars,onComplete:function(e){loadCls.End();var temp=eval("("+e.responseText+")");if(temp.rtn_code=="nosession"){login_user_ajax();}else if(temp.rtn_code=="0"){teambattle_sel_userid=uid;pop_w=new Popup({contentType:1,isReloadOnClose:false,width:400,height:300,isSupportDraging:true});pop_w.setContent("title","我要争霸");pop_w.setContent("contentUrl","/modules/sanguo.php?act=reqteambattle_tip&uid="+uid+(typeof(sceneId)=='string'?'&sceneid='+sceneId:''));pop_w.build();pop_w.show();}else if(temp.rtn_code=="1"){fk_alert("我正在争霸中！",250,50);}else if(temp.rtn_code=="2"){fk_alert("需要有部下才能玩游戏此环节哦~<p><a href='/modules/sanguo.php?act=attack'>现在就去战斗多俘虏几个部下！</a></p>");}else if(temp.rtn_code=="3"){var url="/modules/sanguo.php?act=getbuzubing";pop_w=new Popup({contentType:1,isReloadOnClose:false,width:430,height:300,isSupportDraging:true,isHaveTitle:true});pop_w.setContent("title","士兵不足提醒");pop_w.setContent("contentUrl",url);pop_w.build();pop_w.show();}else if(temp.rtn_code=="4"){fk_alert("TA正在争霸中！",250,50);}else if(temp.rtn_code=="5"){fk_alert("TA还没有手下将领，无法战斗！",250,50);}else if(temp.rtn_code=="6"){var url="/modules/sanguo.php?act=getbuzubing";pop_w=new Popup({contentType:1,isReloadOnClose:false,width:430,height:300,isSupportDraging:true,isHaveTitle:true});pop_w.setContent("title","士兵不足提醒");pop_w.setContent("contentUrl",url);pop_w.build();pop_w.show();}else if(temp.rtn_code=="7"){fk_alert("你们是上下级关系，无法争霸！",250,50);}else if(temp.rtn_code=="8"){fk_alert("TA正在使用隐身，等TA隐身失效时再来决战或救部下吧！买照妖镜立刻就能打TA o(∩_∩)o...",350,50);}else if(temp.rtn_code=="11"){fk_alert("我军尚不足4级，无力争霸中原。不过如果上级参加了争霸，我们也可以支援TA一臂之力！",350,50);}else if(temp.rtn_code=="12"){fk_alert("敌军尚不足4级，放TA一马吧！",350,50);}else{fk_alert("系统错误!",250,50);}}});}
function sanguoCls_attack(uid){var str;if(typeof pageName!="undefined"&&pageName!="")
var url="/ajax/sanguo.php?"+pageName;else
var url="/ajax/sanguo.php";var par=[];var pars="act=prepareforbattle";par.push(pars);var pars="uid="+uid;par.push(pars);pars=par.join("&");if($('attack_'+uid)){$('attack_'+uid).blur();}
loadCls.Begin('attack_'+uid);new Ajax.Request(url,{method:"post",parameters:pars,onComplete:function(e){loadCls.End();var temp=eval("("+e.responseText+")");if(temp.rtn_code=="nosession"){login_user_ajax();}else{switch(temp.rtn_code){case'0':break;case'1':str="我的士兵不够了！记住了，每小时你会补充一次士兵。拿越多KOO分，士兵就补充越多！";break;case'2':str="TA的士兵不够了！";break;case'4':str="TA正在使用隐身，等TA隐身失效时再来决战或救部下吧！买照妖镜立刻就能打TA o(∩_∩)o...";break;case'7':str="你要挑战的人不存在！";break;case'8':str="你还没有登陆！";break;case'9':str="你和TA还没有参加三国！";break;case'10':str="你还没有参加三国！";break;case'11':str="TA还没有参加三国！";break;case'12':str="你不能和自己战斗！";break;case'19':str="使用了金钟罩，每天最多打同一用户5次哦！";break;}
if(temp.rtn_code=='13'||temp.rtn_code=='14'||temp.rtn_code=='15'||temp.rtn_code=='16'||temp.rtn_code=='17'||temp.rtn_code=='18'||temp.rtn_code=='3'){var url="/modules/sanguo.php?act=preparebattle&uid="+uid+"&battletype="+temp.rtn_code;if(temp.rtn_code=='15'||temp.rtn_code=='18'){pop_w=new Popup({contentType:1,isReloadOnClose:false,width:616,height:337,isSupportDraging:true,isHaveTitle:false});}else{pop_w=new Popup({contentType:1,isReloadOnClose:false,width:616,height:367,isSupportDraging:true,isHaveTitle:false});}
pop_w.setContent("contentUrl",url);pop_w.build();pop_w.show();}else if(temp.rtn_code==1||temp.rtn_code==0){var url="/modules/sanguo.php?act=getbuzubing";pop_w=new Popup({contentType:1,isReloadOnClose:false,width:430,height:300,isSupportDraging:true,isHaveTitle:true});pop_w.setContent("title","士兵不足提醒");pop_w.setContent("contentUrl",url);pop_w.build();pop_w.show();}else{fk_alert(str);}}}});}
function sanguoCls_support_master(battleid,type){var url="/ajax/sanguo.php";var par=[];var pars="act=support_master_before";par.push(pars);pars="battleid="+battleid;par.push(pars);pars="type="+type;par.push(pars);pars=par.join("&");new Ajax.Request(url,{method:"post",parameters:pars,onComplete:function(e){var temp=eval("("+e.responseText+")");if(temp.rtn_code=="nosession"){login_user_ajax();}else if(temp.rtn_code=="0"){var leftsnum=Math.round(parseInt(temp.rtn_solider)/2);var str="<div style='font-size:14px' class='m_top15 m_left15 m_right15'><p>力挺上级，将调配你现在兵力的50%给上级。</p><p>现有兵力："+temp.rtn_solider+"<span class='m_left15'>调配给上级："+leftsnum+"</span></p><p style='font-size:12px;'>战争若胜利，你的各点数会上升！若士兵数有剩余，将返</div>还！</p><p class='m_top10 t_center'><input type='button' class='newbtn_input' onclick='sanguoCls_support_master_collback(\""+battleid+"\","+type+");' value='确定增援' /></p>";fk_alert(str,350,40,false);}else if(temp.rtn_code=="1"||temp.rtn_code=="false"){fk_alert("你的士兵目前不足以增援你的上级，等士兵大于1000时再来吧。");}else if(temp.rtn_code=='2'){fk_alert("你早就加入这场战役啦！等待胜利的消息吧！");}}});}
function sanguoCls_support_master_collback(battleid,type){if(get_is_busy)
return;get_is_busy=true;var url="/ajax/sanguo.php";var par=[];var pars="act=support_master";par.push(pars);pars="battleid="+battleid;par.push(pars);pars="type="+type;par.push(pars);pars=par.join("&");new Ajax.Request(url,{method:"post",parameters:pars,onComplete:function(e){var temp=eval("("+e.responseText+")");if(temp.rtn_code=="nosession"){login_user_ajax();}else if(temp.rtn_code=="0"){fk_alert("加入成功！",250,50);}else if(temp.rtn_code=="1"){fk_alert("你的士兵目前不足以增援你的上级，等士兵大于1000时再来吧。");}else if(temp.rtn_code=="2"){fk_alert("非法操作,对方不是你的上级！");}else if(temp.rtn_code=="3"){fk_alert("你早就加入这场战役啦！等待胜利的消息吧！");}else if(temp.rtn_code=="4"){fk_alert("系统错误，请重试！",250,50);}else if(temp.rtn_code=="5"){fk_alert("非法的参数！",250,50);}else if(temp.rtn_code=="6"){fk_alert("他的队伍已经满员，下次记得早点儿报名哦！");}else if(temp.rtn_code=="7"){fk_alert("此战役已经结束了，下次再参与吧！");}
get_is_busy=false;}});}