// ========================================================================
// Image Rollovers for link elements - methods for use in modern browsers
// From Danny Goodman's JavaScript & DHTML Cookbook
//   section 12.2 p. 344
//     author    : Danny Goodman
//     title     : JavaScript & DHTML Cookbook
//     publisher : O'Reilly
//     ISBN      : 0-596-00467-2
// ========================================================================
// $Id: linkRolloverMod.js 2 2005-05-18 17:51:52Z tprice $
// ========================================================================

// Use this to configure rollovers for link elements
// set the class of the relevant element to 'swappable'    
// (be sure to create the imagesNormal and imagesHilite arrays before
// using this!)

// generic swappable image changer
function setImage(evt) {
    if (document.images) {
        // equalise w3c and IE event objects
        evt = (evt) ? evt : ((window.event) ? window.event : null);
        if (evt) {
            // equalise w3c and IE event property
            var elmt = (evt.target) ? evt.target :
                        ((evt.srcElement) ? evt.srcElement : null);
            // filter out older browsers (elmt == null) and unswappable
            // elements
            if (elmt && elmt.className.indexOf("swappable") != -1) {
                // let event type govern state
                switch (evt.type) {
                    case "mouseover":
                        elmt.src = imagesHilite[elmt.id].src;
                        break;
                    case "mouseout":
                        elmt.src = imagesNormal[elmt.id].src;
                        break;
                }
            }
        }
    }  
}

