  var cachedIndex = 0;
  var lastIndex = -1;
  var errorPageName = null;
  var defaultPageName = null;
  var defaultContextName = 'ecl_main_context';

  function updateHistory() {
      var history = window.document.getElementById( 'ecl_history' );

      if( history ) {
          var historyDocument = history.contentWindow.document;

          if( historyDocument ) {
              var index = historyDocument.getElementById( 'ecl_index' ).value;
              var contextName = historyDocument.getElementById( 'ecl_cache' ).value;
              var url = historyDocument.getElementById( 'ecl_url' ).value;

              url = url || defaultPageName;
              contextName = contextName || defaultContextName;

              //alert( "(index (" + index + ") < lastIndex (" + lastIndex + ")) || (index (" + index + ") > lastIndex (" + lastIndex + ") && index (" + index + ") < cachedIndex (" + cachedIndex + "))\nshould call history request (" + ((index < lastIndex) || ((index > lastIndex) && (index < cachedIndex))) + ")" );

              if( (index < lastIndex) || ((index > lastIndex) && (index < cachedIndex))) {
                  sendHistoryRequest( decodeURIComponent( url ), contextName );
              }

              if( cachedIndex <= index ) {
                  cachedIndex++;
              }

              lastIndex = index;
          }
      }
  }

