 function StringBuffer() { this.buffer = []; }
StringBuffer.prototype.append = function(string) {
    this.buffer.push(string);
    return this;
}

StringBuffer.prototype.toString = function() {
    return this.buffer.join("");
}

function solicita()
{
    doRequest('server.php?act=listar&dir='+ arguments[0],resposta);
}

function resposta()
{
     var f = eval('('+ arguments[0] +')');
     for(i = 0; i < f.length; i++) 
     {
       var d = document.getElementById("p"+ f[i]["Div"])
       if(i == 0)
            d.innerHTML = "";
            
       switch(f[i]["Tipo"])
       {
        case "dir":
            d.innerHTML += "<a href=\"javascript:solicita('"+ f[i]["Local"] +"/"+ f[i]["Resp"] +"')\">"+ f[i]["Resp"] + "</a><div class=\"dir\" id=\"p"+ f[i]["Div"] +"_"+ f[i]["Resp"] +"\"></div>";
            break;
        case "file":
            d.innerHTML += "<div class=\"file\"><a href=\"downloads/"+ f[i]["Local"] +"/"+ f[i]["Resp"] +"\">"+ f[i]["Resp"] + "</a></div>";
            break;
       }
     }
}