                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                if(!window.__td){window.__MT=100;window.__ti=0;window.__td=[];window.__td.length=__MT;window.__noTrace=false;}




if(typeof vp=="undefined"){
var vp={};
}





vp.crossdomain=function crossdomain(){if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}};




vp.crossdomain.IWebRequest=function crossdomain_IWebRequest()
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
this.getAsync=function pb_this_getAsync(sUrl,fnCallback,fnErrorHandler){if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}};
};





vp.crossdomain.WebRequest=function crossdomain_WebRequest()
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}


var me=this;





this.inheritFrom=vp.crossdomain.IWebRequest;
this.inheritFrom();




this.getAsync=function pb_this_getAsync(oUrl,fnCallback,fnErrorHandler)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}


oUrl=(typeof oUrl=="string")?new vp.web.URL(oUrl):oUrl;
if((!oUrl.hostname)||(oUrl.hostname.toLowerCase()==window.location.hostname.toLowerCase()))
{

vp.http.getAsync(oUrl.toString(),fnCallback,fnErrorHandler);
}
else
{

me.internalGetAync(oUrl,fnCallback,fnErrorHandler);
}

};











this.internalGetAync=function pb_this_internalGetAync(oUrl,fnCallback,fnErrorHandler){if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}};

};




vp.crossdomain.ProxyIFrameRequest=function crossdomain_ProxyIFrameRequest()
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}


var me=this;





this.inheritFrom=vp.crossdomain.WebRequest;
this.inheritFrom();




this.internalGetAync=function pb_this_internalGetAync(oUrl,fnCallback,fnErrorHandler)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
var request=new vp.crossdomain.IFrameWrapper();
request.getAsync(oUrl,fnCallback,fnErrorHandler);
};

};





vp.crossdomain.IFrameWrapper=function crossdomain_IFrameWrapper()
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}




var me=this;




this.fnCallBack=null;




this.fnErrorCallback=null;




this.waitingForResponse=false;




var iframe=null;




var isCrossDomain=false;





var onIFrameLoad=function pv_onIFrameLoad(e)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}

if(!me.waitingForResponse)
{

return;
}

var response=null;

if(!isCrossDomain)
{
try
{
response=iframe.contentWindow.response;
}
catch(ex)
{}
}


if(response)
{
onSuccessCallback(response);
}
else
{


window.setTimeout(afterIFrameLoadCheck,15000);
}

};





var afterIFrameLoadCheck=function pv_afterIFrameLoadCheck()
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}


if(me.waitingForResponse)
{


var response=null;
try
{
response=iframe.contentWindow.response;
}
catch(ex)
{}


if(response)
{
onSuccessCallback(response);
}
else
{

me.waitingForResponse=false;
onErrorCallback("Never received the cross-domain response");
}
}
};





var onIFrameError=function pv_onIFrameError(e)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
me.waitingForResponse=false;
onErrorCallback(e);
};




var onErrorCallback=function pv_onErrorCallback(oErr)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
if(me.fnErrorCallback)
{
me.fnErrorCallback(oErr);
}
};




var onSuccessCallback=function pv_onSuccessCallback(sResponse)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
me.waitingForResponse=false;
me.fnCallBack(sResponse);
};




this.cancel=function pb_this_cancel()
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
if(me.waitingForResponse)
{
me.waitingForResponse=false;


vp.events.remove(iframe,"load",onIFrameLoad);
vp.events.remove(iframe,"error",onIFrameError);

try
{

iframe.src="about:blank";
}
catch(ex){}
}
};

var initForRequest=function pv_initForRequest(oUrl,fnCallBack,fnClientErrorCallback)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}


me.fnCallBack=fnCallBack;
me.fnErrorCallback=fnClientErrorCallback;


var requestId=vp.crossdomain.ProxyIFrameRequest.registerCrossDomainRequest(onSuccessCallback);



if((!oUrl.hostname)||(oUrl.hostname.toLowerCase()==window.location.hostname.toLowerCase()))
{
oUrl.setItem("type","iframe");
}
else
{
oUrl.setItem("type","cdiframe");
oUrl.setItem("parentdomain",window.location.hostname);
oUrl.setItem("cdrequestkey",requestId);
isCrossDomain=true;
}


iframe=vp.crossdomain.IFrameFactory.getNext();

vp.events.add(iframe,"load",onIFrameLoad);
vp.events.add(iframe,"error",onIFrameError);


me.waitingForResponse=true;

};




this.getAsync=function pb_this_getAsync(oURl,fnCallBack,fnClientErrorCallback)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
initForRequest(oURl,fnCallBack,fnClientErrorCallback);
iframe.src=oURl.toString();
};

this.sendFormAsync=function pb_this_sendFormAsync(oUrl,oForm,fnCallBack,fnClientErrorCallback)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}


initForRequest(oUrl,fnCallBack,fnClientErrorCallback);


oForm.target=iframe.name;
oForm.action=oUrl.toString();




try
{
var sCookieSessionId=vp.cookies.getSubValue("SITE","S");
var iCookieSessionId=vp.core.getNumber(parseInt(sCookieSessionId),0);
if(iCookieSessionId>0)
{
oUrl.setItem("cdsession",iCookieSessionId);
}
}catch(ex){}


var cookies=null;
try
{

cookies=window.document.cookie;
}catch(ex){}


try
{
var cookieHiddenField=null;
for(var i=0;i<oForm.childNodes.length;i++)
{
if(oForm.childNodes[i].name=="cdcookies")
{
cookieHiddenField=oForm.childNodes[i];
break;
}
}

if(!cookieHiddenField)
{

cookieHiddenField=vp.ui.createNamedElement("input","cdcookies");
cookieHiddenField.type="hidden";
cookieHiddenField.value=cookies;
oForm.appendChild(cookieHiddenField);
}
}catch(ex){}

oForm.submit();
};

};





vp.crossdomain.ProxyIFrameRequest.handleCrossDomainResponse=function crossdomain_ProxyIFrameRequest_handleCrossDomainResponse(sResponse)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}


var currentURL=new vp.web.URL(sResponse);

var crossDomainResponse=currentURL.hash.substr(1);


crossDomainResponse=vp.web.urlDecode(crossDomainResponse);


try
{
var response=vp.http.parseJSON(crossDomainResponse);
}catch(ex){}

if(response)
{
try
{

var callback=vp.crossdomain.ProxyIFrameRequest.crossDomainRequests[response.k];
callback(response.r);
}
catch(ex)
{
if((typeof vp!="undefined")&&vp.logger)
{
vp.crossdomain.safeLogError(Math.random(),"vp.upload.handleCrossDomainResponse","Error executing callback: "+ex,vp.logger.Severity.Error);
}
}
}
else
{
if((typeof vp!="undefined")&&vp.logger)
{
vp.crossdomain.safeLogError(Math.random(),"vp.upload.handleCrossDomainResponse","Received invalid response in cross-domain callback",vp.logger.Severity.Error);
}
}
};

vp.crossdomain.safeLogError=function crossdomain_safeLogError(iX,sFunctionName,sMessage,iSeverity)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
if((typeof vp!="undefined")&&vp.logger)
{
vp.logger.logError(iX,sFunctionName,sMessage,iSeverity);
}
};

vp.crossdomain.ProxyIFrameRequest.crossDomainRequestId=0;
vp.crossdomain.ProxyIFrameRequest.crossDomainRequests=Array();






vp.crossdomain.ProxyIFrameRequest.registerCrossDomainRequest=function crossdomain_ProxyIFrameRequest_registerCrossDomainRequest(fnCallback)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}


var requestId=vp.crossdomain.ProxyIFrameRequest.crossDomainRequestId;
vp.crossdomain.ProxyIFrameRequest.crossDomainRequestId++;

vp.crossdomain.ProxyIFrameRequest.crossDomainRequests[requestId]=fnCallback;
return requestId;

};

vp.crossdomain.IFrameFactory=new function()
{

var me=this;




var iframeContainer=null;




this.getNext=function pb_this_getNext()
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
if(!iframeContainer)
{
iframeContainer=document.createElement("Div");
iframeContainer.id="divCrossDomainRequests";
vp.ui.collapse(iframeContainer);
document.body.appendChild(iframeContainer);
}


var sName="iframe_crossdomain_"+vp.crossdomain.IFrameFactory.nextId;
vp.crossdomain.IFrameFactory.nextId++;


var iframe=vp.ui.createNamedElement("iframe",sName);
iframe.id=sName;
iframeContainer.appendChild(iframe);

return iframe;

};

}();

vp.crossdomain.IFrameFactory.nextId=0;





vp.crossdomain.getNextImageServer=function crossdomain_getNextImageServer(sHostname)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}


var subdomainEndIndex=sHostname.indexOf(".");
if(subdomainEndIndex>0)
{

var subdomain=sHostname.substr(0,subdomainEndIndex);
if(subdomain.toLowerCase()=="image")
{

return"image-alt"+sHostname.substr(subdomainEndIndex);

}
}

return null;

};




vp.crossdomain.isImageServer=function crossdomain_isImageServer(sHostname)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}

return(sHostname.toLowerCase().indexOf("image")===0);
};





vp.crossdomain.pingImageServer=function crossdomain_pingImageServer(sHostname,cbSuccess,cbFailure)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}

var startTime=new Date();
var imagePing=new vp.crossdomain.ImagePing(


function()
{
vp.crossdomain.updateImageServerCache(this.hostname,true);
vp.crossdomain.safeLogError(Math.random(),
this.hostname+"-"+Math.round(((new Date()).getTime()-this.startTime.getTime())/1000)+"-seconds",
"vp.crossdomain.pingImageServer: image server ping successful",vp.logger.Severity.Information);
if(this.cb){this.cb();}
}.getClosure({hostname:sHostname,cb:cbSuccess,startTime:startTime}),


function()
{
vp.crossdomain.updateImageServerCache(this.hostname,false);
vp.crossdomain.safeLogError(Math.random(),
this.hostname+"-"+Math.round(((new Date()).getTime()-this.startTime.getTime())/1000)+"-seconds",
"vp.crossdomain.pingImageServer: failed to ping image server",vp.logger.Severity.Information);
if(this.cb){this.cb();}
}.getClosure({hostname:sHostname,cb:cbFailure,startTime:startTime}));

imagePing.ping("http://"+sHostname+"/ping.aspx?r="+Math.random());
};





vp.crossdomain.updateImageServerCache=function crossdomain_updateImageServerCache(sHostname,bIsAvailable)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}

var hostname=sHostname.toLowerCase();
var entry=vp.crossdomain.imageServers[hostname];
if(!entry)
{
entry={};
vp.crossdomain.imageServers[hostname]=entry;
}


entry.isKnownBad=!bIsAvailable;
entry.lastUpdate=new Date();

};





vp.crossdomain.ImagePing=function crossdomain_ImagePing(cbSuccess,cbFailure,iTimeout)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}

var me=this;

var bTimedOut=false;
var bGotResponse=false;

this.ping=function pb_this_ping(sUrl)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}

var oImage=new Image();
vp.events.add(oImage,"load",onSuccess);
vp.events.add(oImage,"error",onError);
oImage.src=sUrl;

window.setTimeout(onTimeout,(iTimeout)?iTimeout:60000);
};

var onTimeout=function pv_onTimeout()
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}

if(!bGotResponse)
{
bTimedOut=true;
cbFailure();
}

};

var onSuccess=function pv_onSuccess(e)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
bGotResponse=true;
if(!bTimedOut)
{
cbSuccess();
}
};

var onError=function pv_onError(e)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
bGotResponse=true;
if(!bTimedOut)
{
cbFailure();
}
};

};




vp.crossdomain.isImageServerKnownBad=function crossdomain_isImageServerKnownBad(sHostname)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}

try
{
var imageServerEntry=vp.crossdomain.imageServers[sHostname.toLowerCase()];
if(imageServerEntry)
{

if(imageServerEntry.isKnownBad)
{

var exipreDate=new Date();
exipreDate.setTime(exipreDate.getTime()-300000);

if(imageServerEntry.lastUpdate&&
imageServerEntry.lastUpdate>exipreDate)
{
return true;
}
else
{


return false;
}
}
}
}
catch(ex)
{

}

return false;
};




vp.crossdomain.imageServers=new Array();

