$(function() {
    $("img[ref=over]")  
        .mouseover(function () {  
            this.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_over$2");  
        })  
        .mouseout(function () {  
            this.src = this.src.replace(/^(.+)_over(\.[a-z]+)$/, "$1$2");  
        })  
        .each(function () {  
            this.preloaded = new Image;  
            this.preloaded.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_over$2");  
    });
});