﻿// 4 State Button Rollover Implementation with disable during async postbacks -->
var continue1 = false;
var submit1 = false;


// ! Button Specific !
// Prevent MouseOut from resetting the button in the event the button was clicked and triggered an event.
function btnContinue1MouseOut(btn) {
    if (continue1) {
        btn.style.backgroundPosition = 'left -75px';
        btn.style.cursor = 'wait';
        // Since we are disabling this here, make sure on ASPX.cs you are reenabling the button when/where appropriate.
        btn.disabled = true;
    }
    else {
        btn.style.backgroundPosition = 'left 0px';
    }
}

// ! Button Specific !
// Prevent MouseOut from resetting the button in the event the button was clicked and triggered an event.
function btnSubmit1MouseOut(btn) {
    if (submit1) {
        btn.style.backgroundPosition = 'left -75px';
        btn.style.cursor = 'wait';
        // Since we are disabling this here, make sure on ASPX.cs you are reenabling the button when/where appropriate.
        btn.disabled = true;
    }
    else {
        btn.style.backgroundPosition = 'left 0px';
    }
}

var prm = Sys.WebForms.PageRequestManager.getInstance();

prm.add_initializeRequest(initializeRequest);
prm.add_beginRequest(BeginRequest);
prm.add_endRequest(EndRequest);

function initializeRequest(sender, args) {
    document.body.style.cursor = "wait";

    if (prm.get_isInAsyncPostBack()) {
        //debugger
        args.set_cancel(true);
    }
}

// Implements Progress Bar
function BeginRequest(sender, args) {
    if (sender._postBackSettings.sourceElement.id == "btnStep2NextFromStep2") {
        $find('ModalProgressDisplay').show();
    }
    else{
        $find('ModalPopupExtender1').show();
    }
}

// Implements Progress Bar
function EndRequest(sender, args) {
    if (sender._postBackSettings.sourceElement.id == "btnStep2NextFromStep2") {
        $find('ModalProgressDisplay').hide();
    }
    else {
        $find('ModalPopupExtender1').hide();
    }
    document.body.style.cursor = "default";
    continue1 = false;
    submit1 = false;
}