﻿var __Resp;
var __WaitScr=null;
var __AjaxFileUpload;
var __SuccessFunc;
var __FailureFunc;

if(window.addEventListener)
{
  window.addEventListener("onresize",__PositionWaitScreen,false);
  window.addEventListener("onscroll",__PositionWaitScreen,false);
}
else
{
  window.attachEvent("onresize",__PositionWaitScreen);
  window.attachEvent("onscroll",__PositionWaitScreen);
}

function __MakeRequest(id,requestData,successFunc,failureFunc)
{
  __SuccessFunc=successFunc;
  __FailureFunc=failureFunc;
  __OutputWaitScreen();
  __SendRequest(id,requestData,__ReceiveGoodResponse,__ReceiveBadResponse);
}

function __ReceiveGoodResponse(response, context)
{
  __Resp=__LoadXml(response);
  __HideWaitScreen();
  var status=__NumericNodeValue(__Resp,"status");
  if(status==0)
  {
    new __SuccessFunc;
  }
  else
  {
    new __FailureFunc;
  }
}

function __ReceiveBadResponse(response, context)
{
  __HideWaitScreen();
  new __FailureFunc;
}

function __OutputWaitScreen()
{
  __WaitScr=document.createElement("div");
  if(__WaitScr!=null)
  {
    var waitImg=document.createElement("img");
    if(waitImg!=null)
    {
      waitImg.alt="Please wait...";
      waitImg.src=__RequestPath+"/Desktopmodules/OALUtils/Images/ajax-loader.gif";
      __WaitScr.appendChild(waitImg);
    }
    __WaitScr.className="ScreenCover";
    document.body.appendChild(__WaitScr);
    __PositionWaitScreen();
  }
}

function __PositionWaitScreen()
{
  if(__WaitScr!=null)
  {
    __WaitScr.style.width=(__ScrollWidth())+"px";
    __WaitScr.style.height=(__ScrollHeight())+"px";  
    if(__WaitScr.childNodes.length>0)
    {
      var waitImg=__WaitScr.childNodes[0];
      waitImg.style.left=(((__ClientWidth()-waitImg.offsetWidth)/2)+__ScrollLeft())+"px";
      waitImg.style.top=(((__ClientHeight()-waitImg.offsetHeight)/2)+__ScrollTop())+"px";
    }
  }  
}

function __HideWaitScreen()
{
  if(__WaitScr!=null)
  {
    document.body.removeChild(__WaitScr);
    __WaitScr=null;
  }
}