function xpBox(strID)
{
        this.className          = "xpBox";
        var sInsName            = this.className + '_' + (Math.ceil(Math.random()*10000000000)).toString();
                window[sInsName]        = this;
        this.insName            = sInsName;

    this.bShown = true;
    this.nPInt  = null;
    this.nPCur  = null

    this.nFrom  = null;
    this.nTo    = null

    this.nPCoeff        = .1;
    this.nPTimes        = 10;
    this.nPSpeed        = 10;

    this.oObj    = document.getElementById(strID);

    this.oTdBody        = this.oObj.rows.item(1).cells.item(0);
    this.oDivBody       = this.oTdBody.firstChild;
    this.oDivBody.style.overflow        = "hidden";

    this.ScrollHeight   = this.oDivBody.scrollHeight;
    this.oDivBody.style.height  = this.ScrollHeight;

    this.nUInt  = setInterval(new Function (this.insName+".fnUpdate()"), 100);

    this.oObj.rows.item(0).onclick      = new Function (this.insName+".fnShowHide()");

    this.oImg   = this.oObj.rows.item(0).cells.item(0).firstChild; // .rows.item(0).cells.item(0).firstChild;
    this.oImg_u = new Image();
    this.oImg_u.src     = "/images/tree/folder.gif";
    this.oImg_p = new Image();
    this.oImg_p.src     = "/images/tree/folderopen.gif";

    //-- public methods
    function fnShowHide()
    {
        if (this.bShown) {
            this.ScrollHeight   = this.oDivBody.scrollHeight;
            this.oImg.src       = this.oImg_u.src;
            this.fnResizeTo(0, true);
            this.bShown = false;
        }
        else {
            this.oImg.src       = this.oImg_p.src;
            this.fnResizeTo(this.ScrollHeight, true);
            this.bShown = true;
        }
    }

    function fnProceed(bDir, bFlag)
    {
        if (this.nPCur > this.nPTimes) {
            clearInterval(this.nPInt);
            this.oDivBody.style.height        = this.nTo;
        }
        else {
            this.nPCur++;
            var coef    = Math.pow(this.nPCoeff, this.nPCur);
            this.oDivBody.style.height  = this.nFrom + Math.ceil((1 - coef) * (this.nTo - this.nFrom));
            if (bFlag)
                this.oTdBody.style.filter       = "progid:DXImageTransform.Microsoft.Alpha(Opacity="+(Math.ceil((bDir ? 1-coef : coef)*100))+", Style=0)";
        }
    }

    function fnResizeTo(i, bFlag)
    {
        var sValue  = this.oDivBody.style.height;
        this.nFrom      = sValue.substr(0, sValue.length-2) - 1;

//	alert(this.nFrom);

        this.nTo        = i + 1;
        this.nPCur      = 0;

        if (this.nTo - this.nFrom == 1) return;

            bFlag       = bFlag == null ? false : bFlag;
        var bDir        = this.nFrom < this.nTo ? true  : false;

        if (this.nPInt)
            clearInterval(this.nPInt);
			this.nPInt      = setInterval(new Function (this.insName+".fnProceed(" + bDir + ", " + bFlag + ");"), this.nPSpeed);
		// this.oDivBody.style.height = this.nTo;
    }

    function fnUpdate()
    {
//        document.getElementById("aaa").innerHTML+= "["+this.ScrollHeight+':'+this.oDivBody.scrollHeight+"]-";
        if (this.ScrollHeight != this.oDivBody.scrollHeight && this.bShown)
            this.fnResizeTo(this.ScrollHeight = this.oDivBody.scrollHeight);
    }

    this.fnShowHide = fnShowHide;
    this.fnResizeTo = fnResizeTo;
    this.fnUpdate   = fnUpdate;
    this.fnProceed  = fnProceed;

    if (this.oObj.hidden != null)
        this.fnShowHide();
}
