var $WowheadTalentCalculator;function TalentCalculator(){$WowheadTalentCalculator=this;var _1=54;var _2={};var _3={};var _4=-1,_oldClass=-1;var _5=["druid","hunter","mage","paladin","priest","rogue","shaman","warlock","warrior"];var _6=["德鲁伊","猎人","法师","圣骑士","牧师","盗贼","撒满祭祀","术士","战士"];var _7=[0,1,2,3,4,5,6,7,8];var _8=0;var _9=61;var _a=0;var _b=(Browser.opera);var _c=0;var _d="0zMcmVokRsaqbdrfwihuGINALpTjnyxtgevE";var _e="Z";var _f=1;var _10;var _11=0;var _12;var _13,_tabsDivs;var _14;var _15;var _16;var _17;var _18;var _19,_menu3,_menu5,_menuLinks;var _1a;this.setClass=function(_1b){_unlock();_setClass(_1b);};this.importBlizzBuild=function(){var _1c=-1;var _1d,url=prompt("请输入由暴雪的天赋模拟器生成的加点方案地址。","");if(!url){return;}if(url.indexOf("?")!=-1){for(var i=_5.length-1;i>=0;--i){if(url.indexOf(_5[i])!=-1){_1c=i;break;}}}if(_1c==-1){alert("在你输入的网址中没有找到加点方案。");return;}_1d=url.substring(url.indexOf("?")+1);if(_2[_1c]){_resetAll();_parseBlizzBuild(_1d,_1c);_refreshAll();}else{_3={classId:_1c,blizz:_1d};}_setClass(_1c);};this.importWhBuild=function(){var _1f=-1;var _20,url=prompt("Please paste the URL of a build made with Wowhead's talent calculator.","");if(!url){return;}var pos=url.indexOf("talent=");if(pos!=-1){_20=url.substr(pos+7);var n=_d.indexOf(_20.charAt(0));if(n>=0&&n<=26&&n%3==0){_1f=n/3;_20=_20.substr(1);}}if(_1f==-1){alert("Invalid URL.");return;}if(_2[_1f]){_resetAll();_parseBlizzBuild(blizz,_1f);_refreshAll();}else{_3={classId:_1f,wh:_20};}_setClass(_1f);};this.initialize=function(opt){_a=(opt.mode?opt.mode:0);_preloadImages();_18=ge("mtwtcStats");var _24=gE(_18,"b");_14=_24[0].firstChild;_15=_24[1].firstChild;_16=_24[2].firstChild;_13=ge("mtwtcTabs");_tabsDivs=gE(_13,"span");_17=ge("mtwtcTrees");_12=ge("mtwtcLink");_19=ge("mtwtcMenu2");_menu3=ge("mtwtcMenu3");_menu5=ge("mtwtcMenu5");_menu5.onselectstart=_menu5.ondragstart=rf;_menuLinks=gE(_menu3,"a");if(opt.whBuild){var _25=opt.whBuild;var n=_d.indexOf(_25.charAt(0));if(n>=0&&n<=26){var _27=n%3;var _28=(n-_27)/3;_3={classId:_28,wh:_25.substr(1)};_setClass(_28);}}else{if(opt.classId>=0&&opt.classId<=8){if(opt.blizzBuild){_3={classId:opt.classId,blizz:opt.blizzBuild};}_setClass(opt.classId);}}if(_4<0){_17.style.backgroundPosition="0 -20px";_showMenu();}};this.menuOver=function(){clearTimeout(_10);if(!_f&&_4>=0){_10=setTimeout(_showMenu.bind(this,1),333);}};this.menuOut=function(){clearTimeout(_10);if(_f&&_4>=0){_10=setTimeout(_hideMenu.bind(this),250);}};this.registerClass=function(_29,_2a){if(_2[_29]==null){_2a.n=_29;_2[_29]=_2a;_generateClass(_29);}};this.resetAll=function(){_resetAll();};this.resetTree=function(_2b){if(_4>=0){_unlock();_resetTree(_2b,-1,1);}};this.showSummary=function(_2c){if(_4<0){alert("请选择一个职业。");return;}var c=_2[_4];if(!c.k){alert("你目前没有任何加点。");return;}var win=window.open("","","toolbar=no,menubar=yes,status=yes,scrollbars=yes,resizable=yes");var i,j,k;var _30="<html><head><title>"+document.title+"</title></head><body style=\"font-family: Arial, sans-serif; font-size: 13px\">";win.document.open();if(_2c){_30+="<h2>等级 "+(c.k+9)+" "+_6[c.n]+" ("+c[0].k+"/"+c[1].k+"/"+c[2].k+")</h2>";_30+="<p></p>";for(i=0;i<3;++i){_30+="<h3>"+c[i].n+" ("+c[i].k+" 点"+(c[i].k==1?"":"")+")</h3>";_30+="<blockquote>";k=0;for(j=0;j<c[i].length;++j){if(c[i][j].k){if(k){_30+="<br /><br />";}_30+="<b>"+c[i][j].n+"</b> -等级 "+c[i][j].k+"/"+c[i][j].m+"<br />";_30+=_getTalentDescription(c[i][j]);++k;}}if(k==0){_30+="空";}_30+="</blockquote>";_30+='-------------- 多玩游戏 ---------------- [wow.duowan.com] --------\n';}}else{_30+="<pre>";for(i=0;i<3;++i){_30+="<b>"+c[i].n+" ("+c[i].k+" 点"+(c[i].k==1?"":"")+")</b>\n\n";k=0;for(j=0;j<c[i].length;++j){if(c[i][j].k){_30+="&nbsp;&nbsp;&nbsp;&nbsp;"+c[i][j].k+"/"+c[i][j].m+" "+c[i][j].n+"\n";++k;}}if(k==0){_30+="&nbsp;&nbsp;&nbsp;&nbsp;空\n";}_30+="\n";_30+='-------------- 多玩游戏 ---------------- [wow.duowan.com] --------\n';}_30+="</pre>";}_30+="</body></html>";win.document.write(_30);win.document.close();};this.toggleLock=function(_31){_toggleLock();};this.toggleLevelCap=function(_32,_33){Tooltip.hide();_unlock();_toggleLevelCap();this.showLevelCapTooltip(_33);_refreshAll();};this.showLevelCapTooltip=function(_34){if(_9==61){Tooltip.showAtCursor(_34,"切换到80级配点方案",0,0,"q2");}else{Tooltip.showAtCursor(_34,"切换到70级配点方案",0,0,"q7");}};this.toggleMenu=function(){clearTimeout(_10);if(!_f){_showMenu(0);}else{if(_4>=0&&!_11){_hideMenu();}}};this.setLevelCap=function(lvl,_36){if(lvl<1||lvl>70){return;}var ori=_9;_9=Math.max(0,lvl-9);if(_9<ori){_afterCapDecrease();}if(!_36){_refreshAll();}};this.getBuildInfo=function(){var c=_2[_4];var _39="",treeCount=[0,0,0];if(c){treeCount=[c[0].k,c[1].k,c[2].k];for(var _3a=0;_3a<3;++_3a){for(var i=0;i<c[_3a].length;++i){_39+=c[_3a][i].k;}}}return {spent:treeCount,build:_39};};function _blizzToMT(_3c){var mt="";var _3e=[];for(var i=0;i<_3c.length;i+=2){for(var j=0;j<2;++j){_3e[j]=parseInt(_3c.substring(i+j,i+j+1));if(isNaN(_3e[j])){_3e[j]=0;}}mt+=_d.charAt(_3e[0]*6+_3e[1]);}return mt;}function _setClass(_41){_unlock();if(_41!=_4){_oldClass=_4;_4=_41;_menuLinks[_7[_41]].className="selected";if(_oldClass>=0){_menuLinks[_7[_oldClass]].className="";}_loadClass(_41);}_hideMenu();}function _decrementTalent(_42,_43,_44){var c=_2[_42.classId],i;var _46=_42.tree;if(_42.k>0&&(_43==0||!_8)){if(_42.links){for(i=0;i<_42.links.length;++i){if(c[_46][_42.links[i]].k){return;}}}var sum=0;_42.k--;for(i=0;i<c[_46].length;++i){var _48=c[_46][i];if(_48.k&&_42.y!=_48.y){if(sum<_48.y){_42.k++;return;}}sum+=_48.k;}c[_46].k--;i=c.k--;_updateTree(_46,_43);if(_43){_updateTooltip(_44);if(i>=_9){for(i=0;i<3;++i){_updateTree(i,1);}}}}_refreshStats();_refreshLink();}function _incrementTalent(_49,_4a,_4b){var c=_2[_49.classId];if(_a==0&&_4a==0&&c.k==61){_toggleLevelCap();}if(c.k<_9&&!_8){if(_49.k<_49.m&&_49.enabled){_49.k++;c[_49.tree].k++;c.k++;_updateTree(_49.tree,_4a,_49,_49.classId);if(_4a){_updateTooltip(_4b);_refreshStats();_refreshLink();if(c.k==_9){for(var i=0;i<3;++i){if(i!=_49.tree){_updateTree(i,_4a,0,_49.classId);}}}}}}}function _generateClass(_4e){var c=_2[_4e];var i;_generateTrees(_4e);if(_3.classId==_4e){for(i=0;i<3;++i){_updateTree(i,0,0,_4e);}if(_3.wh||_3.blizz){if(_3.wh){_parseWhBuild(_3.wh,_4e);}else{_parseBlizzBuild(_3.blizz,_4e);}_toggleLock();}}_3={};if(_4e==_4){_onClassChange();c.div.style.display="";}for(i=0;i<3;++i){_updateTree(i,1,0,_4e);}}function _generateTrees(_51){var _,c=_2[_51];var _53=gE(ge("mtwtcArrowsTemplate"),"div");var _54=ge("mtwtcTreeTemplate").firstChild;var _,i;var _56=["Container","Icon","Tile","Border","Bubble","Highlight","Arrow"];c.div=ce("div");c.div.style.display="none";ae(_17,c.div);c.trees=[ce("div"),ce("div"),ce("div")];for(var i=0;i<3;++i){var a=c.trees[i];a.style.cssFloat=a.style.styleFloat="left";ae(c.div,a);}c.k=0;for(var _59=2;_59>=0;--_59){_=c.trees[_59].style;_.backgroundImage="url(talent/data/"+_5[c.n]+"/"+(_59+1)+"_bg.jpg?"+_1+")";_.backgroundRepeat="no-repeat";c.trees[_59].appendChild(_54.cloneNode(1));if(_59>0){c.trees[_59].style.borderLeft="1px solid #404040";}var tds=gE(c.trees[_59],"td");c[_59].k=0;var _5b="url(talent/data/"+_5[c.n]+"/"+(_59+1)+"_icons.jpg?"+_1+")";for(i=c[_59].length-1;i>=0;--i){var _5c=c[_59][i];var _5d=(_5c.y/5*4+_5c.x)-1;_5c.k=0;_5c.i=i;_5c.tree=_59;_5c.classId=_51;var _5e=[];for(var j=0;j<5;++j){_5e[j]=ce("div");_5e[j].className="mtwtc"+_56[j];}ns(_5e[0]);_5e[0].oncontextmenu=rf;var _60=ce("div");_60.className="mtwtcHighlight";_60.onmouseup=_highlightClick;_60.onmouseover=_highlightOver;_60.onmouseout=_highlightOut;_60.oncontextmenu=_highlightContext;_5e.push(_60);if(_5c.r){var _61=c[_59][_5c.r[0]];var dX=_5c.x-_61.x;var dY=(_5c.y-_61.y)/5;var l,t,w,h;var _65=-1;if(!_61.links){_61.links=[i];}else{_61.links.push(i);}if(dY>0){if(dX==0){_65=0;}else{if(dX<0){_65=1;}else{_65=2;}}}else{if(dY==0){if(dX>0){_65=3;}else{if(dX<0){_65=4;}}}}w=(Math.abs(dX)-1)*64;h=(Math.abs(dY)-1)*64;switch(_65){case 0:w=15;h+=29;l=25;t=16-h;break;case 1:w+=51;h+=54;l=24;t=15-h;break;case 2:w+=51;h+=54;l=-w+40;t=15-h;break;case 3:w+=29;h=15;l=-11;t=24;break;case 4:w+=29;h=15;l=46;t=24;break;}var _66=_53[_65].cloneNode(1);_=_66.style;_.left=l+"px";_.top=t+"px";_.width=w+"px";_.height=h+"px";_5e.push(_66);}for(j=1;j<_5e.length;++j){_5e[0].appendChild(_5e[j]);}for(j=0;j<_5e.length;++j){_5c[_56[j].toLowerCase()]=_5e[j];}_5c.highlight.talent=_5c;_5c.icon.style.backgroundImage=_5b;_5e[0].style.position="relative";tds[_5d].appendChild(_5e[0]);}}c.trees=c.div.childNodes;}function _getTalentDescription(_67,_68){var _69=_67.d;var _6a=Math.max(0,_67.k-1)+(_68?1:0);for(var i=0;i<_67.length;++i){var _6c=_69.split("$");var _6d=_6c.length;if(_6d--==1){continue;}_69=_6c[0];if(_67[i].length){_69+=_67[i][Math.min(_6a,_67[i].length-1)];}else{_69+=Math.round(_67[i]*(_6a+1)*100)/100;}for(var j=1;j<_6d;++j){_69+=_6c[j]+"$";}_69+=_6c[_6d];}return _69;}function _hideMenu(){_f=0;if(_oldClass<0){_17.style.backgroundPosition="0 0";_18.style.display="block";_13.style.display="block";ge("kebwrkwbet64").style.display="block";}_19.className="mtwtcMenuBorder mtwtcMenuClip";_menu3.className="";_menu3.style.top=-(_7[_4]+1)*22-3+"px";_menu5.style.backgroundPosition="right 2px";}function _highlightClick(_6f){if(!_6f){_6f=event;}var _70=_6f.which?_6f.which:_6f.button;if(_70>=2){if(_c!=2){_c=1;_decrementTalent(this.talent,1,this);}}else{if(_6f.shiftKey||_6f.ctrlKey){_decrementTalent(this.talent,1,this);}else{_incrementTalent(this.talent,1,this);}}}function _highlightContext(){if(_c==1){return;}_c=2;_decrementTalent(this.talent,1,this);}function _highlightOut(){Tooltip.hide();this.style.backgroundPosition="0";}function _highlightOver(){_updateTooltip(this);this.style.backgroundPosition=(this.talent.enabled?"-76px":"-38px");}function _loadClass(_71){if(_2[_71]){_onClassChange();var c=_2[_71];c.div.style.display="";}else{var _73=document.getElementsByTagName("head")[0];if(Browser.ie6){for(var i=0;i<=2;++i){var img=ce("img");img.src="talent/data/"+_5[_71]+"/"+i+"_icons.jpg";ae(_1a,img);}}ae(_73,ce("script",{type:"text/javascript",src:"talent/data/"+_5[_71]+".js?"+_1}));}if(_2[_oldClass]){_2[_oldClass].div.style.display="none";}}function _parseBlizzBuild(_76,_77){var c=_2[_77];var _79=0,talent=0;var _7a=null,fixN;for(var i=0;i<_76.length;++i){var n=Math.min(parseInt(_76.charAt(i)),c[_79][talent].m);if(isNaN(n)){continue;}for(var k=0;k<n;++k){_incrementTalent(c[_79][talent],0);}if(_7a){for(var k=0;k<fixN;++k){_incrementTalent(_7a,0);}_7a=null;}if(c[_79][talent].k<n){_7a=c[_79][talent];fixN=n-c[_79][talent].k;}if(++talent>c[_79].length-1){talent=0;if(++_79>2){break;}}}}function _parseWhBuild(_7f,_80){var c=_2[_80];var _82=0,talent=0;var _83=[];var _84=null,fixN;for(var i=0;i<_7f.length;++i){var ch=_7f.charAt(i);if(ch!=_e){var n=_d.indexOf(ch);if(n<0){continue;}_83[1]=n%6;_83[0]=(n-_83[1])/6;for(var j=0;j<2;++j){n=Math.min(_83[j],c[_82][talent].m);for(var k=0;k<n;++k){_incrementTalent(c[_82][talent],0);}if(_84){for(var k=0;k<fixN;++k){_incrementTalent(_84,0);}_84=null;}if(c[_82][talent].k<n){_84=c[_82][talent];fixN=n-c[_82][talent].k;}if(++talent>=c[_82].length){break;}}}if(talent>=c[_82].length||ch==_e){talent=0;if(++_82>2){return;}}}}function _preloadImages(){if(Browser.ie6){var _8b=["border","tile","bubble","arrows/down","arrows/down2","arrows/leftdown","arrows/leftdown2","arrows/rightdown","arrows/rightdown2","arrows/right","arrows/right2"];var d=ce("div");for(var i=0;i<_8b.length;++i){var img=ce("img");img.src="talent/images/"+_8b[i]+".gif";ae(d,img);}d.style.position="absolute";d.style.left=d.style.top="-2323px";d.style.visibility="hidden";ae(ge("layers"),d);_1a=d;}}function _refreshAll(_8f){_updateTree(0,1,0,_8f);_updateTree(1,1,0,_8f);_updateTree(2,1,0,_8f);_refreshStats();_refreshLink();}function _refreshLink(){var c=_2[_4];var mt="",blizz,i;for(var _92=0;_92<3;++_92){blizz="";for(i=0;i<c[_92].length;++i){blizz+=c[_92][i].k;}blizz=rtrim(blizz,"0");mt+=_blizzToMT(blizz);i=blizz.length;if(i%2==1){++i;}if(i<c[_92].length){mt+=_e;}}_12.href=location.href.replace(/(.*html).*/,"$1")+"?talent="+_d.charAt(_4*3)+rtrim(mt,_e);}function _refreshStats(){var c=_2[_4];_14.nodeValue=_9-c.k;_16.nodeValue=c.k+" ("+c[0].k+"/"+c[1].k+"/"+c[2].k+")";_15.nodeValue=(c.k>0?9+c.k:"-");for(var i=0;i<3;++i){_tabsDivs[i].childNodes[1].nodeValue=" ("+c[i].k+")";}if(_a==0){var _95=document.title;var pos=_95.indexOf("-");if(pos!=-1){_95=_95.substring(pos+2);}document.title=_6[_4]+" ("+c[0].k+"/"+c[1].k+"/"+c[2].k+") - "+_95;}}function _resetAll(){if(_4>=0){_unlock();_resetTree(0);_resetTree(1);_resetTree(2);_refreshAll();}}function _resetTree(_97,_98,_99){var c=(_98>=0?_2[_98]:_2[_4]);var i;for(i=0;i<c[_97].length;++i){c[_97][i].k=0;}i=(c.k<_9);c.k-=c[_97].k;c[_97].k=0;if(_99){if(i){_updateTree(_97,1);}else{for(i=0;i<3;++i){_updateTree(i,1);}}_refreshStats();_refreshLink();}}function _showMenu(_9c){_11=_9c;_f=1;if(_4>=0){_19.className="";_menu3.className="mtwtcMenuBorder";_menu3.style.top="0";}}function _updateTooltip(_9d){var _9e=_9d.talent;var c=_2[_9e.classId];var _a0="<table><tr><td><b>";if(_9e.z){_a0+="<span style=\"float: right\" class=\"q0\">等级 "+_9e.z+"</span>";}_a0+=_9e.n+"</b><br />"+"等级 "+_9e.k+"/"+_9e.m+"<br />";if(_9e.r){if(c[_9e.tree][_9e.r[0]].k<_9e.r[1]){_a0+="<span class=\"q7\">需要 "+_9e.r[1]+" 点";if(_9e.r[1]>1){_a0+="";}_a0+=""+c[_9e.tree][_9e.r[0]].n+"</span><br />";}}if(_9e.y&&c[_9e.tree].k<_9e.y){_a0+="<span class=\"q7\">需要 "+_9e.y+" 点 "+c[_9e.tree].n+" 天赋</span><br />";}if(_9e.t){for(var i=0,len=_9e.t.length;i<len;i+=2){if(_9e.t[i]&&_9e.t[i+1]){_a0+="<table width=\"100%\"><tr><td>"+_9e.t[i]+"</td><th>"+_9e.t[i+1]+"</th></tr></table>";}else{_a0+=_9e.t[i]+"<br />";}}}_a0+="</td></tr></table><table><tr><td>";_a0+="<span class=\"q\">"+_getTalentDescription(_9e)+"</span><br />";if(_9e.enabled&&!_8){if(!_9e.k){_a0+="<span class=\"q2\">单击学习</span><br />";}else{if(_9e.k==_9e.m){_a0+="<span class=\"q7\">"+(_b?"Shift":"右")+"-击撤销学习</span><br />";}}if(_9e.k&&_9e.k<_9e.m){_a0+="<br />下一等级：<br /><span class=\"q\">"+_getTalentDescription(_9e,1)+"</span><br />";}}_a0+="</td></tr></table>";Tooltip.show(_9d,_a0,0,0);}function _updateTree(_a2,_a3,_a4,_a5){var c=(_a5>=0?_2[_a5]:_2[_4]);var _a7;var _a8;if(!_a4||c.k==_9){_a8=0;_a7=40;}else{_a8=_a4.i;_a7=Math.floor(c[_a2].k/5)*5+5;}if(_a4!=null&&_a4.links!=null){for(var i=0,len=_a4.links.length;i<len;++i){if(_a8>_a4.links[i]){_a8=_a4.links[i];}}}for(var i=_a8;i<c[_a2].length;++i){_a4=c[_a2][i];if(c.k<_9){if(_a4.y>_a7){break;}}if((_8||c.k==_9)&&!_a4.k){_a4.enabled=0;}else{if(c[_a2].k>=_a4.y){if(_a4.r){if(c[_a2][_a4.r[0]].k>=_a4.r[1]){_a4.enabled=1;}else{_a4.enabled=0;}}else{_a4.enabled=1;}}else{_a4.enabled=0;}}if(_a3){var _ab;if(_a4.enabled){if((_a4.k==_a4.m)){_a4.border.style.backgroundPosition="-42px";_a4.bubble.style.color="#E7BA00";}else{_a4.border.style.backgroundPosition="-84px";_a4.bubble.style.color="#17FD17";}_a4.icon.style.backgroundPosition=-i*36+"px 0";_a4.bubble.style.visibility="visible";if(_a4.r){_ab=_a4.arrow.firstChild;if(_ab.className.indexOf("2")==-1){_ab.className+="2";}}}else{_a4.border.style.backgroundPosition=0;_a4.icon.style.backgroundPosition=-i*36+"px -36px";_a4.bubble.style.visibility="hidden";if(_a4.r){_ab=_a4.arrow.firstChild;if(_ab.className.indexOf("2")!=-1){_ab.className=_ab.className.replace("2","");}}}_a4.bubble.innerHTML=_a4.k;}}}function _onClassChange(){var c=_2[_4];for(i=0;i<3;++i){_tabsDivs[i].firstChild.firstChild.nodeValue=c[i].n;_tabsDivs[i].style.backgroundImage="url(talent/data/"+_5[c.n]+"/tree"+i+".gif?"+_1+")";}_afterCapDecrease();_refreshAll();}function _toggleLock(){var foo=ge("mtwtcLockToggler");_8=!_8;if(_8){foo.firstChild.nodeValue="解锁";foo.style.backgroundPosition="-110px center";}else{foo.firstChild.nodeValue="锁定";foo.style.backgroundPosition="left center";}_refreshAll();}function _unlock(){if(_8){_toggleLock();}}function _toggleLevelCap(){var foo=ge("mtwtcLevelCap");var ori=_9;_9=(_9==71?61:71);foo.firstChild.nodeValue=(_9==61?70:80);if(_9<ori){_afterCapDecrease();}for(var i=0;i<3;++i){_updateTree(i,0);}}function _afterCapDecrease(){var c=_2[_4];if(c.k>_9){for(var _b2=2;_b2>=0;--_b2){for(var i=c[_b2].length-1;i>=0;--i){var k=c[_b2][i].k;for(var j=0;j<k;++j){_decrementTalent(c[_b2][i],0);if(c.k<=_9){return;}}}}}}}