Javascript Head Code for Rollovers

Change the (size) and the name of the graphics to your button graphics by changing the code in red. To install this script:

Cut and paste this script into the HEAD of your document:


<script language="JavaScript">

<!--//BEGIN Script

if (document.images) {
Button1 = new Image(108,135); Button1.src = "buttons/one_up.jpg";
Button1 = new Image(108,135); Button1.src = "buttons/one_dn.jpg";
Button2 = new Image(108,135); Button2.src = "buttons/two_up.jpg";
Button2 = new Image(108,135); Button2.src = "buttons/two_dn.jpg";
Button3 = new Image(108,135); Button3.src = "buttons/three_up.jpg";
Button3 = new Image(108,135); Button3.src = "buttons/three_dn.jpg";
}

/* Function that swaps images. */

function rollo(id, newSrc) {
    var theImage = FindImage(document, id, 0);
    if (theImage) {
        theImage.src = newSrc;
    }
}

/* Functions that track and set toggle group button states. */

function FindImage(doc, name, j) {
    var theImage = false;
    if (doc.images) {
        theImage = doc.images[name];
    }
    if (theImage) {
        return theImage;
    }
    if (doc.layers) {
        for (j = 0; j < doc.layers.length; j++) {
            theImage = FindImage(doc.layers[j].document, name, 0);
            if (theImage) {
                return (theImage);
            }
        }
    }
    return (false);

}
//END Script-->

</script>