function getXml(url) {
	var xhttp = (window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"));
	xhttp.open("GET", url, false);
	xhttp.send(null);
	return xhttp.responseXML;
}

function unescapeHTML(html) {
	var htmlNode = document.createElement("div");
	htmlNode.innerHTML = html;
	return htmlNode.innerHTML;
}

function loadAndTransformXml(xmlurl, xslurl, destid) {
	var container = document.getElementById(destid);
	while (container.hasChildNodes() && container.firstChild != null) {
		container.removeChild(container.firstChild);
	}
	try {
		var xsl = getXml(xslurl);
		var xml = getXml(xmlurl);
		if (window.ActiveXObject) {
			container.innerHTML = xml.transformNode(xsl);
		} else if (document.implementation && document.implementation.createDocument) {
			var xsltProcessor = new XSLTProcessor();
			xsltProcessor.importStylesheet(xsl);
			resultDocument = xsltProcessor.transformToFragment(xml, document);
			container.appendChild(resultDocument);
		}
	} catch (e) {
		container.innerHTML = '<p class="framed">Error retrieving data: ' + e + '</p>';
	}
}

function searchfocus(txtbox) {
	if (txtbox.value == 'Search') {
		txtbox.value = '';
		txtbox.style.color = 'black';
	}
}

var commenthide = false;

function setComment(value) {
	commenthide = Boolean(value);
}

function commentToggle() {
	commenthide = !commenthide;
	tbl = document.getElementById('commenttable');
	for (var i = 1; i < tbl.rows.length; i++) {
		tbl.rows[i].style.display = (commenthide ? 'none' : '');
	}
	updateComment();
}

function updateComment() {
	knownuser = !document.getElementById('comment_person').options[0].selected;
	tbl = document.getElementById('commenttable');
	tbl.rows[2].style.display = tbl.rows[3].style.display = (commenthide || knownuser ? 'none' : '');
}


