// Include <script language="JavaScript" src="cookies.js"></script> 
// to get access to the cookie functions
// Submits the first form on Enter, for both IE/Netscape 4 and up
var sLoginInfo = "LoginInfo"
var IE4up = document.all
var Net4up = window.Event

function SetLoginCookies(thisform) {
	thisform.auto.checked ? valueal = "1" : valueal = "0";
//	valueal = "0";	
	thisform.save.checked ? valueal += "1" : valueal += "0";
	SetCookie(sLoginInfo, valueal + thisform.userid.value + ":" + thisform.password.value, "", "","");
	return true;
}
function RmLoginCookies(){
	DeleteCookie(sLoginInfo,"","");
	return true;
}
function GetLoginCookies(thisform) {
	sLoginInfoValue = GetCookie(sLoginInfo)
	if ( sLoginInfoValue.length ) {
		var AutoLogin = sLoginInfoValue.charAt(0)
		var SaveLogin = sLoginInfoValue.charAt(1)	
		if ( SaveLogin == "1" ) {
			var mid = sLoginInfoValue.indexOf(":",2)
			thisform.userid.value = sLoginInfoValue.substring(2, mid)
			thisform.password.value = sLoginInfoValue.substring(mid+1)
			thisform.save.checked = true
			if ( window.setTimeout )
				window.setTimeout("document.forms[0].save.checked = true", 300)
			else
				thisform.save.checked = true
			if ( AutoLogin == "1" && location.search.indexOf("stop") < 0 ){
			  document.forms[0].auto.checked = true
			  var s="LoginServlet?butsubmit=yy&page=mainpage.html&file=newloginfile&userid=" + thisform.userid.value + "&password=" + thisform.password.value

			  window.location="LoginServlet?autologin=yes"//s
				thisform.submit()
		    }
		}
	}
}
function GetLogin() {
    var s=""
	sLoginInfoValue = GetCookie(sLoginInfo)
	if ( sLoginInfoValue.length ) {
		var AutoLogin = sLoginInfoValue.charAt(0)
		var SaveLogin = sLoginInfoValue.charAt(1)	
		if ( SaveLogin == "1" ) {
			var mid = sLoginInfoValue.indexOf(":",2)
			  s="LoginServlet?butsubmit=yy&page=mainpage.html&file=newloginfile&userid=" + sLoginInfoValue.substring(2, mid) + "&password=" + sLoginInfoValue.substring(mid+1)
               document.write("<font size=\"+2\" color=\"#0000FF\">Please wait while we log you in . . .</font>")
			   window.location=s
		}
	}
}
function SubmitOnEnter(e) {
	if ( Net4up  ) // For Netscape 4 up
		keyPressed = e.which;
	else if ( IE4up ) // For IE 4 up
		keyPressed = window.event.keyCode;
	if ( keyPressed == 10 || keyPressed == 13 ) {
		SetLoginCookies(document.forms[0])
		document.forms[0].submit();
	}
}
if ( Net4up )
	document.captureEvents( Event.KEYPRESS )
//document.onkeypress = SubmitOnEnter;
