String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g,'') }

function getObject()
{
	var xmlHttp=null;
	try 
	{
   		xmlHttp = new XMLHttpRequest();
	} 
	catch (e) 
	{
   		try 
   		{
     		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
   		} 
   		catch (e) 
   		{
      		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
   		}
	}
	
	return xmlHttp;
}

function get(url, action, response, error, id)
{
	if (action != null)
	{
		action(id);
	}
	var xmlHttp = getObject();
	if (xmlHttp == null)
	{
		if (error != null)
		{
			error("Can't load ajax object");
		}
	}
	
	xmlHttp.onreadystatechange = function() {
	    if (xmlHttp.readyState == 4)
	    {
	       try 
	       {
	          if (xmlHttp.status == 200) 
	          {
	          var completeMessage = xmlHttp.responseText.trim();
	          	var result = completeMessage.substring(0,2);
	          	var message = completeMessage.substring(2);
	          	if (result == "OK")	          
		             response(message, id);
		        else if (result == "NO")
		        	error(message, id);
		        else error("Unformatted message");
	          }
	          else
	          {
	          	error("Server error", id);
	          }
	       } 
	       catch (e) 
	       {
	             error("Error on Ajax return call : " + e.description, id);
	       }
		} 
 	}
 	
	xmlHttp.open("get",url);
	xmlHttp.send(null);
}