startTime = new Date();
time_stamp = startTime.getTime();
time_bound = time_stamp + 1000*60*30;
	var getHost = function(url) { 
	        var host = "null";
	        if(typeof url == "undefined"
	                        || null == url)
	                url = window.location.href;
	        var regex = /.*\:\/\/([^\/]*).*/;
	        var match = url.match(regex);
	        if(typeof match != "undefined"
	                        && null != match)
	                host = match[1];
	        return host;
	}
	

	function timeOutInvolver(){
		startTime = new Date();
		time_stamp = startTime.getTime();
		time_bound = time_stamp + 1000*60*30;
		//time_bound = time_stamp + 1000*60*6;
	
		setTimeout("checkTimeOut()",1000*60*25);
		//setTimeout("checkTimeOut()",1000*60*5);
	}

	function checkTimeOut(){

		reply = confirm('Warning! Due to inactivity, your session will expire in 5 minute(s) on '+new Date(time_bound)+'. Would you like to extend your session another 30 minute(s)?');
		var endTime = new Date();
		if (time_bound- endTime.getTime() <0 || !reply){
			setTimeout("TimeOutAction()",time_bound - endTime.getTime());
		}else if (reply){
			//call ajax to renew the session.
			AjaxDummy.dummy();
			timeOutInvolver();
		}
	}
	function TimeOutAction(){
		alert('Warning! Due to inactivity, your session has expired and return to main menu immediately');
		location.href = "http://"+getHost(location.href.substr(0,location.href.lastIndexOf('/')))+"/Logout.do";
	}
	
	function SessionExpiredAlert(){
		alert('Warning! your session has expired and return to main menu immediately');
		location.href = "http://"+getHost(location.href.substr(0,location.href.lastIndexOf('/')))+"/Logout.do";
	}
