Adding Functionality

Now let's look at some of the JavaScript. We'll start by just looking at the shiftColor function in Example 11-2, which takes the color the user's mouse is over and translates that to the proper layer's background color. It ends up that this function needs another one: getCurrentLayer looks at which layer is “active,” that is, which radio button is currently checked.

Of course, there's some setting of global variables: We create an array that remembers which layers are locked (color won't change) and some basic browser detection.

Example 11-2. Shifting the colors
					locked = new Array() locked["upperLayer"] = false locked["uppermidLayer"] ...

Get Advanced JavaScript™: Insights and Innovative Techniques now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.