Ext.onReady(function(){
  
    Ext.BLANK_IMAGE_URL = 'images/s.gif';

    // shorthand
    var Tree = Ext.tree;
    
    var tree = new Tree.TreePanel({
        el:'reflector',
        useArrows:true,
        autoScroll:true,
        animate:true,
        containerScroll: true,

        // auto create TreeLoader
        dataUrl: 'reflector.php',

        root: {
            nodeType: 'async',
            text: 'Reflector',
            id:'root_source'
        }
    });
    
    // render the tree
    tree.render();
    tree.getRootNode().expand();
    tree.on('click',function(node, e){
      if(node.attributes['searchNode'] != null)
        tree.getNodeById(node.attributes['searchNode']).select();
        
      if(node.attributes['docblock'] != null && 
         node.attributes['class'] != null && 
         node.attributes['originalName'] != null)
      {
        Ext.Ajax.request({
          url: 'reflector.php',
          params: { 
            'node': 'docblock_',
            'class': node.attributes['class'], 
            'sub': node.attributes['originalName']
          },
          success: function(response, options) {
            document.getElementById('doc').innerHTML = "<pre>"+response.responseText+"</pre>";
          }
        });  
      }
    });
});
