﻿Sys.UI._UpdateProgressScript = function Sys$UI$_UpdateProgressScript(element) {
	Sys.UI._UpdateProgressScript.initializeBase(this,[element]);
	this._startRequestMethod = null;
	this._endRequestMethod = null;    
	this._beginRequestHandlerDelegate = null;
	this._startDelegate = null;
	this._endRequestHandlerDelegate = null;
	this._pageRequestManager = null;
	this._timerCookie = null;
}
function Sys$UI$_UpdateProgressScript$get_startRequestMethod() {
	if (arguments.length !== 0) throw Error.parameterCount();
	return this._startRequestMethod;
}
function Sys$UI$_UpdateProgressScript$set_startRequestMethod(value) {
	this._startRequestMethod = value;
}
function Sys$UI$_UpdateProgressScript$get_endRequestMethod() {
	if (arguments.length !== 0) throw Error.parameterCount();
	return this._endRequestMethod;
}
function Sys$UI$_UpdateProgressScript$set_endRequestMethod(value) {
	this._endRequestMethod = value;
}
function Sys$UI$_UpdateProgressScript$_handleBeginRequest(sender, arg) {
	var curElem = arg.get_postBackElement();
	var showProgress = !this._associatedUpdatePanelId; 
	while (!showProgress && curElem) {
		if (curElem.id && this._associatedUpdatePanelId === curElem.id)
			showProgress = true; 
		curElem = curElem.parentNode; 
	} 
	if (showProgress)
		this._timerCookie = window.setTimeout(this._startDelegate, this._displayAfter);
}
function Sys$UI$_UpdateProgressScript$_startRequest() {
	if (this._pageRequestManager.get_isInAsyncPostBack())
		eval(this._startRequestMethod);

	this._timerCookie = null;
}
function Sys$UI$_UpdateProgressScript$_handleEndRequest(sender, arg) {
	eval(this._endRequestMethod);
	if (this._timerCookie) {
		window.clearTimeout(this._timerCookie);
		this._timerCookie = null;
	}
}
function Sys$UI$_UpdateProgressScript$dispose() {
	if (this._pageRequestManager !== null) {
		this._pageRequestManager.remove_beginRequest(this._beginRequestHandlerDelegate);
		this._pageRequestManager.remove_endRequest(this._endRequestHandlerDelegate);
	}
	Sys.UI._UpdateProgressScript.callBaseMethod(this, 'dispose');
}
function Sys$UI$_UpdateProgressScript$initialize() {
	Sys.UI._UpdateProgressScript.callBaseMethod(this, 'initialize');

	this._beginRequestHandlerDelegate = Function.createDelegate(this, this._handleBeginRequest);
	this._endRequestHandlerDelegate = Function.createDelegate(this, this._handleEndRequest);
	this._startDelegate = Function.createDelegate(this, this._startRequest);
	if (Sys.WebForms && Sys.WebForms.PageRequestManager)
		this._pageRequestManager = Sys.WebForms.PageRequestManager.getInstance();
	if (this._pageRequestManager !== null ) {
		this._pageRequestManager.add_beginRequest(this._beginRequestHandlerDelegate);
		this._pageRequestManager.add_endRequest(this._endRequestHandlerDelegate);
	}
}
Sys.UI._UpdateProgressScript.prototype = {
	get_startRequestMethod: Sys$UI$_UpdateProgressScript$get_startRequestMethod,
	set_startRequestMethod: Sys$UI$_UpdateProgressScript$set_startRequestMethod,
	get_endRequestMethod: Sys$UI$_UpdateProgressScript$get_endRequestMethod,
	set_endRequestMethod: Sys$UI$_UpdateProgressScript$set_endRequestMethod,
	_handleBeginRequest: Sys$UI$_UpdateProgressScript$_handleBeginRequest,
	_startRequest: Sys$UI$_UpdateProgressScript$_startRequest,
	_handleEndRequest: Sys$UI$_UpdateProgressScript$_handleEndRequest,
	dispose: Sys$UI$_UpdateProgressScript$dispose,
	initialize: Sys$UI$_UpdateProgressScript$initialize
}
Sys.UI._UpdateProgressScript.registerClass('Sys.UI._UpdateProgressScript', Sys.UI._UpdateProgress);
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();