// set cookie data function setCurrState(setting) { document.cookie = "currState=" + escape(setting) } // retrieve cookie data function getCurrState() { var label = "currState=" var labelLen = label.length var cLen = document.cookie.length var i = 0 while (i < cLen) { var j = i + labelLen if (document.cookie.substring(i,j) == label) { var cEnd = document.cookie.indexOf(";",j) if (cEnd == -1) { cEnd = document.cookie.length } return unescape(document.cookie.substring(j,cEnd)) } else { i = document.cookie.indexOf(";",j) if ( i == -1 ) { i = document.cookie.length } } } return "" } // **function that updates persistent storage of state** // toggles an outline mother entry, storing new value in the cookie function toggle(n) { if (n != 0) { var newString = "" var currState = getCurrState() // of whole outline var expanded = currState.substring(n-1,n) // of clicked item newString += currState.substring(0,n-1) newString += expanded ^ 1 // Bitwise XOR clicked item newString += currState.substring(n,currState.length) setCurrState(newString) // write new state back to cookie } } // **functions used in assembling updated outline** // returns the proper GIF file name for each entry's control function getGIF(n) { var mom = db[n].mother // is entry a parent? var expanded = getCurrState().substring(n-1,n) // of clicked item if (!mom) { return "daughter.gif" } else { if (expanded == 1) { return "exploded.gif" } } return "collapsd.gif" } // returns the proper status line text based on the icon style function getGIFStatus(n) { var mom = db[n].mother // is entry a parent var expanded = getCurrState().substring(n-1,n) // of rolled item if (!mom) { return "No further items" } else { if (expanded == 1) { return "Click to collapse nested items" } } return "Click to expand nested items" } // returns padded spaces (in multiples of 3) for indenting function pad(n) { var result = "" for (var i = 1; i <= n; i++) { result += " " } return result } // initialize 'current state' storage field if (getCurrState() == "" || getCurrState().length != db.length) { initState = "1" for (i = 2; i <= db.length; i++) { initState += "0" } setCurrState(initState) } // see if user is running a Mac browser for special case handling function isMac() { return (navigator.userAgent.indexOf("Macintosh") >= 0) ? true :false } // end -->