<!-- begin cookies.js -->
function Cookie() {
	this.getCookieVal = function(offset) {
		var endstr = document.cookie.indexOf (";", offset);
		if (endstr == -1) {
			endstr = document.cookie.length;
		}
		return unescape(document.cookie.substring(offset, endstr));
	}
	this.GetCookie = function(name) {
		var arg = name + "=";
		var alen = arg.length;
		var clen = document.cookie.length;
		var i = 0;
		while (i < clen) {
			var j = i + alen;
			if (document.cookie.substring(i, j) == arg) {
				return this.getCookieVal (j);
			}
		        i = document.cookie.indexOf(" ", i) + 1;
			if (i == 0) break; 
		}
		return null;
	}
	this.SetCookie = function(name,value,expires,path,domain,secure) {
			document.cookie = name + "=" + escape (value) +
			((expires) ? "; expires=" + expires.toGMTString() : "") +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			((secure) ? "; secure" : "");
	}
	this.SetCookieNoEscape = function(name,value,expires,path,domain,secure) {
		document.cookie = name + "=" + value +
			((expires) ? "; expires=" + expires.toGMTString() : "") +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			((secure) ? "; secure" : "");
	}
	this.DeleteCookie = function(name,path,domain) {
		if (this.GetCookie(name)) {
			document.cookie = name + "=" +
				((path) ? "; path=" + path : "") +
				((domain) ? "; domain=" + domain : "") +
				"; expires=Thu, 01-Jan-70 00:00:01 GMT";
		}
	}
}

theCookie = new Cookie();
//This is needed for window control.
theCookie.SetCookie("clhref", window.location.href, null, "/", ".grolier.com", null);


//process this if its not TOPFRAME
if(window.location.href.indexOf("topframe") < 1){
		//for printer-frendly email
		theLocation = window.location.href;
	
	/* if the page is from search, and it's a fullpage then update the toolbar */
	if ( (theLocation.indexOf("jsp") >= 0) && (top != self) ) {
		pfeurl = "donotprintthissearchresultspage";
	   	theCookie.SetCookie("pfeurl" , pfeurl, null, "/", ".grolier.com", null);
	   	theCookie.SetCookie("new_page" , "yes", null, "/", ".grolier.com", null);
	}
	/* we're in a search popup, don't change the toolbar */
	else if ( (theLocation.indexOf("jsp") >=0) && (top == self) ) {
		/* do nothing, the toolbar should not change */
	}
	/* otherwise change the toolbar */
	else if ((top != self) || (theLocation.indexOf ("ada") >= 0)){
		//remove docKey from url.
		i = theLocation.indexOf("&docKey");
		if (i > 1) {
			pfeurl = theLocation.substring(0,theLocation.indexOf("&docKey"));
		}
		else {
			pfeurl = theLocation;
		}
	 
	   	theCookie.SetCookie("pfeurl" , pfeurl, null, "/", ".grolier.com", null);
		//for frame bookmarking
		theCookie.SetCookie("cltitle", document.title, null, "/", ".grolier.com", null);
		theCookie.SetCookie("new_page" , "yes", null, "/", ".grolier.com", null);
	}
	else {
	   theCookie.SetCookie("new_page" , "no", null, "/", ".grolier.com", null);	
	} 
} 

<!-- end cookies.js -->

