var errCode = location.search.substr(1) * 1;function LoginOK() {	var username;	if (document.loginForm.username.value == '') {		alert("You must enter a valid username and password to enter the site.");		return false;		if (confirm('You didn\'t enter a username.  Would you like to log in as a Guest?')) {			username = "Guest";			document.loginForm.username.value = "Guest";		} else {			document.loginForm.username.select();			return false;		}	} else {		username = document.loginForm.username.value;	}		if (username.substr(0,5).toLowerCase() != 'guest' && document.loginForm.password.value == '') {		if (confirm('You didn\'t enter a password.  Would you like to log in as a Guest?')) {			username = "Guest";			document.loginForm.username.value = "Guest";		} else {			document.loginForm.password.select();			return false;		}	}		// store the user's name to fill in later	var later = new Date();	later.setFullYear (later.getFullYear() + 10);	document.cookie = "lfiofoe=" + username + "; path=/; expires=" + later.toGMTString();			return true;}function LoginFromReg(u, p) {	document.loginForm.username.value = u;	document.loginForm.password.value = p;	LoginOK();	// stores the username cookie	document.loginForm.submit();	suppwin.close();}function ShowSupp(searchString) {	OpenSuppWindow(searchString);	}var suppwin;function OpenSuppWindow(searchString) {	if (suppwin != null && !suppwin.closed)		suppwin.focus();	suppwin = window.open("supp.html?" + searchString, "loginSuppWindow", "top=20,left=20,width=750,height=600,menubar,resizable,scrollbars,status", true);}// The supp window calls the following two functions upon open, thinking it// is being opened by the textbook window.function AddToHistory() {	;}function CurrentChapter() {	return 0;}function UpdateHistoryLinks() {	// Mimic ebookAPI's KeepSuppWindowOpen function	suppwin.banner.document.getElementById('keepopen').style.display = "none";	suppwin.banner.document.getElementById('backvis').style.display = "none";	suppwin.banner.document.getElementById('forwardvis').style.display = "none";	suppwin.banner.document.getElementById('backdim').style.display = "none";	suppwin.banner.document.getElementById('forwarddim').style.display = "none";	suppwin.banner.document.getElementById('helpDiv').style.display = "none";}function FillinUsername() {	var cook = document.cookie;	var pos = cook.indexOf ("lfiofoe=");	if (pos != -1) {		var start = pos + 8;		var end = cook.indexOf (";", start);		if (end == -1) end = cook.length;		cook = cook.substring (start, end);		document.loginForm.username.value = cook;	}	// document.loginForm.username.select();	self.focus();	// Not sure if this is necessary, but got it from http://www.htmlgoodies.com/tabindex.html	document.loginForm.username.focus()		// Fill in the hidden "start" input with the sent-in value if necessary	}function StoreCookie(name, val) {	var later = new Date();	later.setFullYear (later.getFullYear() + 10);	document.cookie = name + "=" + val + "; path=/; expires=" + later.toGMTString();}function ShowError() {	if (errCode != "") {		switch (errCode) {			case 10:				alert('You must open the eBook through the login screen by specifying a valid username and password. Error code: ' + errCode);				break;			case 11:				alert('You entered an incorrect username and/or password.'); // Enter "Guest" in the username field and leave the password field blank to login as a guest user of the site.');				break;			case 13:				alert('Your account has expired.');				break;			case 14:				alert('You have been automatically logged out of the eBook because someone else has logged in using the same username.  Your access to the eBook will be blocked for the next one hour.');				break;			case 15:				alert('This username is currently blocked from logging in.  The block will be removed in less than one hour.');				break;			case 16:				alert('There was a problem with your account. Error code :16');				break;			case 20:				// User clicked a link to jump to a page, but wasn't logged in.				alert('Please log in first.  You will then be sent to the requested page in the textbook.');				break;			case 99:				alert('Guest access without a password will not be permitted until December, 2004. If you would like to view the site, please contact Jason Dirks at dirks@sinauer.com');				break;			default:				break;		}	}}