/* See Wagner p. 447.  Cookies are the mechanism for conveying information
from one html page to another, or from one browser window to another.
By default (as used in LCS2) cookies are deleted when the browser session
ends.
*/

function putCookie(cname, cval)
{

	document.cookie = cname + "=" + escape(cval);

	// escape() prevents semicolons, quotes, etc from wrecking syntax.
	// This = APPENDS, never replaces the document's cookie.
	// By default, cookie is deleted when browser is shut down.
}

function getCookie(cname)
{
	var result = null;
	var raw = " " + document.cookie + ";";
	var toget = " " + cname + "=";
	var s0 = raw.indexOf(toget);
	var s1;

	if (s0 != -1)
	{
		s0 += toget.length // skip cname
		s1 = raw.indexOf(";", s0);
		result = unescape(raw.substring(s0, s1));
	}
	return result;
}

