function postNote() {
	var creator = getElementValue("creator");
	var headline = getElementValue("headline");
	var message = getElementValue("content");
	var mainId = getElementValue("mainId");
	var menuId = getElementValue("menuId");
	var comments = getElementValue("commentsOn");
	if(emptyPost(creator, headline, message)) {
		return;
	}
	var status = document.getElementById("bottom");
	var statusOld = '';
	if(status != '' && status != null) {
		statusOld = status.innerHTML;
		status.innerHTML = "<img src=\"images/smallsaveblob.gif\" width=\"16\" height=\"16\" title=\"Saving ...\" alt=\"Saving ...\"> Saving ...";
	}
	commentDiv.toggle();
	var url = "notepost.php";
	var values = "creator="+creator+"&headline="+escape(headline)+"&content="+escape(message);
	values += "&mainId="+mainId+"&menuId="+menuId+"&comments="+comments+"&ajax=true&erase=true";
	
	request(values, url, function() {
		var newComment = "<h2>"+headline+"</h2><p>"+message+"</p>";
		var allComments = document.getElementById("comments").innerHTML;
		document.getElementById("comments").innerHTML = newComment + allComments;
		if(statusOld != '') {
			status.innerHTML = statusOld;
		}
		document.getElementById("headline").value = "";
		document.getElementById("content").value = "";
		commentDiv.toggle();
	});
}

function getElementValue(id) {
	var element = document.getElementById(id);
	if(element == null || element == '') {
		return "";
	}
	return element.value;
}

function checkPost() {
	var creator = getElementValue("creator");
	var headline = getElementValue("headline");
	var message = getElementValue("content");
	return !emptyPost(creator, headline, message);
}

function ifAcceptable() {
	if(checkPost()) {
		document.getElementById("erase").value = "true";
		document.getElementById("formComments").submit();
		return true;
	}
	return false;
}

function emptyPost(creator, headline, content) {
	if(creator == '') {
		if(!confirm("Post without a name?")) {
			return true;
		}
	}
	if(headline == '') {
		if(!confirm("Post without headline?")) {
			return true;
		}
	}
	if(content == '') {
		alert("Sorry, no empty posts allowed");
		return true;
	}
	return false;
}
