function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

var randomImages = {
	// Use linkID to set the ID of the link that will be randomly selected
	config : {
		linkID: 'mainlink'
	},
	
	theImages : [
		'images/huntingseason.jpg',
		'images/fishingtrip.jpg',
		'images/guncare.jpg'
	],
	
	theUrls : [
		'http://www.tnmoutdoors.com/store/shopdisplaycategories.asp?id=2&cat=Hunting+Gear',
		'http://www.tnmoutdoors.com/store/shopdisplaycategories.asp?id=66&cat=Fishing',
		'http://www.tnmoutdoors.com/store/shopdisplaycategories.asp?id=24&cat=Shooting+Gear'
	],
	
	init : function(){
		if (!document.getElementById) return false;
	
		var i = 0
		var p = randomImages.theImages.length;

		var preBuffer = new Array()
		for (i = 0; i < p; i++){
			preBuffer[i] = new Image()
	 		preBuffer[i].src = randomImages.theImages[i]
		}
		var whichImage = Math.round(Math.random()*(p-1));

		var mainLink = document.getElementById(randomImages.config.linkID);
		if(mainLink){
			mainLink.setAttribute("href", randomImages.theUrls[whichImage]);
			mainLink.firstChild.setAttribute("src", randomImages.theImages[whichImage]);
		}
	}
}
addLoadEvent(randomImages.init);
