/**
 * Send a request for clearing the current form.
 */
function clearForm() {
	httpRequestClearForm = createXMLHttpRequest();
	if (!httpRequestClearForm) {
		if (showMessage) showMessage('error.xmlhttp.clear');
		return false;
	}

	httpRequestClearForm.onreadystatechange = callbackClearForm;
	httpRequestClearForm.open('POST', 'clearform', true);
	httpRequestClearForm.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	httpRequestClearForm.send('form=' + currentForm.toUpperCase());
}

/**
 * Callback for the clear form request.
 * If the clearing succeeded, show the current form.
 */
function callbackClearForm() {
	if (httpRequestClearForm.readyState == 4) {
		if (httpRequestClearForm.status == 200) {
			var xmldoc = httpRequestClearForm.responseXML;
			var error = xmldoc.getElementsByTagName('error').item(0);
			if (error) {
				var msg = error.textContent;
				if (msg == undefined) msg = error.text; // IE
				showMessage(msg);
			} else {
				showForm(currentForm,-2);
			}
		} else {
			if (showMessage) showMessage('error.request.clear', httpRequestClearForm.status);
		}
	}
}

