MerkmalePanel = function(config)
{
    //-----< apply config >-----------------------------------------------------
    Ext.apply(this, config);
    //-----< call parent constructor >------------------------------------------
    MerkmalePanel.superclass.constructor.call(this, {
        animate:true,
        loader: new ParameterizedTreeLoader({
            dataUrl: '../services/MerkmaleTree.php',
            preloadChildren:true,
            baseAttrs: {checked:false}
        }),
        enableDD:false,
        rootVisible:true,
        lines:false,
        border:false,
        autoScroll:true,
        root: new Ext.tree.AsyncTreeNode({
            text: 'Merkmale',
            draggable:false,
            id:'00'
        }),
        collapseFirst:false,
        singleExpand:false
    });
    //-----< additional tasks after parents constructor has run >---------------
    this.on('show', this.onShowMe, this);
};

//-----< define new class MerkmalePanel >---------------------------------------
Ext.extend(MerkmalePanel, Ext.tree.TreePanel,
{

    setBerichtssystem : function(art)
    {
        this.reset();
        this.getLoader().setBaseParams( { bericht: art } );
    },

    reset : function()
    {
        if(this.root.loaded)
        {
            this.root.collapse(false, false);
            while(this.root.firstChild){
                this.root.removeChild(this.root.firstChild);
            }
            this.root.childrenRendered = false;
            this.root.loaded = false;
        }
    },

    // private
    onShowMe : function(me)
    {
        //-----< expand this root node when wizard tab gets activated >---------
        if(!this.root.isExpanded())
        {
            this.root.expand();
        }
    },

    getSelectedMerkmale : function()
    {
        //-----< create empty array for results >-------------------------------
        var result = Array();
        //-----< iterate over all groups >--------------------------------------
        var allgroupnodes = this.root.childNodes;
        for(var i = 0; i < allgroupnodes.length; i++)
        {
            var groupnode = allgroupnodes[i];
            if(!groupnode.loaded)
            {
                this.loader.doPreload(groupnode);
            }
            for(var ii = 0; ii < groupnode.childNodes.length; ii++)
            {
                var merkmalnode = groupnode.childNodes[ii];
                if( groupnode.attributes.checked || merkmalnode.attributes.checked )
                {
                    result.push(merkmalnode.id);
                }
            }
        }
        //-----< return results >-----------------------------------------------
        return(result);
    }

});
