String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}


 var XMLErrorsCount = 0;

 function checkNumber(AValue)
 {
   var xhr = null;

   //Try to get an HTTP handler
   if(window.XMLHttpRequest)
     xhr = new XMLHttpRequest();
   else if(window.ActiveXObject)
   {
     try
     {
       xhr = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e)
     {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
     }
   }
   else
   {
     alert("Please use an XMLHttpRequest compliant browser");
     xhr = false;
     return;
   }

   //Start the request
   xhr.onreadystatechange = function()
   {
    if ((xhr.readyState == 4)  && (xhr.status == 200))
    {
      lResponse = xhr.responseText;
      lResponse = lResponse.trim();
      if ( lResponse == "valid" )
        changeElements(false);
      else
      {
        changeElements(true);
        if (lResponse != "invalid")
        {
          XMLErrorsCount++;
          if (XMLErrorsCount == 1) //Do not raise error more than once
            alert(lResponse);
        }
      }
    }
   }

   lUrl = "xml.php?checknumber=" + AValue;
   xhr.open("GET", lUrl , true);
   xhr.send(null);
 }