﻿// JScript File

// Ajax Status Indicator Support ////////////////////////////////////////////////////
// must be placed on page AFTER the script manager

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);

function InitializeRequest(sender, args) 
{
    //this will cancel a request if another one is already running
    if (prm.get_isInAsyncPostBack()) {
       args.set_cancel(true);
    }
    else
    {
        //show the disable mask on the page
        //$get('ProgressMask').style.display = "block"; 

        // get body tag, so we can set cursor over it
        var allPageTags = document.getElementsByTagName("body");
        var body = allPageTags[0];
        body.style.cursor = "wait";

        //set initial animation text
        //Animate(); 
        //Start animation using setInterval while request is processed
        intervalID = window.setInterval("Animate()", 1000); 
    }
}            

function EndRequest(sender, args) 
{
    window.clearInterval(intervalID); //process is done so stop animating
    //$get("ProgressAnimate").className = "ProcessComplete";   
    //$get("ProgressAnimate").innerHTML = "Complete"; //set the text of what you want to display when finished  
    //intervalID = window.setInterval("ClearAnimate()", 3000) //Hide after 3 seconds

    // get body tag, so we can reset cursor over it
    var allPageTags = document.getElementsByTagName("body");
    var body = allPageTags[0];
    body.style.cursor = "auto";

    window.clearInterval(intervalID);
}

function Animate()
{
    //$get("AjaxStatus").className = "ActiveProcess";
    //$get("AjaxStatus").innerHTML = GetStatusText($get("AjaxStatus").innerHTML); //grabs the text while processing
}

function ClearAnimate()
{
    //$get("AjaxStatus").className = "AnimateNormal"; //set CSS back to normal
    //$get("AjaxStatus").innerHTML = GetStatusText($get("AjaxStatus").innerHTML); //grabs the text while processing
}

function GetStatusText(ctrText)
{
    //set the animation text
    return (ctrText=="Please wait.")?"Processing...":"Please wait.";
}

// End Ajax Status Indicator Support /////////////////////////////////////////////////

