// Generic variables
var activeID = ''; // The ID of the item that we are dealing with. By default it is the postback item's ID
var activeValue = ''; // A placeholder for the value of the item being manipulated. Can be used to swap old/new values.
//var prm; 
//var prm = Sys.WebForms.PageRequestManager.getInstance(); // Page Request Manager class variable. Usually set in body onload event.
//prm.add_endRequest(EndRequestHandler); // End request event handler
//prm.add_beginRequest(BeginRequestHandler); // Begin request event handler
 Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
 Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

function EndRequestHandler(sender, args) 
{
    // Change the submit button back to normal if needed
    if (activeID != '')
    {
        var elem = document.getElementById(activeID);
        if (elem.type == 'submit' || elem.type == 'button')
        {
            var btn = document.getElementById(activeID);
            btn.value = activeValue;
            btn.className='button';
            btn.disabled = false;
            activeID = ''; // Reset the active ID for future use
        }
    }
}

function BeginRequestHandler(sender, args)
{
    var elem = args.get_postBackElement();
    activeID = elem.id;
    
    // Change the submit button to progress bar
    if (elem.type == 'submit' || elem.type == 'button')
    {
        //var btn = document.getElementById(activeID);
        activeValue = elem.value;
        //btn.className = 'buttonClick';
        elem.className = 'buttonClick';
        //btn.value = '   Loading';
        elem.value = '   Loading';
        //btn.disabled = true;
        elem.disabled = true
    }

}

function onBodyLoad() 
{
   /*prm = Sys.WebForms.PageRequestManager.getInstance(); // Page Request Manager Instance
   prm.add_endRequest(EndRequestHandler); // End request event handler
   prm.add_beginRequest(BeginRequestHandler); // Begin request event handler*/
}
 
function OpenWindow(page)
{
    window.open(page,"ExpertIndex","height=400,width=660,status=yes,toolbar=no,menubar=no,location=no,scroll=yes");
}
 
