function forgotLogin(theForm){
	var URL = "/tlc/lmsloginforgot.asp?UserName=" + theForm.username.value;
	document.location.href = URL;
}

function noSubmit(theForm){
	doLogin(theForm);
	return false;
}

function doLogin(theForm){
	Set_Cookie( 'test', 'none', '', '/', '', '' );
	if(xmlHttp){
		if((theForm.username.value.length > 0)&&(theForm.password.value.length > 0)){
			var theURL = "/tlc/lmslogin.asp?myName=" + theForm.myName.value + "&exitPage=" + theForm.exitPage.value + "&username=" + theForm.username.value + "&password=" + theForm.password.value;
			if(theForm.AdminLogin!=null)
				theURL += "&AdminLogin=1";
			xmlHttp.open("GET", theURL, true);
			xmlHttp.onreadystatechange = commitLogin;
			xmlHttp.send(null);
		}else{
			alert("You must provide a username and password.");}}}

function commitLogin(){
	if(xmlHttp.readyState==4){
		if(xmlHttp.status==200){
			var theResponse = xmlHttp.responseText.toLowerCase();
			if(theResponse.indexOf(".asp") > 1){
				document.location.href=theResponse;
			}else{
				var theMessage = "";
				switch(theResponse){
					case "backuptime":
						theMessage = "The system is currently undergoing maintenance.     \nPlease try again later.";
						break;    
					case "nosubscription":
						theMessage = "No Subscription could be found.\nPlease contact your system administrator for assistance.     ";
						break;    
					case "attachfailed":
						theMessage = "Unable to attach an access record.\nPlease contact Technical Support for assistance.     \n   (888) 360-3300";
						break;    
					case "subscriptionexpired":
						theMessage = "Your organization subscription has expired.\nPlease contact your system administrator for assistance.     ";
						break;    
					case "nosuchuser":
						theMessage = "The user information provided does not match any user in the system.     \nPlease try again.";
						break;    
					case "inactiveuser":
						theMessage = "Your account has been deactivated.\nPlease contact your system administrator for assistance.     ";
						break;    
					case "adminonly":
						theMessage = "Only ortganization Admins are allowed entry at this time.\nPlease contact your system administrator for assistance.     ";
						break;    
					case "nocookies":
						theMessage = "Cookies MUST be enabled to use The Learning Community.     \nPlease enable cookies and try again.";
						break;    
					default:
						theMessage = "An unrecognized error has ocurred.\nPlease contact Technical Support for assistance.     \n   (888) 360-3300";
						break;}
				alert(theMessage);}
		}else{
			alert("Error connecting to resource");}}}

function Set_Cookie(name, value, expires, path, domain, secure){
	var today = new Date();
	today.setTime( today.getTime());
	if ( expires ){
		expires = expires * 1000 * 60 * 60 * 24;}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name + "=" +escape(value) + ((expires) ? ";expires=" + expires_date.toGMTString() : "") +  ((path) ? ";path=" + path : "") +  ((domain) ? ";domain=" + domain : "") + ((secure) ? ";secure" : "");}

nn=(document.layers)?true:false; 
ie=(document.all)?true:false; 
function keyDown(e) { 
    var evt=(e)?e:(window.event)?window.event:null;
    if(evt){
        var key=(evt.charCode)?evt.charCode:((evt.keyCode)?evt.keyCode:((evt.which)?evt.which:0));
        if(key==13){
        	document.loginForm.Submit.click();
        }
    }
}
document.onkeydown=keyDown; 
if(nn) document.captureEvents(Event.KEYDOWN); 