var mxz;
function sessionCounter() {
	
		if (theDate!='') {
			var startDate=new Date(theDate);
			var timediff=(new Date()-startDate);
			var week,days,hours,mins,secs;	
			weeks = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7));
			timediff -= weeks * (1000 * 60 * 60 * 24 * 7);
			days = Math.floor(timediff / (1000 * 60 * 60 * 24)); 
			timediff -= days * (1000 * 60 * 60 * 24);
			hours = Math.floor(timediff / (1000 * 60 * 60)); 
			timediff -= hours * (1000 * 60 * 60);
			mins = Math.floor(timediff / (1000 * 60)); 
			timediff -= mins * (1000 * 60);
			secs = Math.floor(timediff / 1000); 
			timediff -= secs * 1000;
			var d=document.forms[0];
			//window.status=timeoutLength+" "+mins+" "+timeoutNotify;
			if ((timeoutLength-mins <= timeoutNotify) && (d!=null)) {
					
						var timeoutmins=timeoutLength - timeoutNotify;
						var minsleft=(timeoutNotify+timeoutmins)-mins-1;
						var secleft=(((minsleft+1)*60)-secs)%60;
						var e=getElement('aaal');
						if (e==null) {
							e=document.createElement("span");
							e.id="alertMessage";
							d.appendChild(e);
						}
						
						var _dy,_dx;
						if (e!=null) {
							_dy=(document.body.scrollTop+document.body.clientHeight-e.offsetHeight);
							if (IsIE()) {
								_dx=(document.body.scrollLeft+document.body.clientWidth-e.offsetWidth);
							} else {
								_dx=(document.body.scrollLeft+document.body.clientWidth-e.offsetWidth);
							}
						
						
						getElement('sessionmsg').innerHTML=("You will be logged out in "+minsleft+" min and "+secleft+" secs.<br/><a href=\"requestMoreSessionTime.aspx\">Click here to stay logged on</a>")
					
					
						if (mxz==null) {
							e.style.top=_dy+e.offsetHeight;
							e.style.left=_dx;
							mxz= new MoveAble("mxz",e,10,true);
							mxz.slideUpdate();
							window.onresize=function() {mxz.slideUpdate()}
						}
							if (minsleft<0) {
								document.location.href="timeout.aspx?redirect="+document.href
							}
						}
										
			} else {
				
			}
		}		
}	
setInterval(sessionCounter,1000)
