// Format /LastVisited/Module,page,page/Module,page,page/
// eg. SE6/SA,1,2,3,4,5/SE,1,2,3,4,5,6/
// no particular order of pages or modules
lastPageVisited = -1 //constant
bookmarkCookieName = "free"
// set the cookie
function resetBookmarkCookie() {
	if (confirm("Press 'OK' if you want to clear all bookmarks")) {
		setBookmarkCookie(bookmarkCookieName,"Z1/")
		lastPageVisited = -1
		removeTicks()
	}	
}
function setBookmarkCookie(name,value) {
var expdate = new Date ();
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 60)); // expires in 60 days
var expires =  "; expires=" + expdate.toGMTString();
var path = "; path=/"
document.cookie = name + "=" + escape(value) + "&" + expires + path;
}
// update the cookie for the current page called through <body onLoad = "addBookmark('SA',2)">
// do not create cookie, because then higher directories cannot see it
function addBookmark(thisSection, thisPage) {
value  = readBookmarkCookie(bookmarkCookieName)
// alert(value)
if (value.indexOf("/") > -1) {  // if the cookie is not found skip
// first visit to this section, so add section and page
	if (value.indexOf(thisSection) == -1) {
		value = value + thisSection + "," + thisPage + ",/"
	}
// else check if this page not previously visited
	else {
		sectionStart = value.indexOf("/")
		sectionStart = value.indexOf(thisSection,sectionStart)
		sectionEnd = value.indexOf("/",sectionStart,sectionStart + 1)
		section = value.slice(sectionStart,sectionEnd + 1)
		if (section.indexOf("," + thisPage + ",") == -1) {
			section = section.slice(0,section.length - 1) + thisPage + ",/"		
			preSection = value.substr(0,sectionStart)
			postSection = value.substr(sectionEnd+1)
			value = preSection + section + postSection
		}
	}
// make this the last visited page
	current = value.indexOf("/")
	value = value.substr(current)
	value = thisSection + thisPage + value
	setBookmarkCookie(bookmarkCookieName,value)
}
}
// read the cookie with 'name' returns the cookie string
function readBookmarkCookie(name) {
bookmarkCookieString = "not_found"
if (document.cookie) {
	index = document.cookie.indexOf(name);
	if (index != -1) {
		index = document.cookie.indexOf("=",index) + 1;
		cookieStop = document.cookie.indexOf("&", index);
		bookmarkCookieString = unescape(document.cookie.substring(index,cookieStop));
		}
	}	
return bookmarkCookieString
} 
// called by  <body  onLoad = "setBookmarks()"> on the contents page
function setBookmarks() {
value = readBookmarkCookie(bookmarkCookieName)
if (value.indexOf("found") < 0) {
// alert(value)
// Section I (Introduction to Statistics)
	thisSection = "I"
	sectionStart = value.indexOf("/")
	sectionStart = value.indexOf(thisSection,sectionStart)
	sectionEnd = value.indexOf("/",sectionStart + 1)
	section = value.slice(sectionStart,sectionEnd + 1)
	if (section.indexOf(",1,") > -1) document.QuestionForm.checkboxI1.checked = true
	if (section.indexOf(",2,") > -1) document.QuestionForm.checkboxI2.checked = true
	if (section.indexOf(",3,") > -1) document.QuestionForm.checkboxI3.checked = true
	if (section.indexOf(",4,") > -1) document.QuestionForm.checkboxI4.checked = true
	if (section.indexOf(",5,") > -1) document.QuestionForm.checkboxI5.checked = true
	if (section.indexOf(",6,") > -1) document.QuestionForm.checkboxI6.checked = true
	if (section.indexOf(",7,") > -1) document.QuestionForm.checkboxI7.checked = true
	if (section.indexOf(",8,") > -1) document.QuestionForm.checkboxI8.checked = true
	if (section.indexOf(",9,") > -1) document.QuestionForm.checkboxI9.checked = true
	if (section.indexOf(",10,") > -1) document.QuestionForm.checkboxI10.checked = true
	if (section.indexOf(",11,") > -1) document.QuestionForm.checkboxI11.checked = true
	if (section.indexOf(",12,") > -1) document.QuestionForm.checkboxI12.checked = true
	if (section.indexOf(",13,") > -1) document.QuestionForm.checkboxI13.checked = true
	if (section.indexOf(",14,") > -1) document.QuestionForm.checkboxI14.checked = true
	if (section.indexOf(",15,") > -1) document.QuestionForm.checkboxI15.checked = true
	if (section.indexOf(",16,") > -1) document.QuestionForm.checkboxI16.checked = true
	lastPageVisited = value.slice(0, value.indexOf("/"))
} else {
	setBookmarkCookie(bookmarkCookieName,"Z1/")
}
}
// called by the 'return to where you left off' button on the contents page
function leftOff() {
switch (lastPageVisited) {
case "I1":
	window.location = "eStats-INT/int01.htm"
	break
case "I2":
	window.location = "eStats-INT/int02.htm"
	break	
case "I3":
	window.location = "eStats-INT/int03.htm"
	break	
case "I4":
	window.location = "eStats-INT/int04.htm"
	break	
case "I5":
	window.location = "eStats-INT/int05.htm"
	break	
case "I6":
	window.location = "eStats-INT/int06.htm"
	break	
case "I7":
	window.location = "eStats-INT/int07.htm"
	break
case "I8":
	window.location = "eStats-INT/int08.htm"
	break	
case "I9":
	window.location = "eStats-INT/int09.htm"
	break	
case "I10":
	window.location = "eStats-INT/int10.htm"
	break	
case "I11":
	window.location = "eStats-INT/int11.htm"
	break	
case "I12":
	window.location = "eStats-INT/int12.htm"
	break	
case "I13":
	window.location = "eStats-INT/int13.htm"
	break	
case "I14":
	window.location = "eStats-INT/int14.htm"
	break
case "I15":
	window.location = "eStats-INT/int15.htm"
	break	
case "I16":
	window.location = "eStats-INT/int16.htm"
	break	
}
}
function removeTicks() {
document.QuestionForm.checkboxI1.checked = false
document.QuestionForm.checkboxI2.checked = false
document.QuestionForm.checkboxI3.checked = false
document.QuestionForm.checkboxI4.checked = false
document.QuestionForm.checkboxI5.checked = false
document.QuestionForm.checkboxI6.checked = false
document.QuestionForm.checkboxI7.checked = false
document.QuestionForm.checkboxI8.checked = false
document.QuestionForm.checkboxI9.checked = false
document.QuestionForm.checkboxI10.checked = false
document.QuestionForm.checkboxI11.checked = false
document.QuestionForm.checkboxI12.checked = false
document.QuestionForm.checkboxI13.checked = false
document.QuestionForm.checkboxI14.checked = false
document.QuestionForm.checkboxI15.checked = false
document.QuestionForm.checkboxI16.checked = false
}


