/*

HTMLHttpRequest v1.0 beta
(c) 2001-2005 Angus Turnbull, TwinHelix Designs http://www.twinhelix.com

Licensed for redistribution and/or modification under the terms
of the GNU Lesser General Public License (version 2.1 or later)
as published by the Free Software Foundation.
See http://www.gnu.org/copyleft/lesser.txt for more details.

*/

function HTMLHttpRequest(myName,blankFile){this.myName=myName;this.blankFile=blankFile?blankFile:'about:self';this.buf=null;this.doc=null;this.loading=false;this.onload=null;document._ifr_buf_count|=0;var ifrID='iframebuffer'+document._ifr_buf_count++;if(document.createElement&&document.documentElement&&(window.opera||navigator.userAgent.indexOf('MSIE 5.0')==-1)){var ifr=document.createElement('iframe');ifr.setAttribute('id',ifrID);ifr.setAttribute('src',this.blankFile);ifr.style.visibility='hidden';ifr.style.position='absolute';ifr.style.width=ifr.style.height=ifr.borderWidth='0px';this.buf=document.getElementsByTagName('body')[0].appendChild(ifr)}else if(document.body&&document.body.insertAdjacentHTML){document.body.insertAdjacentHTML('beforeEnd','<iframe name="'+ifrID+'" id="'+ifrID+'" src="'+this.blankFile+'" style="display:none"></iframe>')}if(window.frames&&window.frames[ifrID])this.buf=window.frames[ifrID];return this};HTMLHttpRequest.prototype.load=function(uri,callback){with(this){if(!uri||!buf||loading)return false;if(callback)this.onload=callback;doc=null;var ifrDoc=buf.contentDocument||buf.document;if(buf&&!ifrDoc)return setTimeout(myName+'.load("'+uri+'",null)',100);if(document.readyState){if(!window.opera&&ifrDoc.location&&ifrDoc.location.href!=location.href)ifrDoc.location.replace(uri);else buf.src=uri;setTimeout(myName+'.checkLoad(false)',(window.opera?250:100));loading=true;return true}else if(ifrDoc.write){ifrDoc.write('<html><body onload="if(!self.loaded)parent.'+myName+'.checkLoad(true);self.loaded=true"><iframe id="nestBuf" name="nestBuf" src="'+uri+'"></iframe></body></html>');ifrDoc.close();loading=true;return true}return false}};HTMLHttpRequest.prototype.checkLoad=function(nested){with(this){doc=buf.contentDocument?(nested?buf.contentDocument.getElementById('nestBuf').contentDocument:buf.contentDocument):(nested?buf.nestBuf.document:buf.document);if(nested||(buf.src!=blankFile&&(doc.readyState=='complete'||!document.getElementById&&doc.readyState=='interactive'))){loading=false;this.onload(doc)}else setTimeout(myName+'.checkLoad('+nested+')',50)}};