var target = 'a.hasHover';
var postfix = '_o';
(function() {
    $(target)
        .find('img').each(function() {
            var src   = this.src;
            var src_o = this.src.replace(/\.\w+$/, postfix + '$&');
            (new Image).src = src_o;

            $.data(this, 'src', src);
            $.data(this, 'src_o', src_o);
        })
        .end()
        .hover(
            function() {
                $(this).find('img').each(function() {
                    this.src = $.data(this, 'src_o');
                });
            },
            function() {
                $(this).find('img').each(function() {
                    this.src = $.data(this, 'src');
                });
            }
        );
})();
$(window).unload(function(){
    $(target)
        .find('img').each(function() {
            this.src = $.data(this, 'src');
        });
});
