﻿// JScript File
<!--
var _IsPageNavigation = false;

function onBeforePageUnloadEvent(){
//Client side checks prior to page unload
   //Check dirty navigation first
   //alert("On Before Page Unload has started");
   var strConfirm
   strConfirm = confirmDirtyNavigation();
   if (strConfirm==null){
   //Set link navigation flag
      _IsPageNavigation = true;
   }
   else {
      return strConfirm;
   }
}

function onRequestStart(sender, arguments)
{
   var eventTargetId = arguments.EventTarget
   var eventTargetClientId = returnClientId(eventTargetId);
   var eventTargetElement = document.getElementById(eventTargetClientId)
   
   //Cursor Swap
   //dumpProps(arguments);
   //alert(eventTargetId);
   //alert(returnClientId(eventTargetId));
   setAjaxPostBackTabModuleId(eventTargetElement); 
   if (eventTargetId.indexOf("radAdAjaxTimer") == -1)//Don't Swap for Timers
   {
      document.body.className = document.body.className.replace("Normal", "Wait");
   }
   //alert("Request was just started");
   if (!_IsPageNavigation)
      {
      return true;
      }
   else
      {
      //Reset the page navigation flag
      _IsPageNavigation = false;
      if (eventTargetId.indexOf("radAdAjaxTimer") != -1)//Cancel event if a timer
         {
         return false;
         }
      else
         {
         return true;
         }
      }
}
function onRequestSent()
{
alert("Request has been just sent");
}
function onResponseReceived()
{
alert("Response has been received");
}
function onResponseEnd(sender,arguments)
{
   var eventTargetId = arguments.EventTarget
   //Cursor Swap
   if (eventTargetId.indexOf("radAdAjaxTimer") == -1)//Don't Swap for Timers
   {
      document.body.className = document.body.className.replace("Wait", "Normal");
   }
   //alert("Response is already handled");
   if (eventTargetId.indexOf("ucNews") !=-1)
   {
      //update News Box Scroll
      var ctlId = eventTargetId.slice(0,eventTargetId.indexOf("$"));
      initScrollLayerByClient(ctlId,'v');      
      theForm.oldSubmit = theForm.submit;
      theForm.submit = WebForm_SaveScrollPositionSubmit;
      theForm.oldOnSubmit = theForm.onsubmit;
      theForm.onsubmit = WebForm_SaveScrollPositionOnSubmit;
   }
}
function dumpProps(obj, parent) {
   // Go through all the properties of the passed-in object 
   for (var i in obj) {
      // if a parent (2nd parameter) was passed in, then use that to 
      // build the message. Message includes i (the object's property name) 
      // then the object's property value on a new line 
      if (parent) { var msg = parent + "." + i + "\n" + obj[i]; } else { var msg = i + "\n" + obj[i]; }
      // Display the message. If the user clicks "OK", then continue. If they 
      // click "CANCEL" then quit this level of recursion 
      if (!confirm(msg)) { return; }
      // If this property (i) is an object, then recursively process the object 
      if (typeof obj[i] == "object") { 
         if (parent) { dumpProps(obj[i], parent + "." + i); } else { dumpProps(obj[i], i); }
      }
   }
}
//Code to set the AjaxPostBackTabModuleId
function setAjaxPostBackTabModuleId(obj){

   var tabModuleId = null
   while (obj != null && obj.tagName != "BODY" && tabModuleId == null) {
      tabModuleId = obj.getAttribute("tabModuleId");
      obj = obj.parentElement;
   }
   try {
      if (tabModuleId != null)
         document.getElementById('__AjaxPBTabModId').value = tabModuleId;
   }
   catch(e){}
   //alert(document.getElementById('__AjaxPBTabModId').value);
}


//function takes in the .Net uniqueId and returns a string for the clientId
function returnClientId(uniqueId) {
   var clientId = uniqueId
   while (clientId.indexOf('$',0) != -1){
      clientId = clientId.replace('$','_');
   }
   return clientId
}
-->