
// if you need to call the resize function one last time after the "last" resize event.
// the resizeMonitor will do that.
var resizeMonitor = {
  resizeTimeout: 500,
  watchDogTimer: false,
  resizeCallback: null,
  onlyCallOnce: false,

  registerCallback: function ( func ) {
    this.resizeCallback = func;
  },
  
  callResizeCallback: function() {
    if ( this.resizeCallback ) {
      this.resizeCallback();
    }
  },

  onresize: function () {
    if ( this.watchDogTimer ) 
      clearTimeout(this.watchDogTimer);
    this.watchDogTimer = setTimeout(function (thisObj) { thisObj.resetTimer(); }, this.resizeTimeout, this);
    if ( ! this.onlyCallOnce ) 
      this.callResizeCallback();
  },

  resetTimer: function () {
    // call the resizeCallback one more time.
    this.callResizeCallback();
  },

  setResizeTimeout: function ( rto ) {
    this.resizeTimeout = rto;
  },

  setOnlyCallOnce: function ( oco ) {
    this.onlyCallOnce = oco;
  }

};

