httpcall = function( url, _func , method, data, async )
{
	
	this.proc_arg = '';
	this.url = url;
	this.mime = 'application/x-www-form-urlencoded';
	this.method= undef(method) ? 'GET' : 'POST';
	this.data = data;
	this.async = undef(async) ? true : async;
	
	if (!empty(_func))
	{
		if (_func.indexOf('(') !=-1)
		{
			var tmp = _func.split('('); // functionname
			this.proc_function = tmp[0].replace(/ /g,'');
			if (typeof(tmp[1]) != 'undefined')
			{
				this.proc_arg = tmp[1].replace(/\)/,'').replace(/ /g,''); 
			}
		}
		else
		{
			this.proc_function = _func;
		}
	}
};

httpcall.prototype.load = function(silent) 
{

    if(window.XMLHttpRequest) 
    {
    	try 
    	{
			this.req = new XMLHttpRequest();
			if (this.req.overrideMimeType) 
			{
			  this.req.overrideMimeType(this.mime);
			}
        } 
        catch(e) 
        {
        	this.req = false;
        }
    } 
    else if(window.ActiveXObject) 
    {
       	try 
       	{
       		this.req = new ActiveXObject("Msxml2.XMLHTTP");
       	}
      	catch(e) 
      	{
        	try 
        	{
        		this.req = new ActiveXObject("Microsoft.XMLHTTP");
        	}
        	catch(e) 
        	{
        		this.req = false;
        	}
		}
    }
    
	if(this.req) 
	{
		var copy = this;
		this.req.onreadystatechange = function()
		{		
			if (copy.req.readyState == 4)  // LOADED
			{
				if (copy.req.status == 200) // OK
				{
					if (!empty(copy.proc_function))
					{
						eval(copy.proc_function+"('"+copy.proc_arg+"')");
					}
					return;
				} 
				else 
				{
					if (undef(silent))
					alert
					(
						"[XMLHttpRequest] "
						+"There was a problem retrieving the XML data:\n"
						+ copy.req.statusText
					);
				}
			}
		}

		if (this.method == 'POST')
		{
			this.req.open("POST", this.url, this.async);
			this.req.setRequestHeader(
				'Content-Type'
				,'application/x-www-form-urlencoded'
			);
			this.req.send(this.data);
		}
		else
		{
			this.req.open("GET", this.url, this.async);
			this.req.send("");
		}
	}
}
