// Pages that dont want to disable back button should call backHandler.disableBackButton
// Pages which have back button disabled must call backHandler.allowNav prior to navigating to another page
// Methodology:
//   Body unload always calls backHandler.leavingPage
//   leavingPage decides whether to stay on the same page allow the browser to leave the page.
backHandler = {
  allowNav: true,
  allowNavFromOverlay: false,
  
  disableBackButton: function () {
    this.allowNav = false;
  },
  
  allowNavigation: function () {
    this.allowNav = true;
  },
  
  allowNavigationFromOverlay: function () {
    this.allowNavFromOverlay = true;
    this.allowNav = true;
  },
  
  leavingPage: function () {
    // alert("overlay = "+overlayHandler.isOverlay + ", allowNav = " + this.allowNav);
    if ( ( overlayHandler.overlayUp() && ! this.allowNavFromOverlay ) || ! this.allowNav ) {
      // alert("trapped back button")
      // alert(window.location)
      // window.location.reload();
      history.go(0);
      // return false;
    } 
  }
}