Ajax.Responders.register({
  onCreate: showProcessing,
  onComplete: hideProcessing
});

function showProcessing() {
  if(Ajax.activeRequestCount > 0)
    document.getElementById('inProgressL').style.display = 'inline';
    document.getElementById('inProgressR').style.display = 'inline';
}

function hideProcessing () {
  if(Ajax.activeRequestCount <= 0)
    document.getElementById('inProgressL').style.display = 'none'; 
    document.getElementById('inProgressR').style.display = 'none';
}

			
function sendRequest() {
				new Ajax.Request("wng.php", 
					{ 
					method: 'post', 
					postBody: 'realname='+ $F('realname'),
					onSuccess: showResponse

					}); 
				}
				
function showResponse(req){
				$('wngform').innerHTML= req.responseText;
				$('realname').clear ()
			}

function callInProgress (xmlhttp) {
switch (xmlhttp.readyState) {
case 1: case 2: case 3:
return true;
break;
// Case 4 and 0
default:
return false;
break;
}
}
function showFailureMessage() {
alert('Oh crap.  Sorry, your request timed out.  Give it another shot.\nIf it keeps happening, come back later because the server may be horked up.');
}
// Register global responders that will occur on all AJAX requests
Ajax.Responders.register({
onCreate: function(request) {
request['timeoutId'] = window.setTimeout(
function() {
// If we have hit the timeout and the AJAX request is active, abort it and let the user know
if (callInProgress(request.transport)) {
request.transport.abort();
showFailureMessage();
// Run the onFailure method if we set one up when creating the AJAX object
if (request.options['onFailure']) {
request.options['onFailure'](request.transport, request.json);
}
}
},
5000 // Five seconds
);
},
onComplete: function(request) {
// Clear the timeout, the request completed ok
window.clearTimeout(request['timeoutId']);
}
});