var success = "<!--Success-->"	//string that would be in a server's process response on a success
var ajaxTimeout = 8000					//number of milliseconds until the AJAX times out and returns an error
function submitForm(form, onSuccess, result,page)
{
	//result.innerHTML=getLoadingImageHTML()
	
	AjaxRequest.submit(
		form,
		{
			'url':page,
			'onSuccess':function(request) 
			 {
				//if we should perform the default action
				if(onSuccess == null)
				{
					result.innerHTML = request.responseText;
					//if not success, enable the button
				} 
				else 
				{
					onSuccess(request,result)
				}
			 },
			'onError':function(request){ alert('There was an error contacting the server. Please try again.'); result.innerHTML = ""; },
			'timeout':ajaxTimeout,
			'onTimeout':function(request){ alert('The server has not responded in a while. Please try again.'); result.innerHTML = "";}
		}
	);
}

function getLoadingImageHTML() 
{
	var txt = '<div style="padding-top:100px;"><img src="images\/loading.gif" alt="Loading..." align="absmiddle" \/><\/div>';
	return txt;	
}
function getLoadingTextHTML() {
	return '<span class="loading">Loading...<\/span>'
}

function isSuccessMessage(message) 
{
	return message.indexOf(success) != -1
}
