function L(a){return a};
function tryStartup(){if(startup){startup()}}function myEval(A){eval(A)}function myEval(A){return eval(A)}function $(a){if(document.getElementById){$=function(b){return document.getElementById(b)};return $(a)}if(document.all){$=function(b){return document.all[b]};return $(a)}}function setOpacity(b,a){b.style.opacity=a/10;b.style.filter="progid:DXImageTransform.Microsoft.alpha(opacity="+a*10+")"}function obj_left(b){var a=b.offsetLeft;while((b=b.offsetParent)!=null){a+=b.offsetLeft}return a}function obj_top(b){var a=b.offsetTop;while((b=b.offsetParent)!=null){a+=b.offsetTop}return a}function IsNumeric(a){var d="0123456789.-",c=true,b;if(typeof a=="undefined"){return false}if(a==""){return false}for(i=0;i<a.length&&c==true;i++){b=a.charAt(i);if(d.indexOf(b)==-1){c=false}}return c}function IsPosInt(a){var d="0123456789",c=true,b;if(typeof a=="undefined"){return false}if(a==""){return false}for(i=0;i<a.length&&c==true;i++){b=a.charAt(i);if(d.indexOf(b)==-1){c=false}}return c}function nl2pnl(b){var a;if(b){b=escape(b);if(b.indexOf("%0D%0A")>-1){a=/%0D%0A/g}else{if(b.indexOf("%0A")>-1){a=/%0A/g}else{if(b.indexOf("%0D")>-1){a=/%0D/g}}}return unescape(b.replace(a,"\n"))}return b}function nl2br(c){var b,a;if(c){c=escape(c);if(c.indexOf("%0D%0A")>-1){b=/%0D%0A/g}else{if(c.indexOf("%0A")>-1){b=/%0A/g}else{if(c.indexOf("%0D")>-1){b=/%0D/g}}}a=unescape(c.replace(b,"<br />"));a=a.replace(/&lt;br\ \/&gt;/g,"<br />");return a}return c}function stripnl(b){var a;if(b){b=escape(b);if(b.indexOf("%0D%0A")>-1){a=/%0D%0A/g}else{if(b.indexOf("%0A")>-1){a=/%0A/g}else{if(b.indexOf("%0D")>-1){a=/%0D/g}}}return unescape(b.replace(a,""))}return b}function htmlspecialchars(a){if(a){a=a.replace(/\"/g,"&quot;");a=a.replace(/</g,"&lt;");a=a.replace(/>/g,"&gt;")}return a}function uni_unescape(a){return a.replace(/(%u([0-9A-F]{4}))/gi,"&#x$2;")}function stringFill(c,d){var a="";for(var b=0;b<d;b++){a+=c}return a}function ajax(b,c,e,a){var d=grabAjaxObj();if(!d){alert("It appears your browser does not support XMLHTTP requests. Some functions may not work correctly.");d=function(){return false};return false}d.onreadystatechange=function(){if(d.readyState==4){if(d.status==200){e(d.responseText)}else{a(d)}}};d.open("POST",b,true);d.setRequestHeader("Content-type","application/x-www-form-urlencoded");d.setRequestHeader("Content-length",c.length);d.setRequestHeader("Connection","close");d.send(c)}function defaultErrorHandler(a){switch(a.status){case 404:alert(L("This action could not be completed, 404: Unable to find page."));break;case 403:alert(L("This action could not be completed, 403: Access Denied."));break;case 500:alert(L("This action could not be completed, 500: Internal Server Error."));break;default:alert(L("This action could not be completed, Unknown error (")+a.status+")");break}}function grabAjaxObj(){var b;if(window.XMLHttpRequest){grabAjaxObj=function(){return new XMLHttpRequest()};return grabAjaxObj()}try{b=new ActiveXObject("Microsoft.XMLHTTP");grabAjaxObj=function(){return new ActiveXObject("Microsoft.XMLHTTP")}}catch(a){b=new ActiveXObject("Msxml2.XMLHTTP");grabAjaxObj=function(){return new ActiveXObject("Msxml2.XMLHTTP")}}return b}function cleanData(a){var a=a.replace(/^\"/g,"");a=a.replace(/\\$/g,"");a=a.replace(/([^\\])\"/g,"$1");a=a.replace(/\\\"/g,'"');a=unescape(a);return a}function BindArgument(b,a){return function(){return b(a)}}function getPageSize(){var c,a,b,d;if(window.innerHeight&&window.scrollMaxY){c=document.body.scrollWidth;a=window.innerHeight+window.scrollMaxY}else{if(document.body.scrollHeight>document.body.offsetHeight){c=document.body.scrollWidth;a=document.body.scrollHeight}else{c=document.body.offsetWidth;a=document.body.offsetHeight}}if(self.innerHeight){b=self.innerWidth;d=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){b=document.documentElement.clientWidth;d=document.documentElement.clientHeight}else{if(document.body){b=document.body.clientWidth;d=document.body.clientHeight}}}if(a<d){pageHeight=d}else{pageHeight=a}if(c<b){pageWidth=b}else{pageWidth=c}arrayPageSize=new Array(pageWidth,pageHeight,b,d);return arrayPageSize}function getCookie(a){if(document.cookie.length>0){c_start=document.cookie.indexOf(a+"=");if(c_start!=-1){c_start=c_start+a.length+1;c_end=document.cookie.indexOf(";",c_start);if(c_end==-1){c_end=document.cookie.length}return unescape(document.cookie.substring(c_start,c_end))}}return""}function setCookie(b,c,a){var d=new Date();d.setDate(d.getDate()+a);document.cookie=b+"="+escape(c)+((a==null)?"":";expires="+d.toGMTString())}function addListener(b,c,d,a){if(window.addEventListener){addListener=function(f,g,h,e){e=e||false;f.addEventListener(g,h,e);return true};return addListener(b,c,d,a)}else{if(window.attachEvent){addListener=function(f,g,h,e){f.attachEvent("on"+g,h);return true};return addListener(b,c,d,a)}else{addListener=function(f,g,h,e){return false};return addListener(b,c,d,a)}}}function ucFirst(a){var b=a.charAt(0);if(parseInt(a.length)==1){return b.toUpperCase()}else{return b.toUpperCase()+a.slice(1).toLowerCase()}}function trim(a){return a.replace(/(^\s+)([^\s]*)(\s+$)/,"$2")}function validEmail(a){var b=/^[A-Z0-9~!#$%^&*{}|\/=_'`?]?[A-Z0-9~!#$%^&*{}|\/=._'`\?+-]+[A-Z0-9~!#$%^&*{}|\/=_'`?-]?@([A-Z0-9._-]{0,}[A-Z_-]\.[A-Z]{2,3}|\[{0,1}[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\]{0,1})/i;return(null!=a.match(b))}function getNow(){return new Date().getTime()};
var execLogin=null,knownbaduser=new Array(),knownbadmail=new Array();function requestLogin(){var d=$("loginuser").value,b=$("loginpass").value,c="N",a="";if(d.length<1||d.length>100){a+=L("- Please enter a valid username.\n")}if(b.length<1||b.length>100){a+=L("- Please enter a valid password.\n")}if(d==b&&b!=""){a+=L("- This is not a valid password.\n")}if(a==""){setDisableLoginForm(true);formcontent="la=login&loginuser="+escape(d)+"&loginpass="+escape(b)+"&loginrem="+escape(c);ajax("ajax.php?a=l",formcontent,handleLoginResponds,defaultErrorHandler)}else{alert(a)}return false}function requstSignup(){var f=$("signupuser").value,e=$("signuppass1").value,d=$("signuppass2").value,a=$("signupmail").value,b="",c;if(f.length<1||f.length>100){b+=L("- Please enter a valid username.\n")}if(e.length<1||e.length>100){b+=L("- Please enter a valid password.\n")}if(e!=d&&e!=""){b+=L("- The passwords you entered did not match.\n")}if(f==e&&e!=""){b+=L("- This is not a valid password.\n")}for(c=0;c<knownbaduser.length;c++){if(knownbaduser[c]==f){b+=L("- This username is already in use.\n")}}if(a!=""){if(!validEmail(a)){b+=L("- This e-mail address is not valid.\n")}else{for(c=0;c<knownbadmail.length;c++){if(knownbadmail[c]==a){b+=L("- This e-mail address is already in use.\n")}}}}if(b==""){setDisableSignupForm(true);formcontent="la=signup&user="+escape(f)+"&pass="+escape(e)+"&mail="+escape(a);ajax("ajax.php?a=l",formcontent,handleSignupResponds,defaultErrorHandler)}else{alert(b)}}function handleSignupResponds(a){switch(a.substr(0,4)){case"suc:":curUser=myEval("("+a.substr(4)+")");$("usernamelabel").innerHTML=curUser.username;$("header_right_menu").style.display="";$("userava").className="noava";switch(curUser.avatar_type){case"0":$("userava").src="img/spacer.gif";break;case"1":$("userava").src="ava/"+curUser.avatar_arg+".jpg";break;case"2":$("userava").src=curUser.avatar_arg;break}previewBackground(curUser.background);closeSignupWindow();if(execLogin!=null){execLogin();execLogin=null}break;case"err:":alert(a.substr(4));break;case"dis:":alert(L("The server declined the request:\n")+a.substr(4));break;case"use:":switch(a.substr(4)){case"user":knownbaduser.push($("signupuser").value);alert(L("Your registration was not successful, username already in use."));break;case"mail":knownbadmail.push($("signupmail").value);alert(L("Your registration was not successful, e-mail address already in use."));break;case"both":knownbaduser.push($("signupuser").value);knownbadmail.push($("signupmail").value);alert(L("Your registration was not successful, username and e-mail address already in use."));break}break;default:alert(L("Your registration was not successful, the server was unable to handle your request. (")+a+")");break}setDisableSignupForm(false)}function handleLoginResponds(a){switch(a.substr(0,4)){case"suc:":curUser=myEval("("+a.substr(4)+")");$("usernamelabel").innerHTML=curUser.username;$("header_right_menu").style.display="";$("userava").className="noava";switch(curUser.avatar_type){case"0":$("userava").src="img/spacer.gif";break;case"1":$("userava").src="ava/"+curUser.avatar_arg+".jpg";break;case"2":$("userava").src=curUser.avatar_arg;break}previewBackground(curUser.background);closeLoginWindow();if(execLogin!=null){execLogin();execLogin=null}break;case"err:":alert(a.substr(4));break;default:alert(L("You have not been logged in, the server was unable to handle your request. (")+a+")");break}setDisableLoginForm(false)}function handleLogoutResponds(a){switch(a.substr(0,4)){case"err:":setCookie("ugsession","invalid");case"suc:":curUser={userID:"0"};$("usernamelabel").innerHTML=L("Guest (Click to login)");$("header_right_menu").style.display="none";$("userava").className="guestava";$("userava").src="img/spacer.gif";break}}function setDisableLoginForm(a){$("loginuser").disabled=a;$("loginpass").disabled=a;$("loginbutton").disabled=a;$("loginbutton").value=(a?L("Loading..."):L("Log-in"));$("loginbutton").className=(a?"loginbuttondis":"loginbutton");$("registerbutton").style.display=(a?"none":"");$("cancelbutton").style.display=(a?"none":"")}function setDisableSignupForm(a){$("signupuser").disabled=a;$("signuppass1").disabled=a;$("signuppass2").disabled=a;$("signupmail").disabled=a;$("signupbutton").disabled=a;$("signupbutton").value=(a?L("Loading..."):L("Save"));$("signupbutton").className=(a?"loginbuttondis":"loginbutton");$("signupcancelbutton").style.display=(a?"none":"")}function loginClick(){if(curUser.userID==0){return openLoginWindow()}}function menuClick(){if($("usermenu").style.display=="none"){$("usermenu").style.display=""}else{$("usermenu").style.display="none"}}function menuClose(){$("usermenu").style.display="none"}function doLogout(){ajax("ajax.php?a=l","la=logout",handleLogoutResponds,defaultErrorHandler);$("usermenu").style.display="none"}function searchMyTree(){top.location="bt.html#%26a"+curUser.username+"%7Cd1%7Ccall%7Cqt%3A0";$("usermenu").style.display="none"}function openLoginWindow(){blackBox();ajax("ajax.php?a=w","w=login",windowRespondsLogin,defaultErrorHandler)}function openSignupWindow(){blackBox();ajax("ajax.php?a=w","w=signup",windowRespondsSignup,defaultErrorHandler)}function openProfileWindow(){var b=getPageSize(),a=$("profilebox");blackBox();a.style.display="block";a.style.left=(b[2]/2)-(a.clientWidth/2)+"px";a.style.top=(b[3]/2)-(a.clientHeight/2)+"px"}function windowRespondsLogin(a){var b=document.createElement("div");b.innerHTML=a;document.body.appendChild(b);window.openLoginWindow=function(){blackBox();var d=$("loginbox");var c=getPageSize();d.style.display="block";d.style.left=(c[2]/2)-(d.clientWidth/2)+"px";d.style.top=(c[3]/2)-(d.clientHeight/2)+"px";setDisableLoginForm(false)};openLoginWindow()}function windowRespondsSignup(a){var b=document.createElement("div");b.innerHTML=a;document.body.appendChild(b);window.openSignupWindow=function(){blackBox();var d=$("signupbox");var c=getPageSize();d.style.display="block";d.style.left=(c[2]/2)-(d.clientWidth/2)+"px";d.style.top=(c[3]/2)-(d.clientHeight/2)+"px";setDisableSignupForm(false)};openSignupWindow()}function blackBox(){var b=getPageSize(),a=$("blackbox");a.style.display="block";a.style.height=b[1]+"px"}function closeLoginWindow(){$("loginbox").style.left="-100%";setDisableLoginForm(false);$("blackbox").style.display="none"}function closeProfileWindow(){$("profilebox").style.left="-100%";setDisableLoginForm(false);$("blackbox").style.display="none"}function signupButton(){$("loginbox").style.left="-100%";setDisableLoginForm(false);openSignupWindow()}function closeSignupWindow(){$("signupbox").style.left="-100%";setDisableSignupForm(false);$("blackbox").style.display="none"}function previewBackground(a){switch(a){case 0:document.body.style.backgroundImage="url(/img/arthas.png)";document.body.style.backgroundPosition="center 130px";break;case 1:document.body.style.backgroundImage="url(/img/illidan.png)";document.body.style.backgroundPosition="center 130px";break;case 2:document.body.style.backgroundImage="url(/img/illidan.png)";document.body.style.backgroundPosition="left 130px";break;case 3:document.body.style.backgroundImage="url(/img/illidan.png)";document.body.style.backgroundPosition="right 130px";break;case 4:document.body.style.backgroundImage="url(/img/kaelthasL.png)";document.body.style.backgroundPosition="left 130px";break;case 5:document.body.style.backgroundImage="url(/img/draeneiL.png)";document.body.style.backgroundPosition="left 130px";break;case 6:document.body.style.backgroundImage="url(/img/kaelthasR.png)";document.body.style.backgroundPosition="right 130px";break;case 7:document.body.style.backgroundImage="url(/img/draeneiR.png)";document.body.style.backgroundPosition="right 130px";break;case 8:document.body.style.backgroundImage="none";break}};
function TalentObj(a,d,e){this.tree=a;this.pos=e;this.row=d;this.talentname=L("Unused");this.desc=L("This talent is currently unused. Click the talent in edit mode to start using it.");this.numRanks=0;this.curRank=0;this.icon="Temp.jpg";this.reqs=new Array();this.type="empty";this.ranks=new Array(6);for(var c=0;c<=5;c++){this.ranks[c]=new Array(11);for(var b=0;b<=10;b++){this.ranks[c][b]=""}}this.treeelm=treee[a];this.butbg=$(this.getID());this.butc=$(this.getID()+"c");this.butimg=$(this.getID()+"i");this.butbg.style.left=(25+65*(this.pos-1)+treel[a])+"px";this.butbg.style.top=(5+65*(this.row-1)+treet[a])+"px";addListener(this.butbg,"mouseup",butclick);addListener(this.butbg,"contextmenu",butclick2);addListener(this.butbg,"mouseover",butmouseover);addListener(this.butbg,"mouseout",butmouseout);this.redraw(false)}TalentObj.prototype.setLoc=function setLoc(a,b,c){this.removeReqs();this.tree=a;this.pos=c;this.row=b;this.treeelm=treee[a];this.butbg=$(this.getID());this.butc=$(this.getID()+"c");this.butimg=$(this.getID()+"i");this.butbg.style.left=(25+65*(this.pos-1)+treel[a])+"px";this.butbg.style.top=(5+65*(this.row-1)+treet[a])+"px";this.redraw("")};TalentObj.prototype.setIcon=function setIcon(a){if(a.indexOf("/")!=-1){this.icon="Spells/"+a.substring((a.lastIndexOf("/")+1))}else{this.icon=a}};TalentObj.prototype.setActiveCastTime=function setActiveCastTime(a){if((a==0)&&(this.ActiveSpellType=="casttime")){this.ActiveSpellType="instant"}this.ActiveCastTime=a};TalentObj.prototype.setType=function setType(a){a=a.toLowerCase();if(a==this.type){return}if(this.row>getMaxi()){a="hidden"}switch(a.toLowerCase()){case"e":case"empty":this.setIcon("Temp.jpg");this.setNumRanks(0);this.setCurRank(0);this.removeReqs();this.talentname=L("Unused");this.desc=L("This talent is currently unused. Click the talent in edit mode to start using it.");this.type="empty";break;case"a":case"active":this.setNumRanks(1);this.setCurRank(0);this.type="active";break;case"p":case"passive":this.setCurRank(0);this.type="passive";break;case"h":case"hidden":this.setNumRanks(0);this.setCurRank(0);this.removeReqs();this.type="hidden";break}};TalentObj.prototype.setCurRank=function setCurRank(a){if(a>this.numRanks){this.curRank=this.numRanks}else{this.curRank=a}};TalentObj.prototype.setNumRanks=function setNumRanks(a){this.numRanks=a;this.setCurRank(0)};TalentObj.prototype.setRank=function setRank(c,a,b){this.ranks[c][a]=b};TalentObj.prototype.getRank=function setRank(b,a){return this.ranks[b][a]};TalentObj.prototype.getPassiveDesc=function getPassiveDesc(d){if(d<1||d>5){d=1}var b=0,a=this.desc.indexOf("@",0),c=nl2br(htmlspecialchars(this.desc));while(a!=-1){b++;a=this.desc.indexOf("@",(a+1));if(b>10){return this.desc}}for(a=0;a<b;a++){c=c.replace(/@/,this.getRank(d,a))}return c};TalentObj.prototype.getPassiveDescEdit=function getPassiveDescEdit(d){var c=0,b=this.desc.indexOf("@",0);title=nl2br(htmlspecialchars(this.desc)),replacement="[";while(b!=-1){c++;b=this.desc.indexOf("@",(b+1));if(c>10){return this.desc}}for(b=0;b<c;b++){for(var a=1;a<=this.numRanks;a++){if(a!=1){replacement+="|"}if(this.curRank==a){replacement+="<em>"+this.getRank(a,b)+"</em>"}else{replacement+=this.getRank(a,b)}}replacement+="]";title=title.replace(/@/,replacement)}return title};TalentObj.prototype.getPassiveRanks=function getPassiveRanks(){var c=0,b=this.desc.indexOf("@",0),a;result="";while(b!=-1){c++;b=this.desc.indexOf("@",(b+1));if(c>10){return""}}for(a=0;a<c;a++){for(b=1;b<=this.numRanks;b++){if(result!=""){result+="|"}result+=this.getRank(b,a)}}return this.numRanks+result};TalentObj.prototype.getReqs=function getReqs(a){return this.reqs.join("|")};TalentObj.prototype.addReq=function addReq(b){this.reqs.push(b);var a=translateSticky(b);spawnArrow(this.tree,a[1],a[2],this.row,this.pos)};TalentObj.prototype.isReq=function isReq(b){var a;for(a=0;a<this.reqs.length;a++){if(this.reqs[a]==b){return true}}return false};TalentObj.prototype.removeReq=function removeReq(c){var b,a;for(var b=0;b<this.reqs.length;b++){if(this.reqs[b]!=c){continue}var a=translateSticky(this.reqs[b]);removeArrow(this.tree,a[1],a[2],this.row,this.pos);this.reqs.slice(b,1);return}};TalentObj.prototype.removeReqs=function removeReqs(){var b,a;for(var b=0;b<this.reqs.length;b++){a=translateSticky(this.reqs[b]);removeArrow(this.tree,a[1],a[2],this.row,this.pos)}this.reqs=new Array()};TalentObj.prototype.reqsAreOk=function reqsAreOk(){var d,b,a,e=(rowpoints*(this.row-1)),c=0;for(d=0;d<this.reqs.length;d++){a=translateSticky(this.reqs[d]);if(!treec[this.tree][a[1]][a[2]].isMaxRank()){return false}}if(e>0){for(d=1;d<this.row;d++){for(b=1;b<=4;b++){c+=parseInt(treec[this.tree][d][b].curRank)}}if(c<e){return false}}return true};TalentObj.prototype.addPoint=function addPoint(){var d=0,a=getMaxi(),c,b;if((this.curRank<this.numRanks)&&(pointlock==0||((((treep[1]+treep[2]+treep[3]))*levelBetweenPoints)+startLevel)<=pointlock)){this.setCurRank(this.curRank+1);this.redraw(false);for(c=1;c<=a;c++){for(b=1;b<=4;b++){d+=parseInt(treec[this.tree][c][b].curRank)}}treep[this.tree]=d;if((pointlock>0)&&((treep[1]+treep[2]+treep[3])>=pointlock)){redrawAll()}else{for(c=1;c<=a;c++){for(b=1;b<=4;b++){treec[this.tree][c][b].redraw(false)}}}return true}return false};TalentObj.prototype.subPoint=function subPoint(){var c=getMaxi(),e,d,b,a;if(this.curRank>0){this.setCurRank(this.curRank-1);treep[this.tree]--;for(e=this.row;e<=c;e++){for(d=1;d<=4;d++){if(treec[this.tree][e][d].curRank>0&&!treec[this.tree][e][d].reqsAreOk()){this.setCurRank(this.curRank+1);treep[this.tree]++;for(b=this.row;b<=e;b++){for(a=1;a<=4;a++){treec[this.tree][b][a].redraw(false)}}return false}else{treec[this.tree][e][d].redraw(false)}}}if(pointlock>0&&((treep[1]+treep[2]+treep[3])<pointlock)){redrawAll()}else{this.redraw(false)}return true}return false};TalentObj.prototype.getReadCost=function getReadCost(){var e=this.ActiveCost,d=e.substring(0,1),c=e.substring(1,2),a=e.substring(2,3),b="";if(this.ActiveCostType=="runes"){if(parseInt(d)>0){b+=d+'<img src="img/spacer.gif" width="13" height="13" alt="Blood Runes" class="runeB" /> '}if(parseInt(c)>0){b+=c+'<img src="img/spacer.gif" width="13" height="13" alt="Unholy Runes" class="runeF" /> '}if(parseInt(a)>0){b+=a+'<img src="img/spacer.gif" width="13" height="13" alt="Frost Runes" class="runeU" /> '}return b}else{return htmlspecialchars(this.ActiveCost)+""+htmlspecialchars(this.getReadCostType())}};TalentObj.prototype.getReadCostType=function getReadCostType(){if(this.ActiveCostType=="procmana"){return L("% of base mana")}if(this.ActiveCostType=="procrmana"){return L("% of remaining mana")}if(this.ActiveCostType=="runic"){return L(" Runic Power")}return" "+L(ucFirst(this.ActiveCostType))};TalentObj.prototype.getReadRange=function getReadRange(){if(this.hasNoRange()){return""}if(this.ActiveRangeMin==0&&this.ActiveRangeMax>0){return this.ActiveRangeMax+L(" yd range")}if(this.ActiveRangeMin==this.ActiveRangeMax){return this.ActiveRangeMax+L(" yd range")}return this.ActiveRangeMin+"-"+this.ActiveRangeMax+L(" yd range")};TalentObj.prototype.getReadCasttime=function getReadCasttime(){if((this.ActiveCastTime==0)&&(this.ActiveSpellType=="casttime")){this.ActiveSpellType="instant"}if(this.ActiveSpellType=="channeled"){return L("Channeled")}if(this.ActiveSpellType=="nextmelee"){return L("Next Melee")}if(this.ActiveCost>0){if(this.ActiveSpellType=="instant"&&this.ActiveCostType=="mana"){return L("Instant cast")}if(this.ActiveSpellType=="instant"){return L("Instant")}if(this.ActiveCastTime<60){return this.ActiveCastTime+L(" sec cast")}if(this.ActiveCastTime%60==0){return parseInt(this.ActiveCastTime/60)+L(" min cast")}if(parseInt(this.ActiveCastTime%60)<10){return parseInt(this.ActiveCastTime/60)+L(" min ")+parseInt(this.ActiveCastTime%60)+L(" sec cast")}return parseInt(this.ActiveCastTime/60)+L(" min ")+parseInt(this.ActiveCastTime%60)+L(" sec cast")}else{if(this.ActiveSpellType=="instant"){return L("Instant")}if(this.ActiveCastTime<60){return this.ActiveCastTime+L(" sec")}if(this.ActiveCastTime%60==0){return parseInt(this.ActiveCastTime/60)+L(" min")}if(parseInt(this.ActiveCastTime%60)<10){return parseInt(this.ActiveCastTime/60)+L(" min ")+parseInt(this.ActiveCastTime%60)+L(" sec")}return parseInt(this.ActiveCastTime/60)+L(" min ")+parseInt(this.ActiveCastTime%60)+L(" sec")}};TalentObj.prototype.getReadCooldown=function getReadCooldown(){if(this.ActiveCooldown<60){return this.ActiveCooldown+L(" sec")}if(this.ActiveCooldown%60==0){return parseInt(this.ActiveCooldown/60)+L(" min")}if(parseInt(this.ActiveCooldown%60)<10){return parseInt(this.ActiveCooldown/60)+L(" min ")+parseInt(this.ActiveCooldown%60)+L(" sec")}return parseInt(this.ActiveCooldown/60)+L(" min ")+parseInt(this.ActiveCooldown%60)+L(" sec")};TalentObj.prototype.doTooltip=function doTooltip(){var e="<strong>"+htmlspecialchars(this.talentname)+"</strong><br />",c=(rowpoints*(this.row-1)),b,a,d,f;if(this.numRanks>0){e+=L("Rank ")+this.curRank+"/"+this.numRanks+"<br />"}if(c!=0){if(treep[this.tree]>=c){e+='<span class="reqmet">'}else{e+='<span class="reqnotmet">'}e+=L("Requires ")+(rowpoints*(this.row-1))+L(" points in ")+treen[this.tree]+L(" Talents.")+"</span><br />"}for(b=0;b<this.reqs.length;b++){a=translateSticky(this.reqs[b]);d=a[1];f=a[2];if(!treec[this.tree][d][f].isMaxRank()){e+='<span class="reqnotmet">'}else{e+='<span class="reqmet">'}e+=L("Requires ")+treec[this.tree][d][f].numRanks+" ";if(treec[this.tree][d][f].numRanks==1){e+=L("point")}else{e+=L("points")}e+=L(" in ")+htmlspecialchars(treec[this.tree][d][f].talentname)+".</span><br />"}if(this.type=="active"){if(this.ActiveCost>0){e+='<span class="hleft">'+this.getReadCost()+"</span>";if(!this.hasNoRange()){e+='<span class="hright">'+htmlspecialchars(this.getReadRange())+"</span>"}e+='<div class="cb"></div>';e+='<span class="hleft">'+htmlspecialchars(this.getReadCasttime())+"</span>";if(this.ActiveCooldown>0){e+='<span class="hright">'+htmlspecialchars(this.getReadCooldown())+L(" cooldown")+"</span>"}}else{if(this.hasNoRange()){e+='<span class="hleft">'+htmlspecialchars(this.getReadCasttime())+"</span>";if(this.ActiveCooldown>0){e+='<span class="hright">'+htmlspecialchars(this.getReadCooldown())+L(" cooldown")+"</span>"}}else{e+='<span class="hleft">'+htmlspecialchars(this.getReadRange())+"</span>";e+='<div class="cb"></div>';e+='<span class="hleft">'+htmlspecialchars(this.getReadCasttime())+"</span>";if(this.ActiveCooldown>0){e+='<span class="hright">'+htmlspecialchars(this.getReadCooldown())+L(" cooldown")+"</span>"}}}e+='<div class="cb"></div>';if(this.ActiveReagents!=""){e+='<span class="left">'+L("Reagents: ")+uni_unescape(htmlspecialchars(this.ActiveReagents))+"</span>"}if(this.ActiveRequires!=""){e+='<span class="left">'+L("Requires ")+uni_unescape(htmlspecialchars(this.ActiveRequires))+"</span>"}e+='<div class="cb"></div>';e+='<span class="desc">'+nl2br(htmlspecialchars(this.desc))+"</span>"}else{if(this.type=="passive"){if(mode=="preview"){e+='<span class="desc">'+this.getPassiveDesc(this.curRank)+"</span>"}else{e+='<span class="desc">'+this.getPassiveDescEdit()+"</span>"}}else{e+='<span class="desc">'+nl2br(htmlspecialchars(this.desc))+"</span>"}}tooltipcelm.innerHTML=e;showTooltip(this.butbg);tooltipcelm.innerHTML=e};TalentObj.prototype.redraw=function redraw(b){var a;if(this.type=="hidden"){this.hideButton();this.butc.innerHTML="";return}if(mode=="preview"){if(this.type=="empty"){this.hideButton();this.butc.innerHTML="";return}else{this.showButton()}if(this.reqsAreOk()){if(pointlock>0&&((((treep[1]+treep[2]+treep[3])*levelBetweenPoints)+(startLevel-1))>=pointlock)&&this.curRank==0){this.butimg.style.backgroundPosition="0px 0px";setOpacity(this.butbg,10);this.butc.innerHTML="";a=this.icon.replace(/Spells\//gi,"SpellsGrey/");this.butbg.style.backgroundImage="url("+imagepath+a+")"}else{if(this.numRanks>0){this.butc.innerHTML=this.curRank+"/"+this.numRanks}else{this.butc.innerHTML="X"}if(this.curRank==this.numRanks){this.butimg.style.backgroundPosition="-224px 0px";this.butc.style.color="#FFD100"}else{this.butimg.style.backgroundPosition="-56px 0px";this.butc.style.color="#2EFF00"}setOpacity(this.butbg,10);this.butbg.style.backgroundImage="url("+imagepath+this.icon+")"}}else{this.butimg.style.backgroundPosition="0px 0px";setOpacity(this.butbg,10);this.butc.innerHTML="";a=this.icon.replace(/Spells\//gi,"SpellsGrey/");this.butbg.style.backgroundImage="url("+imagepath+a+")"}}else{this.showButton();this.butbg.style.backgroundImage="url("+imagepath+this.icon+")";if(curtree==this.tree&&currow==this.row&&curpos==this.pos){this.butimg.style.backgroundPosition="-112px 0px";this.butc.style.color="#0000FE";setOpacity(this.butbg,10);switch(this.type){case"active":this.butc.innerHTML="A";break;case"passive":this.butc.innerHTML="P"+this.numRanks;break;case"empty":this.butc.innerHTML="X";break;default:this.butc.innerHTML="";break}return}if(b){this.butimg.style.backgroundPosition="-168px 0px";this.butc.style.color="#FF3900";setOpacity(this.butbg,10);switch(this.type){case"active":this.butc.innerHTML="A";break;case"passive":this.butc.innerHTML="P"+this.numRanks;break;case"empty":this.butc.innerHTML="X";break;default:this.butc.innerHTML="";break}return}switch(this.type){case"active":this.butimg.style.backgroundPosition="-56px 0px";this.butc.style.color="#2EFF00";setOpacity(this.butbg,10);this.butc.innerHTML="A";break;case"passive":this.butimg.style.backgroundPosition="-224px 0px";this.butc.style.color="#FFD100";setOpacity(this.butbg,10);this.butc.innerHTML="P"+this.numRanks;break;default:case"empty":this.butimg.style.backgroundPosition="0px 0px";setOpacity(this.butbg,3);this.butc.innerHTML="";break}}};TalentObj.prototype.reposition=function reposition(){var b,a,c,d;this.butbg.style.left=(25+65*(this.pos-1)+treel[this.tree])+"px";this.butbg.style.top=(5+65*(this.row-1)+treet[this.tree])+"px";for(b=0;b<this.reqs.length;b++){a=translateSticky(this.reqs[b]);c=a[1];d=a[2];removeArrow(this.tree,c,d,this.row,this.pos);spawnArrow(this.tree,c,d,this.row,this.pos)}this.redraw(false)};TalentObj.prototype.showButton=function showButton(){this.butbg.style.display=""};TalentObj.prototype.hideButton=function hideButton(){this.butbg.style.display="none"};TalentObj.prototype.hasNoRange=function hasNoRange(){return(this.ActiveRangeMin==0&&this.ActiveRangeMax==0)};TalentObj.prototype.getID=function getID(){return"t"+this.tree+"r"+this.row+"p"+this.pos};TalentObj.prototype.getShortID=function getShortID(){return this.tree+""+this.row+""+this.pos};TalentObj.prototype.isMaxRank=function isMaxRank(){return(this.curRank==this.numRanks)};TalentObj.prototype.getActiveSave=function getActiveSave(){var a=this.ActiveCost;a+="|"+this.ActiveCostType;a+="|"+this.ActiveSpellType;a+="|"+this.ActiveCastTime;a+="|"+this.ActiveCooldown;a+="|"+this.ActiveRangeMin;a+="|"+this.ActiveRangeMax;a+="|"+this.ActiveReagents;a+="|"+this.ActiveRequires;return htmlspecialchars(a)};
function spawnArrow(j,h,f,c,a){var e=$("tree"+j),b=(a-f),g,d;j=parseInt(j);h=parseInt(h);f=parseInt(f);c=parseInt(c);a=parseInt(a);if(!checkArrow(j,h,f,c,a,false)){return false}e=$("tree"+j);b=(a-f);if(b>0){g=e.appendChild(document.createElement("div"));if(h<c){g.className="arrowrd";g.style.left=(obj_left(e)+25)+65*(f-1)+47+"px";g.style.top=(5+65*(h)+obj_top(e))-45+"px";g.style.height="15px";g.style.width=51+(65*(b-1))+"px"}else{g.className="arrowr";g.style.left=(obj_left(e)+25)+65*(f-1)+47+"px";g.style.top=(5+65*(h)+obj_top(e))-45+"px";g.style.height="15px";g.style.width=25+(65*(b-1))+"px"}g.id="arrow"+j+h+f+c+a}if(b<0){possideways=b*-1;g=e.appendChild(document.createElement("div"));if(h<c){g.className="arrowld";g.style.width=51+(65*(possideways-1))+"px";g.style.left=(obj_left(e)+25)+65*(f-1)-47-(65*(possideways-1))+"px";g.style.top=(5+65*(h)+obj_top(e))-45+"px";g.style.height="15px"}else{g.className="arrowl";g.style.width=25+(65*(possideways-1))+"px";g.style.left=(obj_left(e)+25)+65*(f-1)-23-(65*(possideways-1))+"px";g.style.top=(5+65*(h)+obj_top(e))-45+"px";g.style.height="15px"}g.id="arrow"+j+h+f+c+a}if(h<c){g=e.appendChild(document.createElement("div"));g.className="arrowd";g.style.left=(obj_left(e)+25)+65*(a-1)+18+"px";if(b!=0){g.style.top=(5+65*(h)+obj_top(e))-30+"px";g.style.height=35+(65*((c-h)-1))+"px"}else{g.style.top=(5+65*(h)+obj_top(e))-18+"px";g.style.height=22+(65*((c-h)-1))+"px"}g.style.width="15px";g.id="arrow"+j+h+f+c+a+"d"}b=(f-a);if(b<0){b*=-1;b-=1;for(d=0;d<b;d++){treec[j][h][f+(b-d)].setType("hidden");treec[j][h][f+(b-d)].redraw(false)}}else{b-=1;for(d=0;d<b;d++){treec[j][h][a-(d-b)].setType("hidden");treec[j][h][a-(d-b)].redraw(false)}}if(h<c){if((f-a)!=0){treec[j][h][a].setType("hidden");treec[j][h][a].redraw(false)}for(d=1;d<(c-h);d++){treec[j][h+d][a].setType("hidden");treec[j][h+d][a].redraw(false)}}}function checkArrow(j,h,f,c,a,e){var b,d=0;j=parseInt(j);h=parseInt(h);f=parseInt(f);c=parseInt(c);a=parseInt(a);if(h>c){return false}if(h==c&&f==a){return false}if((c-h)>4){return false}if(!validArrowTalent(j,h,f)){return false}if(!validArrowTalent(j,c,a)){if(!e){return false}}b=(f-a);if(b<0){b*=-1;b-=1;while(d<b){if(canArrow(j,h,f+(b-d))){d++}else{return false}}}else{b-=1;while(d<b){if(canArrow(j,h,a-(d-b))){d++}else{return false}}}if(h<c){if(!canArrow(j,h,a)&&((f-a)!=0)){return false}var g=c-h;for(d=1;d<g;d++){if(!canArrow(j,(h+d),a)){return false}}}return true}function removeArrow(j,h,f,c,a){var g=$("arrow"+j+h+f+c+a),b=(f-a),e;j=parseInt(j);h=parseInt(h);f=parseInt(f);c=parseInt(c);a=parseInt(a);if(h>c){return false}if(h==c&&f==a){return false}if((f-a)!=0&&g){g.parentNode.removeChild(g)}if(h<c){g=$("arrow"+j+h+f+c+a+"d");if(g){var d=g.parentNode;d.removeChild(g)}}if(b<0){b*=-1;b-=1;for(e=0;e<b;e++){treec[j][h][f+(b-e)].setType("empty");treec[j][h][f+(b-e)].redraw(false)}}else{b-=1;for(e=0;e<b;e++){treec[j][h][a-(e-b)].setType("empty");treec[j][h][a-(e-b)].redraw(false)}}if(h<c){if((f-a)!=0){treec[j][h][a].setType("empty");treec[j][h][a].redraw(false)}for(e=1;e<(c-h);e++){treec[j][h+e][a].setType("empty");treec[j][h+e][a].redraw(false)}}}function canArrow(a,b,c){a=parseInt(a);b=parseInt(b);c=parseInt(c);if(treec[a][b][c].type=="active"){return false}if(treec[a][b][c].type=="passive"){return false}if(treec[a][b][c].type=="hidden"){return false}return true}function validArrowTalent(a,b,c){a=parseInt(a);b=parseInt(b);c=parseInt(c);if(treec[a][b][c].type=="active"){return true}if(treec[a][b][c].type=="passive"){return true}return false};
function makeRequest(a){ajax("ajax.php?a=gt&id="+a,"",procesData,defaultErrorHandler)}function makeFullRequest(a){ajax("ajax.php?a=ft&dummy="+getNow()+"&id="+a,"",procesData,defaultErrorHandler)}function makeCountingRequest(b,a){ajax("ajax.php?a=v&id="+b,"",procesData,defaultErrorHandler)}function makeRequestUrl(a){ajax(a,"",procesData,defaultErrorHandler)}function procesData(h){var d=getMaxi(),f,l,g,b,o,c,a,m=null;if(h==""){alert("The selected information could not be loaded. Please try again later.");return}if(h=="err:404"){alert(L("The selected tree was not found."))}else{if(h.substr(0,4)!="jsn:"){if(h.substr(0,4)=="suc:"){h=h.substr(4)}for(f=1;f<=3;f++){for(l=1;l<=d;l++){for(g=1;g<=4;g++){treec[f][l][g].setType("empty");treec[f][l][g].redraw(false)}}}if(h.substr(0,1)=="c"){b=h.indexOf("#");o=h.substr(1,(b-2));c=h.substr((b-1),1);setClass(o);switch(c){case 0:treeTypeNormal();break;case 1:treeTypeTBC();break;case 2:treeTypeWotLK();break}}a=h.split("\n");for(l=0;l<a.length;l++){if(a[l].length>1){procesTalent(a[l])}}for(l=0;l<a.length;l++){if(a[l].length>1){procesTalentPreReqs(a[l])}}}else{h=h.substr(4);try{m=myEval("("+h+")")}catch(n){return}$("treeTitle").value=m.title;$("authorComments").value=m.authorcomment;$("isHidden").value=m.isHidden;setClass(m.pclass);switch(m.treetype){case"0":treeTypeNormal();break;case"1":treeTypeTBC();break;case"2":treeTypeWotLK();break}a=m.content.split("\n");for(l=0;l<a.length;l++){if(a[l].length>1){procesTalent(a[l])}}for(l=0;l<a.length;l++){if(a[l].length>1){procesTalentPreReqs(a[l])}}}}}function procesTalent(c){var e=/(\d+)#([AP])#\\{0,1}\"(.*)\\{0,1}\"#\\{0,1}\"(.*)\\{0,1}\"#\\{0,1}\"(.*)\\{0,1}\"#([\d|]*)#(.*)#/i.exec(c),b=e[1],d,a,g,h,f;if(b.length>=3){d=translateSticky(e[1]);a=d[0];g=d[1];h=d[2];f=treec[a][g][h];f.setType(cleanData(e[2]));f.talentname=cleanData(e[3]);f.setIcon("Spells/"+cleanData(e[4]));f.desc=cleanData(e[5]);if(f.type=="active"){procesTalentActive(a,g,h,e[7])}if(f.type=="passive"){procesTalentPassive(a,g,h,e[7])}f.redraw(false)}}function procesTalentPreReqs(a){var c=/(\d+)#([AP])#\\{0,1}\"(.*)\\{0,1}\"#\\{0,1}\"(.*)\\{0,1}\"#\\{0,1}\"(.*)\\{0,1}\"#([\d|]*)#(.*)#/i.exec(a),b=translateSticky(c[1]);procesTalentReqs(b[0],b[1],b[2],c[6])}function procesTalentReqs(a,e,f,d){var c,b;if(d.length<3){return}c=d.split("|");for(b=0;b<c.length;b++){treec[a][e][f].addReq(c[b])}}function procesTalentActive(a,e,f,c){var b=c.split("|"),d;if(b.length==9){d=treec[a][e][f];d.ActiveCost=b[0];d.ActiveCostType=b[1];d.ActiveSpellType=b[2];d.setActiveCastTime(b[3]);d.ActiveCooldown=b[4];d.ActiveRangeMin=b[5];d.ActiveRangeMax=b[6];d.ActiveReagents=b[7];d.ActiveRequires=b[8]}}function procesTalentPassive(a,f,g,e){var c,d,b;if(e.length<3){treec[a][f][g].setNumRanks(1);return}c=e.split("|");d=e.substring(0,1);treec[a][f][g].setNumRanks(d);c[0]=c[0].substring(1);for(b=0;b<c.length;b++){treec[a][f][g].setRank((parseInt(b%d)+1),(parseInt(Math.ceil((b+0.5)/d))-1),c[b])}};
var curtree=0,currow=0,curpos=0,treec=new Array(3),treep=new Array(3),treen=new Array(3),treee=new Array(3),treet=new Array(3),treel=new Array(3),switchActive=false,tooltipelm=null,tooltipcelm=null,pointlock=0,rowpoints=5,startLevel=10,levelBetweenPoints=1;function getMaxi(){if(currentClass=="pet"){return 5}switch(treeType){case"WotLK":return 11;case"TBC":return 9;case"normal":return 7}}function redrawAll(){var b=getMaxi(),a,d,c;for(a=1;a<=3;a++){for(d=1;d<=b;d++){for(c=1;c<=4;c++){treec[a][d][c].redraw(false)}}}}function setClass(a){if(a!=currentClass){currentClass=a;switch(a){case"unset":treen[1]=L("Blue");treen[2]=L("Red");treen[3]=L("Green");rowpoints=5;startLevel=10;levelBetweenPoints=1;resetTreeType();break;case"druid":treen[1]=L("Balance");treen[2]=L("Feral");treen[3]=L("Restoration");rowpoints=5;startLevel=10;levelBetweenPoints=1;resetTreeType();break;case"deathknight":treen[1]=L("Blood");treen[2]=L("Frost");treen[3]=L("Unholy");rowpoints=5;startLevel=10;levelBetweenPoints=1;treeTypeWotLK();break;case"hunter":treen[1]=L("Beast Mastery");treen[2]=L("Marksmanship");treen[3]=L("Survival");rowpoints=5;startLevel=10;levelBetweenPoints=1;resetTreeType();break;case"mage":treen[1]=L("Arcane");treen[2]=L("Fire");treen[3]=L("Frost");rowpoints=5;startLevel=10;levelBetweenPoints=1;resetTreeType();break;case"paladin":treen[1]=L("Holy");treen[2]=L("Protection");treen[3]=L("Retribution");rowpoints=5;startLevel=10;levelBetweenPoints=1;resetTreeType();break;case"priest":treen[1]=L("Discipline");treen[2]=L("Holy");treen[3]=L("Shadow");rowpoints=5;startLevel=10;levelBetweenPoints=1;resetTreeType();break;case"rogue":treen[1]=L("Assasination");treen[2]=L("Combat");treen[3]=L("Subtlety");rowpoints=5;startLevel=10;levelBetweenPoints=1;resetTreeType();break;case"shaman":treen[1]=L("Elemental");treen[2]=L("Enhancement");treen[3]=L("Restoration");rowpoints=5;startLevel=10;levelBetweenPoints=1;resetTreeType();break;case"warlock":treen[1]=L("Affliction");treen[2]=L("Demonology");treen[3]=L("Destruction");rowpoints=5;startLevel=10;levelBetweenPoints=1;resetTreeType();break;case"warrior":treen[1]=L("Arms");treen[2]=L("Fury");treen[3]=L("Protection");rowpoints=5;startLevel=10;levelBetweenPoints=1;resetTreeType();break;case"pet":treen[1]=L("Tenacity");treen[2]=L("Ferocity");treen[3]=L("Cunning");rowpoints=3;startLevel=20;levelBetweenPoints=4;treeTypeWotLK();break}}for(i=1;i<=3;i++){treee[i].style.backgroundImage="url(bg/"+treeType+a+i+".jpg)";$("treeheadertext"+i).innerHTML=treen[i]}}function butclick2(a){if(!a){a=event}if(a.preventDefault){a.preventDefault()}else{a.returnResult=false}if(a.stopPropagation){a.stopPropagation()}else{a.cancelBubble=true}return false}function butmouseover(b){var c,a,d,f,e;if(!b){b=event}if(b.target){e=b.target}if(b.srcElement){e=b.srcElement}c=translateElmId(e.id);a=c[0];d=c[1];f=c[2];e=$(treec[a][d][f].getID());treec[a][d][f].doTooltip();if(mode=="edit"){treec[a][d][f].redraw(true)}}function butmouseout(b){var c,a,d,e;if(!b){b=event}if(b.target){elm=b.target}if(b.srcElement){elm=b.srcElement}if(mode=="edit"){c=translateElmId(elm.id);a=c[0];d=c[1];e=c[2];treec[a][d][e].redraw(false)}hideTooltip()}function schoolHover(c){var a=getMaxi(),d,b;counts=0;countt=0;counta=0;countp=0;for(d=1;d<=a;d++){for(b=1;b<=4;b++){counts+=parseInt(treec[c][d][b].curRank);countt+=parseInt(treec[c][d][b].numRanks);if(treec[c][d][b].type=="active"){counta+=1}if(treec[c][d][b].type=="passive"){countp+=1}}}treep[c]=counts;tooltipcelm.innerHTML="<strong>"+treen[c]+"</strong><br />"+L("Points spend in this tree: ")+counts+"<br />"+L("Total points in this tree: ")+countt+"<br />"+L("Active talents in this tree: ")+counta+"<br />"+L("Passive talents in this tree: ")+countp;showTooltip($("treeheader"+c),true)}function hideTooltip(){tooltipelm.style.display="none"}function showTooltip(f,a){tooltipelm.style.display="";var c={x:(document.body.clientWidth)?document.body.clientWidth:window.innerWidth,y:(document.body.clientHeight)?document.body.clientHeight:window.innerHeight},b=(a==true?0:f.offsetWidth),e=obj_left(f)+b,d=obj_top(f)-tooltipelm.offsetHeight;if(e<0){e=0}if(d<0){d=obj_top(f)+f.offsetHeight}if(a==true){if((e+tooltipelm.offsetWidth)+1>=c.x){e=c.x-tooltipelm.offsetWidth}}else{if((e+tooltipelm.offsetWidth+b)+1>=c.x){e=obj_left(f)-tooltipelm.offsetWidth}}if((d+tooltipelm.offsetHeight)+1>=c.y){d=obj_top(f)-tooltipelm.offsetHeight}tooltipelm.style.top=d+"px";tooltipelm.style.left=e+"px"}function translateElmId(a){a.match(/t(\d+)r(\d+)p(\d+)/);return[RegExp.$1,RegExp.$2,RegExp.$3]}function translateSlash(a){a.match(/(\d+)\/(\d+)\/(\d+)/);return[RegExp.$1,RegExp.$2,RegExp.$3]}function translateSticky(a){a.match(/([1|2|3])(\d+)([1|2|3|4])/);return[RegExp.$1,RegExp.$2,RegExp.$3]};
var translator=new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");window.onload=function(){var c,e,d,b=getMaxi(),f,a;tooltipelm=$("tooltipbox");tooltipcelm=$("tooltipcontent");hideTooltip();for(c=1;c<=3;c++){treec[c]=new Array(b);treep[c]=0;treen[c]="";treee[c]=$("tree"+c);treet[c]=obj_top(treee[c]);treel[c]=obj_left(treee[c]);f=$("treeheader"+c);a=$("treeheaderimg"+c);addListener(f,"mouseover",BindArgument(schoolHover,c));addListener(f,"mouseout",hideTooltip);addListener(f,"mouseup",butclick2);addListener(f,"mousedown",butclick2);addListener(a,"mouseover",function(g){if(!g){g=event}if(g.target){elm=g.target}if(g.srcElement){elm=g.srcElement}elm.style.backgroundPosition="-9px -106px"});addListener(a,"mouseout",function(g){if(!g){g=event}if(g.target){elm=g.target}if(g.srcElement){elm=g.srcElement}elm.style.backgroundPosition="-29px -106px"});addListener(a,"mouseup",BindArgument(ResetTree,c));addListener(treee[c],"mouseup",butclick2);addListener(treee[c],"mousedown",butclick2);addListener(treee[c],"contextmenu",butclick2);addListener(treee[c],"mouseover",butclick2);addListener(treee[c],"mouseout",butclick2);addListener(treee[c],"dragstart",butclick2);addListener(treee[c],"selectstart",butclick2);for(e=1;e<=b;e++){treec[c][e]=new Array(4);for(d=1;d<=4;d++){treec[c][e][d]=new TalentObj(c,e,d)}}}setClass(classToLoad);procesData(taldata);loadBuild();updatePointsOverview();redrawAll()};function butclick(b){var c,a,e,f;if(!b){b=event}if(b.target){elm=b.target}if(b.srcElement){elm=b.srcElement}var d=b.which?b.which:b.button;c=translateElmId(elm.id);a=c[0];e=c[1];f=c[2];if(treec[a][e][f].type=="empty"){return false}if(b.shiftKey==true||d>1){treec[a][e][f].subPoint();updatePointsOverview(a)}else{if(treec[a][e][f].reqsAreOk()){treec[a][e][f].addPoint();updatePointsOverview(a)}}treec[a][e][f].doTooltip();return false}function ResetTrees(){var b=getMaxi(),a,d,c;for(a=1;a<=3;a++){treep[a]=0;for(d=1;d<=b;d++){for(c=1;c<=4;c++){treec[a][d][c].setCurRank(0);treec[a][d][c].redraw(false)}}}updatePointsOverview()}function ResetTree(a){var b=getMaxi(),d,c;for(d=1;d<=b;d++){for(c=1;c<=4;c++){treec[a][d][c].setCurRank(0);treec[a][d][c].redraw(false)}}treep[a]=0;updatePointsOverview()}function redrawAll(){var b=getMaxi(),a,d,c;for(a=1;a<=3;a++){treep[a]=0;for(d=1;d<=b;d++){for(c=1;c<=4;c++){treep[a]+=parseInt(treec[a][d][c].curRank)}}}for(a=1;a<=3;a++){for(d=1;d<=b;d++){for(c=1;c<=4;c++){treec[a][d][c].redraw(false)}}}updatePointsOverview()}function updatePointsOverview(){var b=$("pointsused"),a;b.innerHTML=treep[1]+treep[2]+treep[3];b=$("levelneeded");if(treep[1]+treep[2]+treep[3]==0){b.innerHTML=1}else{b.innerHTML=(((treep[1]+treep[2]+treep[3])-1)*levelBetweenPoints)+startLevel}b=$("buildoverview");b.innerHTML=treep[1]+" / "+treep[2]+" / "+treep[3];for(a=1;a<=3;a++){$("treeheadertext"+a).innerHTML=treen[a]+" ("+treep[a]+")"}}function loadBuild(){var c,d="000",b,a,e,f;if(autoFilloOut.length==0){return}switch(autoFilloOut.charAt(0)){case"9":setPointLock(0);autoFilloOut=autoFilloOut.substring(1);break;case"8":setPointLock(60);autoFilloOut=autoFilloOut.substring(1);break;case"7":setPointLock(70);autoFilloOut=autoFilloOut.substring(1);break;case"6":setPointLock(0);autoFilloOut=autoFilloOut.substring(1);break;default:setPointLock(0);break}for(c=(translator.length-1);c>1;c--){autoFilloOut=autoFilloOut.replace(translator[c],stringFill("0",c))}for(c=0;c<autoFilloOut.length;c++){butloc=translateSlash(d);a=butloc[0];e=butloc[1];f=butloc[2];d=getNext(a,e,f);if(d==""){return}butloc=translateSlash(d);a=butloc[0];e=butloc[1];f=butloc[2];treec[a][e][f].setCurRank(parseInt(autoFilloOut.charAt(c)))}}function getNext(a,f,g){var c=getMaxi(),b,e,d;if(a==0&&f==0&&g==0){for(b=1;b<=3;b++){for(e=1;e<=c;e++){for(d=1;d<=4;d++){if(treec[b][e][d].type=="passive"||treec[b][e][d].type=="active"){return b+"/"+e+"/"+d}}}}}else{a=Math.min(a,3);a=Math.max(a,1);f=Math.min(f,c);f=Math.max(f,1);g=Math.min(g,4);g=Math.max(g,1);for(b=a;b<=3;b++){for(e=1;e<=c;e++){if(a==b&&e<f){continue}for(d=1;d<=4;d++){if(a==b&&f==e&&g==d){continue}if(a==b&&f==e&&d<g){continue}if(treec[b][e][d].type=="passive"||treec[b][e][d].type=="active"){return b+"/"+e+"/"+d}}}}}return""}function createBuildLink(){var c=getMaxi(),a="",b,e,d;for(b=1;b<=3;b++){for(e=1;e<=c;e++){for(d=1;d<=4;d++){if(treec[b][e][d].type=="passive"||treec[b][e][d].type=="active"){a+=treec[b][e][d].curRank.toString()}}}}for(e=(translator.length-1);e>1;e--){a=a.replace(stringFill("0",e),translator[e])}switch(pointlock){default:case 0:a="9"+a;break;case 51:a="8"+a;break;case 61:a="7"+a;break;case 71:a="6"+a;break}top.location=linkprefix+a}function setPointLock(a){var b;switch(a){case 80:if(((((treep[1]+treep[2]+treep[3])-1)*levelBetweenPoints)+startLevel)>a){redrawAll();if(((((treep[1]+treep[2]+treep[3])-1)*levelBetweenPoints)+startLevel)>a){alert(L("Unable to set a new maximum level, you used too much points for this level."));return}}b=$("pointlock80");b.innerHTML="<strong>80</strong>";b=$("pointlock70");b.innerHTML='<a href="javascript:setPointLock(70)">70</a>';b=$("pointlock60");b.innerHTML='<a href="javascript:setPointLock(60)">60</a>';b=$("pointlock0");b.innerHTML='<a href="javascript:setPointLock(0)">'+L("none")+"</a>";break;case 70:if(((((treep[1]+treep[2]+treep[3])-1)*levelBetweenPoints)+startLevel)>a){redrawAll();if(((((treep[1]+treep[2]+treep[3])-1)*levelBetweenPoints)+startLevel)>a){alert(L("Unable to set a new maximum level, you used too much points for this level."));return}}b=$("pointlock70");b.innerHTML="<strong>70</strong>";b=$("pointlock80");b.innerHTML='<a href="javascript:setPointLock(80)">80</a>';b=$("pointlock60");b.innerHTML='<a href="javascript:setPointLock(60)">60</a>';b=$("pointlock0");b.innerHTML='<a href="javascript:setPointLock(0)">'+L("none")+"</a>";break;case 60:if(((((treep[1]+treep[2]+treep[3])-1)*levelBetweenPoints)+startLevel)>a){redrawAll();if(((((treep[1]+treep[2]+treep[3])-1)*levelBetweenPoints)+startLevel)>a){alert(L("Unable to set a new maximum level, you used too much points for this level."));return}}b=$("pointlock60");b.innerHTML="<strong>60</strong>";b=$("pointlock80");b.innerHTML='<a href="javascript:setPointLock(80)">80</a>';b=$("pointlock70");b.innerHTML='<a href="javascript:setPointLock(70)">70</a>';b=$("pointlock0");b.innerHTML='<a href="javascript:setPointLock(0)">'+L("none")+"</a>";break;default:case 0:b=$("pointlock0");b.innerHTML="<strong>None</strong>";b=$("pointlock80");b.innerHTML='<a href="javascript:setPointLock(80)">80</a>';b=$("pointlock60");b.innerHTML='<a href="javascript:setPointLock(60)">60</a>';b=$("pointlock70");b.innerHTML='<a href="javascript:setPointLock(70)">70</a>';break}pointlock=a;redrawAll()}function hideAC(){var a=$("actext");a.style.display="none";a=$("achideshow");a.innerHTML='(<a href="javascript:showAC()">'+L("show")+"</a>)";reposAll()}function showAC(){var a=$("actext");a.style.display="";a=$("achideshow");a.innerHTML='(<a href="javascript:hideAC()">'+L("hide")+"</a>):";reposAll()}function reposAll(){var b,d,c,a=getMaxi();for(b=1;b<=3;b++){treet[b]=obj_top(treee[b]);treel[b]=obj_left(treee[b])}for(b=1;b<=3;b++){for(d=1;d<=a;d++){for(c=1;c<=4;c++){treec[b][d][c].reposition()}}}}function rateTree(){var b=$("treerating").value,a=parseInt(b);if(b==""){alert(L("Please enter a rating first"));$("treerating").focus();return}if(!IsPosInt(b)){alert(L("Please enter a number between 0 and 100 (inclusive)"));$("treerating").focus();return}if(a<0||a>100){alert(L("Please enter a number between 0 and 100 (inclusive)"));$("treerating").focus();return}if(curUser.userID==0){execLogin=function(){rateTree()};openLoginWindow();return}ajax("ajax.php?a=rt&dummy="+getNow(),"rating="+a+"&tid="+treeID,updateRating,defaultErrorHandler)}function updateRating(a){var b=$("ratingspan"),d=a.substr(4),c=d.split("_");switch(a.substr(0,4)){case"suc:":if(c[0]==1){b.innerHTML=c[1]+" (1 vote)"}else{b.innerHTML=c[1]+" ("+c[0]+" votes)"}$("treeRatebox").style.display="none";break;case"err:":alert(L("Your rating has NOT been saved: ")+a.substr(4)+".");break;case"dis:":alert(L("Your rating has NOT been saved, the server diclined the request.")+"\n"+a.substr(4));break;case"ban:":alert(L("Your rating has NOT been saved, the server has this IP blacklisted.\n "));break;default:alert(L("Your rating has NOT been saved, the server was unable to handle your request. (")+a+")");break}}function editTree(){top.location="ct.html?l="+treeID}function deleteTree(){var c=$("deleteTreeBox"),b=getPageSize(),a=$("blackbox");c.style.left="35%";c.style.display="";$("deleteaction").value=0;$("redirecttargetbody").style.display="none";a.style.display="block";a.style.height=b[1]+"px"}function showhideRedirect(a){if(a.value==1){$("redirecttargetbody").style.display=""}else{$("redirecttargetbody").style.display="none"}}function doDelete(){switch($("deleteaction").value){case"0":break;case"1":if(IsPosInt($("redirectTarget").value)){ajax("ajax.php?a=dt","type=redirect&id="+treeID+"&target="+$("redirectTarget").value,proccesDeleteResParsed,defaultErrorHandler)}else{alert(L("Please enter a number to redirect to."));return}break;case"2":ajax("ajax.php?a=dt","type=delete&id="+treeID,proccesDeleteResParsed,defaultErrorHandler);break}closeDeleteWindow()}function proccesDeleteResParsed(a){switch(a.substr(0,4)){case"dis:":case"err:":alert(L("Unable to delete and/or redirect tree: ")+a.substr(4));break;case"nost":alert(L("The redirect target was not found."));break;case"noal":alert(L("You are not allowed to redirect to that tree"));break;case"dele":if(confirm(L("You tree has been successfully deleted. Do you wish to go to the overview page?"))){searchMyTree()}else{$("treeRatebox").style.display="none"}break;case"redi":if(confirm(L("You tree has been successfully redirected. Do you wish to go to the overview page?"))){searchMyTree()}else{$("treeRatebox").style.display="none"}break;default:alert(L("Invalid server responds. Reload the page to see if the request was successful."));break}}function closeDeleteWindow(){var a=$("deleteTreeBox");a.style.left="-35%";a.style.display="none";$("blackbox").style.display="none"}function resetTreeType(){}function treeTypeWotLK(){};
