// JavaScript Document

function SimpleSwap(element){
    // save original src
    element.setAttribute("holder",element.src);	
	// swap images
    element.src=element.getAttribute("swapimage");
	// swap images for next time
	element.setAttribute("swapimage",element.getAttribute("holder"));
}

function SimpleSwapSetup(){
  var images = document.getElementsByTagName("img");
  for (var i=0;i<images.length;i++){
    var swapImage = images[i].getAttribute("swapimage");
    if (!swapImage) continue; //If no swapImage property, ignore
    // preload image
    // comment the next two lines to disable image pre-loading
    images[i].swapImage_img = new Image();
    images[i].swapImage_img.src=swapImage;
    // set event handlers
    images[i].onclick = new Function("SimpleSwap(this);");
  }
}

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