﻿
function addCell(contents, styleOrClassName, colSpan, cellType, attributes) {
	var s = "<" + cellType;
	if (styleOrClassName) {
		if (styleOrClassName.contains(":")) s += " style='" + styleOrClassName + "'";
		else s += " class='" + styleOrClassName + "'";
	}
	if (colSpan) s += " colspan=" + colSpan;
	if (attributes) s += " " + attributes;
	s += ">";
	if (contents) s += contents;
	s += "</" + cellType + ">";
	return s;
}

function addTD(contents, styleOrClassName, colSpan, attributes) { return addCell(contents, styleOrClassName, colSpan, "td"); }
function addTH(contents, styleOrClassName, colSpan, attributes) { return addCell(contents, styleOrClassName, colSpan, "th", attributes); }
function addTD_Ell(contents, styleOrClassName, colSpan, width, title, attributes) {
	var sTitle = contents;
	if (title) sTitle = title;
	sTitle = String.fromCharCode(34) + sTitle + String.fromCharCode(34);
	return addTD(addCell(contents, "width:" + width + "px; text-overflow:ellipsis; overflow:hidden; display:block; white-space:nowrap", null, "span", "title=" + sTitle), styleOrClassName, colSpan, attributes);
}

function stripeTable(container) {
	$(container).find('tr[class!=RecordLinks]').removeClass("AltColor");
	var L = 1;
	$(container).find('tr[class!=RecordLinks]').each(function() {
		if (this.style.display != "none") {
			L++;
			if (L % 2 == 0) {
				$(this).addClass("AltColor");
			}
		}
	});
}
