
var index1 = null;

function aggiorna() {
    // funzioni che deve chiamare l'utility
    lista_index();
    conta_index();
}

function popola_index() {
    intest[0] = new Array(
        new Array("Lista libri in Vetrina", "nofrecce"), // id per azioni bottone
        new Array("&nbsp;", "t.id_libro", 0, false), // id link
        new Array("ISBN", "l.isbn", 0, false),
        new Array("titolo", "l.titolo", 0, false),
        new Array("argomento", "g.nome", 0, false),
        new Array("venditore", "t.idvenditore", 0, false),
        new Array("prezzo di vendita", "t.prezzo", 0, false)
    );
    
    crea_tabella_intestazione();
    lista_index();
    crea_tabella_piede();
    conta_tabella(4)
}

function lista_index(XY) {
    if (XY == null) XY = 0;
    var dati_post = "op=list_index&rand="+Math.random();
    index1 = CreateXmlHttpReq(result_lista_index);
    spedisci_richiesta(index1, liv+'engineMYSQL/q_index.php', dati_post);
}

function result_lista_index() {
    if (index1.readyState == 4 && index1.status == 200) {
        if (index1.responseText == "errore")
            visualizza_errore();
        else {
            var matrice = converti(index1.responseText);
            var righe = new Array();
            var link = new Array();
            var url1 = liv+"cerca/libro/dati_libro.php?id=";
            var url2 = liv+"cerca/utente/profilo.php?iduser=";
            var nome_img = new Array();
            
            for (x = 0; x < matrice.length; x++) {
                righe[x] = new Array(matrice[x][1], matrice[x][3], matrice[x][4], matrice[x][5], matrice[x][6], matrice[x][7]);
                link[x] = new Array(url1+matrice[x][2], url1+matrice[x][2], url1+matrice[x][2], url1+matrice[x][2], url2+matrice[x][8], url1+matrice[x][2]);
                nome_img[x] = new Array(matrice[x][2], matrice[x][10]);
            }
        
            crea_tabella_righe_figo(righe, link, nome_img, false);
        }
    }
}
