function initCommentEdit() {
	var xhr = new XMLHttpRequest();
	xhr.overrideMimeType("application/xml+xhtml");
	xhr.open("GET", "/comment/edit_partial?style_id=" + document.getElementById("style_id").value, false);
	xhr.send(null);
	var form = document.getElementById(xhr.responseXML.documentElement.getAttribute("id")).parentNode;
	form.innerHTML = xhr.responseText;
	form.scrollIntoView();
	form.getElementsByTagName("form")[0].setAttribute("onsubmit", "return checkComment(event)");
}

function checkComment(event) {
	var form = event.target;
	//make sure the user picked a rating
	var possibleRatings = form.getElementsByTagName("input");
	for (var i = 0; i < possibleRatings.length; i++) {
		if (possibleRatings[i].name == "comment[rating]" && possibleRatings[i].checked) {
			return true;
		}
	}
	alert("You have to give the style a numeric rating.");
	return false;
}

//window.addEventListener("DOMContentLoaded", initCommentEdit, false);
