﻿Type.registerNamespace("Telerik.Web.UI");
Type.registerNamespace("Telerik.Web.UI.ProgressManager");
function getRadProgressManager(){return Telerik.Web.UI.ProgressManager.Manager
}function RadUploadSafariPoller(f,h,e,g){this._callbackUrl=f;
this._refreshPeriod=h;
this._waitingForResponse=false;
this._timeFormat=e
}function RadUploadSafariProgressArea(b){this._id=b;
if(typeof(window.progressAreas)=="undefined"){window.progressAreas=[]
}window.progressAreas[window.progressAreas.length]=this
}Telerik.Web.UI.RadProgressManager=function(b){Telerik.Web.UI.RadProgressManager.initializeBase(this,[b]);
this._uniqueRequestIdentifier="RadUrid";
this._formId="";
this._form=null;
this._pageGUID="";
this._suppressMissingHttpModuleError=false;
this._refreshPeriod=500;
this._shouldRegisterForSubmit=true;
this._ajaxCallUrl="";
$telerik.RadUpload_isIFrameProgress=$telerik.isSafari||$telerik.isOpera;
this._disposed=false;
this._timeFormat="%HOURS%:%MINUTES%:%SECONDS%s"
};
Telerik.Web.UI.RadProgressManager.prototype={initialize:function(){Telerik.Web.UI.RadProgressManager.callBaseMethod(this,"initialize");
this._registerAsPageManager();
this._initializeForm();
this._callbackUrl=this._createCallbackUrl(this._ajaxCallUrl);
this._waitingForResponse=false;
if(typeof(Telerik.Web.UI.ProgressAreas)=="undefined"){Telerik.Web.UI.ProgressAreas=[]
}if($telerik.RadUpload_isIFrameProgress){this._safariPollerDelegate=Function.createDelegate(this,this._createSafariPoller);
Sys.Application.add_load(this._safariPollerDelegate)
}},dispose:function(){this._disposed=true;
if(this._form&&this._shouldRegisterForSubmit==true){$removeHandler(this._form,"submit",this._clientSubmitDelegate);
this._clientSubmitDelegate=null
}if($telerik.RadUpload_isIFrameProgress&&this._safariPollerDelegate){Sys.Application.remove_load(this._safariPollerDelegate);
this._safariPollerDelegate=null
}Telerik.Web.UI.RadProgressManager.callBaseMethod(this,"dispose")
},_getSafariPollerDefinition:function(){RadUploadSafariPoller.prototype={_createReadyStateChangeDelegate:this._createReadyStateChangeDelegate,_sendXmlHttpRequest:this._sendXmlHttpRequest,_makeCallback:this._makeCallback,_getTimeStampedCallbackUrl:this._getTimeStampedCallbackUrl,_handleCallback:this._handleCallback,_errorOccured:this._errorOccured,_showNotFoundMessage:this._showNotFoundMessage,_showGenericErrorMessage:this._showGenericErrorMessage,_showInvalidContentMessage:this._showInvalidContentMessage,get_refreshPeriod:this.get_refreshPeriod,_modifyProgressData:this._modifyProgressData,getFormattedTime:this.getFormattedTime,_normalizeTime:this._normalizeTime,_toSeconds:this._toSeconds,_updateProgressAreas:this._updateProgressAreas,_formatTimePart:this._formatTimePart};
return RadUploadSafariPoller
},_getSafariProgressAreaDefinition:function(){RadUploadSafariProgressArea.prototype={get_id:function(){return this._id
},show:Telerik.Web.UI.RadProgressArea.prototype.show,update:Telerik.Web.UI.RadProgressArea.prototype.update,updateHorizontalProgressBar:Telerik.Web.UI.RadProgressArea.prototype.updateHorizontalProgressBar,updateTextIndicator:Telerik.Web.UI.RadProgressArea.prototype.updateTextIndicator};
return RadUploadSafariProgressArea
},_addClassAsString:function(g,j,l){l[l.length]=g.toString();
l[l.length]=";";
l[l.length]=j;
l[l.length]=".prototype = {";
var h=true;
for(var i in g.prototype){var k=g.prototype[i];
if(typeof(k)!="function"){continue
}if(!h){l[l.length]=","
}h=false;
l[l.length]=i;
l[l.length]=":";
l[l.length]=k.toString()
}l[l.length]="};"
},_createSafariPoller:function(){this._createSafariIFrame()
},_addSafariProgressAreas:function(c){for(var d=0;
d<Telerik.Web.UI.ProgressAreas.length;
d++){Telerik.Web.UI.ProgressAreas[d]._addSafariDefinition(c)
}},_setupSafariProgressAreas:function(){for(var b=0;
b<Telerik.Web.UI.ProgressAreas.length;
b++){Telerik.Web.UI.ProgressAreas[b]._setupSafariProgressAreaControls()
}},_createSafariIFrame:function(){this._safariPoller=document.createElement("iframe");
this._safariPoller.id=this._safariPoller.name=this.get_id()+"_safariPoller";
this._safariPoller.src="javascript:''";
this._safariPoller.style.display="none";
document.forms[0].appendChild(this._safariPoller);
var c=this._safariPoller.contentWindow.document;
c.open();
var d=[];
d[d.length]="<script type='text/javascript'>";
this._addClassAsString(this._getSafariPollerDefinition(),"RadUploadSafariPoller",d);
d[d.length]="var pollerInstance = new RadUploadSafariPoller('"+this._callbackUrl+"', "+this.get_refreshPeriod()+", '"+this.get_timeFormat()+"');";
d[d.length]="$telerik = {};";
d[d.length]="$telerik.RadUpload_isIFrameProgress = ";
d[d.length]=$telerik.RadUpload_isIFrameProgress.toString();
d[d.length]=";";
if(Telerik.Web.UI.ProgressAreas.length>0){this._addClassAsString(this._getSafariProgressAreaDefinition(),"RadUploadSafariProgressArea",d);
this._addSafariProgressAreas(d)
}d[d.length]="</script>";
c.write("<html><head>"+d.join("")+"</head><body></body></html>");
c.close();
this._setupSafariProgressAreas()
},_getParentForm:function(){var b=this.get_element();
while(b&&b.tagName&&b.tagName.toLowerCase()!="form"){b=b.parentNode
}if(b&&(!b.tagName||b.tagName.toLowerCase()!="form")){b=null
}return b
},_registerAsPageManager:function(){if(!Telerik.Web.UI.ProgressManager.Manager){Telerik.Web.UI.ProgressManager.Manager=this
}},_initializeForm:function(){var b=null;
this._form=this._getParentForm();
if(!this._form){alert("RadProgressManager requires to be in a form tag to operate properly!");
return
}this._updateFormAction(this._form);
if(this._shouldRegisterForSubmit==true){this._registerForSubmit(this._form)
}},_updateFormAction:function(b){if(typeof(b.action)=="undefined"){b.action=""
}if(b.action.match(/\?/)){b.action=this._removeQueryStringParameter(b.action,this._uniqueRequestIdentifier);
if(b.action.substring(b.action.length-1)!="?"){b.action+="&"
}}else{b.action+="?"
}b.action+=this._uniqueRequestIdentifier+"="+this._pageGUID;
b.enctype=b.encoding="multipart/form-data";
b._initialAction=b.action
},_removeQueryStringParameter:function(f,d){var e=new RegExp("&?"+d+"=[^&]*");
if(f.match(e)){return f.replace(e,"")
}return f
},_registerForSubmit:function(b){this._registerForLinkButtons(b);
this._registerForRegularButtons(b)
},_registerForLinkButtons:function(i){var f=i.submit;
try{var g=this;
i.submit=function(){if(g._clientSubmitHandler()==false){return
}i.submit=f;
i.submit()
}
}catch(h){try{var j=__doPostBack;
__doPostBack=function(b,c){var a=true;
if(typeof(Page_ClientValidate)=="function"){a=Page_ClientValidate()
}if(a){if(g._clientSubmitHandler()==false){return
}j(b,c)
}}
}catch(h){}}},_registerForRegularButtons:function(d){this._clientSubmitDelegate=Function.createDelegate(this,this._clientSubmitHandler);
$addHandler(d,"submit",this._clientSubmitDelegate);
if(Sys&&Sys.WebForms&&Sys.WebForms.PageRequestManager){var c=Sys.WebForms.PageRequestManager.getInstance();
if(c){c.add_beginRequest(this._clientSubmitDelegate)
}}},_clientSubmitHandler:function(d){var c=new Sys.CancelEventArgs();
this.raiseEvent("submitting",c);
if(c.get_cancel()){return $telerik.cancelRawEvent(d)
}if(typeof(Page_IsValid)!="undefined"){if(!Page_IsValid){return
}}this.startProgressPolling()
},startProgressPolling:function(){this._initSelectedFilesCount();
this.raiseEvent("progressStarted");
if($telerik.RadUpload_isIFrameProgress){this._safariPoller.contentWindow.pollerInstance._startTime=new Date();
this._safariPoller.contentWindow.pollerInstance._makeCallback();
this._safariPoller.contentWindow.pollerInstance._selectedFilesCount=this._selectedFilesCount
}else{this._startTime=new Date();
this._makeCallback()
}},_initSelectedFilesCount:function(){this._selectedFilesCount=0;
var e=document.getElementsByTagName("input");
for(var d=0;
d<e.length;
d++){var f=e[d];
if(f.type=="file"&&f.value!=""){this._selectedFilesCount++
}}},_createReadyStateChangeDelegate:function(){if(!$telerik.RadUpload_isIFrameProgress){return Function.createDelegate(this,this._handleCallback)
}var b=this;
return function(){b._handleCallback()
}
},_sendXmlHttpRequest:function(){if(typeof(XMLHttpRequest)!="undefined"){this._xmlHttpRequest=new XMLHttpRequest()
}else{if(typeof(ActiveXObject)!="undefined"){this._xmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP")
}else{return
}}this._xmlHttpRequest.onreadystatechange=this._createReadyStateChangeDelegate();
if($telerik.RadUpload_isIFrameProgress){this._xmlHttpRequest.open("GET",this._getTimeStampedCallbackUrl(),false)
}else{this._xmlHttpRequest.open("GET",this._getTimeStampedCallbackUrl(),true)
}this._xmlHttpRequest.send("")
},_makeCallback:function(){if(!this._waitingForResponse){this._waitingForResponse=true;
this._sendXmlHttpRequest()
}},_handleCallback:function(){if(this._xmlHttpRequest.readyState!=4){return
}this._waitingForResponse=false;
if(this._errorOccured()){return
}var g=this._xmlHttpRequest.responseText;
if(g){try{eval(g)
}catch(h){this._showInvalidContentMessage();
return
}if(rawProgressData){if(!this._suppressMissingHttpModuleError&&rawProgressData.ProgressError){this.handleProgressError(rawProgressData.ProgressError);
return
}if(rawProgressData.InProgress){this._modifyProgressData(rawProgressData);
if(!this._updateProgressAreas(rawProgressData)){this.hideProgressAreas();
this._resetCancelClicked();
if(window.stop){window.stop()
}else{try{document.execCommand("Stop")
}catch(h){window.location.href=window.location.href
}}return
}}}}if(this._disposed||(typeof(rawProgressData)!="undefined"&&rawProgressData.OperationComplete&&rawProgressData.OperationComplete.toLowerCase()=="true")){return
}if($telerik.RadUpload_isIFrameProgress){var f=this;
var e=function(){f._makeCallback()
};
window.setTimeout(e,this.get_refreshPeriod())
}else{if(Function.createDelegate){var e=Function.createDelegate(this,this._makeCallback);
window.setTimeout(e,this.get_refreshPeriod())
}}},_createCallbackUrl:function(d){var c=d.indexOf("?")<0?"?":"&";
return d+c+this._uniqueRequestIdentifier+"="+this._pageGUID
},_getTimeStampedCallbackUrl:function(){return this._callbackUrl+"&RadUploadTimeStamp="+new Date().getTime()+"&"
},_modifyProgressData:function(c){var d=new Date()-this._startTime;
if(typeof(c.TimeElapsed)=="undefined"){c.TimeElapsed=this.getFormattedTime(this._toSeconds(d))
}else{if(parseInt(c.TimeElapsed).toString()==c.TimeElapsed){c.TimeElapsed=this.getFormattedTime(this._toSeconds(c.TimeElapsed))
}}if(typeof(c.SecondaryTotal)=="undefined"){c.SecondaryTotal=this._selectedFilesCount
}if(typeof(c.SecondaryPercent)=="undefined"){c.SecondaryPercent=Math.round(100*c.SecondaryValue/(this._selectedFilesCount!=0?this._selectedFilesCount:1))
}if(typeof(c.TimeEstimated)=="undefined"&&typeof(c.PrimaryPercent)=="number"){if(c.PrimaryPercent==0){c.TimeEstimated=this.getFormattedTime(this._toSeconds(359999000))
}else{c.TimeEstimated=this.getFormattedTime(this._toSeconds(d*(100/c.PrimaryPercent-1)))
}}else{if(parseInt(c.TimeEstimated).toString()==c.TimeEstimated){c.TimeEstimated=this.getFormattedTime(this._toSeconds(c.TimeEstimated))
}}},_updateProgressAreas:function(d){if($telerik.RadUpload_isIFrameProgress){if(typeof(window.progressAreas)!="undefined"){for(var e=0;
e<progressAreas.length;
e++){var f=progressAreas[e];
if(f.cancelClicked){return false
}f.update(d)
}}}else{this.raiseEvent("progressUpdating",{ProgressData:d});
for(var e=0;
e<Telerik.Web.UI.ProgressAreas.length;
e++){var f=Telerik.Web.UI.ProgressAreas[e];
if(f.cancelClicked){return false
}f.update(d)
}}return true
},_resetCancelClicked:function(){for(var b=0;
b<Telerik.Web.UI.ProgressAreas.length;
b++){Telerik.Web.UI.ProgressAreas[b].cancelClicked=false
}this._initializeForm()
},hideProgressAreas:function(){for(var b=0;
b<Telerik.Web.UI.ProgressAreas.length;
b++){Telerik.Web.UI.ProgressAreas[b].hide()
}},_toSeconds:function(b){return Math.round(b/1000)
},_formatBytes:function(f){var d=f/1024;
var e=d/1024;
if(e>0.8){return""+Math.round(e*100)/100+"MB"
}if(d>0.8){return""+Math.round(d*100)/100+"kB"
}return""+f+" bytes"
},getFormattedTime:function(c){var d=this._normalizeTime(c);
return this._timeFormat.replace(/%HOURS%/,d.Hours).replace(/%MINUTES%/,d.Minutes).replace(/%SECONDS%/,d.Seconds)
},_normalizeTime:function(h){var f=this._formatTimePart(h%60);
var j=Math.floor(h/60);
var i=this._formatTimePart(j%60);
var g=this._formatTimePart(Math.floor(j/60));
return{Hours:g,Minutes:i,Seconds:f}
},_formatTimePart:function(b){if(b.toString().length>1){return b.toString()
}return"0"+b.toString()
},_errorOccured:function(){if(!document.all){return false
}if(this._xmlHttpRequest.status==404){this._showNotFoundMessage()
}else{if(this._xmlHttpRequest.status>0&&this._xmlHttpRequest.status!=200){this._showGenericErrorMessage()
}else{return false
}}return true
},_showNotFoundMessage:function(){alert("RadUpload Ajax callback error. Source url was not found: \n\r\n\r"+this._callbackUrl+"\n\r\n\rDid you register the RadUploadProgressHandler in web.config?\r\n\r\nPlease, see the help for more details: RadUpload for ASP.NET Ajax - Configuration - RadUploadProgressHandler.")
},_showGenericErrorMessage:function(){alert("RadUpload Ajax callback error. Source url returned error: "+this._xmlHttpRequest.status+" \n\r\n\r"+this._xmlHttpRequest.statusText+" \n\r\n\r"+this._callbackUrl+"\n\r\n\rDid you register the RadUploadProgressHandler in web.config?\r\n\r\nPlease, see the help for more details: RadUpload for ASP.NET Ajax - Configuration - RadUploadProgressHandler.")
},_showInvalidContentMessage:function(){alert("RadUpload Ajax callback error. Source url returned invalid content: \n\r\n\r"+this._xmlHttpRequest.responseText+"\n\r\n\r"+this._callbackUrl+"\n\r\n\rDid you register the RadUploadProgressHandler in web.config?\r\n\r\nPlease, see the help for more details: RadUpload for ASP.NET Ajax - Configuration - RadUploadProgressHandler.")
},handleProgressError:function(b){alert(b)
},get_formId:function(){return this._formId
},set_formId:function(b){this._formId=b
},get_refreshPeriod:function(){return this._refreshPeriod
},set_refreshPeriod:function(b){if(b&&!isNaN(b)&&b>=500){this._refreshPeriod=b
}},get_pageGUID:function(){return this._pageGUID
},set_pageGUID:function(b){this._pageGUID=b
},get_suppressMissingHttpModuleError:function(){return this._suppressMissingHttpModuleError
},set_suppressMissingHttpModuleError:function(b){this._suppressMissingHttpModuleError=b
},get_shouldRegisterForSubmit:function(){return this._shouldRegisterForSubmit
},set_shouldRegisterForSubmit:function(b){this._shouldRegisterForSubmit=b
},get_ajaxCallUrl:function(){return this._ajaxCallUrl
},set_ajaxCallUrl:function(b){this._ajaxCallUrl=b
},get_timeFormat:function(){return this._timeFormat
},set_timeFormat:function(b){this._timeFormat=b
},add_progressStarted:function(b){this.get_events().addHandler("progressStarted",b)
},remove_progressStarted:function(b){this.get_events().removeHandler("progressStarted",b)
},add_progressUpdating:function(b){this.get_events().addHandler("progressUpdating",b)
},remove_progressUpdating:function(b){this.get_events().removeHandler("progressUpdating",b)
},add_submitting:function(b){this.get_events().addHandler("submitting",b)
},remove_submitting:function(b){this.get_events().removeHandler("submitting",b)
}};
Telerik.Web.UI.RadProgressManager.registerClass("Telerik.Web.UI.RadProgressManager",Telerik.Web.UI.RadWebControl);
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();