bizqqwpa.define("util.domain",function(){var domain={},dm=document.domain;try{domain.url=location.href}catch(e){domain.url=""}domain.topdomain=function(){var reg1=/\.(?:(?:edu|gov|com|org|net)\.cn|co\.nz)$/,reg2=/^[12]?\d?\d\.[12]?\d?\d\.[12]?\d?\d\.[12]?\d?\d$/,slicepos=reg1.test(dm)?-3:reg2.test(dm)?0:-2;return dm.split(".").slice(slicepos).join(".")}();domain.domain=function(){var reg=/(?::[\/]{2}|:[\\]{3})([a-za-z0-9_\.]+)/;try{var ret=reg.exec(domain.url);return ret?ret[1]||dm:dm}catch(e){return dm}}();return domain});bizqqwpa.define("wpa.wpamgr","globalsettings,lang.each,util.proxy,util.cookie,util.titleflash,util.report,util.serialize,util.domain,wpa.wpa",function(require){var globalsettings=require("globalsettings"),each=require("each"),proxy=require("proxy"),titleflash=require("titleflash"),report=require("report"),serialize=require("serialize"),domain=require("domain"),cookie=require("cookie"),wpa=require("wpa");var report_possibility=40;var passrandom=function(poss){var r=poss||10;if(math.random()*100<=r){return true}return false};var reportwpa=function(url,opts){if(passrandom(report_possibility)){report(url+"?"+serialize(opts))}};var displayreport=function(params){var url="http://prom.b.qq.com/wpadisplay/r.gif?",optsarr=["wty","type","nameaccount","kfuin","ws","aty","a","title","wording","wording2"],reportopts={version:globalsettings.version};each(optsarr,function(){reportopts[this]=typeof params[this]==="undefined"?"":params[this]});report(url+serialize(reportopts))};return{newwpa:function(params){var nameaccount=params.nameaccount;if(!nameaccount){return}displayreport(params);reportwpa("http://report.b.qq.com/crmreport/accesslog",{fuid:cookie.get("pgv_pvi"),fkfuin:params.kfuin,fna:params.nameaccount,frurl:window.document.referrer});return new wpa(params)},invite:function(params,di){var mgr=this,defaultinvite=function(){titleflash.on("【您有新信息】");params.insert=function(node){var body=document.getelementsbytagname("body")[0];body.insertbefore(node,body.firstchild)};mgr.newwpa(params)};if(!di){defaultinvite();return}try{var chat=proxy({params:params},wpa.prototype.launchchat);window[di]&&window[di](chat,params["msg"])}catch(e){defaultinvite()}}}});bizqqwpa.define("wpa.visitor","lang.browser,util.log,util.speedreport,util.getjsonp,util.domain,util.pubsub,wpa.filter,wpa.ta,wpa.invite,wpa.wpamgr,wpa.ta,wpa.kfuin",function(require){var invite=require("invite"),domain=require("domain"),filter=require("filter"),getjsonp=require("getjsonp"),pubsub=require("pubsub"),log=require("log"),speedreport=require("speedreport"),ta=require("ta"),kfuincahe=require("kfuin"),browser=require("browser");var crm_block_on_serverside=1;var get_config_url="http://visitor.crm2.qq.com/cgi/visitorcgi/ajax/wpa_first_heart_beat.php";return function(config){var nameaccount=config.nameaccount;if(!nameaccount||nameaccount==="undefined"){return}if(invite.isloaded(nameaccount)||!filter.ta){return}var uid,cfg,launch=function(uid,cfg){if(!uid||!cfg){return}if(cfg.block===crm_block_on_serverside){return}if(browser&&browser.ua){var spiderreg=/spider|bot|^\s*$/;if(spiderreg.test(browser.ua)){return}}if(filter.crm){cfg.di=config.di;cfg.kfuin=config.kfuin;log(nameaccount+" try launch slave");invite.load(nameaccount,uid,cfg)}};pubsub.one("ta.loaded",function(data){uid=data;launch(uid,cfg)});pubsub.one("invite.first",function(data){cfg=data;launch(uid,cfg)});ta(nameaccount,domain.topdomain,function(uid){pubsub.pub("ta.loaded",uid)});var opts={nameaccount:nameaccount,dm:domain.topdomain,title:document.title,url:location.href.split("://")[1].split("?")[0]};getjsonp(get_config_url,opts,function(cfg){pubsub.pub("invite.first",cfg)});config.kfuin&&kfuincahe.set(nameaccount,config.kfuin)}});bizqqwpa.define("wpa.kfuin","util.getjsonp",function(require){var getjsonp=require("getjsonp");var get_kfuin_url="http://wpl.b.qq.com/cgi/conv.php";var kfuins={};return{get:function(nameaccount,callback){callback=callback||function(){};if(!nameaccount||kfuins[nameaccount]){callback(kfuins[nameaccount]);return}var opts={num:nameaccount};getjsonp(get_kfuin_url,opts,function(rs){if(!rs||rs.r!==0){callback();return}var kfuin=kfuins[nameaccount]=rs.data.kfuin;callback(kfuin)})},set:function(nameaccount,kfuin){kfuins[nameaccount]=kfuin}}});bizqqwpa.define("util.proxy",function(){return function(ns,fn){return function(){return fn.apply(ns,arguments)}}});bizqqwpa.define("util.titleflash","util.taskmgr",function(require){var title_flash_gap=120;var taskmgr=require("taskmgr");var doc=document,title=doc.title,task=taskmgr.newtask(function(){var t=doc.title;doc.title=t.substr(1,t.length)+t.substr(0,1)},title_flash_gap);return titleflash={on:function(msg){doc.title=msg+(""+doc.title);task.run()},off:function(){task.pause();doc.title=title}}});bizqqwpa.define("util.cookie",function(){var doc=document;return{set:function(name,value,domain,path,expires){if(expires){expires=new date(+new date+expires)}var tempcookie=name+"="+escape(value)+(expires?"; expires="+expires.togmtstring():"")+(path?"; path="+path:"")+(domain?"; domain="+domain:"");if(tempcookie.length<4096){doc.cookie=tempcookie}},get:function(name){var carr=doc.cookie.match(new regexp("(^| )"+name+"=([^;]*)(;|$)"));if(carr!=null){return unescape(carr[2])}return null},del:function(name,domain,path){if(this.get(name)){doc.cookie=name+"="+(path?"; path="+path:"")+(domain?"; domain="+domain:"")+";expires=thu, 01-jan-1970 00:00:01 gmt"}},find:function(pattern){return doc.cookie.match(pattern).split(",")}}});bizqqwpa.define("wpa.wpa","globalsettings,lang.browser,util.cookie,lang.typeenhance,util.serialize,util.proxy,util.pad,util.bits,util.getscript,util.getjsonp,util.domain,util.events,util.onload,util.offset,util.report,util.log,util.speedreport,wpa.selectpanel,util.oniframeloaded,util.guid,wpa.getqqversion,wpa.viewhelper,wpa.views,wpa.ta,wpa.kfuin,wpa.sid",function(require){var globalsettings=require("globalsettings"),proxy=require("proxy"),typeenhance=require("typeenhance"),pad=require("pad"),bits=require("bits"),getscript=require("getscript"),getjsonp=require("getjsonp"),domain=require("domain"),events=require("events"),onload=require("onload"),serialize=require("serialize"),browser=require("browser"),offset=require("offset"),report=require("report"),log=require("log"),speedreport=require("speedreport"),guid=require("guid"),selectpanel=require("selectpanel"),oniframeloaded=require("oniframeloaded"),getqqversion=require("getqqversion"),viewhelper=require("viewhelper"),views=require("views"),ta=require("ta"),kfuincache=require("kfuin"),cookie=require("cookie"),sidcache=require("sid");var global=window;var wpa_type_ta_invite_only="0",wpa_type_normal="1",wpa_type_link="2",wpa_type_custom="3",session_version_ta="4",wpa_style_type_invite="20",appointed_type_auto="0",appointed_type_kfext="1",appointed_type_group="2",wpa_float_type_fixed="0",wpa_float_type_scroll="1",wpa_float_position_x_left="0",wpa_float_position_x_center="1",wpa_float_position_x_right="2",wpa_float_position_y_top="0",wpa_float_position_y_center="1",wpa_float_position_y_bottom="2",is_invite_wpa_false="0",is_invite_wpa_true="1",chat_type_aio=1,chat_type_anonymous=2;var speed_report_display=.1,report_possibility=40;var passrandom=function(poss){var r=poss||10;if(math.random()*100<=r){return true}return false};var reportwpa=function(url,opts){if(passrandom(report_possibility)){report(url+"?"+serialize(opts))}};var wpa=function(params){this.params=params;this.insert=params.insert;this.wty=params.wty;var self=this,nameaccount=this.nameaccount=params.nameaccount,kfuin=this.kfuin=params.kfuin;switch(this.wty){case wpa_type_normal:this.render();break;case wpa_type_custom:this.custom()}!this.kfuin&&kfuincache.get(nameaccount,function(data){data&&(self.kfuin=data)});!this.sid&&sidcache.get(nameaccount,function(data){data&&(self.sid=data)});report("http://prom.b.qq.com/se/r.gif?na="+nameaccount+"&ref="+encodeuricomponent(document.referrer))};wpa.prototype={render:function(){var params=this.params;var width,height,type=parseint(params["type"]),typestr,isfloat=false;switch(type){case 1:typestr="a01";width=92;height=22;break;case 2:typestr="a02";width=77;height=22;break;case 10:typestr="b01";width=93;height=151;isfloat=true;break;case 11:typestr="b02";width=327;height=172;isfloat=true;break;case 12:typestr="b03";width=121;height=277;isfloat=true;break;case 20:typestr="i01";width=327;height=172;isfloat=true;break;case 30:typestr="d01";width=params["txw"];height=params["txh"];isfloat=true;break}this.type=typestr;this.width=width;this.height=height;this.createwpa();if(type>9&&type<14||type===20||type===30){this.initfloatwpa()}},createwpa:function(){var speedrpt=speedreport("7818","21","1");var wpa=this,type=this.type,width=this.width,height=this.height,view=views[type];var iframe;try{iframe=document.createelement('')}catch(e){iframe=document.createelement("iframe");iframe.width=width;iframe.height=height;iframe.setattribute("scrolling","no");iframe.setattribute("frameborder",0);iframe.setattribute("allowtransparency",true);iframe.setattribute("src","about:blank")}this.node=iframe;this.insert(iframe);if(browser.msie){try{var accesstest=iframe.contentwindow.document}catch(e){iframe.src="javascript:void((function(){document.open();document.domain='"+document.domain+"';document.close()})())"}}var loaded=function(){var iwin=iframe.contentwindow,idoc=iframe.contentdocument||iwin.document;idoc.open();idoc.write(['','',"",'',browser.msie&&iframe.src!=="about:blank"?"":"","","",view.templ,"",""].join(""));idoc.close();var helper=new viewhelper(idoc,wpa);view.init(idoc,helper);var point=1;speedrpt.addpoint(point).send(speed_report_display)};oniframeloaded(iframe,loaded)},initfloatwpa:function(){var doc=window.document,params=this.params,type=parseint(params["type"]),node=this.node,width=this.width,height=this.height;node.style.csstext=["display:none;","position:absolute;",type===20?"z-index:2147483647!important;":"z-index:2147483646!important;"].join(" ");onload(initiframeload);function initiframeload(){var isty=node.style,isie=browser.msie,ver=parseint(browser.version,10),isquirk=doc.compatmode==="backcompat";isty.position=parseint(params["fsty"],10)==0?"fixed":"absolute";if(parseint(params["fposx"])==0){isty.left=8+"px";isty.right="auto";isty.marginleft=0}else if(parseint(params["fposx"])==1){isty.left="50%";isty.right="auto";isty.marginleft="-"+parseint(width/2)+"px"}else{isty.left="auto";isty.right=8+"px";isty.marginleft=0}if(parseint(params["fposy"])==0){isty.top=8+"px";isty.bottom="auto";isty.margintop=0}else if(parseint(params["fposy"])==1){isty.top="50%";isty.bottom="auto";isty.margintop="-"+parseint(height/2)+"px"}else{isty.top="auto";isty.bottom=8+"px";isty.margintop=0}if(isie&ver<7||isquirk){isty.position="absolute";if(parseint(params["fsty"])==0){isty.margintop=0;var itop;if(parseint(params["fposy"])==0){itop=8}else if(parseint(params["fposy"])==1){itop=(offset.getclientheight(doc)-height)/2}else{itop=offset.getclientheight(doc)-height-8}setinterval(function(){isty.top=offset.getscrolltop(doc)+itop+"px"},128)}}isty.display="block"}},custom:function(){events.addevent(this.params.node,"click",proxy(this,this.launchchat))},remove:function(){var node=this.node;node.parentnode.removechild(node)},launchchat:function(callback){var wpa=this,sptreport=speedreport("7818","21","2"),chattype=this.params.chattype;reportwpa("http://report.b.qq.com/crmreport/clicklog",{fuid:cookie.get("pgv_pvi"),fkfuin:wpa.params.kfuin,fna:wpa.params.nameaccount,frurl:global.document.referrer});if(browser.isios||browser.isandroid){this.launchmobilechat();return}if(chattype==chat_type_anonymous){wpa.launchanonymouschat(callback);return}if(chattype==chat_type_aio){wpa.launchaiochat(callback);return}!browser.msie&&wpa.launchaiochat(callback);getqqversion(function(version){sptreport.addpoint(7).send();if(version){browser.msie&&wpa.launchaiochat(callback);return}new selectpanel({onaiochat:function(){wpa.launchaiochat(callback)},onanonychat:function(){wpa.launchanonymouschat(callback)}})})},launchmobilechat:function(){var nameaccount=this.params.nameaccount;kfuincache.get(nameaccount,function(kfuin){if(navigator.useragent.indexof("micromessenger")>-1&&domain.domain.indexof("qq.com")===-1){location.href="http://wpd.b.qq.com/page/info.php?nameaccount="+nameaccount;return}launch(schema(),fallback);function schema(){var dm=domain.domain,type="crm";if(browser.isqq&&browser.qqversion==="4.5"){type="wpa"}return browser.isandroid&&browser.chrome&&parseint(browser.version,10)>25?"intent://im/chat?chat_type="+type+"&uin="+kfuin+"&version=1&src_type=web&web_src="+location.protocol+"://"+dm+"#intent;scheme=mqqwpa;action=android.intent.action.view;end":"mqqwpa://im/chat?chat_type="+type+"&uin="+kfuin+"&version=1&src_type=web&web_src="+location.protocol+"://"+dm}function launch(schema,fail){var start=+new date;location.href=schema;settimeout(function(){var gap=+new date-start;if(gap<1e3){fail&&fail()}},800)}function fallback(){location.href="http://wpd.b.qq.com/page/info.php?nameaccount="+nameaccount}})},launchaiochat:function(){var iframe=document.createelement("iframe"),body=document.getelementsbytagname("body")[0];iframe.style.display="none";body.insertbefore(iframe,body.firstchild);return function(callback){var params=this.params,kfuin=this.kfuin,opts={na:params.nameaccount,kfuin:kfuin,aty:params.aty,a:params.a,sid:this.sid,uid:ta.uid,url:domain.url,title:document.title,dm:domain.topdomain,clksrc:params.clksrc||"",ext:params.ext||""},guid=guid();var sptreport=speedreport("7818","21","2");getjsonp("http://wpd.b.qq.com/cgi/get_sign.php",opts,function(rs){if(!rs||rs.r!==0||!rs.data){return}iframe.src=rs.data.sign;var isloaded=false,loaded=function(){if(isloaded){return}isloaded=true;var clickid=rs.data.clkid;sptreport.addpoint(5).send();report("http://promreport.crm2.qq.com/wpaclick/r.gif?ty=1&kfuin="+kfuin+"&version="+globalsettings.version+"&browser="+encodeuricomponent(navigator.useragent)+"&bfrom=1&appointtype="+params.aty+"&appoint="+params.a+"&clkid="+clickid+"&guid="+guid);global.taclick&&global.taclick(clickid,"clickid");typeenhance.isfunction(callback)&&settimeout(function(){callback(params)},1e3)};oniframeloaded(iframe,loaded);if(browser.msie){var fallback=function(){settimeout(function(){if(isloaded){return}/interactive/.test(iframe.readystate)?loaded():fallback()},500)};fallback()}});report("http://promreport.crm2.qq.com/wpaclickorg/r.gif?kfuin="+kfuin+"&version="+globalsettings.version+"&browser="+encodeuricomponent(navigator.useragent)+"&bfrom=1&appointtype="+params.aty+"&appoint="+params.a+"&guid="+guid)}}(),launchanonymouschat:function(callback){var params=this.params,sptreport=speedreport("7818","21","2"),url="http://wpd.b.qq.com/page/webchat.html?nameaccount="+this.nameaccount,opener=window.open(url,"_blank","height=516, width=598,toolbar=no,scrollbars=no,menubar=no,status=no,location=no");typeenhance.isfunction(callback)&&callback(params);report("http://promreport.crm2.qq.com/wpaclick/r.gif?ty=2&kfuin="+this.kfuin+"&version="+globalsettings.version+"&browser="+encodeuricomponent(navigator.useragent)+"&bfrom=1&appointtype="+params.aty+"&appoint="+params.a);opener.onload=function(){sptreport.addpoint(6).send()}}};return wpa});bizqqwpa.define("util.getjsonp","util.getscript,util.serialize",function(require){var getscript=require("getscript"),serialize=require("serialize");var count=0;return function(url,options,callback){var fnname="jsonp_callback_"+ ++count+"_"+math.round(math.random()*100),script;options.cb=fnname;url+=url.indexof("?")===-1?"?":"&";url+=serialize(options);script=getscript(url);window[fnname]=function(json){callback(json);settimeout(function(){window[fnname]=null;script.parentnode.removechild(script)},1)}}});bizqqwpa.define("wpa.filter","util.domain",function(require){var ta_blacklist="",crm_blacklist="qq.com,pengyou.com,qzoneapp.com,nipic.com,docin.com,51zxw.net,2155.com,xd.com,yto.net.cn,c-c.com,27.cn,05wan.com,alivv.cn,gogo.com,doctorjob.com.cn,emoney.cn,m4.cn,chinaktv.net,yk988.com,bangkaow.com,wsxsp.com,55tools.com,youxi518.com",crm_whitelist="b.qq.com,sales.b.qq.com,guilin.house.qq.com,ta.qq.com,hn.qq.com,nantong.house.qq.com";var domain=require("domain");return{ta:function(){var dm=domain.topdomain,ipreg=/^[12]?\d?\d\.[12]?\d?\d\.[12]?\d?\d\.[12]?\d?\d$/,localreg=/^localhost$/,previewpagereg=/^wpa\.b\.qq\.com/;return ta_blacklist.indexof(dm)===-1&&!ipreg.test(dm)&&!localreg.test(dm)&&!previewpagereg.test(domain.domain)}(),crm:function(){try{var reg=new regexp("(^|,)"+domain.domain);if(reg.test(crm_whitelist)){return true}var dm=domain.topdomain,dmreg=new regexp("(^|,)"+dm),ipreg=/^[12]?\d?\d\.[12]?\d?\d\.[12]?\d?\d\.[12]?\d?\d$/,localreg=/^localhost$/;return!dmreg.test(crm_blacklist)&&!ipreg.test(dm)&&!localreg.test(dm)}catch(e){}}()}});bizqqwpa.define("wpa.ta","util.getscript,util.serialize,util.cookie",function(require){var url="http://tajs.qq.com/crmqq.php",uid_cookie_name="pgv_pvi";var getscript=require("getscript"),serialize=require("serialize"),cookie=require("cookie");var loaded=false;var ta=function(nameaccount,domain,callback){var istriggered=false;if(ta.uid){callback(ta.uid);istriggered=true}if(!loaded){var options={uid:nameaccount,dm:domain},url=url+"?"+serialize(options,"=","&");getscript(url,function(){loaded=true;if(istriggered){return}ta.uid=cookie.get(uid_cookie_name);if(ta.uid){callback(ta.uid)}else{settimeout(arguments.callee,30)}})}};ta.uid=cookie.get(uid_cookie_name)||"";return ta});bizqqwpa.define("wpa.invite","util.log,util.getjsonp,util.proxy,util.domain,util.blockstorage,util.taskmgr,wpa.wpamgr",function(require){var master_monitor_gap=2e3,invite_monitor_gap=1e3,master_heatbeat_gap=2e3,slave_heartbeat_gap=2e3,server_monitor_gap_min=5e3,server_monitor_gap_max=15e3,server_monitor_sleepcheck_gap=36e5,server_monitor_sleeping_gap=1e3;var invite_signal="is",invite_kfext="ik",invite_msg="msg",master_heartbeats="mh",master_id="mid",slave_ids="slid";var invite_signal_uninvited="0",invite_signal_invite="1",invite_signal_invited="2",invite_kfext_auto="0",master_heartbeats_error="-1",data_seperator="|";var heartbeat_url="http://visitor.crm2.qq.com/cgi/visitorcgi/ajax/wpa_heart_beat.php",confirm_auto_invite_url="http://visitor.crm2.qq.com/cgi/visitorcgi/ajax/auto_invite.php";var result_success=0,invite_state_uninvited="0",invite_state_invite="1",invite_state_invited="2",auto_invite_true=1;var wpa_type_ta_invite_only="0",wpa_type_normal="1",wpa_type_link="2",session_version_ta="4",wpa_style_type_invite="20",appointed_type_auto="0",appointed_type_kfext="1",appointed_type_group="2",appointed_type_auto_invite="4",appointed_type_invite="5";var wpa_float_type_fixed="0",wpa_float_position_y_center="1",wpa_float_position_x_center="1",is_invite_wpa_false="0",is_invite_wpa_true="1";var log=require("log"),getjsonp=require("getjsonp"),proxy=require("proxy"),domain=require("domain"),blockstorage=require("blockstorage"),taskmgr=require("taskmgr"),wpamgr=require("wpamgr");var slave=function(nameaccount,uid,cfg){this.nameaccount=nameaccount;this.uid=uid;this.config=cfg;this.genid();this.storage=blockstorage(nameaccount);this.monitors={master:taskmgr.newtask(proxy(this,this.mastermonitor),master_monitor_gap).run(),invite:taskmgr.newtask(proxy(this,this.invitemonitor),invite_monitor_gap).run()};this.heartbeat=taskmgr.newtask(proxy(this,this.heartbeatprocess),slave_heartbeat_gap).run();this.setactive();window.onfocus=proxy(this,this.setactive);log("slave "+this.id+" launched!")};slave.prototype={genid:function(){this.id="slid_"+ +new date%1e3+"_"+math.round(math.random()*100)},mastermonitor:function(){if(masters[this.nameaccount]){return}log("monitoring mater state");var lastmasterheartbeat=this.storage.get(master_heartbeats)||0,gap=+new date-parseint(lastmasterheartbeat);log("gap of master is "+gap);if(gap>3*master_heatbeat_gap){this.recovermaster()}},recovermaster:function(){masters[this.nameaccount]=new master(this.nameaccount,this.uid,this.config);log("recover master by slave "+this.id)},invitemonitor:function(){if(this.isinvited()){this.kill()}else if(this.isinviting()){if(this.isactive()){this.invite()}}log("slave "+this.id+" monitoring invite state")},kill:function(){this.monitors.invite.drop();this.heartbeat.drop();var storage=this.storage,keys=[this.id];for(var i=0,key;key=keys[i++];){storage.del(key)}log("slave "+this.id+" killed")},invite:function(){var kfext=this.storage.get(invite_kfext);var params={wty:wpa_type_normal,nameaccount:this.nameaccount,kfuin:this.config.kfuin,type:wpa_style_type_invite,aty:kfext?kfext===invite_kfext_auto?appointed_type_auto_invite:appointed_type_invite:appointed_type_auto_invite,a:kfext||"",iv:is_invite_wpa_true,fsty:wpa_float_type_fixed,fposx:wpa_float_position_x_center,fposy:wpa_float_position_y_center,sv:session_version_ta,uid:this.uid,dm:domain.topdomain,msg:this.storage.get(invite_msg)};wpamgr.invite(params,this.config.di);this.storage.set(invite_signal,invite_signal_invited);log("invited by slave "+this.id)},heartbeatprocess:function(){var storage=this.storage,ids=storage.get(slave_ids);if(!ids){storage.set(slave_ids,this.id+"|")}else if(ids.indexof(this.id+"|")===-1){storage.set(slave_ids,this.id+"|"+ids)}storage.set(this.id,+new date)},setactive:function(){var storage=this.storage,ids=storage.get(slave_ids)||"",sign=this.id+data_seperator;if(ids.indexof(this.id)>-1){ids=ids.replace(sign,"")}ids+=sign;storage.set(slave_ids,ids)},isactive:function(){var slaves=this.storage.get(slave_ids);if(!slaves){return false}return slaves.substr(0,slaves.length-1).split(data_seperator).pop()===this.id},isinvited:function(){return this.storage.get(invite_signal)===invite_signal_invited},isinviting:function(){return this.storage.get(invite_signal)===invite_signal_invite}};var masters={};var master=function(nameaccount,uid,cfg){this.nameaccount=nameaccount;this.uid=uid;this.config=cfg;this.storage=blockstorage(nameaccount);this.genid();this.sleep=false;this.heartbeaturl=cfg.hbdomain||heartbeat_url;this.storage.set(master_id,this.id);this.heartbeatprocess();this.heartbeat=taskmgr.newtask(proxy(this,this.heartbeatprocess),master_heatbeat_gap).run();this.initwithconfig();log("master launched!")};master.prototype={genid:function(){this.id=+new date%1e3+"_"+math.round(math.random()*100)},setinvitestate:function(signal,kfext,msg){if(signal===invite_signal_invite){this.storage.set(invite_kfext,kfext);this.storage.set(invite_msg,msg)}this.storage.set(invite_signal,signal)},isinvited:function(){var invited=this.storage.get(invite_signal)===invite_signal_invited;if(invited){this.recycle();this.isinvited=function(){return true}}return invited},initwithconfig:function(){var cfg=this.config;if(cfg.r!==result_success){this.storage.set(master_heartbeats,master_heartbeats_error);return}if(cfg.isauto===auto_invite_true){this.storage.set(invite_msg,cfg.automsg);this.autoinvitetimer=settimeout(proxy(this,function(){this.autoinvite()}),cfg.autotime*1e3)}this.monitors={slave:taskmgr.newtask(proxy(this,this.slavemonitor),slave_heartbeat_gap).run(),server:taskmgr.newtask(proxy(this,this.servermonitor),server_monitor_gap_min).run(),sleep:taskmgr.newtask(proxy(this,this.sleepmonitor),server_monitor_sleepcheck_gap).run()};log("master inited with config")},autoinvite:function(){if(this.isinvited()){return}var opt={nameaccount:this.nameaccount,uid:this.uid};var servermonitor=this.monitors.server;servermonitor.pause();getjsonp(confirm_auto_invite_url,opt,proxy(this,function(rs){if(rs.r!==result_success){servermonitor.run();return}if(!this.isinvited()){this.setinvitestate(invite_signal_invite,invite_kfext_auto,this.storage.get(invite_msg));taskmgr.once(function(){servermonitor.run()},5e3).run()}}))},ajustservermonitorgap:function(time){this.monitors.server.setgap(math.min(math.max(server_monitor_gap_min,time),server_monitor_gap_max))},servermonitor:function(){var invitesignal=this.storage.get(invite_signal);if(this.sleep){return}var opt={nameaccount:this.nameaccount,uid:this.uid};if(invitesignal===invite_signal_invite){opt["invitestate"]=invite_state_invite}if(invitesignal===invite_signal_invited){opt["invitestate"]=invite_state_invited}getjsonp(this.heartbeaturl,opt,proxy(this,function(rs){if(rs.r!==result_success){return}if(rs.gap){this.ajustservermonitorgap(rs.gap*1e3)}if(rs.invitestate===invite_state_uninvited){return}if(rs.invitestate===invite_state_invite){this.setinvitestate(invite_signal_invite,rs.kfext,rs.invitemsg);return}if(rs.invitestate===invite_state_invited){this.setinvitestate(invite_signal_invited)}}))},slavemonitor:function(){if(this.isinvited()){this.monitors.slave.drop()}var storage=this.storage,slaves=storage.get(slave_ids);if(!slaves){return}slaves=slaves.split(data_seperator);var aliveslaves="",time=+new date,lastslaveheartbeat,slave,gap;for(var i=0;slave=slaves[i++];){log("monitoring slave "+slave+" state");lastslaveheartbeat=storage.get(slave)||0;gap=time-parseint(lastslaveheartbeat);log("gap of slave "+slave+" is "+gap);if(gap>3*slave_heartbeat_gap){storage.del(slave);log("clear slave "+slave+" in storage")}else{aliveslaves+=slave+data_seperator}}storage.set(slave_ids,aliveslaves)},sleepmonitor:function(){var slaves=this.storage.get(slave_ids)||"",activeslave=slaves.substr(0,slaves.length-1).split(data_seperator).pop();if(this.sleep){if(this.activeslave!==activeslave){this.activeslave=activeslave;this.sleep=false;this.monitors.sleep.setgap(server_monitor_sleepcheck_gap)}}else{if(this.activeslave===activeslave){this.sleep=true;this.monitors.sleep.setgap(server_monitor_sleeping_gap)}else{this.activeslave=activeslave}}},kill:function(){masters[this.nameaccount]=undefined;if(this.monitors){this.monitors.server.drop();this.monitors.slave.drop();this.heartbeat.drop();cleartimeout(this.autoinvitetimer)}log("master killed")},recycle:function(){var storage=this.storage,keys=[invite_kfext,invite_msg];for(var i=0,key;key=keys[i++];){storage.del(key)}log("storage recycled")},heartbeatprocess:function(){var storage=this.storage;if(storage.get(master_id)!==this.id){this.kill();return false}this.storage.set(master_heartbeats,+new date)}};var slaves={};return{load:function(nameaccount,uid,cfg){if(this.isloaded(nameaccount)){log(nameaccount+" slave already running");return}var slave=new slave(nameaccount,uid,cfg);slaves[nameaccount]?slaves[nameaccount].push(slave):slaves[nameaccount]=[slave]},isloaded:function(nameaccount){return typeof slaves[nameaccount]!=="undefined"}}});bizqqwpa.define("util.taskmgr","util.proxy",function(require){var task_run="run",task_pause="pause",task_drop="drop",loop_time=50;var proxy=require("proxy");var tm=function(){this.circle=[];this.pos=0;setinterval(proxy(this,this.loop),16)};tm.prototype={newtask:function(fn,gap){var t=new task(fn,gap);this.circle.push(t);return t},once:function(fn,gap){return this.newtask(function(){fn.apply(this);this.drop()},gap)},loop:function(){var c=this.circle,pos=this.pos,count=c.length,start=+new date,looptime=loop_time,t=c[pos];while(count>0&&+new date-start-1&&(matchie11=/rv:([\d.]+)/.exec(ua))){match[1]="msie";match[2]=matchie11[1]}var matched={browser:match[1]||"",version:match[2]||"0"};if(matched.browser){browser[matched.browser]=true;browser.version=matched.version}if(browser.chrome){browser.webkit=true}else if(browser.webkit){browser.safari=true}var ismobile=browser.ismobile=ua.match(/(nokia|iphone|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|coolpad|webos|techfaith|palmsource|blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220)/i);browser.iswindow=/windows|win32/.test(ua);browser.ismac=/mac/.test(ua);browser.isios=/(?:iphone|ipad|ipod)/i.test(ua);browser.isandroid=/android/i.test(ua);if(ismobile){var qqreg=/qq\/(\d+\.\d+)\.\d/,oldqqreg=/v1_and_sq_(\d+\.\d+)\.\d/,match=qqreg.exec(ua)||oldqqreg.exec(ua);browser.isqq=!match;match&&(browser.qqversion=match[1])}return browser});bizqqwpa.define("util.pad",function(){return function(str,pad,length,isleft){var padlength=length-str.length,i;if(isleft===false){for(i=0;i','

<%=title%>

','
<%=content%>
','
<%=buttons%>
','
',""].join(""),buttontemplate:['<%=text%>'].join(""),csstext:[".wpa3-confirm { z-index:2147483647; width:285px; height:141px; margin:0; background:url(data:image/png;base64,ivborw0kggoaaaansuheugaaar0aaacncamaaac9pv6+aaaagxrfwhrtb2z0d2fyzqbbzg9izsbjbwfnzvjlywr5ccllpaaaaybpvfh0we1momnvbs5hzg9izs54bxaaaaaaadw/ehbhy2tldcbizwdpbj0i77u/iibpzd0ivzvnme1wq2voauh6cmvtek5uy3pryzlkij8+idx4onhtcg1ldgegeg1sbnm6ed0iywrvymu6bnm6bwv0ys8iihg6eg1wdgs9ikfkb2jlifhnucbdb3jliduumc1jmdywidyxljezndc3nywgmjaxmc8wmi8xmi0xnzozmjowmcagicagicagij4gphjkzjpsreygeg1sbnm6cmrmpsjodhrwoi8vd3d3lnczlm9yzy8xotk5lzaylziylxjkzi1zew50yxgtbnmjij4gphjkzjpezxnjcmlwdglvbibyzgy6ywjvdxq9iiigeg1sbnm6eg1wpsjodhrwoi8vbnmuywrvymuuy29tl3hhcc8xljaviib4bwxuczp4bxbntt0iahr0cdovl25zlmfkb2jllmnvbs94yxavms4wl21tlyigeg1sbnm6c3rszwy9imh0dha6ly9ucy5hzg9izs5jb20vegfwlzeumc9zvhlwzs9szxnvdxjjzvjlzimiihhtcdpdcmvhdg9yvg9vbd0iqwrvymugughvdg9zag9wientnsbxaw5kb3dziib4bxbnttpjbnn0yw5jzulepsj4bxauawlkoju5quiyqzvcnuiwqtexrtjcm0ffrdncmtc1rti3nzg4iib4bxbnttpeb2n1bwvudelepsj4bxauzglkoju5quiyqzvdnuiwqtexrtjcm0ffrdncmtc1rti3nzg4ij4gphhtce1nokrlcml2zwrgcm9tihn0umvmomluc3rhbmnlsuq9inhtcc5pawq6ntlbqjjdntk1qjbbmtffmkizquvem0ixnzvfmjc3odgiihn0umvmomrvy3vtzw50suq9inhtcc5kawq6ntlbqjjdnue1qjbbmtffmkizquvem0ixnzvfmjc3odgilz4gpc9yzgy6rgvzy3jpchrpb24+idwvcmrmoljerj4gpc94onhtcg1ldge+idw/ehbhy2tldcblbmq9iniipz6qoyataaadafbmvew5xdckvtnjjhzf6ozo7/lueqehhifz1tbv8vaibw7/9vrvxgrr3en4+vuvexwzgct///82n0prtrrgu0mkisxueg2utuqvewo2tbb2mwln0dhoiqnexmacpkwojzt29/n+qaf0mbf9xratm6abm5vtnbxj0tvffgh/kgd+ugqtra2yjrskq7ypdxvzgwdk7o//2zfoigh7/f1gsv6peaherutwwf2eizhhnix1dxwlk53/yslppqt/gid9iah7mgj0jqcjnttj4+qaii0zndr/0cvq9f/s+/5eygrn9fz0eyxz5o3/tbd8/f5udhy6natv2t9obhl8gy9ubw/19fxq8fxn2ut/5z/h7pc2oavmzwoqjr6mmcl3+f33kqm1fhr6nrt9///w/v/ftrjjdqby9vpkkcwhc3vh7vvz5uvppycrmehu7/de7fne5+709voyksti7pvbjrcultnnnazhfhd7/p3adwdfnxtj6vhz9fj09vj3///19/ny9pevumi9pepw8/bw8vbx9pdhywhx8/fy9ff19vj19vny9fjw8/fc6foosbza5/lx5fdv4+/u4u7s4e3r4o3o3uvd6vte6vtd6fpb6ppb6plw5pdz5/hw5o/z5vhv5o/t4e7t4u7y5vhy5fho3evr4ozp3+vp3uvq3+xgt/9lg7dz9vjv8/x7+/3d5+vi6+7g6ezh6u3w9pbc5+rt8vtl7fdn7vhr8fp2+pr3+fv6+/zq8ppc5urb5en4+/7y5epgsvjn3erw4oxf6+/s8/bn8ppk7vlv9fiayfdhro6aorz09vnx9fnz9pb09/vv8fvhsfd+zp/jwyldexfeklipywln3ojr3oa0k5n/9fxx6pdh7vdu4ey6fazv4+5hoshiobp+/v3b6oppagrt4ovk6/lw8pe8p1pz+v/w8/nz5vdw4eroztl/lgt3+pn2+pvy5/ta5/hvuxfz5ojm8f6lrrri1upw0izpt1sps7r19/iqtlzxkgjz3n9rvftqskbl2ujm2+ku4f1qaaaidkleqvr42uzcc3atdr7a8s3qhzajm+rsemxzehit2vkvju1awqapwr1isrtkorzb4qoi6xmfyhued5coqe8wflsofoxv0oeishg13anurbmoeme9z6dxnbp34of517mouo/7jyknysxzjpp/rzpb37d0y7yz/5n9zp43u9tnmunqhbcuqpzuakatf2qafkqz+lqm5931t0khwv9udunavwmk3xox43oq+koyxemqxem0wlmv/fyp6yd1hou2v39rarhzvblhsnywbtmoxyre9do7dawwfjmpyvjwu2czlo0cnaejyzgumsm3yx0fjafi3b1pszqsszoqhjkyx2bz6iiv7j189j93sqntzz5l8+mr61hnazqxg5mz/xhisrw+6civhok8pow5u7zkqfzt8/dcv5q6zdz+lw7vvckmg8oh7cjly78kjz2tzdpw/g/rntq7oihx3i+xy21yxzy1hsmrxv17zom8s2to2s4pducrbfcvyz1nbdtngltzmi4yvsbru+nzpcdfkznf5mp9vkp9qnw2+newzj7hdlzdzrnx/z/ikj9ohklf86bqo5dyullhx2l4wz7j1kbtokftgfnfovsf+5zvqer5o7j2lsmy6f3ilfqvrd3p8h55lpzu/zkpsdu0f/8jz8ix1qkxjhf6zo95zl2wzlb87sdosk/wz1+403dcrindxs+vtl/xle+cbhxej0zn34d36kgjnnwyvgfqnaj4xoe8ez84ftolz1pwl9wwtqngotz3dsip+1b2jecr0nupzsonpbamvlgiyz1nbgrcne3dwttp8o2xmxghldopjg/voixvyz6ralhnt1b/uqfie4lmsogfcpb3evpkoxy2znql79i7w6jhnw0cns5m9f4+4jnuq4j7868//3z6z3osehs9rhdu2solddskwhq627pvlzih43p75sxevjw+pn55xvqfgo2mr8fx5uvfiebfluhxz3vk9pwrnkoqp+tjnjqujph4r87sbvomadrtemqkuklk2l1dognrbf9ovpnsekpjskmam/2mjizlgtfnxqczgm00seuo0agytm6qrs5egraqvmyv01hue9ejseqzjkvxzau4uclobdiajd17jrrw2soqi81otp/y+jeiktlwkfrzskqkzk6paq+gyrqk/dpvpdv3sdos83jkmuynpmmc092zxracqlynqqhoruh4f2pszs9in6ybzbapj0szyz1cnjwn40wvd69budhbiv/hucrkyjerrs+vqmdfnpkriyzmhqnqpbgp1gg5hr9dqtjn2keipz9/48yf4dbm558/p6pazdlvmdki3r7ov09imsedw0q5ptupklrhhjopogdgtvuumkokey7l7m4bqeo0r+iart+or6/kzmivrg9orcvvmfp4s6bolwcyifhoks/9sfmcyz3wcp3hkvdcxk08u6rbbmb7t0hevz28vni6tg71pzcvrizeeqazllbpfvmnxehzdvg0f+xvz1uzsy+qqq4ufldxd3/a5itkw/567gydvtrilhzdqzr1dkqo13pfi0xzfdfnqsvdz8urehime+pouco5y5vm9v0h/j2txvol5ecfkgcrdvplec+ncw7r3b+bz0rpw1f2nt9+1phryvtw/uigqz1439qznkt1jrvkvkclqlbvaxdoft93q2jnfotlrbtodk19xenk1ukz5ehjapfgwkchfe0tfteurauwth7mcdsp/dtfsr6xjwrs2mfaimei6zqswjalm5gzxdoz8avvuvhx4kzsonzf/adwtcgx65s2sfonkui6jv96zthldtyy8jty/cl+7an9/i4ufeafa5libuovf8vqmiqy1nfh1sx8eaev3fim60r8kvxirc9i2rqlolwczc/kcumm7kahdeahdl4bnr9d4qid0aed0aed0aed0bkfoj+fwgu6ajqpquechqgdb6fwgq7oga7oga7oga7oga7oqkdztxr+ciuldeahdeahdeahdeahdeahap2vpfmzkfygi6dzcbqu0bhq+qkultabhdabhdabhdabntax2nzcaznvm/zjljednn99zpsf0nleufmxa95pi9q7a2jgxj1rykplfourzgxbm0jbz9og4+//kldvh99wegrcxwxzrvr71hgwvk572121hlqrrd0/rltwszn3jlf0nidukm7zlbnjp5nqqtqdlbnhp2ssobocdszrtisd1wgvppma5ctrwf0qovyh6rxkura6m0nx3nag1jvrzrs1+8d1y2i/l88dtcv0de49r6htgtrpuu4khvi3don0an9hfkfnzcoeejnq5zdlxnfzepbqswn1dljojj0jharsoui5cxrovkkok4e6r1auhm4w0mgdy4tcov5x3bjjlhmhbqkdnbfgeeqtqj1xlbnj5yihgnsouk4cndtfjtttgtovu04cntduinqbgto3uc6ezkokwzovearr+md1y16gndtos+jojh2jugmddv6indg6h14k1kfanrcpj45ox1hcdqtqjkwcodr3hiluvye6hygnkk4hoyj0oignhs6g997+fahefu8d/7ioat+n2+soexri1hwn9zvi42tizoyma0j+1y9o9jptnog6zpyjmrtipwxwquzxylibnxscvp/gvapswf/fdx4m3oqjxibasuxhbzaqopijdar0jkdhah3qar3qar3qar3qaz3rrznzgrtcdpk2jnuu8itbmatnqlnzxfcobtop/58aawa/1amkkhxcbqaaaabjru5erkjggg==) no-repeat;}",".wpa3-confirm { *background-image:url(http://combo.b.qq.com/crm/wpa/release/3.3/wpa/views/panel.png);}",'.wpa3-confirm * { position:static; z-index:auto; top:auto; left:auto; right:auto; bottom:auto; width:auto; height:auto; max-height:auto; max-width:auto; min-height:0; min-width:0; margin:0; padding:0; border:0; clear:none; clip:auto; background:transparent; color:#333; cursor:auto; direction:ltr; filter:; float:none; font:normal normal normal 12px "helvetica neue", arial, sans-serif; line-height:16px; letter-spacing:normal; list-style:none; marks:none; overflow:visible; page:auto; quotes:none; -o-set-link-source:none; size:auto; text-align:left; text-decoration:none; text-indent:0; text-overflow:clip; text-shadow:none; text-transform:none; vertical-align:baseline; visibility:visible; white-space:normal; word-spacing:normal; word-wrap:normal; -webkit-box-shadow:none; -moz-box-shadow:none; -ms-box-shadow:none; -o-box-shadow:none; box-shadow:none; -webkit-border-radius:0; -moz-border-radius:0; -ms-border-radius:0; -o-border-radius:0; border-radius:0; -webkit-opacity:1; -moz-opacity:1; -ms-opacity:1; -o-opacity:1; opacity:1; -webkit-outline:0; -moz-outline:0; -ms-outline:0; -o-outline:0; outline:0; -webkit-text-size-adjust:none;}',".wpa3-confirm * { font-family:microsoft yahei,simsun;}",".wpa3-confirm .wpa3-confirm-title { height:40px; margin:0; padding:0; line-height:40px; color:#2b6089; font-weight:normal; font-size:14px; text-indent:80px;}",".wpa3-confirm .wpa3-confirm-content { height:55px; margin:0; line-height:55px; color:#353535; font-size:14px; text-indent:29px;}",".wpa3-confirm .wpa3-confirm-panel { height:30px; margin:0; padding-right:16px; text-align:right;}",".wpa3-confirm .wpa3-confirm-button { position:relative; display:inline-block!important; display:inline; zoom:1; width:99px; height:30px; margin-left:10px; line-height:30px; color:#000; text-decoration:none; font-size:12px; text-align:center;}",".wpa3-confirm .wpa3-confirm-button-focus { width:78px;}",".wpa3-confirm .wpa3-confirm-button .wpa3-confirm-button-text { line-height:30px; text-align:center; cursor:pointer;}",".wpa3-confirm-close { position:absolute; top:7px; right:7px; width:10px; height:10px; cursor:pointer;}"].join(""),buttons:[{isfocus:true,text:"确认",events:{click:function(){this.remove()}}},{text:"取消",events:{click:function(){this.remove()}}}],modal:true};style.add("_wpa_confirm_style",settings.csstext);var panel=function(opts){this.opts=opts;this.render()};panel.prototype={render:function(){var panel=this,opts=this.opts,body=this.container=opts.container||document.getelementsbytagname("body")[0];var framehtml=opts.template||settings.template,buttonreplaceid="wpa_buttons_place"+ +new date%100+math.floor(math.random()*100);framehtml=framehtml.replace(/<%=title%>/g,opts.title||"").replace(/<%=content%>/g,opts.content||"").replace(/<%=buttons%>/g,'
');var frag=document.createelement("div"),frame;frag.innerhtml=framehtml;this.$el=frame=frag.firstchild;events.addevent(frame.lastchild,"click",function(){panel.remove();opts.onclose&&opts.onclose()});(function(){try{body.appendchild(frame)}catch(e){settimeout(arguments.callee,1);return}if(opts.modal||settings.modal){panel.rendermodal()}panel.renderbuttons(buttonreplaceid);panel.setcenter()})()},renderbuttons:function(buttonreplaceid){var replaceelement=document.getelementbyid(buttonreplaceid),parentnode=replaceelement.parentnode;parentnode.removechild(replaceelement);var buttonopts=this.opts.buttons||settings.buttons,buttontempl=this.opts.buttontemplate||settings.buttontemplate,frag=document.createelement("div"),button,opt,evts;for(var i=0,l=buttonopts.length;i",opt.text);button=frag.firstchild;opt.isfocus&&classname.addclass(button,"wpa3-confirm-button-focus");if(opt.events){evts=opt.events;for(var type in evts){if(evts.hasownproperty(type)){events.addevent(button,type,proxy(this,evts[type]))}}}parentnode.appendchild(button)}},rendermodal:function(){var container=this.container,width=css(container,"width"),height=css(container,"height"),overflow=css(container,"overflow");var modallayer=document.createelement("div"),styles={position:"fixed",top:0,left:0,zindex:2147483647,width:offset.getclientwidth()+"px",height:offset.getclientheight()+"px",backgroundcolor:"black",opacity:.3,filter:"alpha(opacity=30)"};var isquirk=document.compatmode==="backcompat";if(browser.msie&&parseint(browser.version,10)<7||isquirk){styles.position="absolute";setinterval(proxy(modallayer,function(){this.style.top=offset.getscrolltop()+"px"}),128)}css(modallayer,styles);container.insertbefore(modallayer,this.$el);this.modal=modallayer;events.addevent(window,"resize",proxy(modallayer,function(){css(this,{width:offset.getclientwidth()+"px",height:offset.getclientheight()+"px"})}))},show:function(){this.css("display","block");this.modal&&css(this.modal,"display","block");return this},hide:function(){this.css("display","none");this.modal&&css(this.modal,"display","none");return this},remove:function(){this.$el.parentnode.removechild(this.$el);this.modal&&this.modal.parentnode.removechild(this.modal);return this},css:function(){var args=[this.$el].concat(array.prototype.slice.call(arguments));return css.apply(this,args)},setcenter:function(){this.css({position:"absolute",top:"50%",left:"50%"});var styles={position:"fixed",marginleft:"-"+this.outerwidth()/2+"px",margintop:"-"+this.outerheight()/2+"px"};var isquirk=document.compatmode==="backcompat";if(browser.msie&&parseint(browser.version,10)<7||isquirk){styles.position="absolute";styles.margintop=0;var top=styles.top=(offset.getclientheight()-this.outerheight())/2;setinterval(proxy(this.$el,function(){this.style.top=offset.getscrolltop()+top+"px"}),128)}this.css(styles)},outerwidth:function(){return this.$el.offsetwidth},outerheight:function(){return this.$el.offsetheight}};return panel});