var rtFileLoaderCount = 0;
var rtFileLoaderObjects = new Array();

function rtFileLoader(url,onload) {
  	this.id = rtFileLoaderCount++;
  	window["rtFileLoaderObjects"][this.id] = this;
  	this.url = url;
  	this.onload = onload;
  	this.createIFRAME();
	setTimeout('rtFileLoaderObjects[' + this.id + '].loadDocument()', 5);
}

function rtFileLoader_createIFRAME(){
	this.frameName = 'rtFileLoader' + this.id;
	var ifr = document.createElement('IFRAME');
  	ifr.id = ifr.name = this.frameName;
  	ifr.style.display = 'none'; // just for testing
 	ifr.width = 300; 
  	ifr.height = 100;
  	ifr.src = 'about:blank';
  	document.body.appendChild(ifr);
}
rtFileLoader.prototype.createIFRAME = rtFileLoader_createIFRAME;

function rtFileLoader_getHTML(){
	var iframeDoc = window.frames['rtFileLoader_'+this.id].document;
  	var iframeBody = iframeDoc.body;
 	if (iframeBody){
		return iframeBody.innerHTML;
   	} else {
		return "Your Browser isn't supported!!!";
	}
}
rtFileLoader.prototype.getHTML = rtFileLoader_getHTML;

function rtFileLoader_loadDocument(url) {
  if (url)
    this.url = url;
  this.loaded = false;
  this.document = null;
  var ifrWin = 
    document.all ? document.frames[this.frameName] :
    window.frames[this.frameName];
  var html = '';
  html += '<HTML>';
  html += '<BODY ONLOAD="';
  //html += 'alert(event.type);';  // just for testing
  html += 'var fl = top.rtFileLoaderObjects[' + this.id + '];';
  html += 'fl.loaded = true;';
  html += 'fl.document = window.frames[0].document;';
  html += 'fl.onload(fl.document);';
  html += '"';
  html += '>';
  html += '<IFRAME SRC="' + this.url + '">';
  html += '<\/IFRAME>';
  html += '<\/BODY>';
  html += '<\/HTML>';
  ifrWin.document.open();
  ifrWin.document.write(html);
  ifrWin.document.close();
}
rtFileLoader.prototype.loadDocument = rtFileLoader_loadDocument;