﻿
var toggleActions = "";
function SaveCookieOnToggle(sender, args) {
    var node = args.get_node();
    //  alert(node.get_attributes().getAttribute("nid"));
    toggleActions += node.get_attributes().getAttribute("nid") + '*';
    createCookie('TreeToggleActions', toggleActions, 2000);
}

function ReadCookie(cookieName) {
    var theCookie = "" + document.cookie;
    var ind = theCookie.indexOf(cookieName);
    if (ind == -1 || cookieName == "") return "";
    var ind1 = theCookie.indexOf(';', ind);
    if (ind1 == -1) ind1 = theCookie.length;
    return unescape(theCookie.substring(ind + cookieName.length + 1, ind1));
}

function SaveCookieOnColapsed(sender, args) {
    var node = args.get_node();
    toggleActions = ReadCookie('TreeToggleActions');
    toggleActions = toggleActions.replace(node.get_attributes().getAttribute("nid") + '*', "");
    createCookie('TreeToggleActions', toggleActions, 2000);
}

function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else {
        var expires = "";
    }
    document.cookie = name + "=" + value + expires + "; path=/";
}

function GetNodes() {
    var tree = $find("ctl00_panelTematyczne1_RadTreeView1");

    var gatree = tree.get_allNodes();
    var intgatree = gatree.length;
    for (var i = 0; i < intgatree; i++) {
        var node = gatree[i];
        if (typeof (node) == "undefined") continue;
        var allNodes = node.get_allNodes();
        var suma = 0;
        for (var j = 0; j < allNodes.length; j++) {
            suma = suma + parseInt(allNodes[j].get_value());
        }
        if (allNodes.length > 0) {
            var ppp = node.get_attributes().getAttribute("txt") + '<span class="cSzary">&nbsp;(' + suma + ')</span>';
            node.set_text(ppp);
        }
    }
}

function policz(node) {

}

