//this script loops through all images on the page and adds hover swapping on images with class="before"

function hoverSwap(imageURL) {
   return imageURL.replace("before","after");
}

function hoverRestore(imageURL) {
   return imageURL.replace("after","before");
}

function beforeAfterImages() {
 var images = getElementsByClass("before");
 for (var i=0; i<images.length; i++) {
   var image = images[i];
   if (image.getAttribute("src")) {
   //image.onmouseover = function () { this.src=this.src.replace("-before.","-after."); }
   //image.onmouseout = function () { this.src=this.src.replace("-after.","-before."); }
   image.onmouseover = function () { this.src=hoverSwap(this.src); }
   image.onmouseout = function () { this.src=hoverRestore(this.src); }
   }
 }
}
addLoadEvent(beforeAfterImages);