function USSessionTimeout(){}
USSessionTimeout.OriginalDuration = 120 * 1000;
USSessionTimeout.TimeRemaining = USSessionTimeout.OriginalDuration;
USSessionTimeout.WakeUpAndCheckInterval = 5 * 1000; // 5 seconds
USSessionTimeout.WarningThreshold = 120 * 1000;
USSessionTimeout.UserWarned = false;
USSessionTimeout.KeepSessionAlive = false;
USSessionTimeout.HasComplementaryPageInSession = false;

function sessionCallback(response){
  if (response == "success"){
    USSessionTimeout.TimeRemaining = USSessionTimeout.OriginalDuration;
    log.clearSessionWarnings();
  }
}
function updateTimeout(){
  if (USSessionTimeout.TimeRemaining <= 0){
    shutDown();
  }  
  // If we got here the alert has been responded to.  Update session via ajax call.
  var ajax = new AjaxRequest();
  ajax.Service = "CommonService";
  ajax.Method = "PingSession";
  ajax.CallBackMethod = sessionCallback;
  ajax.Params["ping"] = "true";
  ajax.send();
}
USSessionTimeout.updateTimeout = updateTimeout;
function shutDown(){
  WindowManager.closeAllChildren();
  window.location = GlobalVars["RootVD"] + "/Login.aspx?timedout=true";
}
function runDownTime(){
      USSessionTimeout.TimeRemaining -= USSessionTimeout.WakeUpAndCheckInterval;
      if (USSessionTimeout.TimeRemaining <= 0){
        shutDown();
      }
      else if (USSessionTimeout.TimeRemaining <= USSessionTimeout.WarningThreshold){      
        if(windowMain().USSessionTimeout.HasComplementaryPageInSession == false)
            log.warnSessionTimeout();
      }
}