// Scripts to update the status bar of the shopbot

// These scripts enable to dynamically replace the content of the status bar elements.
// The use of document.getElementById to get the elements is supported since NS6 and IE5.

// update the status bar of the shopbot
// used with empty parameter to hide the status bar when no result
function updateStatusBar() {
   if (eval(document.getElementById)) {
      var d = document.getElementById('statusBar');
      // Make sure the element exists
      if (d) {
         d.innerHTML = arguments[0];
      }
   }
}

// update the status of the search
// the parameter is the text of the status (eg "completed", "in progress", ...)
function updateStatus() {
   if (eval(document.getElementById)) {
      var d = document.getElementById('currentStatus');
      // Make sure the element exists
      if (d) {
         d.innerHTML = arguments[0];
      }
   }
}

// update the counter of the status bar
// the parameter is the text giving the number of results (eg "10 results (of total 118) from 30 shops")
function updateCounter() {
   if (eval(document.getElementById)) {
      var d = document.getElementById('counter');
      // Make sure the element exists
      if (d) {
         d.innerHTML = arguments[0];
      }
   }
}

function updatePage(currentPage, totalPage) {
   if (eval(document.getElementById)) {
      for (i = currentPage + 1; i <= totalPage; i++) {
         var id = 'page' + i;
         var pageDiv = document.getElementById(id);
         if (pageDiv) {
            pageDiv.style.display = "inline";
         }
      }
   }
}
