function JsonRequest(mn,callback){
	this.mn = mn;
	this.cb = callback;
	this.rObj = this.makeObj();
};

JsonRequest.prototype.makeRequest = function(url,p){
	// return false if no XHR object, so that form/link whatever will know to submit manually
	if (!this.rObj) return false;
	if (!p) p = false;

	// set up the request
	if (p){
		this.rObj.open('POST', url, true);
		this.rObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		this.rObj.setRequestHeader("Content-length", p.length);
		this.rObj.setRequestHeader("Connection", "close");
	}
	else this.rObj.open('GET', url, true);
	
	// set the callback function
	if (this.cb) this.rObj.onreadystatechange = new Function('if ('+this.mn+'.rObj.readyState == 4) '+this.mn+'.cb(eval("("+'+this.mn+'.rObj.responseText+")"));');
	else this.rObj.onreadystatechange = function(){return};
	
	// send the request
	this.rObj.send(p ? p : null);

	// return true- TODO: return false if request somehow fails...
	return true;
};

JsonRequest.prototype.makeObj = function(){
	if (window.XMLHttpRequest) // Mozilla, Safari,...
		r = new XMLHttpRequest();
  else if (window.ActiveXObject) { // IE
    try {
        r = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
          r = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {}
  }}
	return r ? r : false;
};