var keepSessionTimeout = 18 * 60 * 1000 //set to 1 minute for testing
var ExpireSessionTimeout = 2 * 60 * 1000 //set to 2  minute 

watchSessionTime = setTimeout("sessionAboutToExpire();", keepSessionTimeout );
var countDownSessionTime 
var req = null;

function sessionAboutToExpire() {

	
	Lightview.show({ href: '#sessionTimeoutDiv' , options:{ width: 300, height: 130, menubar: top, closeButton: false}  });
	clearTimeout(watchSessionTime) 
	countDownSessionTime = setTimeout("sessionHasExpired();", ExpireSessionTimeout );
}

function keepSession(){

	Lightview.hide()

  	var url = "../extendSession.asp"; //this file contains a db query that returns nothing
     
     if ( window.XMLHttpRequest ) 
     {
          req = new XMLHttpRequest();
     } 
     else if ( window.ActiveXObject ) 
     {
          req = new ActiveXObject("Microsoft.XMLHTTP");
     }
     
     req.open("GET", url, true);
     req.onreadystatechange = keepSessionCallback;
     req.send(null);
     clearTimeout(countDownSessionTime) 
     watchSessionTime = setTimeout("sessionAboutToExpire();", keepSessionTimeout );
        
}

function keepSessionCallback()
{
     if (req.readyState == 4) 
     {
       if (req.status == 200) 
          {
               //the page request was a success
          }
     }
}

function sessionHasExpired(){
window.location = "http://www.alabamagulfcoastrentals.com/error.asp?err=Sorry your session expired before you completed the reservation.<br>Please make your reservation again."
}

