ArticleNavigationPanel = function()
{
    //-----< define object vars >-----------------------------------------------
    this.currentState = '';
    //-----< create root node >-------------------------------------------------
    this.root_node = new Ext.tree.AsyncTreeNode({
        text : 'Root',
        draggable : false,
        id : '00'
    });
    //-----< call parent constructor >------------------------------------------
    ArticleNavigationPanel.superclass.constructor.call(this, {
        animate : true,
        enableDD : false,
        rootVisible : true,
        lines : false,
        loader : new ParameterizedTreeLoader({
            dataUrl: 'services/ArticleTree.php'
        }),
        border : true,
        autoScroll : true,
        collapseFirst : false,
        singleExpand : false,
        root : this.root_node
    });
    //-----< additional tasks after parents constructor has run >---------------
    this.addEvents({articleselect:true});
    this.on('click', this.onClick, this);
};

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

    switchToStart : function(path)
    {
        if(this.currentState == 'start')
        {
            if(path)
            {
                var x = this;
                this.selectPath(path,'id',function(bSuccess,oSelNode){x.fireEvent('articleselect', x.currentState, oSelNode.id)});
            }
            else
            {
                this.fireEvent('articleselect', this.currentState, this.getSelectionModel().getSelectedNode().id);
            }
            return;
        }
        this.getLoader().dataUrl = 'services/ArticleTree.php';
        this.getLoader().setBaseParams( { source : 'start' } );
        this.currentState = 'start';
        this.root.setText('Start');
        this.reset();
        this.root.expand();
        if(path)
        {
            var x = this;
            this.selectPath(path,'id',function(bSuccess,oSelNode){x.fireEvent('articleselect', x.currentState, oSelNode.id)});
        }
        else
        {
            this.root.select();
            this.fireEvent('articleselect', this.currentState, '00');
        }
    },

    switchToLinks : function(path)
    {
        if(this.currentState == 'links')
        {
            if(path)
            {
                var x = this;
                this.selectPath(path,'id',function(bSuccess,oSelNode){x.fireEvent('articleselect', x.currentState, oSelNode.id)});
            }
            else
            {
                this.fireEvent('articleselect', this.currentState, this.getSelectionModel().getSelectedNode().id);
            }
            return;
        }
        this.getLoader().dataUrl = 'services/ArticleTree.php';
        this.getLoader().setBaseParams( { source : 'links' } );
        this.currentState = 'links';
        this.root.setText('Links');
        this.reset();
        this.root.expand();
        if(path)
        {
            var x = this;
            this.selectPath(path,'id',function(bSuccess,oSelNode){x.fireEvent('articleselect', x.currentState, oSelNode.id)});
        }
        else
        {
            this.root.select();
            this.fireEvent('articleselect', this.currentState, '00');
        }
    },

    switchToHilfe : function(path)
    {
        if(this.currentState == 'hilfe')
        {
            if(path)
            {
                var x = this;
                this.selectPath(path,'id',function(bSuccess,oSelNode){x.fireEvent('articleselect', x.currentState, oSelNode.id)});
            }
            else
            {
                this.fireEvent('articleselect', this.currentState, this.getSelectionModel().getSelectedNode().id);
            }
            return;
        }
        this.getLoader().dataUrl = 'services/ArticleTree.php';
        this.getLoader().setBaseParams( { source : 'hilfe' } );
        this.currentState = 'hilfe';
        this.root.setText('Hilfe');
        this.reset();
        this.root.expand();
        if(path)
        {
            var x = this;
            this.selectPath(path,'id',function(bSuccess,oSelNode){x.fireEvent('articleselect', x.currentState, oSelNode.id)});
        }
        else
        {
            this.root.select();
            this.fireEvent('articleselect', this.currentState, '00');
        }
    },

    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;
        }
    },

    onClick : function(node)
    {
        this.fireEvent('articleselect', this.currentState, node.id);
    }

});
