Zpk_ScriptSrcTransport=new function(){
this.preventCache=true;
this.maxUrlLength=1000;
this.inFlightTimer=null;
this.DsrStatusCodes={Continue:100,Ok:200,Error:500};
this.startWatchingInFlight=function(){
if(!this.inFlightTimer){
this.inFlightTimer=setInterval("Zpk_ScriptSrcTransport.watchInFlight();",100);
}
};
this.watchInFlight=function(){
var _1=0;
var _2=0;
for(var _3 in this._state){
_1++;
var _4=this._state[_3];
if(_4.isDone){
_2++;
delete this._state[_3];
}else{
if(!_4.isFinishing){
var _5=_4.kwArgs;
try{
if(_4.checkString&&eval("typeof("+_4.checkString+") != 'undefined'")){
_4.isFinishing=true;
this._finish(_4,"load");
_2++;
delete this._state[_3];
}else{
if(_5.timeoutSeconds&&_5.timeout){
if(_4.startTime+(_5.timeoutSeconds*1000)<(new Date()).getTime()){
_4.isFinishing=true;
this._finish(_4,"timeout");
_2++;
this.removeScript(_4.id);
delete this._state[_3];
}
}else{
if(!_5.timeoutSeconds){
_2++;
}
}
}
}
catch(e){
_4.isFinishing=true;
this._finish(_4,"error",{status:this.DsrStatusCodes.Error,response:e});
this.removeScript(_4.id);
}
}
}
}
if(_2>=_1){
clearInterval(this.inFlightTimer);
this.inFlightTimer=null;
}
};
this.removeScript=function(id){
var _7=document.getElementById(id);
var _8=_7.parentNode;
if(_7&&_7.className=="Zpk_ScriptSrcTransport"){
var _8=_7.parentNode;
_8.removeChild(_7);
}
};
this.bind=function(_9){
var _a=_9.url;
var _b="";
if(_a.indexOf("#")>-1){
_a=_a.split("#")[0];
}
var _c=_a.split("?");
if(_c&&_c.length==2){
_a=_c[0];
_b+=(_b?"&":"")+_c[1];
}
var id=_9["apiId"]?_9["apiId"]:"id"+this._counter++;
var _e=_9["content"];
var _f=_9.jsonParamName;
if(_9.sendTransport||_f){
if(!_e){
_e={};
}
if(_9.sendTransport){
_e["dojo.transport"]="scriptsrc";
}
if(_f){
_e[_f]="Zpk_ScriptSrcTransport._state."+id+".jsonpCall";
}
}
if(_e[_f]){
_b+=((_b)?"&":"")+_f+"="+encodeURIComponent(_e[_f]);
}
if(_9["apiId"]){
_9["useRequestId"]=true;
}
var _10={"id":id,"idParam":"_dsrid="+id,"url":_a,"query":_b,"kwArgs":_9,"startTime":(new Date()).getTime(),"isFinishing":false};
if(!_a){
this._finish(_10,"error",{status:this.DsrStatusCodes.Error,statusText:"url.none"});
return;
}
if(_e&&_e[_f]){
_10.jsonp=_e[_f];
_10.jsonpCall=function(_11){
if(_11["Error"]||_11["error"]){
if(dojo["json"]&&dojo["json"]["serialize"]){
}
Zpk_ScriptSrcTransport._finish(this,"error",_11);
}else{
Zpk_ScriptSrcTransport._finish(this,"load",_11);
}
};
}
if(_9["useRequestId"]||_9["checkString"]||_10["jsonp"]){
this._state[id]=_10;
}
if(_9["checkString"]){
_10.checkString=_9["checkString"];
}
_10.constantParams=(_9["constantParams"]==null?"":_9["constantParams"]);
if(_9["preventCache"]||(this.preventCache==true&&_9["preventCache"]!=false)){
_10.nocacheParam="dojo.preventCache="+new Date().valueOf();
}else{
_10.nocacheParam="";
}
var _12=_10.url.length+_10.query.length+_10.constantParams.length+_10.nocacheParam.length+this._extraPaddingLength;
if(_9["useRequestId"]){
_12+=_10.idParam.length;
}
if(!_9["checkString"]&&_9["useRequestId"]&&!_10["jsonp"]&&!_9["forceSingleRequest"]&&_12>this.maxUrlLength){
if(_a>this.maxUrlLength){
this._finish(_10,"error",{status:this.DsrStatusCodes.Error,statusText:"url.tooBig"});
return;
}else{
this._multiAttach(_10,1);
}
}else{
var _13=[_10.constantParams,_10.nocacheParam,_10.query];
if(_9["useRequestId"]&&!_10["jsonp"]){
_13.unshift(_10.idParam);
}
var _14=this._buildUrl(_10.url,_13);
_10.finalUrl=_14;
this._attach(_10.id,_14);
}
this.startWatchingInFlight();
};
this._counter=1;
this._state={};
this._extraPaddingLength=16;
this._buildUrl=function(url,_16){
var _17=url;
var _18="?";
for(var i=0;i<_16.length;i++){
if(_16[i]){
_17+=_18+_16[i];
_18="&";
}
}
return _17;
};
this._attach=function(id,url){
var _1c=document.createElement("script");
_1c.type="text/javascript";
_1c.src=url;
_1c.id=id;
_1c.className="Zpk_ScriptSrcTransport";
document.getElementsByTagName("head")[0].appendChild(_1c);
};
this._multiAttach=function(_1d,_1e){
if(_1d.query==null){
this._finish(_1d,"error",{status:this.DsrStatusCodes.Error,statusText:"query.null"});
return;
}
if(!_1d.constantParams){
_1d.constantParams="";
}
var _1f=this.maxUrlLength-_1d.idParam.length-_1d.constantParams.length-_1d.url.length-_1d.nocacheParam.length-this._extraPaddingLength;
var _20=_1d.query.length<_1f;
var _21;
if(_20){
_21=_1d.query;
_1d.query=null;
}else{
var _22=_1d.query.lastIndexOf("&",_1f-1);
var _23=_1d.query.lastIndexOf("=",_1f-1);
if(_22>_23||_23==_1f-1){
_21=_1d.query.substring(0,_22);
_1d.query=_1d.query.substring(_22+1,_1d.query.length);
}else{
_21=_1d.query.substring(0,_1f);
var _24=_21.substring((_22==-1?0:_22+1),_23);
_1d.query=_24+"="+_1d.query.substring(_1f,_1d.query.length);
}
}
var _25=[_21,_1d.idParam,_1d.constantParams,_1d.nocacheParam];
if(!_20){
_25.push("_part="+_1e);
}
var url=this._buildUrl(_1d.url,_25);
this._attach(_1d.id+"_"+_1e,url);
};
this._finish=function(_27,_28,_29){
if(_28!="partOk"&&!_27.kwArgs[_28]&&!_27.kwArgs["handle"]){
if(_28=="error"){
_27.isDone=true;
throw _29;
}
}else{
switch(_28){
case "load":
var _2a=_29?_29.response:null;
if(!_2a){
_2a=_29;
}
_27.kwArgs[(typeof _27.kwArgs.load=="function")?"load":"handle"]("load",_2a,_29,_27.kwArgs);
_27.isDone=true;
break;
case "partOk":
var _2b=parseInt(_29.response.part,10)+1;
if(_29.response.constantParams){
_27.constantParams=_29.response.constantParams;
}
this._multiAttach(_27,_2b);
_27.isDone=false;
break;
case "error":
_27.kwArgs[(typeof _27.kwArgs.error=="function")?"error":"handle"]("error",_29.response,_29,_27.kwArgs);
_27.isDone=true;
break;
default:
_27.kwArgs[(typeof _27.kwArgs[_28]=="function")?_28:"handle"](_28,_29,_29,_27.kwArgs);
_27.isDone=true;
}
}
};
};
