var timerID;
function 
buttonShowCounters_click()
{
    GetProfileProperties()
;
    return false; 
// Required to prevent normal postback
}

function buttonCancelCounters_click()
{
    
var spanProgressDisplay = document.getElementById("spanProgressDisplay");
    
spanProgressDisplay.innerHTML "";
    window
.clearTimeout(timerID);
    return false; 
// Required to prevent normal postback
}

function GetProfileProperties()
{
    Sys.Services.ProfileService.load(
null
        ProfileLoadSuccess, 
        ProfileLoadError, 
        
null);
}

function HideResults()
{
    
// Called by async postback button to clear the 
    // display of any previous run of the LRP.
    
var labelResults = document.getElementById("labelResults");
    
labelResults.innerHTML "";
}

function ProfileLoadSuccess(counterProperties, userContext, methodName)
{
    
var results Sys.Services.ProfileService.properties.FWLinkcounters;
    var 
spanProgressDisplay = document.getElementById("spanProgressDisplay");
    
    switch
(results)
    {
        
case "canceled":
               spanProgressDisplay.innerHTML 
"";
               window
.clearTimeout(timerID);
               break;
        case 
"done":
               spanProgressDisplay.innerHTML 
"Done!";
               window
.clearTimeout(timerID);
               break;
        default
:
               spanProgressDisplay.innerHTML 
results;
               
timerID = window.setTimeout("GetProfileProperties()"1000);
               break;
    
}
}

function ProfileLoadError(errorObject, userContext, methodName)
{
   
var spanProgressDisplay = document.getElementById("spanProgressDisplay")
   
spanProgressDisplay.innerHTML errorObject.get_message();
}

// Tell ASP.NET AJAX that we're loaded (after it's finished loading)
if(typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded()

Colorized by: CarlosAg.CodeColorizer