// Put <%@ MasterType VirtualPath="~/lib/eains-interior.master" %> in .aspx secured page
// In its code behind Page_Load, add 2 line of code to register warnuser()
// Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
//
//        Dim mybody As HtmlGenericControl = Me.Master.MasterPageBody
//        mybody.Attributes.Add("onload", "warnuser()")
//    End Sub


function warnuser() 
{
	//var t = setTimeout("confirmBox()", 6900000)  // The time out default is 120 minutes, set dialog pop up before 5 minutes ===> (120 - 5) = 115 ===> (115 * 60 * 1000) = 6900000
	//var t = setTimeout("confirmBox()", 60000)		// Used for Testing 1 min : (1 * 60 *  1000) = 60000

	var t = setTimeout("confirmBox()", 35700000)  // The time out default is 600 minutes, set dialog pop up before 5 minute ===> (600 - 5) = 595 ===> (595 * 60 * 1000) = 35700000
}




function confirmBox() 
{
	var timeNow = new Date();
	var hours   = timeNow.getHours();
	var minutes = timeNow.getMinutes();
	var seconds = timeNow.getSeconds();
	var timeString = "" + ((hours > 12) ? hours - 12 : hours);
	timeString  += ((minutes < 10) ? ":0" : ":") + minutes;
	timeString  += ((seconds < 10) ? ":0" : ":") + seconds;
	timeString  += (hours >= 12) ? " P.M." : " A.M.";
		
	var ret = confirm("The Time : " + timeString + "\nYour eains.com session will expire in 5 minutes.\nWould you like to continue with your session?\nTo continue, press 'OK' or click 'Cancel' to log out.\nDoing nothing then the system will log you out.")	
	if (ret == true) 
	{
		//post the page to itself		
		var sPath = window.location;    		
		window.location.href = sPath;
	}
	else 
	{		
		var sPath = window.location.pathname;
        var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
		document.location.href = sPage + "?Logout=true";		
	}
} 



