function AjaxRequest(in_Url) {
  //base object
  var requestObj;
  if (window.XMLHttpRequest) { // if Mozilla, IE7, Safari etc
    requestObj = new XMLHttpRequest();
  }
  else if (window.ActiveXObject) { // if IE6 or below
    try {
      requestObj = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch (e) {
      try {
        requestObj = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e) {
        throw 'No Ajax support'; //no Ajax
      }
    }
  }
  
	//properties
	this.url = in_Url;
	this.params = new Array();
	this.onload = null;
	var that = this;
  
	clearProperties(this.params); //clear any properites that might have been defined on array prototype		

	requestObj.onreadystatechange=function() {
	  if ((requestObj.readyState==4) && (that.onload))
		  that.onload(that,requestObj.status);
	}
  //methods
  this.getRequest=function(in_Url) {
	  if (in_Url) this.url=in_Url;
		l_Params=this.constructParamStr(true);
		requestObj.open('GET',this.url+"?"+l_Params, true);
		requestObj.send(null);
  };
	
  this.postRequest=function(in_Url) {
	  if (in_Url) this.url=in_Url;
		l_Params=this.constructParamStr(true);
		requestObj.open('POST',this.url, true);
		requestObj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    requestObj.setRequestHeader("Content-length", l_Params.length);
    requestObj.setRequestHeader("Connection", "close");
		requestObj.send(l_Params);
  };
	
	this.constructParamStr=function(in_encode) {
	  if (in_encode==undefined) in_encode=true;
	  result = '';
		var l_value;
		var l_params=this.params
	  for(i in l_params) {
		  if (l_params[i]!=undefined) {
			  if (in_encode) l_value=encodeURIComponent(l_params[i]);
			    else l_value=l_params[i];
		    result+='&'+i+'='+l_value;
			}	
	  }
		return result.substr(1);
	}

  this.getReadyState = function() {return requestObj.readyState;};
  this.getResponseText = function() {return requestObj.responseText;};
  this.getResponseXML = function() {return requestObj.responseXML;};
  this.getResponseJSON = function() {
    if (window.JSON) return JSON.parse(requestObj.responseText);
    else return eval('(' + requestObj.responseText + ')');
  }
  this.getStatus = function() {return requestObj.status;};
  this.getStatusText = function() {return requestObj.statusText;};
} 

function clearProperties(in_Obj) {
  for (i in in_Obj) in_Obj[i] = undefined;
  return in_Obj;
}


