window.onload = init;

function init()
{
	/* DEFINE ALL ADVERTISEMENT IMAGES AND LINKS HERE */
	image_list = [
				  
				  
				  'http://rmxa.org/images/sponsor_ads/SPONSORAd_jkh.jpg',
				  'http://rmxa.org/images/sponsor_ads/SPONSORAd_MotoAdventure.jpg',
				  'http://rmxa.org/images/sponsor_ads/SPONSORAd_MileHigh.jpg',
				  'http://rmxa.org/images/sponsor_ads/SPONSORAd_FayMyers.jpg',
				  '/images/sponsor_ads/SPONSORAd_rmxa201.jpg',
				  'http://rmxa.org/images/sponsor_ads/SPONSORAd_ProAction.jpg',
				  'http://rmxa.org/images/sponsor_ads/SPONSORAd_Mb.jpg',
				  'http://rmxa.org/images/sponsor_ads/SPONSORAd_store.jpg',
				  'http://rmxa.org/images/sponsor_ads/SPONSORAd_Performance.jpg'
				  
	];
	
	link_list = [
				  
				  
				  'http://www.rmxa.com/',
				  'http://www.motoadventure.com/',
				  'http://www.rmxa.com/',
				  'http://www.faymyers.com/',
				  'http://www.rmxa.com/',
				  'http://www.pro-action.com/',
				  'http://www.alternativeplusrealty.com/',
				  'http://blairnapparel.com/index.php?main_page=index&cPath=9',
				  'http://www.performancecycle.com/'
			      
	];
	
	/* PRELOAD IMAGES IN ARRAY */
	image = new Image();
	for(i=0; i<image_list.length; i++)
	{
		image.src = image_list[i];
	}
	
	ad_link = document.createElement("a");
	ad_image = document.createElement("img");
	
	ad_link.setAttribute("id", "sponsor_ad");
	rotate_image();
	
}

function rotate_image()
{
	/* GENERATE RANDOM NUMBER */
	number = Math.floor(Math.random() * (image_list.length));
	ad_link.setAttribute("href", link_list[number]);
	ad_image.setAttribute("src", image_list[number]);
	ad_link.appendChild(ad_image);
	document.body.appendChild(ad_link);
	setTimeout("rotate_image()", 4000);
}
