function MTWTC()
{
var _d2=[],_a2=[],_i2=0,_cc=-1,_oc=-1,_c2=['Druid','Hunter','Mage','Paladin','Priest','Rogue','Shaman','Warlock','Warrior','^^^'],_c3=[0,1,2,3,4,5,6,7,8,-1],_c4=['德鲁依','猎人','法师','圣骑士','牧师','盗贼','萨满祭司','术士','战士','^^^'],_m2=0;
var _a,_b,_c,_d,_e,_f,_g,_h,_i,_j,_k,_l,_m,_n,_o,_p,_q,_r,_s,_t=1,_u,_v=0,_w='Z',_x='0zMcmVokRsaqbdrfwihuGINALpTjnyxtgevE',_y=0,_z=(navigator.userAgent.indexOf('Opera')!=-1||navigator.userAgent.indexOf('Safari')!=-1)

this.ChooseClass=function(z){_ChooseClass(z)}

this.HideMenu=function(){_HideMenu()}

this.HideTooltip=function(){if(_i2)_c.style.display='none'}

this.ImportBlizz=function(){var a=-1,b,c=prompt("您可以将暴雪天赋模拟器配点方案导入这里.",'');if(!c)return;if(c.indexOf('?')!=-1){for(var i=_c2.length-1;i>=0;--i){if(c.indexOf(_c2[i].toLowerCase())!=-1){a=i;break}}}if(a==-1){alert('在您粘贴的URL中未找到任何职业.');return}else if(a==9)a=5;b=c.substring(c.indexOf('?')+1);if(!_d2[a]){_a2[0]=a;_a2[1]=0;_a2[2]=b;_a2[3]=1}else{this.ResetAll();_ParseBlizz(b,a);_RefreshAll()}_ChooseClass(a)}

this.Initialize=function(z){_PreloadImages();_c=ge('mtwtcTooltip');_d=gE(_c,'table')[0];_e=gE(_d,'div')[0];_l=ge('mtwtcStats');var a=gE(_l,'span');_i=a[0].firstChild;_j=a[1].firstChild;_h=a[2].firstChild;_f=ge('mtwtcTabs');_g=gE(_f,'div');_k=ge('mtwtcTrees');_b=ge('mtwtcLink');_a=frames['mtwtcDataFrame'];_m=ge('mtwtcMenu1').style;_n=ge('mtwtcMenu2').style;_o=ge('mtwtcMenu3');_q=gE(_o,'a');_o=_o.style;_p=ge('mtwtcMenu4').style;_r=ge('mtwtcModeToggler');_s=ge('mtwtc');var b;if(typeof(z)=='string'&&z.length)b=z;else b=(window.location?location.search.substring(location.search.lastIndexOf('?')+1).split(';')[0]:'');_a2[0]=-1;if(b.length){if(parent==self){var n=_x.indexOf(b.charAt(0));if(n<0||n>29)_a2=[-1];else{_a2[1]=n%3;_a2[0]=(n-_a2[1])/3;_a2[2]=b.substring(1);_a2[3]=0;if(_a2[0]==9)_a2[0]=5;_ChooseClass(_a2[0])}}else{var n=parseInt(b);if(n>=1&&n<=9){_a2[0]=n-1;_a2[1]=0;if(_a2[0]==9)_a2[0]=5;_ChooseClass(_a2[0])}}}if(_cc<0){_k.style.backgroundPosition='0 -20px';_ShowMenu()}var m=gc('mtwtcMode');if(parent==self&&(m==null||m==1))_ToggleMode(0);_s.style.visibility='visible';_m.visibility='visible';_i2=1}

this.MenuOut=function(){clearTimeout(_u);if(_t&&_cc>=0)_u=setTimeout('mtwtc.HideMenu()',250)}
this.MenuOver=function(){clearTimeout(_u);if(!_t&&_cc>=0)_u=setTimeout('mtwtc.ShowMenu(1)',333)}
this.ProcessData=function(){if(_a.data==null)return;var a=_a.data.n;if(_d2[a]==null){_d2[a]=_a.data;_GenerateClass(a)}}
this.RequestData=function(z){_a.location.replace(z)}
this.ResetAll=function(){if(_cc>=0){_ResetTree(0);_ResetTree(1);_ResetTree(2);_RefreshAll()}}
this.ShowMenu=function(z){_ShowMenu(z)}
this.ShowSummary=function(z){if(_cc<0){alert('请先选择一个职业.');return}var c=_d2[_cc];if(!c.k){alert("您尚未进行任何配点.");return}var f=window.open('','','toolbar=no,menubar=yes,status=yes,scrollbars=yes,resizable=yes');var i,j,k,b='<html><head><title>'+document.title+'</title></head><body>';f.document.open();if(z){b+='<h2>Level '+(c.k+9)+' '+_c4[c.n]+' ('+_j.nodeValue+')</h2>';b+='<p></p>';for(i=0;i<3;++i){b+='<h3>'+c[i].n+' ('+c[i].k+' point'+(c[i].k==1?'':'s')+')</h3>';b+='<blockquote>';k=0;for(j=0;j<c[i].length;++j){if(c[i][j].k){if(k)b+='<br><br>';b+='<b>'+c[i][j].n+'</b> - Rank '+c[i][j].k+'/'+c[i][j].m+'<br>';b+=_GetTalentDescription(c[i][j]);++k}}if(k==0)b+='None';b+='</blockquote>'}}else{b+='<pre>';for(i=0;i<3;++i){b+='<b>'+c[i].n+' ('+c[i].k+' point'+(c[i].k==1?'':'s')+')</b>\n\n';k=0;for(j=0;j<c[i].length;++j){if(c[i][j].k){b+='&nbsp;&nbsp;&nbsp;&nbsp;'+c[i][j].k+'/'+c[i][j].m+' '+c[i][j].n+'\n';++k}}if(k==0)b+='&nbsp;&nbsp;&nbsp;&nbsp;None\n';b+='\n'}b+='</pre>'}b+='</body></html>';f.document.write(b);f.document.close()}
this.ShowTooltip=function(z,y){if(_i2){_e.innerHTML=y;_c.style.display='';_MoveTooltip(z, 0, 0)}}
this.TabClick=function(z,y,x){var a=x.which?x.which:x.button;if(a>=2){if(_y!=2){_y=1;_ResetTree(z,-1,1);this.TabOver(z,y)}}else if(x.shiftKey||x.ctrlKey){_ResetTree(z,-1,1);this.TabOver(z,y)}else _ShowTree(z)}
this.TabContext=function(z,y){if(_y==1)return;_y=2;_ResetTree(z,-1,1);this.TabOver(z,y)}
this.TabOver=function(z,y){var c=_d2[_cc];if(c){var b='<div style="white-space: nowrap"><b>'+c[z].n+' </b><br>'+(c[z].k>0?c[z].k:'没有')+'点数'+(c[z].k==1?'':'')+'在该系';if(c[z].k){for(var i=0;i<c[z].length;++i){if(c[z][i].k){b+='<br>';if(c[z][i].k==c[z][i].m)b+='<var>';else b+='<i>';b+=c[z][i].k+'/'+c[z][i].m+' '+c[z][i].n;if(c[z][i].k==c[z][i].m)b+='</var>';else b+='</i>'}}}if(c[z].k>0)b+='<br><em>'+(_z?'Shift':'右键')+'-点击重置</em></div>';_e.innerHTML=b;_c.style.display='';_MoveTooltip(y,-6,0)}}
this.ToggleMenu=function(){clearTimeout(_u);if(!_t)_ShowMenu(0);else if(_cc>=0&&!_v)_HideMenu()}
this.ToggleMode=function(){_ToggleMode(1)}

function _BlizzToMT(z){var mt='';var a=[];for(var i=0;i<z.length;i+=2){for(var j=0;j<2;++j){a[j]=parseInt(z.substring(i+j,i+j+1));if(isNaN(a[j]))a[j]=0}mt+=_x.charAt(a[0]*6+a[1])}return mt}
function _ChooseClass(z){if(z!=_cc){_oc=_cc;_cc=z;_q[_c3[z]].className='selected';if(_oc>=0)_q[_c3[_oc]].className='';_LoadClass(z)}_HideMenu()}
function _DecrementTalent(z){var c=_d2[z.talent.classId],i,f=z.talent.tree;if(c.currentTree!=f)_ShowTree(f);if(z.talent.k>0){if(z.talent.links){for(i=0;i<z.talent.links.length;++i){if(c[f][z.talent.links[i]].k)return}}var sum=0;z.talent.k--;for(i=0;i<c[f].length;++i){var talent=c[f][i];if(talent.k&&talent.y!=z.talent.y){if(sum<talent.y){z.talent.k++;return}}sum+=talent.k}c[f].k--;i=c.k--;_UpdateTooltip(z);if(i<61)_UpdateTree(f,1,z.talent);else{for(i=0;i<3;++i)_UpdateTree(i,1)}}_RefreshStats();_RefreshLink()}
function _GenerateClass(a){var c=_d2[a];var i,f=0;_GenerateTrees(a);if(_a2[0]!=-1){for(i=0;i<3;++i)_UpdateTree(i,0,0,_a2[0]);if(_a2[2]){if(_a2[3]==0)_ParseMT(_a2[2],_a2[0]);else _ParseBlizz(_a2[2],_a2[0])}if(_a2[1])f=_a2[1];_a2[0]=-1}if(a==_cc){for(i=0;i<3;++i)_g[i].innerHTML=c[i].n;c.div.style.display=''}for(i=0;i<3;++i)_UpdateTree(i,1,0,a);_ShowTree(f,a)}

//* 图片路径
function _GenerateTrees(a){var c=_d2[a];var f=gE(ge('mtwtcArrowsTemplate'),'div');var d=ge('mtwtcTreeTemplate').firstChild;var _,i,k=['Container','Icon','Tile','Border','Bubble','Highlight','Arrow'];var trs=_k.firstChild.childNodes;c.div=trs[a];c.trees=c.div.childNodes;c.k=0;c.currentTree=0;for(var tree=2;tree>=0;--tree){_=c.trees[tree].style;_.backgroundImage='url(data/'+_c2[c.n]+'/'+(tree+1)+'_bg.jpg)';_.backgroundRepeat='no-repeat';c.trees[tree].appendChild(d.cloneNode(1));var tds=gE(c.trees[tree],'td');c[tree].k=0;var iconBackgroundImage='url(data/'+_c2[c.n]+'/'+(tree+1)+'_icons.jpg)';for(i=c[tree].length-1;i>=0;--i){var talent=c[tree][i];var formule=(talent.y/5*4+talent.x)-1;talent.k=0;talent.i=i;talent.tree=tree;talent.classId=a;var divs=[];for(var j=0;j<5;++j){divs[j]=ce('div');divs[j].className='mtwtc'+k[j]}var hl=ce('div');hl.className='mtwtcHighlight';hl.onmouseup=_HighlightClick;hl.onmouseover=_HighlightOver;hl.onmouseout=_HighlightOut;hl.oncontextmenu=_HighlightContext;divs.push(hl);if(talent.r){var n=c[tree][talent.r[0]];var dX=talent.x-n.x;var dY=(talent.y-n.y)/5;var l,t,w,h,m=-1;if(!n.links)n.links=[i];else n.links.push(i);if(dY>0){if(dX==0)m=0;else if(dX<0)m=1;else m=2}else if(dY==0){if(dX>0)m=3;else if(dX<0)m=4}w=(Math.abs(dX)-1)*64;h=(Math.abs(dY)-1)*64;switch(m){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}var arrow=f[m].cloneNode(1);_=arrow.style;_.left=l;_.top=t;_.width=w;_.height=h;divs.push(arrow)}for(j=1;j<divs.length;++j)divs[0].appendChild(divs[j]);for(j=0;j<divs.length;++j)talent[k[j].toLowerCase()]=divs[j];talent.highlight.talent=talent;talent.icon.style.backgroundImage=iconBackgroundImage;divs[0].style.position='relative';tds[formule].appendChild(divs[0])}}c.trees=c.div.childNodes}

function _GetTalentDescription(z,y){var d=z.d,r=Math.max(0,z.k-1)+(y?1:0);for(var i=0;i<z.length;++i){var p=d.split('$');var lastIndex=p.length;if(lastIndex--==1)continue;d=p[0];if(z[i].length)d+=z[i][Math.min(r,z[i].length-1)];else d+=Math.round(z[i]*(r+1)*100)/100;for(var j=1;j<lastIndex;++j)d+=p[j]+'$';d+=p[lastIndex]}return d}
function _HideMenu(){_t=0;if(_oc<0){_m.left=_m.top='0';_k.style.backgroundPosition='0 0';_l.style.display='block';_f.style.display='block'}_n.height='20px';_o.top=-(_c3[_cc]+1)*22-3+'px';_p.backgroundPosition='right'}
function _HighlightClick(y){if(!y)y=event;var a=y.which?y.which:y.button;if(a>=2){if(_y!=2){_y=1;_DecrementTalent(this)}}else if(y.shiftKey||y.ctrlKey){_DecrementTalent(this)}else _IncrementTalent(this.talent,1,this)}
function _HighlightContext(){if(_y==1)return;_y=2;_DecrementTalent(this)}
function _HighlightOut(){_c.style.display='none';this.style.backgroundPosition='0'}
function _HighlightOver(){_c.style.display='';_UpdateTooltip(this);this.style.backgroundPosition=(this.talent.enabled?'-76px':'-38px')}

//* 文件路径
function _IncrementTalent(z,y,x){var c=_d2[z.classId];if(c.currentTree!=z.tree)_ShowTree(z.tree);if(c.k<61){if(z.k<z.m&&z.enabled){z.k++;c[z.tree].k++;c.k++;_UpdateTree(z.tree,y,z,z.classId);if(y){_UpdateTooltip(x);_RefreshStats();_RefreshLink();if(c.k==61){for(var i=0;i<3;++i){if(i!=z.tree)_UpdateTree(i,y,0,z.classId)}}}}}}
function _LoadClass(a){if(!_d2[a])setTimeout('mtwtc.RequestData("data/'+_c2[a]+'.dat")',1);else{var c=_d2[a];c.div.style.display='';for(i=0;i<3;++i)_g[i].innerHTML=c[i].n;_ShowTree(c.currentTree)}if(_d2[_oc])_d2[_oc].div.style.display='none'}
function _MoveTooltip(z,y,x){var talent=z.talent;var coords=ac(z);var left=coords[0];var top =coords[1];var w1=z.offsetWidth+y,h1=z.offsetHeight+x;_c.style.width='300px';_c.style.width=_d.offsetWidth+'px';if(left+_d.offsetWidth+w1>document.body.clientWidth){left=Math.max(left-_d.offsetWidth,0);left=Math.max(left-y,0)}else left+=w1;var h;var height=h=_d.offsetHeight;if(talent){if(talent.m>1&&talent.enabled&&(talent.k==0||talent.k==talent.m))h*=(talent.y<10?1.33:1.6)}if(document.body.scrollTop+h>top)top=top+h1;else top=Math.max(top-height,document.body.scrollTop);if(top+h>document.body.scrollTop+document.body.clientHeight)top=Math.max(document.body.scrollTop,document.body.scrollTop+document.body.clientHeight-h);_c.style.left=left+'px';_c.style.top=top +'px'}
function _ParseBlizz(z,y){var c=_d2[y];var tree=0,talent=0;for(var i=0;i<z.length;++i){var n=Math.min(parseInt(z.charAt(i)),c[tree][talent].m);if(isNaN(n))continue;for(var k=0;k<n;++k)_IncrementTalent(c[tree][talent],0);if(++talent>c[tree].length-1){talent=0;if(++tree>2)break}}}
function _ParseMT(z,y){var c=_d2[y];var tree=0,talent=0;var values=[];for(var i=0;i<z.length;++i){var ch=z.charAt(i);if(ch!=_w){var n=_x.indexOf(ch);if(n<0)continue;values[1]=n%6;values[0]=(n-values[1])/6;for(var j=0;j<2;++j){n=Math.min(values[j],c[tree][talent].m);for(var k=0;k<n;++k)_IncrementTalent(c[tree][talent],0);if(++talent>=c[tree].length)break}}if(talent>=c[tree].length||ch==_w){talent=0;if(++tree>2)return}}}
function _PreloadImages(){if(isIE6){var a=['border','tile','bubble','arrows/down','arrows/down2','arrows/leftdown','arrows/leftdown2','arrows/rightdown','arrows/rightdown2','arrows/right','arrows/right2'],b='';for(var i=0;i<a.length;++i)b+='<img src="images/'+a[i]+'.gif">';document.write(b)}}
function _RefreshAll(z){_UpdateTree(0,1,0,z);_UpdateTree(1,1,0,z);_UpdateTree(2,1,0,z);_RefreshStats();_RefreshLink()}
function _RefreshLink(){var c=_d2[_cc];var mt='',blizz,i;for(var tree=0;tree<3;++tree){blizz='';for(i=0;i<c[tree].length;++i)blizz+=c[tree][i].k;blizz=rtrim(blizz,'0');mt+=_BlizzToMT(blizz);i=blizz.length;if(i%2==1)++i;if(i<c[tree].length)mt+=_w}_b.href='?'+_x.charAt(_cc*3+c.currentTree)+rtrim(mt,_w)}
function _RefreshStats(){var c=_d2[_cc];_h.nodeValue=61-c.k;_j.nodeValue=c[0].k+'/'+c[1].k+'/'+c[2].k;_i.nodeValue=(c.k?9+c.k:1);var b=document.title;var pos=b.indexOf('-');if(pos!=-1)b=b.substring(pos+2);document.title=_c4[_cc]+' ('+_j.nodeValue+') - '+b}
function _ResetTree(z,y,x){var c=(y>=0?_d2[y]:_d2[_cc]);var i;for(i=0;i<c[z].length;++i)c[z][i].k=0;i=(c.k<61);c.k-=c[z].k;c[z].k=0;if(x){if(i)_UpdateTree(z,1);else{for(i=0;i<3;++i)_UpdateTree(i,1)}_RefreshStats();_RefreshLink()}}

//* show menu z 设置职业菜单栏的溢出高度
function _ShowMenu(z){_v=z;_t=1;_n.height='223px';_o.top='0';_p.backgroundPosition='-22px 0'}

function _ShowTree(z,y){var c=(y>=0?_d2[y]:_d2[_cc]);if(c){if(z!=-1)c.currentTree=z;else z=c.currentTree;if(_m2){for(var i=0;i<3;++i)c.trees[i].style.display=''}else{c.div.style.display='none';for(var i=0;i<3;++i)c.trees[i].style.display='none';c.trees[z].style.display='';c.div.style.display=''}_g[z].className='selected';for(var i=0;i<3;++i){if(i!=z)_g[i].className=''}if(y==null||_cc==y){_RefreshStats();_RefreshLink()}}}

function _ToggleMode(z){if(_r==null)return;if(++_m2>1)_m2=0;if(_m2){_k.style.width='900px';_r.innerHTML='普通模式'}else{_k.style.width='300px';_r.innerHTML='展开模式'}sc('mtwtcMode',365,_m2,'/');if(z&&_cc>=0)_ShowTree(-1)}

function _UpdateTooltip(z){var talent=z.talent;var c=_d2[talent.classId];var b='<div style="white-space: nowrap"><b>';if(talent.z)b+='<span><u>等级 '+talent.z+'</u></span>';b+=talent.n+'</b><br>'+'等级 '+talent.k+'/'+talent.m+'<br>';if(talent.r){if(c[talent.tree][talent.r[0]].k<talent.r[1]){b+='<em>需要'+talent.r[1]+'点';if(talent.r[1]>1)b+='';b+='在 '+c[talent.tree][talent.r[0]].n+'</em><br>'}}if(talent.y&&c[talent.tree].k<talent.y)b+='<em>需要'+talent.y+'点在 '+c[talent.tree].n+' 天赋</em><br>';if(talent.t){for(var i=0;i<5;i+=2){if(talent.t[i+1])b+='<span>'+talent.t[i+1]+'</span>';if(talent.t[i])b+=talent.t[i]+'<br>'}}b+='</div><var>'+_GetTalentDescription(talent)+'</var><br>';if(talent.enabled){if(!talent.k)b+='<i>点击学习</i><br>';else if(talent.k==talent.m)b+='<em>'+(_z?'Shift':'右键')+'-取消学习</em><br>';if(talent.k&&talent.k<talent.m)b+='<br>下一等级:<br><var>'+_GetTalentDescription(talent,1)+'</var><br>'}_e.innerHTML=b;_MoveTooltip(z,4,4)}
function _UpdateTree(z,y,x,w){var c=(w>=0?_d2[w]:_d2[_cc]);var highestLevel;var start;if(!x||c.k==61){start=0;highestLevel=40}else{start=x.i;highestLevel=Math.floor(c[z].k/5)*5+5}for(var i=start;i<c[z].length;++i){x=c[z][i];if(c.k<61)if(x.y>highestLevel)break;if(c.k==61&&!x.k)x.enabled=0;else{if(c[z].k>=x.y){if(x.r){if(c[z][x.r[0]].k>=x.r[1])x.enabled=1;else x.enabled=0}else x.enabled=1}else x.enabled=0}if(y){var _table;if(x.enabled){if((x.k==x.m)){x.border.style.backgroundPosition='-42px';x.bubble.style.color='#E7BA00'}else{x.border.style.backgroundPosition='-84px';x.bubble.style.color='#17FD17'}x.icon.style.backgroundPosition=-i*36+'px 0';x.bubble.style.visibility='visible';if(x.r){_table=x.arrow.firstChild;if(_table.className.indexOf('2')==-1)_table.className+='2'}}else{x.border.style.backgroundPosition=0;x.icon.style.backgroundPosition=-i*36+'px -36px';x.bubble.style.visibility='hidden';if(x.r){_table=x.arrow.firstChild;if(_table.className.indexOf('2')!=-1)_table.className=_table.className.replace('2','')}}x.bubble.innerHTML=x.k}}}
}

var mtwtc=new MTWTC;