JavaScript Bible, Gold Edition part 150. This book will bring programmers and non-technical professionals, including casual programmers and scripters, painlessly up to speed on all aspects of mastering JavaScript. Key topics include programming fundamentals, JavaScript language elements and how to use them effectively, and how to easily and efficiently add powerful new functionality to HTML documents and Java applets. | 1338 Part V Putting JavaScript to Work if isCSS true isNN4 false else isCSS false isNN4 true To each of the cookie storage functions from the original version I add a branch to handle the storage and retrieval of state data for CSS browsers simply setting and getting the global variable. This may seem to be more indirect than is necessary but it is essential to allow the reuse of many functions in other parts of the code so that those areas don t have to worry about browser platform. Notice that the label for this outline s cookie is slightly different from that of the earlier version. This difference allows you to open both outliners with NN4 in the same session and not worry about one cookie value overlapping with the other. functions that get and set persistent data set persistent data function setCurrState setting if isNN4 NN4Cookie currState2 escape setting else for CSS data is saved as a global variable instead of cookie CSScurrState setting retrieve persistent data function getCurrState if isCSS for CSS data is in global var instead of cookie return CSScurrState var label currState2 var labelLen var cLen var i 0 while i cLen var j i labelLen if i j label var cEnd j if cEnd -1 cEnd return unescape j cEnd i return The toggle function is called by the onClick event handler of the links surrounding the widget icon art in the outline. A variable number of parameters are passed to this function so that the parameters are extracted and analyzed via the arguments property of the function. Both browsers with only a few small Chapter 52 Application Outline-Style Table of Contents 1339 browser-specific branches use a great deal of the code. Inside the large for loop a CSS branch dynamically changes the setting of the property. For NN4 the page is reloaded after all changes to the cookie version of the state are .