function L(A) {
    return A
};
function tryStartup() {
    if (startup) {
        startup()
    }
}
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) {
    if (typeof A == "undefined") {
        return false
    }
    if (A == "") {
        return false
    }
    var D = "0123456789.-";
    var C = true;
    var B;
    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) {
    if (typeof A == "undefined") {
        return false
    }
    if (A == "") {
        return false
    }
    var D = "0123456789";
    var C = true;
    var B;
    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) {
    if (B) {
        var A;
        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) {
    if (C) {
        var B;
        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
                }
            }
        }
        var A = unescape(C.replace(B, "<br />"));
        var A = A.replace(/&lt;br\ \/&gt;/g, "<br />");
        return A
    }
    return C
}
function stripnl(B) {
    if (B) {
        var A;
        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() {
    if (window.XMLHttpRequest) {
        grabAjaxObj = function() {
            return new XMLHttpRequest()
        };
        return grabAjaxObj()
    }
    try {
        var B = new ActiveXObject("Microsoft.XMLHTTP");
        grabAjaxObj = function() {
            return new ActiveXObject("Microsoft.XMLHTTP")
        }
    } catch(A) {
        var 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;
    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
        }
    }
    var B, D;
    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")
};
var execLogin = null;
var knownbaduser = new Array();
var knownbadmail = new Array();
function requestLogin() {
    var D = $("loginuser").value;
    var B = $("loginpass").value;
    var 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 == "") {
        var C = "N";
        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;
    var E = $("signuppass1").value;
    var D = $("signuppass2").value;
    var A = $("signupmail").value;
    var B = "";
    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 (var 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 (var 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(responds) {
    switch (responds.substr(0, 4)) {
    case "suc:":
        curUser = eval("(" + responds.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(responds.substr(4));
        break;
    case "dis:":
        alert(L("The server declined the request:\n") + responds.substr(4));
        break;
    case "use:":
        switch (responds.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. (") + responds + ")");
        break
    }
    setDisableSignupForm(false)
}
function handleLoginResponds(responds) {
    switch (responds.substr(0, 4)) {
    case "suc:":
        curUser = eval("(" + responds.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(responds.substr(4));
        break;
    default:
        alert(L("You have not been logged in, the server was unable to handle your request. (") + responds + ")");
        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("Chargement...") : 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("Chargement...") : 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() {
    var B = getPageSize();
    var A = $("blackbox");
    var C = $("loginbox");
    A.style.display = "block";
    A.style.height = B[1] + "px";
    C.style.display = "block";
    C.style.left = (B[2] / 2) - (C.clientWidth / 2) + "px";
    C.style.top = (B[3] / 2) - (C.clientHeight / 2) + "px";
    setDisableLoginForm(false)
}
function openProfileWindow() {
    var C = getPageSize();
    var A = $("blackbox");
    var B = $("profilebox");
    A.style.display = "block";
    A.style.height = C[1] + "px";
    B.style.display = "block";
    B.style.left = (C[2] / 2) - (B.clientWidth / 2) + "px";
    B.style.top = (C[3] / 2) - (B.clientHeight / 2) + "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 openSignupWindow() {
    var B = getPageSize();
    var A = $("blackbox");
    var C = $("signupbox");
    A.style.display = "block";
    A.style.height = B[1] + "px";
    C.style.display = "block";
    C.style.left = (B[2] / 2) - (C.clientWidth / 2) + "px";
    C.style.top = (B[3] / 2) - (C.clientHeight / 2) + "px";
    setDisableSignupForm(false)
}
function closeSignupWindow() {
    $("signupbox").style.left = "-100%";
    setDisableSignupForm(false);
    $("blackbox").style.display = "none"
}
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 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.getPos() - 1) + treel[A]) + "px";
    this.butbg.style.top = (5 + 65 * (this.getRow() - 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.getPos() - 1) + treel[A]) + "px";
    this.butbg.style.top = (5 + 65 * (this.getRow() - 1) + treet[A]) + "px";
    this.redraw("")
};
TalentObj.prototype.getTree = function getTree() {
    return this.tree
};
TalentObj.prototype.getPos = function getPos() {
    return this.pos
};
TalentObj.prototype.getRow = function getRow() {
    return this.row
};
TalentObj.prototype.getType = function getType() {
    return this.type
};
TalentObj.prototype.getDescription = function getDescription() {
    return this.desc
};
TalentObj.prototype.setDescription = function setDescription(A) {
    this.desc = A
};
TalentObj.prototype.getTalentname = function getTalentname() {
    return this.talentname
};
TalentObj.prototype.setTalentname = function setTalentname(A) {
    this.talentname = A
};
TalentObj.prototype.getNumRanks = function getNumRanks() {
    return this.numRanks
};
TalentObj.prototype.getCurRank = function getCurRank() {
    return this.curRank
};
TalentObj.prototype.getActiveCost = function getActiveCost() {
    return this.ActiveCost
};
TalentObj.prototype.setActiveCost = function setActiveCost(A) {
    this.ActiveCost = A
};
TalentObj.prototype.setActiveCostType = function setActiveCostType(A) {
    this.ActiveCostType = A
};
TalentObj.prototype.getActiveCostType = function getActiveCostType() {
    return this.ActiveCostType
};
TalentObj.prototype.getActiveCastTime = function getActiveCastTime() {
    return this.ActiveCastTime
};
TalentObj.prototype.setActiveSpellType = function setActiveSpellType(A) {
    this.ActiveSpellType = A
};
TalentObj.prototype.getActiveSpellType = function getActiveSpellType() {
    return this.ActiveSpellType
};
TalentObj.prototype.getActiveCastTime = function getActiveCastTime() {
    return this.ActiveCastTime
};
TalentObj.prototype.getActiveCooldown = function getActiveCooldown() {
    return this.ActiveCooldown
};
TalentObj.prototype.setActiveCooldown = function setActiveCooldown(A) {
    this.ActiveCooldown = A
};
TalentObj.prototype.getActiveRangeMin = function getActiveRangeMin() {
    return this.ActiveRangeMin
};
TalentObj.prototype.setActiveRangeMin = function setActiveRangeMin(A) {
    this.ActiveRangeMin = A
};
TalentObj.prototype.getActiveRangeMax = function getActiveRangeMax() {
    return this.ActiveRangeMax
};
TalentObj.prototype.setActiveRangeMax = function setActiveRangeMax(A) {
    this.ActiveRangeMax = A
};
TalentObj.prototype.getActiveReagents = function getActiveReagents() {
    return this.ActiveReagents
};
TalentObj.prototype.setActiveReagents = function setActiveReagents(A) {
    this.ActiveReagents = A
};
TalentObj.prototype.getActiveRequires = function getActiveRequires() {
    return this.ActiveRequires
};
TalentObj.prototype.setActiveRequires = function setActiveRequires(A) {
    this.ActiveRequires = A
};
TalentObj.prototype.getIcon = function getIcon() {
    return this.icon
};
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.getActiveSpellType() == "casttime")) {
        this.setActiveSpellType("instant")
    }
    this.ActiveCastTime = A
};
TalentObj.prototype.setType = function setType(A) {
    A = A.toLowerCase();
    if (A == this.type) {
        return
    }
    if (this.getRow() > 7 && treeType == "normal") {
        A = "hidden"
    }
    switch (A.toLowerCase()) {
    case "e":
    case "empty":
        this.setIcon("Temp.jpg");
        this.setNumRanks(0);
        this.setCurRank(0);
        this.removeReqs();
        this.setTalentname(L("Unused"));
        this.setDescription(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.getNumRanks()) {
        this.curRank = this.getNumRanks()
    } 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;
    var A = this.desc.indexOf("@", 0);
    while (A != -1) {
        B++;
        A = this.desc.indexOf("@", (A + 1));
        if (B > 10) {
            return this.desc
        }
    }
    var C = nl2br(htmlspecialchars(this.desc));
    for (A = 0; A < B; A++) {
        C = C.replace(/@/, this.getRank(D, A))
    }
    return C
};
TalentObj.prototype.getPassiveDescEdit = function getPassiveDescEdit(F) {
    var D = 0;
    var B = this.desc.indexOf("@", 0);
    while (B != -1) {
        D++;
        B = this.desc.indexOf("@", (B + 1));
        if (D > 10) {
            return this.desc
        }
    }
    var E = nl2br(htmlspecialchars(this.desc));
    for (B = 0; B < D; B++) {
        var C = "[";
        for (var A = 1; A <= this.getNumRanks(); A++) {
            if (A != 1) {
                C += "|"
            }
            if (this.getCurRank() == A) {
                C += "<em>" + this.getRank(A, B) + "</em>"
            } else {
                C += this.getRank(A, B)
            }
        }
        C += "]";
        E = E.replace(/@/, C)
    }
    return E
};
TalentObj.prototype.getPassiveRanks = function getPassiveRanks() {
    var D = 0;
    var C = this.desc.indexOf("@", 0);
    while (C != -1) {
        D++;
        C = this.desc.indexOf("@", (C + 1));
        if (D > 10) {
            return ""
        }
    }
    var A = "";
    for (var B = 0; B < D; B++) {
        for (C = 1; C <= this.getNumRanks(); C++) {
            if (A != "") {
                A += "|"
            }
            A += this.getRank(C, B)
        }
    }
    return this.getNumRanks() + A
};
TalentObj.prototype.getReqs = function getReqs(A) {
    return this.reqs.join("|")
};
TalentObj.prototype.addReq = function addReq(C) {
    this.reqs.push(C);
    var A = translateSticky(C);
    var B = A[1];
    var D = A[2];
    spawnArrow(this.getTree(), B, D, this.getRow(), this.getPos())
};
TalentObj.prototype.isReq = function isReq(B) {
    for (var A = 0; A < this.reqs.length; A++) {
        if (this.reqs[A] == B) {
            return true
        }
    }
    return false
};
TalentObj.prototype.removeReq = function removeReq(D) {
    for (var B = 0; B < this.reqs.length; B++) {
        if (this.reqs[B] != D) {
            continue
        }
        var A = translateSticky(this.reqs[B]);
        var C = A[1];
        var E = A[2];
        removeArrow(this.getTree(), C, E, this.getRow(), this.getPos());
        this.reqs.slice(B, 1);
        return
    }
};
TalentObj.prototype.removeReqs = function removeReqs() {
    for (var B = 0; B < this.reqs.length; B++) {
        var A = translateSticky(this.reqs[B]);
        var C = A[1];
        var D = A[2];
        removeArrow(this.getTree(), C, D, this.getRow(), this.getPos())
    }
    this.reqs = new Array()
};
TalentObj.prototype.reqsAreOk = function reqsAreOk() {
    for (var D = 0; D < this.reqs.length; D++) {
        var A = translateSticky(this.reqs[D]);
        var F = A[1];
        var G = A[2];
        if (!treec[this.getTree()][F][G].isMaxRank()) {
            return false
        }
    }
    var E = (5 * (this.getRow() - 1));
    if (E > 0) {
        var C = 0;
        for (var D = 1; D < this.getRow(); D++) {
            for (var B = 1; B <= 4; B++) {
                C += parseInt(treec[this.getTree()][D][B].getCurRank())
            }
        }
        if (C < E) {
            return false
        }
    }
    return true
};
TalentObj.prototype.addPoint = function addPoint() {
    if ((this.getCurRank() < this.getNumRanks()) && (pointlock == 0 || ((treep[1] + treep[2] + treep[3]) < pointlock))) {
        this.setCurRank(this.getCurRank() + 1);
        this.redraw(false);
        var D = 0;
        var A = getMaxi();
        for (var C = 1; C <= A; C++) {
            for (var B = 1; B <= 4; B++) {
                D += parseInt(treec[this.getTree()][C][B].getCurRank())
            }
        }
        treep[this.getTree()] = D;
        if ((pointlock > 0) && ((treep[1] + treep[2] + treep[3]) >= pointlock)) {
            redrawAll()
        } else {
            for (var C = 1; C <= A; C++) {
                for (var B = 1; B <= 4; B++) {
                    treec[this.getTree()][C][B].redraw(false)
                }
            }
        }
        return true
    }
    return false
};
TalentObj.prototype.subPoint = function subPoint() {
    if (this.getCurRank() > 0) {
        this.setCurRank(this.getCurRank() - 1);
        treep[this.getTree()]--;
        var C = getMaxi();
        for (var E = this.getRow(); E <= C; E++) {
            for (var D = 1; D <= 4; D++) {
                if (treec[this.getTree()][E][D].getCurRank() > 0 && !treec[this.getTree()][E][D].reqsAreOk()) {
                    this.setCurRank(this.getCurRank() + 1);
                    treep[this.getTree()]++;
                    for (var B = this.getRow(); B <= E; B++) {
                        for (var A = 1; A <= 4; A++) {
                            treec[this.getTree()][B][A].redraw(false)
                        }
                    }
                    return false
                } else {
                    treec[this.getTree()][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() {
    if (this.ActiveCostType == "runes") {
        var E = this.getActiveCost();
        var D = E.substring(0, 1);
        var C = E.substring(1, 2);
        var A = E.substring(2, 3);
        var B = "";
        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.getActiveCost()) + "" + 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")
    }
    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(" m&egrave;tres de port&eacute;e")
    }
    if (this.ActiveRangeMin == this.ActiveRangeMax) {
        return this.ActiveRangeMax + L(" m&egrave;tres de port&eacute;e")
    }
    return this.ActiveRangeMin + "-" + this.ActiveRangeMax + L(" m&egrave;tres de port&eacute;e")
};
TalentObj.prototype.getReadCasttime = function getReadCasttime() {
    if ((this.ActiveCastTime == 0) && (this.getActiveSpellType() == "casttime")) {
        this.setActiveSpellType("instant")
    }
    if (this.getActiveSpellType() == "channeled") {
        return L("Channeled")
    }
    if (this.getActiveSpellType() == "nextmelee") {
        return L("Next Melee")
    }
    if (this.getActiveCost() > 0) {
        if (this.getActiveSpellType() == "instant" && this.getActiveCostType() == "mana") {
            return L("Incantation Instantane")
        }
        if (this.getActiveSpellType() == "instant") {
            return L("Instantan&eacute;")
        }
        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.getActiveSpellType() == "instant") {
            return L("Instantan&eacute;")
        }
        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 />";
    if (this.getNumRanks() > 0) {
        E += L("Rang ") + this.getCurRank() + "/" + this.getNumRanks() + "<br />"
    }
    var C = (5 * (this.getRow() - 1));
    if (C != 0) {
        if (treep[this.getTree()] >= C) {
            E += '<span class="reqmet">'
        } else {
            E += '<span class="reqnotmet">'
        }
        E += L("Requiert ") + (5 * (this.getRow() - 1)) + L(" points en ") + treen[this.getTree()] + L(". ") + "</span><br />"
    }
    for (var B = 0; B < this.reqs.length; B++) {
        var A = translateSticky(this.reqs[B]);
        var D = A[1];
        var F = A[2];
        if (!treec[this.getTree()][D][F].isMaxRank()) {
            E += '<span class="reqnotmet">'
        } else {
            E += '<span class="reqmet">'
        }
        E += L("Requiert ") + treec[this.getTree()][D][F].getNumRanks() + " ";
        if (treec[this.getTree()][D][F].getNumRanks() == 1) {
            E += L("point")
        } else {
            E += L("points")
        }
        E += L(" en ") + htmlspecialchars(treec[this.getTree()][D][F].getTalentname()) + ".</span><br />"
    }
    if (this.getType() == "active") {
        if (this.getActiveCost() > 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.getActiveCooldown() > 0) {
                E += '<span class="hright">' + htmlspecialchars(this.getReadCooldown()) + L(" de recharge") + "</span>"
            }
        } else {
            if (this.hasNoRange()) {
                E += '<span class="hleft">' + htmlspecialchars(this.getReadCasttime()) + "</span>";
                if (this.getActiveCooldown() > 0) {
                    E += '<span class="hright">' + htmlspecialchars(this.getReadCooldown()) + L(" de recharge") + "</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.getActiveCooldown() > 0) {
                    E += '<span class="hright">' + htmlspecialchars(this.getReadCooldown()) + L(" de recharge") + "</span>"
                }
            }
        }
        E += '<div class="cb"></div>';
        if (this.getActiveReagents() != "") {
            E += '<span class="left">' + L("Reagents: ") + uni_unescape(htmlspecialchars(this.getActiveReagents())) + "</span>"
        }
        if (this.getActiveRequires() != "") {
            E += '<span class="left">' + L("Requiert ") + uni_unescape(htmlspecialchars(this.getActiveRequires())) + "</span>"
        }
        E += '<div class="cb"></div>';
        E += '<span class="desc">' + nl2br(htmlspecialchars(this.desc)) + "</span>"
    } else {
        if (this.getType() == "passive") {
            if (mode == "preview") {
                E += '<span class="desc">' + this.getPassiveDesc(this.getCurRank()) + "</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) {
    if (this.getType() == "hidden") {
        this.hideButton();
        this.butc.innerHTML = "";
        return
    }
    if (mode == "preview") {
        if (this.getType() == "empty") {
            this.hideButton();
            this.butc.innerHTML = "";
            return
        } else {
            this.showButton()
        }
        if (this.reqsAreOk()) {
            if (pointlock > 0 && ((treep[1] + treep[2] + treep[3]) >= pointlock) && this.getCurRank() == 0) {
                this.butimg.style.backgroundPosition = "0px 0px";
                setOpacity(this.butbg, 10);
                this.butc.innerHTML = "";
                var A = this.getIcon().replace(/Spells\//gi, "SpellsGrey/");
                this.butbg.style.backgroundImage = "url(" + imagepath + A + ")"
            } else {
                if (this.getNumRanks() > 0) {
                    this.butc.innerHTML = this.getCurRank() + "/" + this.getNumRanks()
                } else {
                    this.butc.innerHTML = "X"
                }
                if (this.getCurRank() == this.getNumRanks()) {
                    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.getIcon() + ")"
            }
        } else {
            this.butimg.style.backgroundPosition = "0px 0px";
            setOpacity(this.butbg, 10);
            this.butc.innerHTML = "";
            var A = this.getIcon().replace(/Spells\//gi, "SpellsGrey/");
            this.butbg.style.backgroundImage = "url(" + imagepath + A + ")"
        }
    } else {
        this.showButton();
        this.butbg.style.backgroundImage = "url(" + imagepath + this.getIcon() + ")";
        if (curtree == this.getTree() && currow == this.getRow() && curpos == this.getPos()) {
            this.butimg.style.backgroundPosition = "-112px 0px";
            this.butc.style.color = "#0000FE";
            setOpacity(this.butbg, 10);
            switch (this.getType()) {
            case "active":
                this.butc.innerHTML = "A";
                break;
            case "passive":
                this.butc.innerHTML = "P" + this.getNumRanks();
                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.getType()) {
            case "active":
                this.butc.innerHTML = "A";
                break;
            case "passive":
                this.butc.innerHTML = "P" + this.getNumRanks();
                break;
            case "empty":
                this.butc.innerHTML = "X";
                break;
            default:
                this.butc.innerHTML = "";
                break
            }
            return
        }
        switch (this.getType()) {
        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.getNumRanks();
            break;
        default:
        case "empty":
            this.butimg.style.backgroundPosition = "0px 0px";
            setOpacity(this.butbg, 3);
            this.butc.innerHTML = "";
            break
        }
    }
};
TalentObj.prototype.reposition = function reposition() {
    this.butbg.style.left = (25 + 65 * (this.getPos() - 1) + treel[this.getTree()]) + "px";
    this.butbg.style.top = (5 + 65 * (this.getRow() - 1) + treet[this.getTree()]) + "px";
    for (var B = 0; B < this.reqs.length; B++) {
        var A = translateSticky(this.reqs[B]);
        var C = A[1];
        var D = A[2];
        removeArrow(this.getTree(), C, D, this.getRow(), this.getPos());
        spawnArrow(this.getTree(), C, D, this.getRow(), this.getPos())
    }
    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.getCurRank() == this.getNumRanks())
};
TalentObj.prototype.getActiveSave = function getActiveSave() {
    var A = this.getActiveCost();
    A += "|" + this.getActiveCostType();
    A += "|" + this.getActiveSpellType();
    A += "|" + this.getActiveCastTime();
    A += "|" + this.getActiveCooldown();
    A += "|" + this.getActiveRangeMin();
    A += "|" + this.getActiveRangeMax();
    A += "|" + this.getActiveReagents();
    A += "|" + this.getActiveRequires();
    return htmlspecialchars(A)
};
function spawnArrow(I, H, F, C, A) {
    I = parseInt(I);
    H = parseInt(H);
    F = parseInt(F);
    C = parseInt(C);
    A = parseInt(A);
    if (!checkArrow(I, H, F, C, A, false)) {
        return false
    }
    var E = $("tree" + I);
    var B = (A - F);
    if (B > 0) {
        var 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" + I + H + F + C + A
    }
    if (B < 0) {
        possideways = B * -1;
        var 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" + I + H + F + C + A
    }
    if (H < C) {
        var 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" + I + H + F + C + A + "d"
    }
    var B = (F - A);
    if (B < 0) {
        B *= -1;
        B -= 1;
        for (var D = 0; D < B; D++) {
            treec[I][H][F + (B - D)].setType("hidden");
            treec[I][H][F + (B - D)].redraw(false)
        }
    } else {
        B -= 1;
        for (var D = 0; D < B; D++) {
            treec[I][H][A - (D - B)].setType("hidden");
            treec[I][H][A - (D - B)].redraw(false)
        }
    }
    if (H < C) {
        if ((F - A) != 0) {
            treec[I][H][A].setType("hidden");
            treec[I][H][A].redraw(false)
        }
        for (D = 1; D < (C - H); D++) {
            treec[I][H + D][A].setType("hidden");
            treec[I][H + D][A].redraw(false)
        }
    }
}
function checkArrow(I, H, F, C, A, E) {
    I = parseInt(I);
    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(I, H, F)) {
        return false
    }
    if (!validArrowTalent(I, C, A)) {
        if (!E) {
            return false
        }
    }
    var B = (F - A);
    if (B < 0) {
        B *= -1;
        B -= 1;
        var D = 0;
        while (D < B) {
            if (canArrow(I, H, F + (B - D))) {
                D++
            } else {
                return false
            }
        }
    } else {
        B -= 1;
        var D = 0;
        while (D < B) {
            if (canArrow(I, H, A - (D - B))) {
                D++
            } else {
                return false
            }
        }
    }
    if (H < C) {
        if (!canArrow(I, H, A) && ((F - A) != 0)) {
            return false
        }
        var G = C - H;
        for (D = 1; D < G; D++) {
            if (!canArrow(I, (H + D), A)) {
                return false
            }
        }
    }
    return true
}
function removeArrow(I, H, F, C, A) {
    I = parseInt(I);
    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) {
        var G = $("arrow" + I + H + F + C + A);
        if (G) {
            var D = G.parentNode;
            D.removeChild(G)
        }
    }
    if (H < C) {
        var G = $("arrow" + I + H + F + C + A + "d");
        if (G) {
            var D = G.parentNode;
            D.removeChild(G)
        }
    }
    var B = (F - A);
    if (B < 0) {
        B *= -1;
        B -= 1;
        for (var E = 0; E < B; E++) {
            treec[I][H][F + (B - E)].setType("empty");
            treec[I][H][F + (B - E)].redraw(false)
        }
    } else {
        B -= 1;
        for (var E = 0; E < B; E++) {
            treec[I][H][A - (E - B)].setType("empty");
            treec[I][H][A - (E - B)].redraw(false)
        }
    }
    if (H < C) {
        if ((F - A) != 0) {
            treec[I][H][A].setType("empty");
            treec[I][H][A].redraw(false)
        }
        for (E = 1; E < (C - H); E++) {
            treec[I][H + E][A].setType("empty");
            treec[I][H + E][A].redraw(false)
        }
    }
}
function canArrow(A, B, C) {
    A = parseInt(A);
    B = parseInt(B);
    C = parseInt(C);
    if (treec[A][B][C].getType() == "active") {
        return false
    }
    if (treec[A][B][C].getType() == "passive") {
        return false
    }
    if (treec[A][B][C].getType() == "hidden") {
        return false
    }
    return true
}
function validArrowTalent(A, B, C) {
    A = parseInt(A);
    B = parseInt(B);
    C = parseInt(C);
    if (treec[A][B][C].getType() == "active") {
        return true
    }
    if (treec[A][B][C].getType() == "passive") {
        return true
    }
    return false
};
function makeRequest(A) {
    ajax("ajax.php?a=gt&id=" + A, "", procesData, defaultErrorHandler)
}
function makeFullRequest(C) {
    var B = new Date();
    var A = B.getTime();
    ajax("ajax.php?a=ft&dummy=" + A + "&id=" + C, "", procesData, defaultErrorHandler)
}
function makeCountingRequest(B, A) {
    ajax("ajax.php?a=v&id=" + B, "", procesData, defaultErrorHandler)
}
function makeRequestUrl(A) {
    ajax(A, "", procesData, defaultErrorHandler)
}
function procesData(data) {
    if (data == "err:404") {
        alert(L("The selected tree was not found."))
    } else {
        if (data.substr(0, 4) != "jsn:") {
            if (data.substr(0, 4) == "suc:") {
                data = data.substr(4)
            }
            var maxi = getMaxi();
            for (var k = 1; k <= 3; k++) {
                for (var i = 1; i <= maxi; i++) {
                    for (var j = 1; j <= 4; j++) {
                        treec[k][i][j].setType("empty");
                        treec[k][i][j].redraw(false)
                    }
                }
            }
            if (data.substr(0, 1) == "c") {
                var firstIndex = data.indexOf("#");
                var thisclass = data.substr(1, (firstIndex - 2));
                var treeType = data.substr((firstIndex - 1), 1);
                setClass(thisclass);
                switch (treeType) {
                case 0:
                    treeTypeNormal();
                    break;
                case 1:
                    treeTypeTBC();
                    break;
                case 2:
                    treeTypeWotLK();
                    break
                }
            }
            var dataarray = data.split("\n");
            for (var i = 0; i < dataarray.length; i++) {
                if (dataarray[i].length > 1) {
                    procesTalent(dataarray[i])
                }
            }
            for (var i = 0; i < dataarray.length; i++) {
                if (dataarray[i].length > 1) {
                    procesTalentPreReqs(dataarray[i])
                }
            }
        } else {
            data = data.substr(4);
            var rdata = null;
            try {
                var rdata = eval("(" + data + ")")
            } catch(e) {
                return
            }
            $("treeTitle").value = rdata.title;
            $("authorComments").value = rdata.authorcomment;
            $("isHidden").value = rdata.isHidden;
            setClass(rdata.pclass);
            switch (rdata.treetype) {
            case "0":
                treeTypeNormal();
                break;
            case "1":
                treeTypeTBC();
                break;
            case "2":
                treeTypeWotLK();
                break
            }
            var dataarray = rdata.content.split("\n");
            for (var i = 0; i < dataarray.length; i++) {
                if (dataarray[i].length > 1) {
                    procesTalent(dataarray[i])
                }
            }
            for (var i = 0; i < dataarray.length; i++) {
                if (dataarray[i].length > 1) {
                    procesTalentPreReqs(dataarray[i])
                }
            }
        }
    }
}
function procesTalent(C) {
    var E = /(\d+)#([AP])#\\{0,1}\"(.*)\\{0,1}\"#\\{0,1}\"(.*)\\{0,1}\"#\\{0,1}\"(.*)\\{0,1}\"#([\d|]*)#(.*)#/i.exec(C);
    var B = E[1];
    if (B.length >= 3) {
        var D = translateSticky(E[1]);
        var A = D[0];
        var G = D[1];
        var H = D[2];
        var F = treec[A][G][H];
        F.setType(cleanData(E[2]));
        F.setTalentname(cleanData(E[3]));
        F.setIcon("Spells/" + cleanData(E[4]));
        F.setDescription(cleanData(E[5]));
        if (F.getType() == "active") {
            procesTalentActive(A, G, H, E[7])
        }
        if (F.getType() == "passive") {
            procesTalentPassive(A, G, H, E[7])
        }
        F.redraw(false)
    }
}
function procesTalentPreReqs(C) {
    var E = /(\d+)#([AP])#\\{0,1}\"(.*)\\{0,1}\"#\\{0,1}\"(.*)\\{0,1}\"#\\{0,1}\"(.*)\\{0,1}\"#([\d|]*)#(.*)#/i.exec(C);
    var B = E[0];
    var D = translateSticky(E[1]);
    var A = D[0];
    var F = D[1];
    var G = D[2];
    procesTalentReqs(A, F, G, E[6])
}
function procesTalentReqs(A, D, E, C) {
    if (C.length < 3) {
        return
    }
    var B = C.split("|");
    for (i = 0; i < B.length; i++) {
        treec[A][D][E].addReq(B[i])
    }
}
function procesTalentActive(A, E, F, C) {
    var B = C.split("|");
    if (B.length == 9) {
        var D = treec[A][E][F];
        D.setActiveCost(B[0]);
        D.setActiveCostType(B[1]);
        D.setActiveSpellType(B[2]);
        D.setActiveCastTime(B[3]);
        D.setActiveCooldown(B[4]);
        D.setActiveRangeMin(B[5]);
        D.setActiveRangeMax(B[6]);
        D.setActiveReagents(B[7]);
        D.setActiveRequires(B[8])
    }
}
function procesTalentPassive(A, F, G, E) {
    if (E.length < 3) {
        treec[A][F][G].setNumRanks(1);
        return
    }
    var C = E.split("|");
    var D = E.substring(0, 1);
    treec[A][F][G].setNumRanks(D);
    C[0] = C[0].substring(1);
    for (var 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;
var currow = 0;
var curpos = 0;
var treec = new Array(3);
var treep = new Array(3);
var treen = new Array(3);
var treee = new Array(3);
var treet = new Array(3);
var treel = new Array(3);
var switchActive = false;
var tooltipelm = null;
var tooltipcelm = null;
var pointlock = 0;
function getMaxi() {
    var A = 9;
    switch (treeType) {
    case "WotLK":
        return 11;
    case "TBC":
        return 9;
    case "normal":
        return 7
    }
}
function redrawAll() {
    var B = getMaxi();
    for (var A = 1; A <= 3; A++) {
        for (var D = 1; D <= B; D++) {
            for (var C = 1; C <= 4; C++) {
                treec[A][D][C].redraw(false)
            }
        }
    }
}
function setClass(A) {
    currentClass = A;
    switch (A) {
    case "unset":
        treen[1] = L("Blue");
        treen[2] = L("Red");
        treen[3] = L("Green");
        break;
    case "druid":
        treen[1] = L("Balance");
        treen[2] = L("Feral");
        treen[3] = L("Restoration");
        break;
    case "deathknight":
        treen[1] = L("Blood");
        treen[2] = L("Frost");
        treen[3] = L("Unholy");
        break;
    case "hunter":
        treen[1] = L("Beast Mastery");
        treen[2] = L("Marksmanship");
        treen[3] = L("Survival");
        break;
    case "mage":
        treen[1] = L("Arcane");
        treen[2] = L("Fire");
        treen[3] = L("Frost");
        break;
    case "paladin":
        treen[1] = L("Holy");
        treen[2] = L("Protection");
        treen[3] = L("Retribution");
        break;
    case "priest":
        treen[1] = L("Discipline");
        treen[2] = L("Holy");
        treen[3] = L("Shadow");
        break;
    case "rogue":
        treen[1] = L("Assassinat");
        treen[2] = L("Combat");
        treen[3] = L("Finesse");
        break;
    case "shaman":
        treen[1] = L("Elemental");
        treen[2] = L("Enhancement");
        treen[3] = L("Restoration");
        break;
    case "warlock":
        treen[1] = L("Affliction");
        treen[2] = L("Demonology");
        treen[3] = L("Destruction");
        break;
    case "warrior":
        treen[1] = L("Arms");
        treen[2] = L("Fury");
        treen[3] = L("Protection");
        break
    }
    for (i = 1; i <= 3; i++) {
        treee[i].style.backgroundImage = "url(bg/" + treeType + A + i + ".jpg)";
        var B = $("treeheadertext" + i);
        B.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) {
    if (!B) {
        B = event
    }
    if (B.target) {
        elm = B.target
    }
    if (B.srcElement) {
        elm = B.srcElement
    }
    var C = translateElmId(elm.id);
    var A = C[0];
    var D = C[1];
    var E = C[2];
    elm = $(treec[A][D][E].getID());
    treec[A][D][E].doTooltip();
    if (mode == "edit") {
        treec[A][D][E].redraw(true)
    }
}
function butmouseout(B) {
    if (!B) {
        B = event
    }
    if (B.target) {
        elm = B.target
    }
    if (B.srcElement) {
        elm = B.srcElement
    }
    if (mode == "edit") {
        var C = translateElmId(elm.id);
        var A = C[0];
        var D = C[1];
        var E = C[2];
        treec[A][D][E].redraw(false)
    }
    hideTooltip()
}
function schoolHover(C) {
    counts = 0;
    countt = 0;
    counta = 0;
    countp = 0;
    var A = getMaxi();
    for (var D = 1; D <= A; D++) {
        for (var B = 1; B <= 4; B++) {
            counts += parseInt(treec[C][D][B].getCurRank());
            countt += parseInt(treec[C][D][B].getNumRanks());
            if (treec[C][D][B].getType() == "active") {
                counta += 1
            }
            if (treec[C][D][B].getType() == "passive") {
                countp += 1
            }
        }
    }
    treep[C] = counts;
    tooltipcelm.innerHTML = "<strong>" + treen[C] + "</strong><br />" + L("Points d&eacute;pens&eacute;s dans cet arbre: ") + counts + "<br />" + L("Total des points de l'arbre: ") + countt + "<br />" + L("Talents actifs dans cet arbre: ") + counta + "<br />" + L("Talents passifs dans cet arbre: ") + countp;
    var E = $("treeheader" + C);
    showTooltip(E, 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
    };
    var B = (A == true ? 0 : F.offsetWidth);
    var E = obj_left(F) + B;
    var 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() {
    tooltipelm = $("tooltipbox");
    tooltipcelm = $("tooltipcontent");
    hideTooltip();
    for (var C = 1; C <= 3; C++) {
        var B = getMaxi();
        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]);
        var F = $("treeheader" + C);
        var 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 (var E = 1; E <= B; E++) {
            treec[C][E] = new Array(4);
            for (var D = 1; D <= 4; D++) {
                treec[C][E][D] = new TalentObj(C, E, D)
            }
        }
    }
	if (treet[1]==0) return;
    setClass(currentClass);
    procesData(taldata);
	loadBuild();
    updatePointsOverview();
	redrawAll()
};
function butclick(B) {
    if (!B) {
        B = event
    }
    if (B.target) {
        elm = B.target
    }
    if (B.srcElement) {
        elm = B.srcElement
    }
    var D = B.which ? B.which: B.button;
    var C = translateElmId(elm.id);
    var A = C[0];
    var E = C[1];
    var F = C[2];
    if (treec[A][E][F].getType() == "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();
    for (var A = 1; A <= 3; A++) {
        treep[A] = 0;
        for (var D = 1; D <= B; D++) {
            for (var C = 1; C <= 4; C++) {
                treec[A][D][C].setCurRank(0);
                treec[A][D][C].redraw(false)
            }
        }
    }
    updatePointsOverview()
}
function ResetTree(A) {
    var B = getMaxi();
    for (var D = 1; D <= B; D++) {
        for (var 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();
    for (var A = 1; A <= 3; A++) {
        treep[A] = 0;
        for (var D = 1; D <= B; D++) {
            for (var C = 1; C <= 4; C++) {
                treep[A] += parseInt(treec[A][D][C].getCurRank())
            }
        }
    }
    for (var A = 1; A <= 3; A++) {
        for (var D = 1; D <= B; D++) {
            for (var C = 1; C <= 4; C++) {
                treec[A][D][C].redraw(false)
            }
        }
    }
    updatePointsOverview()
}
function updatePointsOverview() {
    var B = $("pointsused");
    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] + 9
    }
    B = $("buildoverview");
    B.innerHTML = treep[1] + " / " + treep[2] + " / " + treep[3];
    for (var A = 1; A <= 3; A++) {
        $("treeheadertext" + A).innerHTML = treen[A] + " (" + treep[A] + ")"
    }
}
function loadBuild() {
    if (autoFilloOut.length == 0) {
        return
    }
    switch (autoFilloOut.charAt(0)) {
    case "9":
        setPoinLock(0);
        autoFilloOut = autoFilloOut.substring(1);
        break;
    case "8":
        setPoinLock(51);
        autoFilloOut = autoFilloOut.substring(1);
        break;
    case "7":
        setPoinLock(61);
        autoFilloOut = autoFilloOut.substring(1);
        break;
    case "6":
        setPoinLock(71);
        autoFilloOut = autoFilloOut.substring(1);
        break;
    default:
        setPoinLock(0);
        break
    }
    for (var C = (translator.length - 1); C > 1; C--) {
        autoFilloOut = autoFilloOut.replace(translator[C], stringFill("0", C))
    }
    var D = "000";
    for (var C = 0; C < autoFilloOut.length; C++) {
        var B = translateSlash(D);
        var A = B[0];
        var E = B[1];
        var F = B[2];
        D = getNext(A, E, F);
        if (D == "") {
            return
        }
        B = translateSlash(D);
        A = B[0];
        E = B[1];
        F = B[2];
        treec[A][E][F].setCurRank(parseInt(autoFilloOut.charAt(C)))
    }
}
function getNext(A, F, G) {
    var C = getMaxi();
    if (A == 0 && F == 0 && G == 0) {
        for (var B = 1; B <= 3; B++) {
            for (var E = 1; E <= C; E++) {
                for (var D = 1; D <= 4; D++) {
                    if (treec[B][E][D].getType() == "passive" || treec[B][E][D].getType() == "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 (var B = A; B <= 3; B++) {
            for (var E = 1; E <= C; E++) {
                if (A == B && E < F) {
                    continue
                }
                for (var 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].getType() == "passive" || treec[B][E][D].getType() == "active") {
                        return B + "/" + E + "/" + D
                    }
                }
            }
        }
    }
    return ""
}
function createBuildLink() {
    var C = getMaxi();
    var A = "";
    for (var B = 1; B <= 3; B++) {
        for (var E = 1; E <= C; E++) {
            for (var D = 1; D <= 4; D++) {
                if (treec[B][E][D].getType() == "passive" || treec[B][E][D].getType() == "active") {
                    A += treec[B][E][D].getCurRank().toString()
                }
            }
        }
    }
    for (var 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 setPoinLock(A) {
    switch (A) {
    case 71:
        if (treep[1] + treep[2] + treep[3] > A) {
            redrawAll();
            if (treep[1] + treep[2] + treep[3] > A) {
                alert(L("Unable to set a new maximum level, you used too much points for this level."));
                return
            }
        }
        var B = $("pointlock80");
        B.innerHTML = "<strong>80</strong>";
        B = $("pointlock70");
        B.innerHTML = '<a href="javascript:setPoinLock(61)">70</a>';
        B = $("pointlock60");
        B.innerHTML = '<a href="javascript:setPoinLock(51)">60</a>';
        B = $("pointlock0");
        B.innerHTML = '<a href="javascript:setPoinLock(0)">' + L("none") + "</a>";
        break;
    case 61:
        if (treep[1] + treep[2] + treep[3] > A) {
            redrawAll();
            if (treep[1] + treep[2] + treep[3] > A) {
                alert(L("Unable to set a new maximum level, you used too much points for this level."));
                return
            }
        }
        var B = $("pointlock70");
        B.innerHTML = "<strong>70</strong>";
        B = $("pointlock80");
        B.innerHTML = '<a href="javascript:setPoinLock(71)">80</a>';
        B = $("pointlock60");
        B.innerHTML = '<a href="javascript:setPoinLock(51)">60</a>';
        B = $("pointlock0");
        B.innerHTML = '<a href="javascript:setPoinLock(0)">' + L("none") + "</a>";
        break;
    case 51:
        if (treep[1] + treep[2] + treep[3] > A) {
            redrawAll();
            if (treep[1] + treep[2] + treep[3] > A) {
                alert(L("Unable to set a new maximum level, you used too much points for this level."));
                return
            }
        }
        var B = $("pointlock60");
        B.innerHTML = "<strong>60</strong>";
        B = $("pointlock80");
        B.innerHTML = '<a href="javascript:setPoinLock(71)">80</a>';
        B = $("pointlock70");
        B.innerHTML = '<a href="javascript:setPoinLock(61)">70</a>';
        B = $("pointlock0");
        B.innerHTML = '<a href="javascript:setPoinLock(0)">' + L("none") + "</a>";
        break;
    default:
    case 0:
        var B = $("pointlock0");
        B.innerHTML = "<strong>None</strong>";
        B = $("pointlock80");
        B.innerHTML = '<a href="javascript:setPoinLock(71)">80</a>';
        B = $("pointlock60");
        B.innerHTML = '<a href="javascript:setPoinLock(51)">60</a>';
        B = $("pointlock70");
        B.innerHTML = '<a href="javascript:setPoinLock(61)">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() {
    for (var B = 1; B <= 3; B++) {
        treet[B] = obj_top(treee[B]);
        treel[B] = obj_left(treee[B])
    }
    var A = getMaxi();
    for (var B = 1; B <= 3; B++) {
        for (var D = 1; D <= A; D++) {
            for (var C = 1; C <= 4; C++) {
                treec[B][D][C].reposition()
            }
        }
    }
}
function rateTree() {
    var C = $("treerating").value;
    if (C == "") {
        alert(L("Please enter a rating first"));
        $("treerating").focus();
        return
    }
    if (!IsPosInt(C)) {
        alert(L("Please enter a number between 0 and 100 (inclusive)"));
        $("treerating").focus();
        return
    }
    var A = parseInt(C);
    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
    }
    var D = new Date();
    var B = D.getTime();
    ajax("ajax.php?a=rt&dummy=" + B, "rating=" + A + "&tid=" + treeID, updateRating, defaultErrorHandler)
}
function updateRating(A) {
    switch (A.substr(0, 4)) {
    case "suc:":
        var B = $("ratingspan");
        var D = A.substr(4);
        var C = D.split("_");
        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");
    C.style.left = "35%";
    C.style.display = "";
    $("deleteaction").value = 0;
    $("redirecttargetbody").style.display = "none";
    var B = getPageSize();
    var A = $("blackbox");
    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"
};