<!-- $Revision:   1.3  $  Project: NetTeller60 -->
<!-- ©2004 Jack Henry & Associates, Inc.  All Rights Reserved -->
<!-- hide this script from non-javascript-enabled browsers
	////////////////////////////////////////////////////////////////////////////////
	//Javascript functions to support a timeout warning for the cold fusion session:
	// Typically, start the total time for logout as 9 minutes 55 seconds,
	// which is just under the 10 minutes for the cold fusion session.
	// Then, display a warning with 60 seconds to go before the timeout will ocurr. 
	// Allow the user to continue the session by selecting continue. At that point,
	// refresh the cold fusion session and reset the timer.
	////////////////////////////////////////////////////////////////////////////////
	
	//page initialization
	var netharborlogo = null; //blank if non-portal
	var promptUser = true;
	var warningWin = null;
	var jscriptWin = null;
	var warningTimerID = null;
	var refreshingTimerID = null;
	var sessionTimeoutMs =	595000;	//Session timeout set for Cold Fusion session variables (milliseconds) make this even minutes. Typically 9 minutes 55 seconds (595,000 ms)
	var warningTimeoutMs = 535000;	//535000 how long to wait before showing warning window (milliseconds). Typically 8 minutes 55 seconds (535,000 ms).	
	var logoutTimeoutMs = sessionTimeoutMs - warningTimeoutMs;	//force a logout after total session time has elapsed (milliseconds). Typically 1 minute (60,000 ms).
	var sessionTimeoutMinutes = sessionTimeoutMs/60000;
	sessionTimeoutMinutes = Math.round(sessionTimeoutMinutes);
	var warningTimeoutMinutes = warningTimeoutMs/60000;
	warningTimeoutMinutes = Math.round(warningTimeoutMinutes);
	var logoutTimeoutSeconds = logoutTimeoutMs/1000;
	logoutTimeoutSeconds = Math.round(logoutTimeoutSeconds);
	var displayIncrementMs = 10000; 	
	var refreshingIncrementMs = 500; 									//How many milliseconds in between refreshing the logout warning page.
	var displayRemainingTimeMs = logoutTimeoutMs + displayIncrementMs; 	//time left until logout after the warning has been displayed, typically starting at 1 minute
	var displayElapsedTimeSeconds = 0;									//How many seconds since warning appeared
	var JHAWin = true;													//identify the window as a jha window to be possibly closed
	var refreshMsg = "Attempting to extend your current login session";	
	var dots = 0;
	
	//functions
	function updateRefreshingHTML(){
		//showRefreshing(dts);
		var msg = refreshMsg;
		
		var strDots = '';
		for(var d=0; d<=dots; d++){
			strDots += ".";
		}
		dots++;
		if(dots > 3){
			dots = 0;
		}
		msg+=strDots;
		msg= "<span style=\"width:100%;padding:30;font-family:Verdana;font-size:10pt;\">" + msg + "</span>";
		//alert("exists="+document.getElementById('message'));
		document.getElementById('message').innerHTML = msg;
	}
	
	function showRefreshing()
	{
		clearTimeout(warningTimerID);
		warningTimerID = null;
		refreshingTimerID = setInterval('updateRefreshingHTML()', refreshingIncrementMs );
	}
	
	function startWarningTimer( Netharborlogo )
	{	//This is the starting point of the timer, called by the base NetTeller window.
		resetTimerFromParent = false;
		if ( Netharborlogo )
			netharborlogo = Netharborlogo;//tell the javascript if it is Netharbor and where the logo is.
		
		if ( window.opener )
		{	//a window opener is found. Make sure the opener is a JHA window
			if ( window.opener.JHAWin != null )
			{	//being called from a child window of the parent NetTeller window, e.g. secure mail window
				window.opener.startWarningTimerFromChild();//reset the parent's timer
			}
			else
			{	//in the main netTeller window 
				//started from another window (opener exists) like from a link with target = _blank
				resetTimerFromParent = true;
			}
		}
		else
		{	//in the main netTeller window
			resetTimerFromParent = true;
		}
		if ( resetTimerFromParent )
		{
			resetWarningTimer();
			if ( warningWin != null )
			{	//close the warning window if it exists
				warningWin.close();	
				warningWin = null;
			}
		}
	}
	function startWarningTimerFromChild()
	{
		startWarningTimer( netharborlogo );
	}
	function resetWarningTimer()
	{
		displayRemainingTimeMs = logoutTimeoutMs; //used in display warning window update updateWarningHTML()
		if ( warningTimerID != null )
		{
			clearTimeout(warningTimerID); //clear the timer, if it exists
			warningTimerID = null;
		}
		warningTimerID = setTimeout("showWarning();",warningTimeoutMs);
		promptUser = true; //make sure the user makes a decision
	}
	function showWarning()
	{	//load the initial page which includes the javascript include, so it is loaded. Note: The javascript include will not load in the browser with a direct document.write();
		window.focus();
		warningWin = window.open("gbTimeoutWarning.html","warningwindow","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=400,height=360,top=100,left=100");
		warningWin.focus();
	}
	function refresh()
	{	//called when selecting 'Ok' on the final javascript prompt in confirmDescision()
		window.focus();
		warningWin = window.open("gbTimeoutRefresh.cfm","warningwindow","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=400,height=360,top=100,left=100");
		warningWin.focus();
	}
	function updateWarningHTML( delay )
	{	//This function is only called for MSIE - Netscape setTimeout() does not support passing parms very well...
		displayRemainingTimeMs = delay;
		displayRemainingTimeMs -= displayIncrementMs;//count down every displayIncrementMs amount
		displayRemainingTimeSeconds = Math.round( displayRemainingTimeMs/1000 );
		var html = new String("");
		html += "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">";
		html += "<html>";
		html += "<head>";
		html += "<title>Login Timeout Warning</title>";
		html += "<meta http-equiv=\"Pragma\" content=\"no-cache\">";
		html += "<script language=\"JavaScript\" src=\"gbTimeoutWarning.js\"></script>";
		html += "</head>";
		html += "<body marginwidth=\"0\" marginheight=\"0\" topmargin=\"0\" leftmargin=\"0\" onLoad=\"javascript: self.focus(); document.refresh.RefreshSession.focus(); warningTimerID = setInterval(\'updateWarningHTML( " + displayRemainingTimeMs + " )\'," + displayIncrementMs + ");\" onUnload=\"javascript: confirmDescision();\">";
		html += "<table width=\"400\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
		html += "<tr><td>";
		if ( window.opener.netharborlogo )
		{
			if ( window.opener.netharborlogo.length > 0 )
				html += "<img src='" + window.opener.netharborlogo + "' border='0'>";
		}
		else if ( netharborlogo )
		{
			if ( netharborlogo.length > 0 )
				html += "<img src='" + netharborlogo + "' border='0'>";
		}
		html += "</td></tr>";
		html += "</table>";
		html += "<form action=\"gbTimeoutRefresh.cfm\" method=\"post\" name=\"refresh\">";
		html += "<table width=\"400\" cellpadding=\"2\" cellspacing=\"2\" border=\"0\">";
		html += "<tr><td colspan=\"2\"><font size=\"-1\" face=\"Verdana\"><b>For your protection, login sessions are automatically timed out after " + sessionTimeoutMinutes + " minutes of inactivity.</b></font></td></tr>";
		html += "<tr><td colspan=\"2\">&nbsp;</td></tr>";
		html += "<tr><td colspan=\"2\"><b><font size=\"+1\" face=\"Verdana\" color=\"Red\">Warning</font><font size=\"-1\" face=\"Verdana\"><br>Your current login session has been inactive for " + warningTimeoutMinutes + " minutes ";
		displayElapsedTimeSeconds = logoutTimeoutSeconds - displayRemainingTimeSeconds;
		if ( displayElapsedTimeSeconds <= 0 )
			html += "and will ";
		else
			html += "and " + displayElapsedTimeSeconds + " seconds and will ";
		if ( displayRemainingTimeSeconds <= 30 )
			html += "<font color=\"red\" size=\-1\" face=\"Verdana\"> timeout in " + displayRemainingTimeSeconds + " seconds....</font>";
		else
			html += "timeout in " + displayRemainingTimeSeconds + " seconds....";
		html += "</b></font></td></tr>";
		html += "</table>";
		html += "<div id=\"message\" name=\"message\"";
		html += " style=\"width:100%;align:left;padding:0;\">";
		html += "<table width=\"400\" cellpadding=\"2\" cellspacing=\"2\" border=\"0\">";
		html += "<tr><td colspan=\"2\">&nbsp;</td></tr>";
		html += "<tr><td align=\"right\"><font size=\"-1\" face=\"Verdana\"><b>Continue with my current session:</b></font></td><td><input type=\"button\" name=\"RefreshSession\" value=\"Continue\" onClick=\"javascript: window.opener.promptUser = false; showRefreshing();document.refresh.submit();\"></td></tr>";
		html += "<tr><td align=\"right\"><font size=\"-1\" face=\"Verdana\"><b>I'm done, logoff and exit:</b></font></td><td><input type=\"button\" name=\"Logoff\" value=\"Logoff\" onClick=\"javascript: window.opener.promptUser = false; remote('logout.cfm');self.close();\"></td></tr>";
		html += "</table>";
		html += "</div>";
		html += "</form>";
		html += "</body>";
		html += "</html>";
		if ( displayRemainingTimeMs <= 0 )
		{
			window.clearTimeout( warningTimerID ); //time has run out
			showLogout();
			if ( window.opener )
				window.opener.location='logout.cfm';	//send main NetTeller window back to logout.cfm
		}
		else
		{	
			if ( window.opener )
			{
				var tmppromptUser = true;//default
				if ( window.opener.promptUser != null )
				{
					tmppromptUser = window.opener.promptUser; //save it
					window.opener.promptUser = false;
				}
				window.document.open();		//clear previous window contents
				window.document.write(html);
				window.document.close();	//flush it
				window.opener.promptUser = tmppromptUser;  //restore it
			}
		}
	}//end updateWarningHTML()
	function showLogout()
	{	//called from secure pages in NetTeller and called from warning window 
		var html = new String("");
		html += "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">";
		html += "<html>";
		html += "<head>";
		html += "<meta http-equiv=\"Pragma\" content=\"no-cache\">";
		html += "<title>Login Expired</title>";
		html += "</head>";
		html += "<body marginwidth='0' marginheight='0' topmargin='0' leftmargin='0' onLoad=\"window.setInterval(\'self.close();\',10000);\">";
		html += "<form><table width='400' cellspacing='0' cellpadding='0' border='0'>";
		html += "<tr><td>";
		if ( window.opener.netharborlogo )
		{
			if ( window.opener.netharborlogo.length > 0 )
				html += "<img src='" + window.opener.netharborlogo + "' border='0'>";
		}
		else if ( netharborlogo )
		{
			if ( netharborlogo.length > 0 )
				html += "<img src='" + netharborlogo + "' border='0'>";
		}
		html += "</td></tr>";
		html += "</table>";
		html += "<table width='400' cellpadding='2' cellspacing='2' border='0'>";
		html += "<tr><td colspan='2'><font size='-1' face='Verdana'>For your protection, login sessions are automatically timed out after " + sessionTimeoutMinutes + " minutes of inactivity.</font></td></tr>";
		html += "<tr><td>&nbsp;</td></tr><tr><td>&nbsp;</td></tr>";
		html += "<tr><td><font size='+1' face='Verdana' color='red'><b>We are unable to extend this session.</b></font></td></tr>";
		html += "<tr><td>&nbsp;</td></tr><tr><td>&nbsp;</td></tr>";
		html += "<tr><td><font face='Verdana' color='red'><b>You have been logged out.</b></font></td></tr>";
		html += "<tr><td>&nbsp;</td></tr><tr><td>&nbsp;</td></tr>";
		html += "<tr><td align='center'><input type='button' name='Ok' value='Close Window' onClick='self.close();'></td></tr>";
		html += "</table>";
		html += "</form></body>";
		html += "</html>";
		if ( window.opener )
		{
			var tmppromptUser = true;//default
			if ( window.opener.promptUser != null )
			{
				tmppromptUser = window.opener.promptUser; //save it
				window.opener.promptUser = false;
			}
			window.document.open();		//clear previous window contents
			window.document.write(html);
			window.document.close();	//flush it
			window.opener.promptUser = tmppromptUser;  //restore it
		}
	}//end logout()
	function remote(url)
	{	//called from Warning window
		if ( window.opener != null )
		{
			window.opener.location=url;
			window.opener.focus();
		}
	}
	function closeChildWin( Netharborlogo )
	{	
		if ( Netharborlogo )
			netharborlogo = Netharborlogo;//tell the javascript if it is Netharbor and where the logo is.
		if ( window.opener )
		{	//a window opener is found. Make sure the opener is a JHA window
			if ( window.opener.JHAWin != null )
			{
				//if a child window hits the login page, close it so we don't leave these hanging out there.
				if ( this.navigator.appVersion.indexOf("WebTV") == -1)
					//This is not WebTV so show the logout function.
					//Don't execute this function here in Web TV. The window.opener object has a 
					//value when running in frames on WebTV. So this would cause the login page to show the logout message.
					showLogout();
			}
		}
	}
	function confirmDescision()
	{
		//Check to make sure the user picked one of the two choices and did not just close the window
		if ( window.opener.promptUser == true )
		{
			window.opener.promptUser = false;
			var msg = "Warning: You did not choose to update the status of your login session.\n\nSelect \"Ok\" to continue your login session.\n\nSelect \"Cancel\" to end your session and logout.";
			if ( confirm(msg) )
				window.opener.refresh();
			else
				remote('logout.cfm');
		}
	}
	function countDown()
	{	//this is called from the initial load of the gbTimeoutWarning.html page
		window.setInterval("self.focus();document.refresh.RefreshSession.focus();",500);
  		this.dom=document.getElementById?1:0
       	if ( this.navigator.appVersion.indexOf("MSIE")>-1 && this.dom )
			updateWarningHTML( displayRemainingTimeMs ); //in MSIE we can count down the time remaining....
		else
			warningTimerID =  setTimeout("showLogout();if ( window.opener ) window.opener.location='logout.cfm';", logoutTimeoutMs );
	}
// stop hiding -->	