﻿<!--
var signoutTimer = null;
var warningTimer = null;
var interv= null;
var leave = null;
 
function ShowSignoutAutoDialog(targetControlHiddenId,extendedTimeOutInterval) 
{ 
    clearInterval(signoutTimer);
    
    try
    {
        DisableControlsForPopup();
    }
    catch(err) {}
    
    //document.getElementById(targetControlHiddenId).click();
    GetControl(targetControlHiddenId).click();
    StartCountDownTimer(extendedTimeOutInterval);
    signoutTimer = window.setTimeout("HideSignoutAutoDialog()",extendedTimeOutInterval * 60 * 1000); //extendedTimeOutInterval * 60 * 1000
}

function SetTimeOut(targetControlHiddenId, timeOutInterval,extendedTimeOutInterval)
	{
	
      DisableTimer();
	  
	  if(targetControlHiddenId.indexOf("ctl00")==-1) 
	  {
	    targetControlHiddenId = 'ctl00_' + targetControlHiddenId;
	  }
	  
	  warningTimer = window.setTimeout("ShowSignoutAutoDialog('" + targetControlHiddenId + "','" + extendedTimeOutInterval  + "')", timeOutInterval * 60 * 1000); //timeOutInterval * 60 * 1000
	}
	
function StartCountDownTimer(extendedTimeOutInterval)
	{
	  leave= extendedTimeOutInterval * 60 ;
	  interv=setInterval(CounterTimer,1000);
      CounterTimer();
	}
	
 function HideSignoutAutoDialog() 
{ 
    clearInterval(interv);
    clearInterval(warningTimer);
    //Need the following URL to log them out but then to switch view to another page telling me logged them out or something?
    //Not sure but may need something in the controller for Login to do the changing of the ViewName?
    //HACK TO:DO 
    var control = GetControlSessionGuid();
   
    document.location= 'Index.aspx?__ClearSessionFormVariables=&__NewSession=&__SessionGuid=' + control.value;
    //SetActionAndValueFormSubmit('Action', 'ActionValue');
}
function CounterTimer()
{
    var minute = Math.floor(leave/60);
    var second = leave % 60;

    minute=minute<10 ? "0" + minute : minute;
    second=second<10 ? "0" + second : second;

    var remain= minute+":"+second;
    leave=leave-1;

    //document.getElementById("timelabel").innerHTML=remain;
    GetControl("timelabel").innerHTML=remain;
}

function DisableTimer()
{
   	  clearInterval(warningTimer);
	  clearInterval(signoutTimer);
	  clearInterval(interv);
}


// -->
