function DoFilter(id, str) {
	var tbl = document.getElementById(id);
	var trs = tbl.getElementsByTagName("tr");
	var txt = "";
	var rowCount = 0;
	//for(var i=1; i<2; i++) { //DUMMY
	for(var i=1; i < trs.length; i++) {
		tds = trs.item(i).getElementsByTagName("td");
		found = 0;
		//for(var j=0; j<1; j++) { //DUMMY
		for(var j=0; j<tds.length; j++) {
			txt = PseudoInnerText(tds.item(j));
			if(txt.toLowerCase().indexOf(str.toLowerCase()) > -1) {
				found++;
				break;
			}
		}
		if(found == 0) {
			trs.item(i).style.display = "none";
		} else {
			trs.item(i).style.display = "block";
			rowCount++;
		}
	}
	var msg = document.getElementById("FilterMessage");
	if(msg) {
		var msgTxt = rowCount.toString() + " matching records ";
		var newNode = document.createTextNode(msgTxt); // create a new text node
		msg.replaceChild(newNode, msg.firstChild) // replace the text node holding the amount with the new text node
	}
}

function ClearFilter(id) {
	var tbl = document.getElementById(id);
	var trs = tbl.getElementsByTagName("tr");
	
	for(var i=1; i < trs.length; i++) {
		trs.item(i).style.display = "block";
	}
	
	var msg = document.getElementById("FilterMessage");
	if(msg) {
		var msgTxt = "(unfiltered) ";
		var newNode = document.createTextNode(msgTxt); // create a new text node
		msg.replaceChild(newNode, msg.firstChild) // replace the text node holding the amount with the new text node
	}
}


/*function ConcatValue(nd) {
	
	if(nd.childNodes.length > 0)
		for(i = 0; i < nd.childNodes.length; i++)
			ConcatValue child
		next
	else
		retrurn str
}*/

function PseudoInnerText(nd) {
	var txtArr = new Array("");
	if(nd) {
		traverse(nd, txtArr);
		return txtArr[0];
	} else {
		return "";
	}
}


function traverse(nd, arr) { // CAN ONLY PASS OBJECTS BY REFERENCE, NOT STRINGS
	if(nd.nodeType == 3) { // 3 means text node
		arr[0] += nd.nodeValue;
	} else {
		var ndChild = nd.firstChild;
		while (ndChild != null) {
			traverse(ndChild, arr);
			ndChild = ndChild.nextSibling;
		}
	}
}

/*
// PASSING STRINGS BY REFERENCE DOESN'T WORK, SO USE ARRAYS
function TestRRR() {
	var asdf = new Array("")
	//asdf[0] = "";
	rrr(asdf);
	alert("asdf: " + asdf[0]);

}

function rrr(txt) {
	txt[0] += "A";
	var s = txt[0];
	if(s.length < 10)
		rrr(txt);
}
*/