if(typeof Frozen=="undefined"){
Frozen={"meta":{"identifier":"com.frozen-o.frozentoolkit","identifierprefix":"com.frozen-o.frozentoolkit.","namespace":"Frozen","state":"alpha","url":"http://frozentoolkit.frozen-o.com","version":"0.2"}};
if(typeof OpenAjax!="undefined"){
OpenAjax.hub.registerLibrary(Frozen.meta.namespace,Frozen.meta.url,Frozen.meta.version,{"state":Frozen.meta.state});
}
}
if(typeof Frozen.Event=="undefined"){
Frozen.Event={};
Frozen.Event.Event=function(){
};
Frozen.Event.Event.prototype={type:"custom"};
Frozen.Event.Dispatcher=function(){
};
Frozen.Event.Dispatcher.prototype={events:{},addEventListener:function(_1,_2,_3){
if(this.events[_1]){
this.events[_1].push(_2);
}
},removeEventListener:function(_4,_5,_6){
if(this.events[_4]==undefined){
return;
}
var _7=this.events[_4].indexOf(_5);
if(this.events[_4][_7]){
this.events[_4].splice(_7,1);
}
},dispatchEvent:function(_8,_9){
if(this.events[_8]){
for(i in this.events[_8]){
if(typeof this.events[_8][i]=="function"){
this.events[_8][i](_9);
}else{
if(typeof this.events[_8][i]=="object"){
this.events[_8][i][1].call(this.events[_8][i][0],_9);
}
}
}
}
}};
}
if(typeof Frozen.Utilities=="undefined"){
Frozen.Utilities={loadedJavaScript:{},loadJavaScript:function(_a,_b,_c){
if(typeof _c=="undefined"){
_c=6000;
}
if(Frozen.Utilities.loadedJavaScript[_a]){
if(_b){
setTimeout(_b,10,true);
}
return true;
}else{
var _d=document.getElementsByTagName("head")[0];
var _e=_d.appendChild(document.createElement("script"));
var _f=setTimeout(function(){
_b(false);
},_c);
_e.addEventListener("load",function(){
clearTimeout(_f);
Frozen.Utilities.loadedJavaScript[_a]=true;
_b(true);
},false);
_e.type="text/javascript";
_e.src=_a;
return true;
}
}};
}

if(typeof Frozen.Ajax=="undefined"){
Frozen.Ajax={};
Frozen.Ajax.Event=function(_1){
this.request=_1;
};
Frozen.Ajax.Event.prototype=new Frozen.Event.Event;
Frozen.Ajax.Event.prototype.type="ajax";
Frozen.Ajax.Event.prototype.request=null;
Frozen.Ajax.Request=function(id){
this.id=id;
if(window.XMLHttpRequest){
this.xhr=new XMLHttpRequest();
}else{
if(window.ActiveXObject){
this.xhr=new ActiveXObject("Microsoft.XMLHTTP");
}
}
var _3=this;
this.xhr.onreadystatechange=function(){
Frozen.Ajax.Request.prototype.stateChanged.apply(_3,arguments);
};
this.events={abort:[],data:[],fail:[],internalservererror:[],load:[],notfound:[],notmodified:[],open:[],partialload:[],requestedrangenotsatisfiable:[],send:[],unauthorized:[]};
};
Frozen.Ajax.Request.prototype=new Frozen.Event.Dispatcher;
Frozen.Ajax.Request.prototype.events={};
Frozen.Ajax.Request.prototype.statusCodeEvents={200:"load",206:"partialload",304:"notmodified",401:"unauthorized",404:"notfound",416:"requestedrangenotsatisfiable",500:"internalservererror"};
Frozen.Ajax.Request.prototype.id=null;
Frozen.Ajax.Request.prototype.xhr=null;
Frozen.Ajax.Request.prototype.aborted=false;
Frozen.Ajax.Request.prototype.headers={};
Frozen.Ajax.Request.prototype.get={};
Frozen.Ajax.Request.prototype.post={};
Frozen.Ajax.Request.prototype.method="POST";
Frozen.Ajax.Request.prototype.stateChanged=function(){
switch(this.xhr.readyState){
case 3:
var e=new Frozen.Ajax.Event(this);
this.dispatchEvent("data",e);
break;
case 4:
try{
if(this.statusCodeEvents[this.xhr.status]){
var e=new Frozen.Ajax.Event(this);
this.dispatchEvent(this.statusCodeEvents[this.xhr.status],e);
}
}
catch(ex){
var e=new Frozen.Ajax.Event(this);
this.dispatchEvent("fail",e);
}
}
};
Frozen.Ajax.Request.prototype.abort=function(){
this.aborted=true;
var _5=new Frozen.Ajax.Event(this);
_5.returned=this.xhr.abort();
this.dispatchEvent("abort",_5);
return _5.returned;
};
Frozen.Ajax.Request.prototype.sendHeaders=function(){
for(i in this.headers){
this.xhr.setRequestHeader(i,this.headers[i]);
}
};
Frozen.Ajax.Request.prototype.open=function(_6,_7){
this.method=_6.toUpperCase();
var _8=this.urlEncodeObject(this.get);
_7+="?"+_8;
var _9=(typeof arguments[2]!="boolean")?true:arguments[2];
var _a=(typeof arguments[2]!="String")?null:arguments[3];
var _b=(typeof arguments[2]!="String")?null:arguments[4];
var _c=new Frozen.Ajax.Event(this);
_c.returned=this.xhr.open(this.method,_7,_9,_a,_b);
this.dispatchEvent("open",_c);
return _c.returned;
};
Frozen.Ajax.Request.prototype.send=function(){
if(this.aborted){
return false;
}
this.sendHeaders();
var _d="";
var _e=new Frozen.Ajax.Event(this);
if(this.method=="POST"){
this.xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
_d=this.urlEncodeObject(this.post);
_e.returned=this.xhr.send(_d);
}else{
_e.returned=this.xhr.send("");
}
this.dispatchEvent("send",_e);
return _e.returned;
};
Frozen.Ajax.Request.prototype.urlEncodeObject=function(_f){
var _10=true;
var _11="";
var _12;
var _13;
for(i in _f){
_12=encodeURIComponent(i);
switch(typeof _f[i]){
case "number":
_13=_f[i];
break;
case "boolean":
_13=(_f[i])?1:0;
break;
case "undefined":
_13="";
break;
default:
_13=encodeURIComponent(_f[i]);
break;
}
if(_10){
_10=false;
_11+=_12+"="+_13;
}else{
_11+="&"+_12+"="+_13;
}
}
return _11;
};
Frozen.Ajax.RequestManager=function(){
};
Frozen.Ajax.RequestManager.prototype={requests:[],createRequest:function(){
var _14=++this.requests.length;
try{
this.requests[_14]=new Frozen.Ajax.Request(_14);
return this.requests[_14];
}
catch(e){
alert(e);
if(this.requests[_14]){
this.requests.pop();
}
return false;
}
},eliminateRequest:function(req){
if(!req||!req.id||!this.requests[req.id]){
return false;
}
var id=req.id;
this.requests[id].abort();
this.requests.splice(id,1);
while(id<this.requests.length){
this.requests[id++].id--;
}
return true;
},abortAll:function(){
for(i=0;i<this.requests.length;i++){
if(this.requests[i]){
this.requests[i].abort();
}
}
},addEventListener:function(_17,_18,_19){
var dis=this;
Frozen.Event.Dispatcher.prototype.addEventListener.call(dis,_17,_18);
},removeEventListener:function(_1b,_1c,_1d){
var dis=this;
Frozen.Event.Dispatcher.prototype.removeEventListener.call(dis,_1b,_1c);
}};
Frozen.Ajax.Manager=new Frozen.Ajax.RequestManager();
}

