// Unmodified version

// This is the implementation of SimpleSwap
// by Jehiah Czebotar
// Version 1.1 - June 10, 2005
// Distributed under Creative Commons
//
// Include this script on your page
// then make image rollovers simple like:
// <img src="/images/ss_img.gif" oversrc="/images/ss_img_over.gif">
//
// http://jehiah.com/archive/simple-swap
// 


function SimpleSwap(el,which){
  el.src=el.getAttribute(which || "origsrc");
}

function SimpleSwapSetup()
{
var images = document.getElementsByTagName("img");
for (var i = 0; img = images[i]; i++) 
{
// preload image
// comment the next two lines to disable image pre-loading
images[i].oversrcimg = new Image();
images[i].oversrcimg.src = images[i].getAttribute("src").replace("off.", "on.");
// set event handlers
images[i].onmouseover = new Function("SimpleSwap(this, 'oversrc');");
images[i].onmouseout = new Function("SimpleSwap(this);");
// save original src
images[i].setAttribute("origsrc", images[i].src);
images[i].setAttribute("oversrc", images[i].oversrcimg.src);
}
}


var PreSimpleSwapOnload =(window.onload)? window.onload : function(){};
window.onload = function(){PreSimpleSwapOnload(); SimpleSwapSetup();}
