// This is the an adaption of SimpleSwap
// by Jehiah Czebotar
// Version 1.1 - June 10, 2005
// Distributed under Creative Commons
//
// http://jehiah.com/archive/simple-swap
// 
// adapted by Tim Osborn - Septemeber 14, 2006

function DJSwap(el,which){
	
	el = document.getElementById("RO_base");
	el.src = (which == undefined) ? el.getAttribute("origsrc") : which;
}


function DisjointSwapSetup(){

	// define the image which will change:
	var dj = window.document.getElementById("RO_base");
	
	// save its original src
	dj.setAttribute("origsrc",dj.src);

	// gather the triggers for the rollover
	var a = document.getElementsByTagName("a");
	
	for (var i=0;i<a.length;i++){
		var djsrc = a[i].getAttribute("djsrc");
		
		if (!djsrc) continue;
	
		// preload image
		a[i].djsrc_img = new Image();
		a[i].djsrc_img.src=djsrc;
		
		// set event handlers
		a[i].onmouseover = new Function("DJSwap(this,'" + djsrc + "');");
		a[i].onmouseout = new Function("DJSwap(this);");
	}
}

// is this at all required?  loading for all rollovers occurs above!
function PreloadImages() {
	
	// make and array of images
	var imgs = document.getElementsByTagName("img");
	
	for (var i=0;i<imgs.length;i++){
		// preload image
		var pre = new Image();
		pre.src = imgs[i].getAttribute("src");
		alert("Image: " + pre.src);
	}
}

var PreSimpleSwapOnload =(window.onload)? window.onload : function(){};
window.onload = function(){PreSimpleSwapOnload(); DisjointSwapSetup();}
