// the count of requests, left: adding the delay to make the progress work,
// not to have 0% always
var lastRequestsCount = 0;

// displaying the AJAX progress element and hiding it in some time
function updateAjaxProgress( currentRequestUrl )
{
  //if ( getRequestsCount() > 0 )
  {
    // progress message
    lastRequestsCount = max( 1, max( lastRequestsCount, getRequestsCount() ) );
    var progress = max( lastRequestsCount - getRequestsCount(), 1 ) / ( lastRequestsCount );
    setElementWidthById( "progressBar", round( progress * getElementWidthById( "progressBarBackground" ) ) );
    var progressMessage = ""+round( 100 * progress )+" %";
    //for ( var r = 0; r < requests.length; r++ )
    //  progressMessage += "<p>" + r + ":" + requests[r]['url'] + "</p>";
    //placeElementWithContentInCenter( 'ajaxboxconstrain', 'ajaxboxcontent', progressMessage, 0, 0, ajaxBoxHidingDelay );
    // autohiding
    setTimeout( "startHidingLastElement('ajaxboxconstrain')", ajaxBoxHidingDelay );
  };
}

// setting the handler
updateAjaxProgressFunction = updateAjaxProgress;

// this timer updates the ajax progress to make it smooth
setInterval( 
  function()
  {
    lastRequestsCount = getRequestsCount();
  },
  60000
);