function isAlien(a){ return isObject(a) && typeof(a.constructor) != 'function';}
function isArray(a){ return isObject(a) && a.constructor == Array; }
function isBoolean(a){ return typeof(a) == 'boolean'; }
function isFunction(a){ return typeof(a) == 'function'; }
function isNull(a){ return a === null; }
function isInt(a){ return typeof(a) == 'number'; }
function isObject(a){ return (a && typeof(a) == 'object') || isFunction(a); }
function isString(a){ return typeof(a) == 'string'; }
function undef(a){ return typeof(a) == 'undefined'; }
function isFormElement(a){ return a.constructor=='[HTMLInputElement]'; }

function empty(a,loosly)
{
	if (undef(a)) return true;
	if (isNull(a)) return true;
	if (isInt(a)) return a < 1 ;
	if (!undef(loosly) && a.match(/^[0-9]+$/)) return parseInt(a,10) == 0;
	if(isBoolean(a)) return !a;
	return count(a) < 1;
}
function count(a) 
{
	if (undef(a)) return 0;
	var c = 0;
	for (var i in a ) c++;
	return c;
}

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 (!undef(_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 (!undef(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("");
		}
	}
}