﻿loadingAnimation = new ScriptLibrary.LswLoadingAnimation('loadingAnimation');
AjaxHandler = new Object();
AjaxHandler._isScriptLoaded = false;
AjaxHandler.AppLoad = function() {
    if (this._isScriptLoaded == false) {
        //Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(PageLoaded);
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);
        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequest);
        this._isScriptLoaded = true;
    }
}
function BeginRequest(sender, args) {
    loadingAnimation.show(); 
}
 
function EndRequest(sender, args) 
{
    if (args.get_error() != undefined)
    {
        //alert(args.get_error());
        args.set_errorHandled(true);
    }
    document.forms[0].action = window.location.href;
    loadingAnimation.reset();
}
function PageLoaded(sender, args) {                
    loadingAnimation.reset();
}  
if(typeof Sys != 'undefined' && AjaxHandler._isScriptLoaded == false) {
	Sys.Application.add_load(AjaxHandler.AppLoad);
	AjaxHandler.AppLoad();
}
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();  
