//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
// utility functions

//----------------------------------------
// set the parent's contained child html/node (sole child)
function set_child (child, parent, default_html) {
	if (typeof child == 'string')
		parent.innerHTML = (child ? child : default_html);
	else if (child) {
		while (parent.firstChild)
			parent.removeChild (parent.firstChild);
		parent.appendChild (child)
	} //else-if
	else
		parent.innerHTML = default_html;
} //function

//----------------------------------------
// create and return a table grid
function create_table (rows, cols) {
	var table = document.createElement ('table');
	var tbody = document.createElement ('tbody');
	table.appendChild (tbody);
	for (r=0;  r<rows;  r++) {
		var row = table.insertRow(0);
		for (c=0;  c<cols;  c++)
			var cell = row.insertCell(0);
	} //for
	return table;
} //function

