/*
Append a grid to object or HTML element
Copyright (C) 2006  Vegard Hammerseth <vegard@hammerseth.com> (http://vegard.hammerseth.com)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

v1.0.0
*/

function appendgrid(_object,_fields,_lines) {

        var table       = document.createElement('table');
        var tbody       = document.createElement('tbody');

        for(tr_nr=0;tr_nr<_lines;tr_nr++)
        {
                /* create <tr> element */
                tr = document.createElement('tr');

                for(td_nr=0;td_nr<_fields;td_nr++)
                {
                        /* create <td> element */
                        td = document.createElement('td');

                        /* set id, class and background image */
			td.id                    = (td_nr+1)+'x'+(tr_nr+1);
			td.style.backgroundImage = 'url(\'pix/gras.gif\')';
			td.className		 = 'td';


                        /* write <td> to the <tr> */
                        tr.appendChild(td);
                }

                /* write the <tr> to the table */
                tbody.appendChild(tr);
        }

        table.appendChild(tbody);
        table.setAttribute('cellspacing','1');
	table.setAttribute('cellpadding','0');

        /* write the table to object */
        _object.appendChild(table);
}
