﻿var secs
var ses
var Tsec
var ftime
var ltime
var dtime
var ftime1
var ltime1
var dtime1
var ftime2
var ltime2
var fttime
var lttime
var td
var tdtime
var timerID = null
var timerID2 = null;
var timerRunning = false
var delay = 60000;
var isSessionDead = false;
var jv_srvPath = window.location.protocol+"//"+window.location.host+window.location.pathname;
jv_srvPath = jv_srvPath.substr(0, jv_srvPath.lastIndexOf('/'));
//var delay = 1000;
function hideDiv()
    {   
    var mm=window.location.href;
    if(timerID2)
        clearTimeout(timerID2)
    if(mm.toLowerCase().indexOf("login.aspx") == -1) 
    {
     timerID2=setTimeout("firsttime();",60000*60)
     }
    }
 function firsttime()
   {
    var d = document.getElementById("dv");
    d.style.display="none"; 
    window.location = jv_srvPath+'/login.aspx'
    //alert("No response was given to the time out warning, your session has ended and any work not saved has been lost.  Please log back in to continue working" "No response was given to the time out warning, your session has ended and any work not saved has been lost.  Please log back in to continue working"); 
    alert("No response was given to the time out warning, your session has ended and any work not saved has been lost.");
    
   }

function showDiv()
{
var d = document.getElementById("dv");
d.style.display="block"; 
}

function InitializeTimer()
{
 hideDiv();
 //alert(window.location.pathname);
var mm=window.location.href;
if(mm.toLowerCase().indexOf("login.aspx") == -1)
{   //aded by kamaljith 11-02-2008
    //secs = ses-5;
    secs=55;
    StopTheClock()
    StartTheTimer()
 }
}

function StopTheClock()
{
    if(timerRunning)
    clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{      var mn=2;
       if(secs==0)
        {
          StopTheClock()
          showDiv();         
          
        }
      else
       {
          self.status = secs
          secs = secs - 1
          timerRunning = true
          timerID = self.setTimeout("StartTheTimer()", delay)
       }
   
}
function cancelSession()
{
isSessionDead = true;
window.location = jv_srvPath+'/login.aspx'
}

function resetTime()
{
showResult();        
InitializeTimer();
}

function GetXmlHttpObject()
{
 var xmlHttp=null;
 try
 {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
 }
 catch (e)
 {
  // Internet Explorer
  try
  {
   xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
  catch (e)
  {
   xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
 return xmlHttp;
}
function stateChanged() 
{ 
 if (xmlHttp.readyState==4)
 { 
  
  var txt= xmlHttp.responseText;
  txt='';  
 }

}
  function showResult()  
  {
   
 try
   {
 
 var str="sendvalue";
   

  if (str.length==0)
  { 

   return false;
  }    
  
  
  xmlHttp=GetXmlHttpObject()  
   
  if(xmlHttp==null)
  {
   alert ("Your browser does not support AJAX!");
   return false;
  }  
   var url=jv_srvPath+"/Empty.aspx"; 
  url=url+"?q="+str;
  url=url+"&amp;sid="+Math.random();  
  xmlHttp.onreadystatechange=stateChanged;     
  xmlHttp.open("GET",url,true); 
  xmlHttp.send(null); 
  }
 catch(e)
 {
  alert(e.message); 
 }
 return false;
}  
