var useBSNns;

if (useBSNns)
{
	if (typeof(bsn) == "undefined")
		bsn = {}
	_bsn = bsn;
}
else
{
	_bsn = this;
}

_bsn.Ajax = function ()
{
	this.req = {};
	this.isIE = false;
}

_bsn.Ajax.prototype.makeRequest = function (url, meth, onComp, onErr)
{
	
	var urlOnly="";
	var poststring="";
	
	if (meth != "POST"){
		meth = "GET";	
	}else{
		urlOnly=url.substring(0,url.indexOf('?'));
		poststring=url.substring(url.indexOf('?')+1);
	}
	this.onComplete = onComp;
	this.onError = onErr;
	
	var pointer = this;
	
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest)
	{
		if(meth=="GET" || meth=="get"){
			this.req = new XMLHttpRequest();
			this.req.onreadystatechange = function () { pointer.processReqChange() };
			this.req.open("GET", url, true); //
			this.req.send(null);
		}else if(meth=="POST"|| meth=="post"){
			this.req = new XMLHttpRequest();
			this.req.onreadystatechange = function () { pointer.processReqChange() };
			this.req.open("POST", urlOnly, true); //
			this.req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');			
			this.req.send(poststring);			
		}		
		
	// branch for IE/Windows ActiveX version
	}
	else if (window.ActiveXObject)
	{
		this.req = new ActiveXObject("Microsoft.XMLHTTP");
		if (this.req)
		{
			if(meth=="GET" || meth=="get"){
				this.req.onreadystatechange = function () { pointer.processReqChange() };
				this.req.open("GET", url, true);
				this.req.send();
			}else if(meth=="POST"|| meth=="post"){
				this.req.onreadystatechange = function () { pointer.processReqChange() };
				this.req.open("POST", urlOnly, true);
				this.req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");    
				this.req.send(poststring);				
				
			}
		}
	}
}


_bsn.Ajax.prototype.processReqChange = function()
{
	
	// only if req shows "loaded"
	if (this.req.readyState == 4) {
		// only if "OK"
		if (this.req.status == 200)
		{
			this.onComplete( this.req );
		} else {
			this.onError( this.req.status );
		}
	}
}