// This is the implementation of SimpleSwap
// by Jehiah Czebotar
// Version 1.1 - June 10, 2005
// Distributed under Creative Commons
//
// http://jehiah.com/archive/simple-swap
// 


function SimpleSwap(el,which){
  el.src=el.getAttribute(which || "src");
}

function SimpleSwapSetup(){
  var x = getElementsByClass("rollover",null,"img");
  for (var i=0;i<x.length;i++){     
    // preload image
    x[i].oversrc_img = new Image();
    x[i].oversrc_img.src=x[i].getAttribute("src").replace(/\.(gif|jpg|png)/i, "_RO.$1");
    // set event handlers
    x[i].onmouseover = new Function("SimpleSwap(this,'oversrc');");
    if(x[i].parentNode.tagName == "A")
    	x[i].parentNode.onfocus = new Function("SimpleSwap(this.firstChild,'oversrc');");
    x[i].onmouseout = new Function("SimpleSwap(this, 'origsrc');");
    if(x[i].parentNode.tagName == "A")
    	x[i].parentNode.onblur = new Function("SimpleSwap(this.firstChild,'origsrc');");
    // save original src
    x[i].setAttribute("origsrc", x[i].src);
    x[i].setAttribute("oversrc", x[i].oversrc_img.src);
  }
}

var PreSimpleSwapOnload =(window.onload)? window.onload : function(){};
window.onload = function(){PreSimpleSwapOnload(); SimpleSwapSetup();}