Ext.onReady(function(){
    // shorthand
    var Tree = Ext.tree;
    var tree = new Tree.TreePanel({
        el:'tree-div',
        autoScroll:true,
        animate:true,
        enableDD:true,
        containerScroll: true, 
        loader: new Tree.TreeLoader({
		dataUrl: './get-nodes.php',
		baseParams:this.id
		})	
	
    });

    // set the root node
    var root = new Tree.AsyncTreeNode({
        text: 'Inland Empire Directory',
        draggable:false,
        id:'source'
    });
    tree.setRootNode(root);

    // render the tree
    tree.render();
    root.expand();
    tree.on("click",function(node,e){update(node,e)},this);
});
function loadNode(name){
	var Tree = Ext.tree;
	alert(name);
	jack = new Object();
	jack.category = name;
	return new Tree.TreeLoader({
		dataUrl:'./get-nodes.php',
		baseParams:jack
	});
}
function update(node,e){
	Ext.get("details").innerHTML='';
	/*new Ext.Panel({
		renderTo:'details',
		width: '200px',
		title: node.id,
		collapsible: true
		});
	*/
	if(typeof(node.attributes.attributes)!='undefined' && typeof(node.attributes.attributes.url)!='undefined'){
		Ext.get('details-iframe').dom.src = node.attributes.attributes.url;
	}
}
