/*
TIMER

Start timer by calling function settimes(numseconds) with the number of seconds

Requires user to implement a function expired() which will be invoked when the timer expires.
*/

	function display(){
		rtime=etime-ctime;
		if (rtime>60)
		m=parseInt(rtime/60);
		else{
			m=0;
		}
		s=parseInt(rtime-m*60);
		if(s<10)
		s="0"+s
		window.status="Your session has this much time remaining :  "+m+":"+s
		
		window.setTimeout("checktime()",1000)
	}

	function settimes(numseconds){
		var time= new Date();
		hours= time.getHours();
		mins= time.getMinutes();
		secs= time.getSeconds();
		etime=hours*3600+mins*60+secs;
		etime+=numseconds-10;
		
		checktime();
	}

	function checktime(){
		var time= new Date();
		hours= time.getHours();
		mins= time.getMinutes();
		secs= time.getSeconds();
		ctime=hours*3600+mins*60+secs
		if(ctime>=etime)
		{
			//Ticket 6468
			var curr_url=window.location.href;
			curr_url=curr_url.toLowerCase();
			if (curr_url.indexOf("renewalai.aspx") > 0  || curr_url.indexOf("currentaisubmissions.aspx") > 0 )
			{	window.location='NewAISubmission.aspx';}
			else
			{ 	expired();	window.location='SessionEnded.aspx'; }
		}
		else
			display();
	}

	function expired(){
		//alert("Due to inactivity, your session has timed out.  You may log in again.");
		window.status=""
	}
	
	
	//added by chandra Ticket #3267: don't time out home page
	//this function will return TRUE if curr_url is Home page or other content page
	function checkContentPages()
	{
		var curr_url=window.location.href;
		curr_url=curr_url.toLowerCase();
		if (curr_url.indexOf("view_submissions.aspx")>0)
			return false;
		else if(curr_url.indexOf("adminagencymaintenance.aspx")>0)
			return false;
		else if(curr_url.indexOf("admineditagencyinfo.aspx")>0)
			return false;
		else if(curr_url.indexOf("adminaddagencyinfo.aspx")>0)
			return false;
		else if(curr_url.indexOf("viewaisubmissions.aspx")>0)
			return false;
		else if(curr_url.indexOf("admin_tasks.aspx")>0)
			return false;
		else if(curr_url.indexOf("adminuwmaintenance.aspx")>0)
			return false;
		else if(curr_url.indexOf("adminuwchange.aspx")>0)
			return false;
		else if(curr_url.indexOf("admin_uwassign.aspx")>0)
			return false;
		else if(curr_url.indexOf("adminsettings.aspx")>0)
			return false;
		else if(curr_url.indexOf("newaisubmission.aspx")>0)
			return false;
		else if(curr_url.indexOf("adminagencylist.aspx")>0)
			return false;
		else if(curr_url.indexOf("currentaisubmissions.aspx")>0)
			return false;
		else if(curr_url.indexOf("renewalai.aspx")>0)
			return false;				
		else
			return true;
	}

