
// Print tree functions -----------------------
    function PrintItem(t, nIndent,nPageKind,nMainId) {
        var n, id, categoryid, name;
        // get shortname
        name = t[0];
        name = mysubstring(name, 37 - nIndent*2/10);
        // save fullname
        fullname = t[0];
        // number of arguments
        n = t.length;

        if (n > 2) {
            id = t[1];                      // idproduct
            categoryid = t[2];      // idcategory
            tURL = new Array(
            "fiche-accessoire.asp",
            "fiche-appareil-photo-numerique.asp",
            "fiche-camescope-numerique.asp",
            "fiche-jumelles.asp",
            "",
            "",
            "",
            "fiche-telephone-portable.asp",
            "",
            "",
            
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",

            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",

            "",
            "",
            "",
            "",
            "fiche-tv-home-cinema.asp"
            );
            if (categoryid > tURL.length)
                url = tURL[0];
            else
                url = tURL[categoryid];
            if (url == "")
                url = tURL[0];

if (nPageKind == 1) {
            if (id == nMainId)
                classname = "menu-selected";
            else
                classname = "menu-item";
} else {
            classname = "menu-item";
}

            s = "<a class='menu-anchor' href='" + url + "?ProductId=" + id + "' title='" + fullname + "'>";
            s = s + "<div class='" + classname + "' onmouseover='this.className=\"menu-item-hover\"' onmouseout='this.className=\"" + classname + "\"'>";
            s = s + "<span style='margin-left:" + nIndent + "px;'><img src='../../img/fleche-lien.gif' width='12' height='9' border='0' align='absmiddle'>&nbsp;" + name + "</span>";
            s = s + "</div>";
            s = s + "</a>";


        } else if (n > 1) {
            id = t[1];                  // idcategory

if (nPageKind == 2) {
            if (id == nMainId)
                classname = "menu-selected";
            else
                classname = "menu-item";
} else {
            classname = "menu-item";
}

            url = "ListeCategorie.asp";

            s = "<a class='menu-anchor' href='" + url + "?Categorie=" + id + "' title='" + fullname + "'>";
            s = s + "<div class='" + classname + "' onmouseover='this.className=\"menu-item-hover\"' onmouseout='this.className=\"" + classname + "\"'>";
            s = s + "<span style='margin-left:" + nIndent + "px;'><img src='../../img/fleche-lien.gif' width='12' height='9' border='0' align='absmiddle'>&nbsp;" + name + "</span>";
            s = s + "</div>";
            s = s + "</a>";

        } else {
        }
        return s;
    }













    function mysubstring(sName, nCount) {
        s = "";
        for(i = 0, j = 0; i < nCount; ++i) {
            c = sName.charAt(j);
            s = s + c;
            if (c == '&') {                         // manage &amp; &#244;
                for(;;) {
                    ++j;
                    c = sName.charAt(j);
                    s = s + c;
                    if (c == ';') break;
                }
            }
            ++j;
        }
        return s;
    }
    
    function PrintNodeStart(Id, sName, bClosed, nIndent) {
        var s;

        name = mysubstring(sName, 37 - nIndent*2/10);

        s = "<div class='menu-item' onmouseover='this.className=\"menu-item-hover\"' onmouseout='this.className=\"menu-item\"' onclick='Hide(" + Id + ")'>";
        s = s + "<span id='node" + Id + "img' style='margin-left:" + nIndent + "px;'>";

        if (bClosed)
            s = s + "<img src='../../img/fleche-horz.gif' width='9' height='9' border='0' align='absmiddle'>";
        else
            s = s + "<img src='../../img/fleche-vert.gif' width='9' height='9' border='0' align='absmiddle'>";

        s = s + "</span>";
        s = s + "<span id='node" + Id + "text'>&nbsp;" + name + "</span>";
        s = s + "</div>";

        if (bClosed)
            s = s + "<div id='node" + Id + "childs' style='display:none;'>";
        else
            s = s + "<div id='node" + Id + "childs' style='display:block;'>";

        return s;
    }

    function PrintNodeEnd() {
        var s;
        s = "</div>";
        return s;
    }
        
    function PrintTree(t, oid, bRoot, nIndent,nPageKind,nMainId) {
        var s;

        if (typeof(t[1]) == "object") {
            // node
            var i;
            var id = oid.getValue();
            if (bRoot) {
                // root node, we don't print the node itself but only the children
                s = '';
                oid.incValue();
                for(i = 0; i < t[1].length; i++) {
                    tmp = PrintTree(t[1][i], oid, false, nIndent,nPageKind,nMainId);
                    s = s + tmp;
                }
            } else {
                // sub nodes
                s = PrintNodeStart(id, t[0], (tState[id] == 0), nIndent);
                oid.incValue();
                var inner  = '';
                for(i = 0; i < t[1].length; i++) {
                    tmp = PrintTree(t[1][i], oid, false, nIndent + 10,nPageKind,nMainId);
                    inner = inner + tmp;
                }
                s = s + inner;
                s = s + PrintNodeEnd();
            }
        } else {
            // item
            s = PrintItem(t, nIndent,nPageKind,nMainId);
        }
        return s;
    }

// Int class -----------------------
    function Int(n) {
        this.n = n;
        this.incValue = IntIncValue;
        this.getValue = IntGetValue;
    }

    function IntIncValue() {
        this.n++;
    }

    function IntGetValue() {
        return this.n;
    }
//-----------------------------------

