var isDocBeingSubmitted;//= false;
function navigateAway() 
{
	// This Function is used if the user leaves a form without saving - and you want to prompt
	// should set the variable isDocBeingSubmitted to true in all the functions that
	// save the data, to prevent the pop up showing the loss of data after saving
	// should set the variable isDocBeingSubmitted to false, once the user keys in some 
	// data in any of the fields, to notify the user of a data loss
	msg = "---------------------------------------------------------------\n";
	msg += "Your data has not been saved.\n";
	msg += "All changes you have made will be lost\n";
	msg += "--------------------------------------------------------------";
	if (isDocBeingSubmitted == false && event.ctrlKey == false)
		{
			event.returnValue = msg;
		}
}	

//--------------------------------------These functions tracks the INACTIVITY and prompts to the user-------------------
//--------------------------------------that the session will expire in 2 minutes---------------------------------------	
function load(mn,dy,yr)
{
	startTmr();
	if(mn.length == 1)
		mn = "0" + mn;
	if(dy.length == 1)
		dy = "0" + dy;
	tmp = mn + "/" + dy + "/" + yr;
}
var timerID = null ;
var timerRunning = false;

function startTmr()
{
	// should give the correct time(in milliseconds) 1 milliseconds = 1.66666667 × 10^-05 minutes
	//currently set to 18 minutes
	stopTmr();
	timerID = setTimeout('showMsg()',1080000);
	timerRunning = true;	
}

function stopTmr()
{
	if(timerRunning)
		clearTimeout(timerID);
	timerRunning = false;
}

function showMsg()
{
	var curDateTime, monthArr, curDate, curMonth, curYear, curHours, curMinutes, curSeconds, expDateTime, msg;
	curDateTime = new Date();
	monthArr = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	curDate = curDateTime.getDate();
	curMonth = monthArr[curDateTime.getMonth()];
	curYear = curDateTime.getFullYear();
	curHours = curDateTime.getHours();
	curMinutes = curDateTime.getMinutes() + 2;
	curSeconds = curDateTime.getSeconds();
	expDateTime = curMonth + " " + curDate + ", " + curYear + "  " + curHours + ":" + curMinutes + ":" + curSeconds;
	msg = "Your browser session for this page will expire in 2 minutes (" + expDateTime + ").\nPlease save your work and proceed.";
	alert(msg);
	curDateTime = new Date();
	newHours = curDateTime.getHours();
	newMinutes = curDateTime.getMinutes();
	if (newMinutes > curMinutes && newHours >= curHours)
	{
		location.href = "http://www.EmpCheck.com/redir.asp?To=empchk";
	}
	//startTmr();
}
//----------------------------------------------INACTIVITY--------------------------------------------------------------