// move function // Analysis function move(direction) { currentObject += direction; if(currentObject >= object.length) currentObject = object.length - 1; else if(currentObject < 0) currentObject = 0; var newPage = "../../" + view + "/" + object[currentObject] + "/" + object[currentObject] + ".htm" this.page.location.href = newPage; this.control.document.forms[0].objSelect.selectedIndex=currentObject; }The move function should be fairly familiar by now. However, the key to this move() function is the way that the newPage variable is constructed. The relative URL begins by stepping up two levels (to the directory where objects.htm is located), and then adds the contents of the view variable, which will be either 'objects' or 'examples'.
The code then adds a slash to indicate a new directory, followed by the name of the object indexed by the currentObject variable in the object array. This will make the URL point to the folder containing the object's documents. Finally, inside the object's folder, there is an HTML document named after the object. To access this document, the code adds another forwards slash, adds the name of the object again, and concatenates the string '.htm' to the end.
Finally, the URL in the newPage variable is assigned to the href property of the location object of the page document.
The next section of code updates the select object at the top of the page in case the call to the
move() function was made by either the previous or next button. The 'this' refers to the current object
(the frameset document), and control is the name of the control bar frame. The code uses the
document's forms array to access the first form on the page (document.forms[0]). objSelect is the name
of the select object, and the code assigns the new page index held in the currentObject variable to the
selectedIndex of the selection list. This scheme works because the options in the select object have a
one-to-one relationship with the elements of the object array.