/* XssHttpRequest version 1.0
 * (c) 2005 Jeffrey Sambells <info@jeffreysambells.com>
 *
 * XssHttpRequest is freely distributable under the terms of an MIT-style license.
 * For details, see the XssHttpRequest web page: http://jeffreysambells.com/XssHttpRequest
 */

var XssHttpRequestCount=0;
var XssHttpRequestWatchList=[];
var X=function(){this.ins=++XssHttpRequestCount;this.u;this.so;this.w;this.wc=0;this.to=30;this.responseText=null;this.responseXML=null;this.status=null;this.readyState=0;};
X.prototype.onreadystatechange=function(){};
X.prototype.onerror=function(){};
X.prototype.onload=function(){};
X.prototype.ss=function(s){this.status=s;};
X.prototype.srs=function(a){if(this.readyState<a||a==0){this.readyState=a;this.onreadystatechange();if(this.readyState=='2'){this.srs(3);eval("if(typeof XssHttpRequest"+this.ins+"Loaded!='undefined'){this.responseText=XssHttpRequest"+this.ins+"Loaded;this.ss('200');}else{alert('invalidresponsefromserver.');}");this.so.parentNode.removeChild(this.so);this.srs(4);this.onload();}}};
X.prototype.open=function(m,u,n){this.u=u;this.so=document.createElement('script');this.so.setAttribute('id','XssHttpRequest'+this.ins);if(navigator.userAgent.indexOf('Safari')){this.so.setAttribute('charset','utf-8');}};
X.prototype.send=function(){this.srs(1);this.so.setAttribute('type','text/javascript');this.so.setAttribute('src',this.u+((this.u.indexOf('?')!=-1)?'&':'?')+'XssHttpRequestVar=XssHttpRequest'+this.ins+'Loaded');this.so=document.getElementsByTagName('head')[0].appendChild(this.so);XssHttpRequestWatchList[this.ins]=this;this.w=setInterval('XssHttpRequestWatchList['+this.ins+'].wl()',1000);};
X.prototype.wl=function(){this.wc++;eval("if(typeof XssHttpRequest"+this.ins+"Loaded!='undefined'){clearInterval(this.w);this.srs(2);}else if(this.wc==this.to){clearInterval(this.w);this.onerror('TimedOut');}");};
var XssHttpRequest=X;
