function HTMLHttpRequest(myName, callback, args) { with (this)
{
 this.myName = myName;
 this.callback = callback;
 this.args = args;

 this.xmlhttp = null;
 this.iframe = null;
 window._ifr_buf_count |= 0;
 this.iframeID = 'iframebuffer' + window._ifr_buf_count++;
 this.loadingURI = '';

 if (window.XMLHttpRequest) {
  xmlhttp = new XMLHttpRequest();
  if (xmlhttp.overrideMimeType) xmlhttp.overrideMimeType('text/xml');
 } else if (window.ActiveXObject) { // IE
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
	}
 }
 //xmlhttp = null;
 if (!xmlhttp) {
  if (document.createElement && document.documentElement &&
   (window.opera || navigator.userAgent.indexOf('MSIE 5.0') == -1))
  {
   var ifr = document.createElement('iframe');
   ifr.setAttribute('id', iframeID);
   ifr.setAttribute('name', iframeID);
   ifr.style.visibility = 'hidden';
   ifr.style.position = 'absolute';
   ifr.style.width = ifr.style.height = ifr.borderWidth = '0px';
   iframe = document.getElementsByTagName('body')[0].appendChild(ifr);
  }
  else if (document.body && document.body.insertAdjacentHTML)
  {
   document.body.insertAdjacentHTML('beforeEnd', '<iframe name="' + iframeID +
   '" id="' + iframeID + '" style="display: none"></iframe>');
  }
  if (window.frames && window.frames[iframeID]) iframe = window.frames[iframeID];
  iframe.name = iframeID;
 }

 return this;
}};


HTMLHttpRequest.prototype.xmlhttpSend = function(uri) { with (this)
{
 xmlhttp.open('GET', uri, true);
 xmlhttp.onreadystatechange = function() {
  if (xmlhttp.readyState == 4) {
  	if (xmlhttp.status == 200) {
	   var doc = xmlhttp.responseText;
	   if (callback) callback(doc, loadingURI, args);
	   loadingURI = '';
	  }
  }
 };
 xmlhttp.send(null);
 loadingURI = uri;
 return true;
}};


HTMLHttpRequest.prototype.iframeSend = function(uri) { with (this)
{
 if (!document.readyState) return false;
 if (document.getElementById) var o = document.getElementById(iframeID).offsetWidth;
 var ifrDoc = iframe.contentDocument || iframe.document;
 if (!window.opera && ifrDoc.location && ifrDoc.location.href != location.href) ifrDoc.location.replace(uri);
 else iframe.src = uri;
 loadingURI = uri;
 setTimeout(myName + '.iframeCheck()', (window.opera ? 250 : 100));
 return true;
}};


HTMLHttpRequest.prototype.iframeCheck = function() { with (this)
{
 doc = iframe.contentDocument || iframe.document;
 var il = iframe.location, dr = doc.readyState;
 if ((il && il.href ? il.href.indexOf(loadingURI) : 1) &&
     (dr == 'complete' || (!document.getElementById && dr == 'interactive')))
 {
  if(isString(doc.documentElement.getElementsByTagName('body')[0].innerHTML)) {
  	if (callback) callback((doc.documentElement.getElementsByTagName('body')[0].innerHTML), loadingURI, args);
  } else {
  	if (callback) callback((doc.documentElement.innerHTML || doc.documentElement || doc), loadingURI, args);
  }
  loadingURI = '';
 }
 else setTimeout(myName + '.iframeCheck()', 50);
}};


HTMLHttpRequest.prototype.load = function(uri) { with (this)
{
 if (!uri || (!xmlhttp && !iframe)) return false;
 if (xmlhttp) return xmlhttpSend(uri);
 else if (iframe) return iframeSend(uri);
 else return false;
}};

function isString(a) {
	return typeof a == 'string';
}
