﻿// override built-in ASP.NET submit code to disable button after click and to set pageCausedUnloadFlag
function WebForm_DoPostBackWithOptions(options) {
    var validationResult = true;
    if (options.validation) {
        if (typeof(Page_ClientValidate) == 'function') {
            validationResult = Page_ClientValidate(options.validationGroup);
        }
    }
    if (validationResult) {
        if ((typeof(options.actionUrl) != "undefined") && (options.actionUrl != null) && (options.actionUrl.length > 0)) {
            theForm.action = options.actionUrl;
        }
        if (options.trackFocus) {
            var lastFocus = theForm.elements["__LASTFOCUS"];
            if ((typeof(lastFocus) != "undefined") && (lastFocus != null)) {
                if (typeof(document.activeElement) == "undefined") {
                    lastFocus.value = options.eventTarget;
                }
                else {
                    var active = document.activeElement;
                    if ((typeof(active) != "undefined") && (active != null)) {
                        if ((typeof(active.id) != "undefined") && (active.id != null) && (active.id.length > 0)) {
                            lastFocus.value = active.id;
                        }
                        else if (typeof(active.name) != "undefined") {
                            lastFocus.value = active.name;
                        }
                    }
                }
            }
        }

        // If we reach this point, validation has passed. Now we must
        // disable the submit buttons while the page is submitting.
        // First disable *all* submit buttons.
        $('input:submit').attr('disabled','disabled');
        var button = $("input[name='" + options.eventTarget + "']");
        // Then re-enable the one that was pressed so that it is posted
        // back to the server.
        button.removeAttr('disabled');
        // Finally replace the button pressed with a progress indicator.
        button.after('Processing... This may take a second.');
        button.css('display', 'none');

        pageCausedUnloadFlag = true;
    }
    if (options.clientSubmit) {
        __doPostBack(options.eventTarget, options.eventArgument);
    }
}
$(document).ready(function() {
    $('a, input:submit:not([onclick])').click(function() { pageCausedUnloadFlag = true; });
    
    var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", { imgDown: "/SpryAssets/SpryMenuBarDownHover.gif", imgRight: "/SpryAssets/SpryMenuBarRightHover.gif" });

    Nifty("div#rc_container_default", "bottom transparent");
    Nifty("div#rc_container_default_find", "bottom transparent");
    Nifty("div#rc_container_default_whatdo", "bottom transparent");
    Nifty("div#rc_container", "bottom transparent");
    Nifty("div#rc_container2", "bottom transparent");
    Nifty("div#rc_container_content", "bottom transparent");
    Nifty("div#rc_container_content_wide", "bottom transparent");
    Nifty("div#rc_container_right", "bottom transparent");
    Nifty("div#content_left", "bottom transparent");
    Nifty("div#content_left2", "bottom transparent");
    Nifty("div#content_right", "bottom transparent");
    Nifty("div#content", "bottom transparent");
    Nifty("div#content_find", "bottom transparent");
    Nifty("div#content_whatdo", "bottom transparent");
});
