var _LILO_warnTimeMin=4.01
var _LILO_sec2alert=30

//----------------------

var _LILO_tmr
var _LILO_refTime
var _LILO_status=false
var _LILO_sessionTimeMin=0
var __wLogin = new _clsPOP("popuplogin")
var __wMsg = new _clsPOP("popupmsg")

//----LI
function _LILO_showForm(title,data){
	var b=/school/i.test(title)?1:0
	if(!d.forms["frmLogin"]||__wLogin._box!=b){
		__wLogin._box=b
		__wLogin.setElement('title:='+title)
		__wLogin.onDisplay=function(){_formReset(this.div.getElementsByTagName('FORM')[0])}
		__wLogin.loadPage('../_login/_frm_login.asp','c0data='+escape(data),POS_COVER,(me==undefined)?0:me)
		return
	}
	__wLogin.display(POS_COVER,(me==undefined)?0:me)
}	
function _LILO_login(it){
	if(!it.C1usr.value||!it.C1pwd.value)return false
	__wLogin.display(POS_HIDE)
	__wMsg.setElement("title:=Logging In","buttonbar:=[OK]")
	__wMsg.loadPage('_login.asp',it,POS_SHOW)
	return false//stop form from processing
}	

function _LILO_sendPassword(frm){
	if(typeof(frm)=="number")frm="id="+frm
	__wMsg.setElement("title:=Email Password","buttonbar:=[OK]")
	__wMsg.loadPage('_sendpwd.asp',frm,POS_SHOW)
	return false//stop form from processing
}

//----LO
function _LILO_startTimeOut(){
	if(_LILO_loggedOut('UID'))return
//	_LILO_sessionTimeMin=1.1//delete!!!!

	clearInterval(_LILO_tmr)
	_LILO_status=false
	_LILO_refTime=new Date
	_LILO_refTime=_LILO_refTime.getTime()+1000*_LILO_sessionTimeMin*60
	_LILO_tmr=setInterval('_LILO_tick()',2000)
}	
function _LILO_tick(){
	var now=new Date();
	var s=parseInt((_LILO_refTime-now.getTime())/1000);
	if(s < _LILO_warnTimeMin*60){
		window.focus()
		if(!_LILO_status){
			clearInterval(_LILO_tmr)
			_LILO_tmr=setInterval('_LILO_tick()',500)
			_LILO_status=true
			__wMsg.setElement("title:=Logout Countdown","buttonbar:=[Logout]_LILO_logout();[Cancel]_LILO_cancelLogout()")
			__wMsg.loadPage('../_login/_msg_timeout.asp')
		}
		if(s<=0){
			_LILO_logout(1)
			return
		}	
		var o=_getObject("countdown")
		if(!o)return
		var m=parseInt(s/60)
		m=(m<=9)?"0"+m:m
		if(s<=_LILO_sec2alert){
			o._flash=!o._flash
			o.style.color=(o._flash)?"#ffffff":"#dd3333"
			o.style.backgroundColor=(o._flash)?"#dd3333":"#ffffff"
		}	
		s%=60	
		s=(s<=9)?"0"+s:s			
		o.innerHTML=m+":"+s
	}
}
function _LILO_cancelLogout(){
	_LILO_startTimeOut()
	__wMsg.setElement("title:=Message","buttonbar:=[Ok]")
	__wMsg.loadPage('../_login/_msg_timeoutabort.asp')
}
function _LILO_loggedOut(pID){
	var v=_getCookie(pID+"x")
	if(!v)return (_getCookie(pID)=='')
	_setCookie(pID+'x','')
	__wMsg.setElement("title:=Message","buttonbar:=[Ok]")
	__wMsg.loadPage('../_login/_msg_logout_'+v+'.html')
	return true
}
function _LILO_logout(pFN){
	if(!pFN)pFN=0
	clearInterval(_LILO_tmr)
	__wMsg.setElement("title:=Logging Out")
	__wMsg.loadPage('../_login/_logout.asp?fn='+pFN)
}
_onLoad.add("setTimeout('_LILO_startTimeOut()',1000)")


