﻿var autoSaveDiv;
var postbackElement;

function pageLoad(sender, args) {
    //  register for our events
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginAutoSave);
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endAutoSave);
}

function beginAutoSave(sender, args) {
    postbackElement = args.get_postBackElement();

    if (autoSaveDiv && postbackElement.id.indexOf("SaveTimer") > -1) {
        // make it visible and position it to the center of the screen
        var infoHeight = 63;
        var infoWidth = 375;
        var width;
        var height;

        if (window.innerWidth) {
            width = window.innerWidth;
            height = window.innerHeight;
        } else {
            width = document.documentElement.clientWidth;
            height = document.documentElement.clientHeight;
        }

        var infoLeft = (width - infoWidth) / 2;
        var infoTop = (height - infoHeight) / 2;

        autoSaveDiv.style.float = "left";
        autoSaveDiv.backgroundColor = "#ffffff";
        autoSaveDiv.style.zIndex = "999";
        autoSaveDiv.style.position = "absolute";
        autoSaveDiv.style.textAlign = "center";
        autoSaveDiv.style.color = "#000000";
        autoSaveDiv.style.border = "3px solid #114466";
        autoSaveDiv.style.fontWeight = "bold";
        autoSaveDiv.style.fontSize = "14px";
        autoSaveDiv.style.display = "block";
        autoSaveDiv.style.width = infoWidth + "px";
        autoSaveDiv.style.height = infoHeight + "px";
        autoSaveDiv.style.left = infoLeft + "px";
        autoSaveDiv.style.top = infoTop + "px";
        autoSaveDiv.style.position = "fixed";
        autoSaveDiv.style.display = 'block';
    }
}

function endAutoSave(sender, args) {
    // make any backdiv and infoDiv hide
    $(".backDiv").hide();
    $(".infoDiv").hide();

    $("[id^='backDiv']").hide();
    $("[id^='infoDiv']").hide();
}
