﻿/// <reference name="MicrosoftAjax.js"/>
Sys.Application.add_init(App_Init);

function App_Init() {
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequest);
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);
}

function BeginRequest(sender, args) {
    var inputs = document.getElementsByTagName('input');

    // Loop through the elements and check each one's type.
    //  if it's a submit type element, disable it.

    if (inputs == null)
        return;
    for (element in inputs) {
        if (inputs[element] == null)
            continue;
        if (inputs[element].type == 'submit' || inputs[element].type == 'image') {
            inputs[element].disabled = true;
            inputs[element].blur();
        }
    }
}

function EndRequest(sender, args) {

    var inputs = document.getElementsByTagName('input');
    if (inputs == null)
        return;

    // Loop through the elements and check each one's type.
    //  if it's a submit type element, disable it.
    for (element in inputs) {
        if (inputs[element] == null)
            continue;
        if (inputs[element].type == 'submit' || inputs[element].type == 'image')
            inputs[element].disabled = false;
    }
}
