// JavaScript Document

function antispam_check($inputElement,$messageElementID)
{
  var $antispam_id = document.getElementById('antispam_id').value;

  $antispam_OK_element = document.getElementById($messageElementID);
  
  
  if ($inputElement.textLength != 5)
  {
  	$antispam_OK_element.innerHTML = "";
	$inputElement.style.bkColor = "#ffffff";
	$inputElement.style.backgroundColor = "#ffffff";
    return;
  }
  
  // check the string is correct...
  
  var $url = "check_antispam.php?p=" + $antispam_id + "&word=" + $inputElement.value;
  
  http_request = initRequest();
  http_request.onreadystatechange = function() {
  	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
		antispam_xml_response($inputElement);
	  }
	}
  }
  http_request.open('GET',$url,true);
  http_request.send(null);
}

function antispam_xml_response($inputElement)
{
  if (http_request.responseText == 'okay')
  {
    $antispam_OK_element.innerHTML = "okay";
	$inputElement.style.bkColor = "#CCFB5D";
	$inputElement.style.backgroundColor = "#CCFB5D";
  }
  else
  {
    //$antispam_OK_element.innerHTML = http_request.responseText;
	$inputElement.style.bkColor = "pink";
	$inputElement.style.backgroundColor = "pink";
  }
}

