﻿Type.registerNamespace("GIRO.Hastinfo.Web");
   
GIRO.Hastinfo.Web.ScriptManagerEvents = function() {};
GIRO.Hastinfo.Web.ScriptManagerEvents.prototype = 
{
   PageRequestManagerEndAllRequest : 0
}
GIRO.Hastinfo.Web.ScriptManagerEvents.registerEnum("GIRO.Hastinfo.Web.ScriptManagerEvents");    
   
GIRO.Hastinfo.Web.ScriptManager = function() 
   {
   GIRO.Hastinfo.Web.ScriptManager.initializeBase(this);

   this._pageRequestManagerInstance = null;
   this._pageRequestManagerPostBackQueue = null;
   this._pageRequestManagerArgsQueue = null; 

   this._onPageRequestManagerInitializeRequest$delegate = null; 
   this._onPageRequestManagerEndRequest$delegate = null; 
   }    

GIRO.Hastinfo.Web.ScriptManager._instance = null;
GIRO.Hastinfo.Web.ScriptManager.GetInstance = function() { return GIRO.Hastinfo.Web.ScriptManager._instance; }

GIRO.Hastinfo.Web.ScriptManager.prototype = 
   {
   initialize : function() 
      {
      GIRO.Hastinfo.Web.ScriptManager._instance = this;
      GIRO.Hastinfo.Web.ScriptManager.callBaseMethod(this, "initialize");

      this._pageRequestManagerInstance = Sys.WebForms.PageRequestManager.getInstance();      
      
      this._pageRequestManagerPostBackQueue = new Array();
      this._pageRequestManagerArgsQueue = new Array();       
      
      this._onPageRequestManagerInitializeRequest = Function.createDelegate(this, this.onPageRequestManagerInitializeRequest);
      this._onPageRequestManagerEndRequest = Function.createDelegate(this, this.onPageRequestManagerEndRequest);
      
      this._pageRequestManagerInstance.add_initializeRequest(this._onPageRequestManagerInitializeRequest);
      this._pageRequestManagerInstance.add_endRequest(this._onPageRequestManagerEndRequest);        
      },
      
   dispose : function() 
      {
      GIRO.Hastinfo.Web.ScriptManager.callBaseMethod(this, "dispose");
      },
      
   add_pageRequestManagerEndAllRequest : function(handler) 
      {
      this.get_events().addHandler(GIRO.Hastinfo.Web.ScriptManagerEvents.PageRequestManagerEndAllRequest.toString(), handler);
      },
   
   remove_PageRequestManagerEndAllRequest : function(handler) 
      {
      this.get_events().removeHandler(GIRO.Hastinfo.Web.ScriptManagerEvents.PageRequestManagerEndAllRequest.toString(), handler);
      },         
      
   onPageRequestManagerInitializeRequest : function(sender, args)
      {
      if (this._pageRequestManagerInstance.get_isInAsyncPostBack()) 
         {
         args.set_cancel(true);
         
         this._pageRequestManagerPostBackQueue.push(args.get_postBackElement().id);
         this._pageRequestManagerArgsQueue.push(sender._form.__EVENTARGUMENT.value);
         }      
      },
      
   onPageRequestManagerEndAllRequest : function(args) 
      {
      var handler = this.get_events().getHandler(GIRO.Hastinfo.Web.ScriptManagerEvents.PageRequestManagerEndAllRequest.toString());
      if (handler != null) 
         handler(this, args);       
      },      
      
   onPageRequestManagerEndRequest : function(sender, args)
      {
      if (this._pageRequestManagerPostBackQueue.length > 0) 
         __doPostBack(this._pageRequestManagerPostBackQueue.shift(), this._pageRequestManagerArgsQueue.shift());
      else
         this.onPageRequestManagerEndAllRequest(args);
      }
}
GIRO.Hastinfo.Web.ScriptManager.registerClass("GIRO.Hastinfo.Web.ScriptManager", Sys.Component);



if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();