var firstrun = 0,
    lcPostbackElement,
    OriginalTextValue;

function pageLoad() {
    if (firstrun == 0) {
        var manager = Sys.WebForms.PageRequestManager.getInstance();
        manager.add_beginRequest(OnBeginRequest);
        manager.add_endRequest(OnEndRequest);
        firstrun = 1;
    };
}
function OnBeginRequest(sender, args) {
    lcPostbackElement = args.get_postBackElement();
    if (lcPostbackElement.id.toLowerCase().indexOf("btn") != -1) {
        //lcPostbackElement.disabled = true;
        try {
            OriginalTextValue = document.getElementById(lcPostbackElement.id).value;
            document.getElementById(lcPostbackElement.id).value = 'Een momentje...';
        }
        catch (e) { }
    };
}
function OnEndRequest(sender, args) {
    if (lcPostbackElement.id.toLowerCase().indexOf("btn") != -1) {
        //lcPostbackElement.disabled = false;
        try {
            document.getElementById(lcPostbackElement.id).value = OriginalTextValue;
        }
        catch (e) { }
    };
};
function toggle(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != '' ) {
		el.style.display = '';
	}
	else {
		el.style.display = 'none';
	};
};
//checks all DataGrid CheckBoxes with the given name with the given value
function CheckAllDataGridCheckBoxes(aspCheckBoxID, checkVal) {
    //re = new RegExp(':' + aspCheckBoxID + '$')  //generated control name starts with a colon
    re = new RegExp(aspCheckBoxID + '$');
    for(i = 0; i < document.forms[0].elements.length; i++) {
        elm = document.forms[0].elements[i];
        if (elm.type == 'checkbox') {
            if (re.test(elm.name)) {
                elm.checked = checkVal;
            };
        };
    };
};
