home *** CD-ROM | disk | FTP | other *** search
- function HighlightButton(document, width, height, label, onclick)
- {
- // First time called, document will be false. Ignore this call.
- if (document == null) return;
-
- if (!HighlightButton.prototype.over) {
- // Initialize the prototype object to create our methods.
- HighlightButton.prototype.over = _HighlightButton_over;
- HighlightButton.prototype.out = _HighlightButton_out;
- HighlightButton.prototype.click = _HighlightButton_click;
-
- }
- this.imagenames = new Array(2);
- this.imagenames[0] = HighlightButton.imagenames[0];
- this.imagenames[1] = HighlightButton.imagenames[1];
-
- this.images = new Array(2);
- this.images[0] = new Image(width, height);
- this.images[1] = new Image(width, height);
- this.images[0].src = this.imagenames[0];
- this.images[1].src = this.imagenames[1];
-
- // Save some of the arguments we were passed.
- this.document = document;
- this.label = label;
-
- // Remember that the mouse is not currently on top of us.
- this.highlighted = false;
-
- this.onclick = onclick;
- if (typeof this.onclick == "string")
- this.onclick = new Function("state", this.onclick);
-
- var index = document.images.length;
-
- document.write('<A HREF ="" ' +
- 'onMouseOver="document.images[' + index + ']._hl.over();return true;" '+
- 'onMouseOut="document.images[' + index + ']._hl.out()" '+
- 'onClick="document.images[' + index + ']._hl.click(); return false;">');
- document.write('<IMG SRC="' + HighlightButton.imagenames[0] +'"'+
- ' WIDTH=' + width +
- ' HEIGHT=' + height +
- ' BORDER=0 HSPACE=0 VSPACE=0>');
- document.write('</A>');
-
- this.image = document.images[index];
- this.image._hl = this;
- }
-
- // This becomes the over() method.
- function _HighlightButton_over()
- {
- // Change the image, and remember that we're highlighted.
- this.image.src = this.imagenames[1];
- this.highlighted = true;
- window.status = this.label;
- }
-
- // This becomes the out() method.
- function _HighlightButton_out()
- {
- // Change the image, and remember that we're not highlighted.
- this.image.src = this.imagenames[0];
- this.highlighted = false;
- window.status = "";
- }
-
- // This becomes the click() method.
- function _HighlightButton_click()
- {
- // Toggle the state of the button, change the image, and call the
- // onclick method, if it was specified for this ToggleButton.
- if (this.onclick) this.onclick();
- }