// JavaScript Document
function sendMessage(){
	if ( !confirm("Send message?") )
		return;
	if (!ajaxIsWorking) {
		//	Validate fields
		var msg		= document.getElementById("okMessage").value;
		var ct		= document.getElementById("okContact").value;
		if (msg == "") {
			alert("You did not type anything as the message.");
			return;
		}
		//
		try {
			showWorking();
			//
			var params = "message=" + msg + "&contact=" + ct;
			http.open("POST", "leave-me-a-short-message.php" , true);
			http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
			http.send(params);
			http.onreadystatechange = onSendMessage;
		}catch(e){
			alert("Could not send your message. You might want to try again?");
		}
	}
}
function onSendMessage(){
	if (http.readyState == 4) {
		// only if "OK"
		if (http.status == 200) {
			hideWorking();
			if ( http.responseText == "pass" ) {
				alert("Sent your message.");
				document.getElementById("okMessage").value = "";
				document.getElementById("okContact").value = "";
			} else {
				alert("Error in sending message.");
			}
		}
	}
}