// JavaScript Document
function submitForm()
{
	var f = document.getElementById("contactForm");
	
	var sUrl = "process_form.php";
	
	var postElements = new Array();
	var postData;
	
	for (var i = 0; i < f.elements.length; i++)
	{
		postElements.push(f.elements[i].id + "=" + escape(f.elements[i].value));
	}
	
	postData = postElements.join("&");
	
	var handleSuccess = function(o) {
		if (o.responseText !== undefined) {
			var x = o.responseText.replace(/^\s*/, '').replace(/\s*$/, '');

			if (x == "success")
			{
				alert ('The system successfully sent your message.');
				
				for (var j = 0; j < f.elements.length; j++)
				{
					f.elements[j].value = '';
				}
			}
			else
			{
				alert ('The system encountered the following error when attempting to send your message: \n\n' + x);
			}
		}
		else
		{
			alert ('The system was unable to send your message at this time. Please try again later.');
		}
	}

	var handleFailure = function(o) {
		if (o.responseText !== undefined) {
			alert ('The system was unable to send your message at this time. Please try again later.');
		}
	}

	var callback =
	{
		success: handleSuccess,
		failure: handleFailure
	};

	var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
}