/*
 * Copyright (c) 2008-2009 HD Greetings (http://www.hdgreetings.com)
 */


/*
*  Adding support for roll over buttons in javascript is preferrable
*  because using only CSS makes it more difficult to support well in IE6.
*/
jQuery.fn.enableRollOvers = function() {

    // preload each image so there is no pause or flicker on first hover
    this.each(function() {
        imageSrc = $(this).attr("src");
        imageSrcOn = imageSrc.replace('OFF', 'ON');
        newImage = new Image(); // create new image object
        $(newImage).attr("src", imageSrcOn); // set new obj's src
    });

    this.mouseover(function() {
            if (typeof ($(this).attr("src")) != 'undefined') {
                imageSrc = $(this).attr("src");
                imageSrcOn = imageSrc.replace('OFF', 'ON');
                $(this).attr("src", imageSrcOn);
            }
        });

    this.mouseout(function() {
        if (typeof ($(this).attr("src")) != 'undefined') {
            imageSrc = $(this).attr("src");
            imageSrcOff = imageSrc.replace('ON', 'OFF');
            $(this).attr("src", imageSrcOff);
        }
    });
};
