function Nascondi_riga(id_riga){
    var IE=(window.navigator.userAgent.indexOf('MSIE')>-1)?1:0;
    document.getElementById(id_riga).style.display=(document.getElementById(id_riga).style.display=='none')?((IE)?'block':'table-row'):'none';
}

function Mostra_riga(id_riga){
    var IE=(window.navigator.userAgent.indexOf('MSIE')>-1)?1:0;
    document.getElementById(id_riga).style.display=(document.getElementById(id_riga).style.display=='')?((IE)?'none':'table-row'):'';
}

function Mostra_tutto(IDtabella){
    trs=document.getElementById(IDtabella).tBodies[0].rows;
    for(i=0;i<trs.length;i++){
        trs[i].style.display="";

        if(String(trs[i].id).substr(0,1)=="C")
            document.getElementById(IDtabella).deleteRow(trs[i].rowIndex);
    }
}
var mostra_prod="Mostra prodotto";
if(String(lingua)=="ES")
    var mostra_prod="Muestra producto";

function Ins_Riga(IDtabella,cspan,cod,des){
    trs=document.getElementById(IDtabella).tBodies[0].rows;
    for(i=0;i<trs.length;i++){
        if(cod== trs[i].id)
        t = trs[i].rowIndex-1;
    }

    var x=document.getElementById(IDtabella).tBodies[0].insertRow(t);
    x.id="C"+cod;
    var y=x.insertCell(0);
    var z=x.insertCell(1);
    z.colSpan=cspan;
    y.innerHTML='<input type="image" src="'+sitourl+'images/occhiali_mostra.gif" Title="'+mostra_prod+'" onclick="Mostra_riga(\''+cod+'\');Cancella_riga(\''+IDtabella+'\',\''+x.id+'\');">';
    z.innerHTML=des;
}

function Cancella_riga(IDtabella,id){
    trs=document.getElementById(IDtabella).tBodies[0].rows;
    for(i=0;i<trs.length;i++){
    	if(id== trs[i].id)
    		document.getElementById(IDtabella).deleteRow(trs[i].rowIndex);
    }
}

function Nascondi_colonna(id_riga){
    var IE=(window.navigator.userAgent.indexOf('MSIE')>-1)?1:0;
    document.getElementById(id_riga).style.display=(document.getElementById(id_riga).style.display=='none')?((IE)?'block':'table-row'):'none';
}

function Mostra_colonna(id_riga){
    var IE=(window.navigator.userAgent.indexOf('MSIE')>-1)?1:0;
    document.getElementById(id_riga).style.display=(document.getElementById(id_riga).style.display=='')?((IE)?'none':'table-row'):'';
}

function Ins_colonna(IDtabella,cspan,cod,des){
    var tbl = document.getElementById(IDtabella); // table reference
    // open loop for each row and append cell
    for (var i=0; i<tbl.rows.length; i++)
        createCell(tbl.rows[i].insertCell(tbl.rows[i].cells.length), i, 'col');
}

function Cancella_colonna(IDtabella,id){
    var tbl = document.getElementById(IDtabella);
    var lastCol = tbl.rows[0].cells.length - 1;

    for (var i=0; i<tbl.rows.length; i++){
        for (var j=lastCol; j>0; j--){
            if(id == tbl.rows[i].id)
                tbl.rows[i].deleteCell(j);
        }
    }
}

// create DIV element and append to the table cell
function createCell(cell, text, style){
    var div = document.createElement('div'); // create DIV element
    var txt = document.createTextNode(text); // create text node
    div.appendChild(txt);                    // append text node to the DIV
    div.setAttribute('class', style);        // set DIV class attribute
    div.setAttribute('className', style);    // set DIV class attribute for IE (?!)
    cell.appendChild(div);                   // append DIV to the table cell
}

