﻿function BtnBlur(obj) {
    obj.blur();
    //obj.disabled = true;
}

// AutoComplete XHMTL-Conform per JS abschalten
function DisableAutocomplete() {
/*
    if (document.getElementsByTagName) {
        //var inputElements = document.getElementsByTagName("input");
        var inputElements = document.getElementsByTagName("form");
        for (i = 0; inputElements[i]; i++) {
            //if (inputElements[i].className && (inputElements[i].className.indexOf("disableAutoComplete") != -1)) {
            inputElements[i].setAttribute("autocomplete", "off");
            //} //if current input element has the disableAutoComplete class set. 
        } //loop thru input elements 
    } //basic DOM-happiness-check 
*/
    if (document.getElementById) {
        var obj = document.getElementById('aspnetForm');
        if (obj.setAttribute) obj.setAttribute('autocomplete', 'off');
    }
}



// ******************* Wait Div (Sanduhr) ***********************
// In der Seite muss eine Funktion GetWaitParent() vorhanden sein
// In der Seite muss ein Div mit dem Namen 'updateProgressDiv' vorhanden sein

var _updateProgressDiv;
var _updateProgressDivOrg;

function pageLoad(sender, args) {
    InitWait();
}

function beginWaitRequest(sender, args) {
    if (typeof (GetWaitParent) == "function") {
        var tabContainer = GetWaitParent();
        ShowWait(tabContainer);
    }
}

function endWaitRequest(sender, args) {
    HideWait();
}

// Wait Div initialisieren
function InitWait() {
    if (typeof (GetWaitParent) == "function") {
        if (!_updateProgressDivOrg) {
            //  register for our events
            Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginWaitRequest);
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endWaitRequest);

            _updateProgressDivOrg = $get('updateProgressDiv');
        }
    }
}

// Wait Div anzeigen
function ShowWait(oContainer) {
    if (oContainer && _updateProgressDivOrg && !_updateProgressDiv) {
        // Div kopieren
        _updateProgressDiv = _updateProgressDivOrg.cloneNode(true);
        // An Container hängen
        oContainer.appendChild(_updateProgressDiv);

        // make it visible
        _updateProgressDiv.style.display = '';

        // get the bounds of both the gridview and the progress div
        var tabContainerBounds = Sys.UI.DomElement.getBounds(oContainer);
        var updateProgressDivBounds = Sys.UI.DomElement.getBounds(_updateProgressDiv);

        //  center of Dialog
        var x = Math.round((tabContainerBounds.width - updateProgressDivBounds.width) / 2);
        var y = Math.round((tabContainerBounds.height - updateProgressDivBounds.height) / 2);

        //	set the progress element to this position
        Sys.UI.DomElement.setLocation(_updateProgressDiv, x, y);
        return true;
    }
    else {
        return false;
    }
}

// Wait Div schließen
function HideWait() {
    if (_updateProgressDiv) {
        if (_updateProgressDiv.style.display != 'none') {
            // make it invisible
            _updateProgressDiv.style.display = 'none';
            _updateProgressDiv = null;
            return true;
        }
        else {
            return false;
        }
    }
    else {
        return false;
    }
} 
