[jQuery] AJAX Tree menu

[jQuery] AJAX Tree menu

OK, here is what I have right now. I know there is an easier way to do this than what I'm doing. What is missing here is the collapsing of all parent or sibling nodes that aren't in the path of the selected item.
Matt
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "<a href="http://www.w3.org/TR/html4/strict.dtd">http://www.w3.org/TR/html4/strict.dtd</a>">
<html>
<head>
<script type="text/javascript" src="lib/js/jquery.js"></script>
<script type="text/javascript">
var loadDirItems = function(id){
    
    var path = id == 'root' ? '' : id.replace(/__p__/g, '/');
    
    $.get("server.php?do=get_dir_contents&path=" + path,function(json){
        if( ! json ){
            return;
        }
        
        eval('var data = ' + json);
        
        var html = '';
        
        $('#json').html('{
');
        
        for(i in data){
            
            $('#json').append('&nbsp;&nbsp;[
');
            $('#json').append('&nbsp;&nbsp;&nbsp;&nbsp;path : ' + data[i].path + '<br/>');
            $('#json').append('&nbsp;&nbsp;&nbsp;&nbsp;type : ' + data[i].type + '<br/>');
            $('#json').append('&nbsp;&nbsp;]
');
            
            var node = data[i];
            var text = '';
            
            var new_id = path + '/' + node.path;
            
            new_id = new_id.replace(/\//g, '__p__');
            
            
            if(
node.type == 'd'){
                text = '<li id="' + new_id + 'LI"><a href="#" id="' + new_id + '__a__">' + node.path + '</a><ul id="' + new_id + '"></ul></li>';
            }else{
                text = '<li id="' + new_id + 'LI">' + node.path + '</li>';
            }
            html += text;
        }
        
        $('#json').append('}');
        
        $('#' + id).html(html);
        
        $('#' + id + ' li a').bind('click', function(e){
            var id = this.getAttribute('id');
            id = id.replace('__a__', '');
            loadDirItems(id);
        });
        
    });
}
var init = function(){
    loadDirItems('root');
}
$(document).ready(function(){
    init();
});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Untitled Document</title>
</head>
<body>
From Server (minus commas!):
<div id="json"></div>
<br /><br />
<ul id="root"></ul>
</body>
</html>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/