var colMinWidth = '8em';
var colorLight = '#c0c0c0';
var colorDart = '#a0a0a0';

function setColMinWidth(d) { colMinWidth = d; }
function setColorLight(d) { colorLight = d; }
function setColorDark(d) { colorDark = d; }

function addrow(tableid, csvtext, isheader) {
	var table = document.getElementById(tableid);
	var tBody = table.getElementsByTagName('tbody')[0];
	var tr = document.createElement('tr');
	var numrows = table.rows.length;
	var color = colorDark;
	if (numrows%2 == 0) { color = colorDark; } else { color = colorLight; }

	tr.style.width='100%';
	tr.style.backgroundColor=color;

	var cols = csvtext.split(',');
	var num = cols.length;
	if( typeof(isheader) == 'undefined' ) { isheader = false; }
	var tdtype = 'td';
	if (isheader) { tdtype = 'th'; }

	for(var i=0;i<num;i++) {
		var td = document.createElement(tdtype);
		td.innerHTML = cols[i];
		td.style.minWidth=colMinWidth;
		td.style.width=colMinWidth;
		if (tdtype == 'td') { 		td.style.backgroundColor=color; }
		tr.appendChild (td);
	}
	tBody.appendChild(tr);
} 
function columnAlign(tableid, colnum, align) {
	var table = document.getElementById(tableid);
	for(var i=0;i<table.rows.length;i++) {
		table.rows[i].cells[colnum].style.textAlign=align;
	}
}
function columnBold(tableid, colnum) {
	var table = document.getElementById(tableid);
	for(var i=0;i<table.rows.length;i++) {
		table.rows[i].cells[colnum].style.fontWeight='bold';
	}
}
function columnWidth(tableid, colnum, width) {
	var table = document.getElementById(tableid);
	for(var i=0;i<table.rows.length;i++) {
		table.rows[i].cells[colnum].style.width=width;
		table.rows[i].cells[colnum].style.minWidth=width;
	}
}

