<!--
// Edit the two strings below to set the username and password.
var correctUsername="oclab";
var correctPassword="eeb500";
var correctUsername2="ocdma";
var correctPassword2="collision";

//###########################
//Do Not Edit Below This Line
//###########################

//Validates the username and password and sets a
//login cookie if valid and goes to student-home.htm 
function validate(thisform)
{
  with (thisform)
  {
    if ((user.value==correctUsername&&pass.value==correctPassword)||(user.value==correctUsername2&&pass.value==correctPassword2)){
      login()
    }
    else{
      alert("Incorrect UserName or Password")
    }
  }
}

//creates a cookie called "oclab" with a value "oclab"
//that will last only for the session
function login()
{
  createCookie("oclab","oclab","")
}

//erases the cookie called "oclab"
function logout()
{
  eraseCookie("oclab")
}

//checks for a cookie called "oclab" with value "oclab"
function checklogin()
{
  var x=readCookie("oclab")

  if (x=="oclab") {
    return true
  }
  else {
    return false
  }
}


//create a cookie.  Format the expiration date (I use no date so that
//the cookie expires at the end of the session)then sets the name, value and expiration date
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

//read in the cookie and return an array of its stored values
//we have only one value so it just returns the value
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

//sets the expiration date to yesterday so that the cookie
//is immediatley erased.  also clears the value
function eraseCookie(name) {
	createCookie(name,"",-1);
}
-->